annotate gtk/dw.c @ 239:403b07f873e1

Use a pointer for HMTX instead of a pthread_mutex_t struct.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 18 Feb 2003 20:09:04 +0000
parents efa724294b5f
children 00d2b1bcf036
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 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */
142
9560efb7bea2 Make DW_CLR_PALEGRAY a bit lighter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 141
diff changeset
41 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
52 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
53
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
54 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
55 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
56 GdkColor _background[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
58 GtkWidget *last_window = NULL, *popup = NULL;
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
59
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
60 int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 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
62 int _dw_mutex_locked[DW_THREAD_LIMIT];
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
63 /* Use default border size for the default enlightenment theme */
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
64 int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
66 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } }
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
67 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
69 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
70 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
71 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
72
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
73 GdkColormap *_dw_cmap = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
75 /* Signal forwarder prototypes */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 gint _generic_event(GtkWidget *widget, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
83 gint _activate_event(GtkWidget *widget, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
84 gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
85 gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
86 gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
87 gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
88 gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
89 gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
90 gint _value_changed_event(GtkAdjustment *adjustment, gpointer user_data);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
91 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
92 gint _tree_select_event(GtkTreeSelection *sel, gpointer data);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
93 #else
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
94 gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
95 #endif
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
96
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97
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
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
140 void _dw_msleep(long period)
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
141 {
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
142 #ifdef __sun__
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
143 /* usleep() isn't threadsafe on Solaris */
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
144 struct timespec req;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
145
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
146 req.tv_sec = 0;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
147 req.tv_nsec = period * 10000000;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
148
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
149 nanosleep(&req, NULL);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
150 #else
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
151 usleep(period * 1000);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
152 #endif
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
153 }
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
154
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
155 /* Finds the translation function for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
156 void *_findsigfunc(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
157 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
158 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
159
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
160 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
161 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
162 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
163 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
164 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
165 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
168 gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
169 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
170 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
171 int retval = FALSE;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
172
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
173 if(work)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
174 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
175 int (*setfocusfunc)(HWND, void *) = work->func;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
176
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
177 retval = setfocusfunc((HWND)window, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
178 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
179 return retval;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
180 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
181
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
185 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
197 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
198 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
199 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
205 int retval = FALSE;
3
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 (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
217 retval = buttonfunc(widget, event->x, event->y, mybutton, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
218 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
219 return retval;
3
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 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
225 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
229 int (*motionfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
234 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
237 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
243 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
248
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
249 retval = motionfunc(widget, x, y, keys, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
250 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
251 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
257 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 int (*closefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
263 retval = closefunc(widget, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
264 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
265 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
271 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 int (*keypressfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
277 retval = keypressfunc(widget, *event->string, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
278 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
279 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 gint _generic_event(GtkWidget *widget, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
285 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 int (*genericfunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
291 retval = genericfunc(widget, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
292 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
293 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
294 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
295
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
296 gint _activate_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
299 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
301 if(work && !_dw_ignore_click)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
303 int (*activatefunc)(HWND, void *) = work->func;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
304
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
305 retval = activatefunc(popup ? popup : work->window, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
306 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
307 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
313 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 int (*sizefunc)(HWND, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
319 retval = sizefunc(widget, event->width, event->height, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
320 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
321 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
322 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
323
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
324 gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
327 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
331 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332 int (*exposefunc)(HWND, DWExpose *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 exp.height = event->area.height;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
338 retval = exposefunc(widget, &exp, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
339 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
340 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
341 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
342
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
343 gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 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
346 static int _dw_recursing = 0;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
347 int retval = FALSE;
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
348
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
349 if(_dw_recursing)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
350 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354 int (*selectfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
358 _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
359
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 if(GTK_IS_COMBO(work->window))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 list = GTK_LIST(GTK_COMBO(work->window)->list)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
365 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
371 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
372 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
373 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
374 if(selectfunc)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
375 retval = selectfunc(work->window, item, work->data);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
376 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
377 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
379 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
380 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
381 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
382 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
383 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
384 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
385 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
386
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
387 gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
388 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
389 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
390 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
392 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
394 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
395 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
396 int (*contextfunc)(HWND, char *, int, int, void *) = work->func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
397 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
398 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
399
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
400 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
402 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
403 retval = contextfunc(work->window, text, event->x, event->y, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
405 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
406 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
407 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
408
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
409 gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
410 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
411 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
412 int retval = FALSE;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
413
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
414 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
415 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
416 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
417 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
418 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
419 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
420 char *text = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
421 void *itemdata = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
422
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
423 if(widget && GTK_IS_TREE_VIEW(widget))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
424 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
425 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
426 GtkTreeIter iter;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
427
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
428 if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
429 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
430 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
431 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, -1);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
432 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
433 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
434
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
435 retval = contextfunc(work->window, text, event->x, event->y, work->data, itemdata);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
436 #else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
437 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
438 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
439 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
440
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
441 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
442 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
443 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
444
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
445 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
446 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
447 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
448
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
449 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
450 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
451 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
452 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
453 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
454 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
455 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
456
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
457 retval = contextfunc(work->window, text, event->x, event->y, work->data, itemdata);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
458 #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
459 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
460 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
461 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
462 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
463
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
464 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
465 gint _tree_select_event(GtkTreeSelection *sel, gpointer data)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
466 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
467 SignalHandler *work = (SignalHandler *)data;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
468 int retval = FALSE;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
469
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
470 if(work)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
471 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
472 int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
473 GtkTreeIter iter;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
474 char *text = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
475 void *itemdata = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
476 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
477
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
478 if(widget && gtk_tree_selection_get_selected(sel, NULL, &iter))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
479 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
480 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
481 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
482 retval = treeselectfunc(work->window, item, text, itemdata, work->data);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
483 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
484 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
485 return retval;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
486 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
487 #else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
488 gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
489 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
490 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
491 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "tree");
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
492 int retval = FALSE;
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
493
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
494 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
495 {
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
496 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
497 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
498 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
499 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
500 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
501
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
502 if(work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
503 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
504 int (*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
505 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
506 void *itemdata = (char *)gtk_object_get_data(GTK_OBJECT(child), "itemdata");
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
507 retval = treeselectfunc(work->window, child, text, itemdata, work->data);
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
508 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
509 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
510 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
511 #endif
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
512
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
513 gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
514 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
515 SignalHandler *work = (SignalHandler *)data;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
516 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
517
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
518 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
519 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
520 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
521 {
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
522 int (*contextfunc)(HWND, char *, void *) = work->func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
523 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
524 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
525
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
526 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
528 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
529 retval = contextfunc(work->window, text, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
530 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
531 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
532 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
533 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
534
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
535 gint _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 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
539 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 if(rowdata)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
543 if(!multi)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
544 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
545 g_list_free(tmp);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
546 tmp = NULL;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
547 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
548
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 tmp = g_list_append(tmp, rowdata);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
550 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
551 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
552 return FALSE;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
553 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
554
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
555 gint _container_select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
556 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
557 SignalHandler *work = (SignalHandler *)data;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
558 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
559 int (*contextfunc)(HWND, char *, void *) = work->func;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
560
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
561 return contextfunc(work->window, rowdata, work->data);;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
562 }
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
563
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
564 gint _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565 {
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
566 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
567 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
568
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
569 if(_dw_unselecting)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
570 return FALSE;
75
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
571
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
572 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
573 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
575 if(rowdata && tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 {
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
577 tmp = g_list_remove(tmp, rowdata);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
580 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
581 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
582
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
583 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
584 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
585 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
586
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
587 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
588 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
589
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
590 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
591 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
592
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
593 gint _value_changed_event(GtkAdjustment *adjustment, gpointer data)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
594 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
595 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
596
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
597 if(work)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
598 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
599 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
600 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
601 int val = _round_value(adjustment->value);
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
602 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "slider");
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
603 GtkWidget *scrollbar = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "scrollbar");
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
604
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
605 if(slider)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
606 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
607 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
608 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
609 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
610 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
611 }
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
612 else if(scrollbar)
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
613 {
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
614 valuechangedfunc(work->window, val, work->data);
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
615 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
616 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
617 return FALSE;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
618 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
619
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
620 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
621 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
622 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
623
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
624 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
625 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
626 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
627 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
628 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
629 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
630 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
631 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
632 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
633 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
634 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
635 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
636
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
637 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
638 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
640 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
642 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
645 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
646 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
648 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
649 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
650
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
651 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
653 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
654 #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
655 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
656
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
657 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
658 *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
659 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
660 *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
661
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
662 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
663 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
664 #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
665 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
666 #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
667 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
668 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
674 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
675 GdkPixbuf *_find_pixbuf(long id)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
676 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
677 char *data = NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
678 int z;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
679
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
680 for(z=0;z<_resources.resource_max;z++)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
681 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
682 if(_resources.resource_id[z] == id)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
683 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
684 data = _resources.resource_data[z];
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
685 break;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
686 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
687 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
688
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
689 if(data)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
690 return gdk_pixbuf_new_from_xpm_data((const char **)data);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
691 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
692 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
693 #endif
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
694
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 void _size_allocate(GtkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
699 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
700 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
701 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
702 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
703 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
704 sizehints.min_height = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
705
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
706 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
708 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
709 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
710 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
711 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
712 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
713
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
714 /* Find the index of a given thread */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
715 int _find_thread_index(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
716 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
717 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
718
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
719 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
720 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
721 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
722 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
723 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
724 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
725 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
726
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
727 /* Add a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
728 void _dw_thread_add(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
729 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
730 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
731
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
732 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
733 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
734 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
735 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
736 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
737 _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
738 _background[z].pixel = 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
739 _background[z].red = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
740 _background[z].green = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
741 _background[z].blue = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
742 return;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
743 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
744 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
745 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
746
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
747 /* Remove a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
748 void _dw_thread_remove(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
749 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
750 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
751
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
752 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
753 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
754 if(_dw_thread_list[z] == (DWTID)tid)
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
755 _dw_thread_list[z] = (DWTID)-1;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
756 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
757 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
758
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
759 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
765 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
768 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
772 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
773 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
774 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
775 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
776 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
777 g_thread_init(NULL);
135
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
778 #if GTK_MAJOR_VERSION > 1
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
779 gdk_threads_init();
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
780 #endif
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
781
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
782 gtk_init(argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 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
790
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
791 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
792 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
793 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
794 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
795 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
796 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
797
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
798 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
799 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
800
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
801 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
802
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807 * Runs a message loop for Dynamic Windows.
150
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
808 */
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
809 void dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
812 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 gdk_threads_enter();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 gdk_threads_leave();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
818 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
819 * 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
820 * 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
821 * 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
822 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
823 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
824 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
825 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
826
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
827 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
828
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
829 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
830 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
831 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
832
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
833 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
834 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
835 gdk_threads_enter();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
836 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
837 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
838 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
839 _dw_msleep(1);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
840 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
841 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
842 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
843 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
844 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
845 _dw_msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
846 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
847
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
848 /*
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
849 * Processes a single message iteration and returns.
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
850 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
851 void dw_main_iteration(void)
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
852 {
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
853 _dw_thread = pthread_self();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
854 _dw_thread_add(_dw_thread);
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
855 gdk_threads_enter();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
856 gtk_main_iteration();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
857 gdk_threads_leave();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
858 }
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
859
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
860 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
868 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
871 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
876 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
877 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
878 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
879
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
880 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
881 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
882 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
883 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
884 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
885
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
886 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 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
899 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915 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
916 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
917
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
918 /* _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
919 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
920 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
921 _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
922 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
923 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
924 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 if(pthread_self() == _dw_thread)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 dw_event_wait(dialog->eve, -1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
931 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
932 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
933 _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
934 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
935 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
936
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
942
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
943 int _delete(GtkWidget *widget, GtkWidget *event, gpointer param)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
944 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
945 gtk_widget_destroy(GTK_WIDGET(param));
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
946 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
947 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
948
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
949 int _delete2(GtkWidget *widget, gpointer param)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
950 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 gtk_widget_destroy(GTK_WIDGET(param));
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
952 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
953 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
954
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
955
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
956 int _dw_ok_func(HWND window, void *data)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
957 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
958 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
959
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
960 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
961 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
962
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
963 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
964 dw_dialog_dismiss((DWDialog *)data, (void *)0);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
965 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
966 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
967
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
973 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
977 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
978 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
979 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 char outbuf[256];
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
982 int x, y;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
983
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
984 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
985 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
986 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
987
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
988 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
989 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
990 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
991
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
992 /* Archive Name */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
993 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
994 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
995
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
996 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
997
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
998 /* Buttons */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
999 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
1000
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1001 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
1002
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1003 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
1004
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1005 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
1006
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1007 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
1008
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1009 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
1010
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1011 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1012 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1013
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1014 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
1015
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1016 dw_window_show(entrywindow);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1017
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1018 dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1020 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1023 int _dw_yes_func(HWND window, void *data)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1024 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1025 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
1026
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1027 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1028 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1029
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1030 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
1031 dw_dialog_dismiss((DWDialog *)data, (void *)1);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1032 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1033 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1034
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1035 int _dw_no_func(HWND window, void *data)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1036 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1037 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
1038
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1039 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1040 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1041
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1042 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
1043 dw_dialog_dismiss((DWDialog *)data, (void *)0);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1044 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1045 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1046
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1057 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
1058 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
1059 DWDialog *dwwait;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1060 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
1061
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1062 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
1063
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1064 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
1065
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1066 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
1067
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1068 /* 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
1069 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
1070 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
1071
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1072 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
1073
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1074 /* Buttons */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1075 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
1076
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1077 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
1078
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1079 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
1080
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1081 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
1082
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1083 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
1084
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1085 dw_box_pack_start(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
1086
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1087 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
1088
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1089 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
1090 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
1091
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1092 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1093 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1094
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1095 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
1096
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1097 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
1098
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1099 return (int)dw_dialog_wait(dwwait);;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1103 * 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
1104 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1105 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1106 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1107 int dw_window_minimize(HWND handle)
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 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1110
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1111 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1112 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1113
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1114 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1115 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
1116 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
1117 DefaultScreen (GDK_DISPLAY ()));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1118 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1119 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1120 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1121
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1122 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1123 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1124 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1125 * 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
1126 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1127 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
1128 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1129 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
1130
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1131 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1132 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1133
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1134 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1135 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
1136 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1137 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1138 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1139
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1140 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1141 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1142 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1143 * 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
1144 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1145 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
1146 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1147 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
1148
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1149 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1150 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1151
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1152 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1153 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
1154 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1155 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1156 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1157
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1158 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 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
1166 GtkWidget *defaultitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1168 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1169 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1170
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 gtk_widget_show(handle);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1173 if(GTK_WIDGET(handle)->window)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1174 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1175 gdk_window_raise(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1176 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1177 gdk_window_show(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1178 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1179 }
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
1180 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
1181 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
1182 gtk_widget_grab_focus(defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1183 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1184 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1185 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1186
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1187 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1188 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1189 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1190 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1191 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1192 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1194 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1195
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1196 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1197 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1198
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 gtk_widget_hide(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1203 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1204
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1205 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1206 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1207 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1208 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1209 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1210 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1211 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1212 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1213
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1214 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1215 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1216
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 DW_MUTEX_LOCK;
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1218 if(GTK_IS_WIDGET(handle))
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1219 gtk_widget_destroy(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223
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
1224 /* 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
1225 * 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
1226 * 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
1227 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1228 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
1229 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1230 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1231
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1233 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1235 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1236 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1238 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1240 int _locked_by_me = FALSE;
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 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1243 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
1244 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 int _set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1249 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
1250 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1263 #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
1264 PangoFontDescription *font = pango_font_description_from_string(fontname);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1265
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1266 if(font)
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1267 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1268 gtk_widget_modify_font(handle, font);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1269 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1270 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1271 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 {
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1283 #if GTK_MAJOR_VERSION > 1
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1284 PangoFontDescription *pfont;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1285 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1286 GdkFont *gdkfont;
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1287 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1302 #if GTK_MAJOR_VERSION < 2
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1303 /* 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
1304 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
1305 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1306 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
1307 gdkfont = gdk_font_load(fontname);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1308 if(!gdkfont)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1309 gdkfont = gdk_font_load("fixed");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1310 gtk_object_set_data(GTK_OBJECT(handle2), "gdkfont", (gpointer)gdkfont);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1311 #endif
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1312
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1313 /* Free old font name if one is allocated */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1314 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1316 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1317
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1318 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1319 #if GTK_MAJOR_VERSION > 1
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1320 pfont = pango_font_description_from_string(fontname);
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1321
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1322 if(pfont)
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1323 {
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1324 gtk_widget_modify_font(handle2, pfont);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1325 pango_font_description_free(pfont);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1326 }
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1327 #endif
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1328 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1332 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1333 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1334 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
1335
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1336 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1337 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1338
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1339 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
1340
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1341 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1342 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1343 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1344
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1345 /* 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
1346 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
1347 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1348 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1349 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1350
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1351 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1352
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1353 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1354 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1355
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1356 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
1357 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
1358 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1359
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 int _set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1362 /* Remember that each color component in X11 use 16 bit no matter
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1363 * what the destination display supports. (and thus GDK)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1364 */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1365 GdkColor forecolor, backcolor;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1366 #if GTK_MAJOR_VERSION < 2
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1367 GtkStyle *style = gtk_style_copy(gtk_widget_get_style(handle));
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1368 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1370 if(fore & DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1371 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1372 forecolor.pixel = 0;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1373 forecolor.red = DW_RED_VALUE(fore) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1374 forecolor.green = DW_GREEN_VALUE(fore) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1375 forecolor.blue = DW_BLUE_VALUE(fore) << 8;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1377 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1378
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1379 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1380 gtk_widget_modify_text(handle, 0, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1381 gtk_widget_modify_text(handle, 1, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1382 gtk_widget_modify_fg(handle, 0, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1383 gtk_widget_modify_fg(handle, 1, &forecolor);
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1384 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1385 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1386 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1387 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1388 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1389 else if(fore != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1390 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1391 forecolor = _colors[fore];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1392
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1393 #if GTK_MAJOR_VERSION > 1
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1394 gtk_widget_modify_text(handle, 0, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1395 gtk_widget_modify_text(handle, 1, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1396 gtk_widget_modify_fg(handle, 0, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1397 gtk_widget_modify_fg(handle, 1, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1398 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1399 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1400 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1401 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1402 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1403 if(back & DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1404 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1405 backcolor.pixel = 0;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1406 backcolor.red = DW_RED_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1407 backcolor.green = DW_GREEN_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1408 backcolor.blue = DW_BLUE_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1409
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1410 gdk_color_alloc(_dw_cmap, &backcolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1411
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1412 #if GTK_MAJOR_VERSION > 1
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1413 gtk_widget_modify_base(handle, 0, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1414 gtk_widget_modify_base(handle, 1, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1415 gtk_widget_modify_bg(handle, 0, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1416 gtk_widget_modify_bg(handle, 1, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1417 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1418 if(style)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1419 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1420 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1421 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1422 else if(back != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1423 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1424 backcolor = _colors[back];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1425
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1426 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1427 gtk_widget_modify_base(handle, 0, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1428 gtk_widget_modify_base(handle, 1, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1429 gtk_widget_modify_bg(handle, 0, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1430 gtk_widget_modify_bg(handle, 1, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1431 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1432 if(style)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1433 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back];
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1434 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1435 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1436
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1437 _save_gdk_colors(handle, forecolor, backcolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1438
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1439 if(GTK_IS_CLIST(handle))
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1440 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1441 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1442
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1443 for(z=0;z<rowcount;z++)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1444 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1445 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1446 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1447 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1448 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1449
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1450 #if GTK_MAJOR_VERSION < 2
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1451 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1452 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1453 gtk_widget_set_style(handle, style);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1454 gtk_style_unref(style);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1455 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1456 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1457 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1458 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1459 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1460 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1461 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1462 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1463 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1464 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1465 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1466 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1473 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1474 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1479 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1480 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1481 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
1482 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1483 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1484 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1485
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1494 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1500 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1501 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1502 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1503
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1510 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1511 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1514 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
1515 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1519 * 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
1520 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1521 * 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
1522 * 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
1523 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1524 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
1525 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1526 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
1527 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
1528
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1529 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
1530 cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1531 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1532 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
1533 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
1534 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
1535 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1536
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1537 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1550 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1551 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1555 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559 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
1560 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 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
1563 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565 gtk_window_set_title(GTK_WINDOW(tmp), title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 if(!(flStyle & DW_FCF_SIZEBORDER))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 gtk_widget_realize(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 if(flStyle & DW_FCF_TITLEBAR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 flags |= GDK_DECOR_TITLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1574 if(flStyle & DW_FCF_MINMAX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1575 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1576
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1577 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
1578 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
1579
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
1580 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 flags |= GDK_DECOR_BORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 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
1584
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1585 if(hwndOwner)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1586 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1600 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 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
1604 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1605 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1606
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1607 gtk_widget_show(eventbox);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1608 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
1609 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
1610 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1611 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1612 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1614 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1617 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1622 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1623 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1624 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1625 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1626 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1627
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1628 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1629 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1630 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
1631 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
1632 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1633 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
1634 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
1635 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
1636 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
1637 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1638 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1639 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1640 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1641 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1645 * 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
1646 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1647 * 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
1648 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1649 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
1650 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1651 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
1652 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
1653
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1654 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
1655 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
1656 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
1657 return tmp;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1658 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1659
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1660 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1663 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1664 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1665 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1666 {
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1667 #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
1668 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
1669 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
1670 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
1671 "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
1672 " 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
1673 ". 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
1674 "."};
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1675 #endif
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1676 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679 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
1680 #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
1681 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
1682 #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
1683 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 #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
1685 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
1686
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
1687 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
1688 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
1689 #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
1690 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 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
1692 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1697 }
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 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1704 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1707 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1715 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
1716 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
1717 #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
1718 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
1719 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 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
1722 gtk_object_set_data(GTK_OBJECT(tmp), "pagearray", (gpointer)pagearray);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1730 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1736 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1737 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1738
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1739 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1740 tmp = gtk_menu_new();
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1741 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1742 accel_group = gtk_accel_group_new();
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1743 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1744 gtk_object_set_data(GTK_OBJECT(tmp), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1758 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1759 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1760
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1761 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1762 tmp = gtk_menu_bar_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location));
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1764 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1765 accel_group = gtk_accel_group_new();
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1766 gtk_object_set_data(GTK_OBJECT(tmp), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 if(box)
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1769 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1787 gtk_widget_destroy(*menu);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1793 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1796 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1801 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1802 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1803 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1804 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1805 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1806 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1807 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1808 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1809 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1810 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1813 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1815
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827 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
1828 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1830 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1831 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1832 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1833 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1835 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1842 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1843
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1844 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu), "accel");
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1845 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1854 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1855 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1856 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1857 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
1858 #if 0 /* This isn't working right */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1859 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
1860 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1861 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1862 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1863 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1864 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1865 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1866 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1869 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1870 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1871 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1872 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1873 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
1874 #if 0 /* This isn't working right */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1875 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
1876 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1877 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1878 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1879 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1880 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1881 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1882
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1883 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1884
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1885 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1886 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1887 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1888
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1889 sprintf(tempbuf, "submenu%d", submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1890 submenucount++;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1891 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1892 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1893 gtk_object_set_data(GTK_OBJECT(menu), "submenucount", (gpointer)submenucount);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1894 }
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1895
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1896 if(GTK_IS_MENU_BAR(menu))
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1897 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 else
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1899 gtk_menu_append(GTK_MENU(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1904 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1907 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1908 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1909 GtkWidget *tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1910 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
1911
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1912 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
1913 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1914
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1915 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1916 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1917 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1918 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1919
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1920 sprintf(tempbuf, "submenu%d", z);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1921
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1922 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
1923 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1924 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1925 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1926 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1927 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1928 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1929 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1930
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1938 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1944 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1948 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1949 tmphandle = _find_submenu_id(menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1953 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 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
1956 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
1976 popup = parent;
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
1977
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
1979 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983
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 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1992 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1994 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
1995 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
1996
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
1997 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 *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
2001 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 {
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
2012 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
2013
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
2014 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 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
2016 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 HWND dw_container_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2043 * 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
2044 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2045 * 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
2046 * 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
2047 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2048 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
2049 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2050 GtkWidget *tmp, *tree;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2051 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2052 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2053 GtkTreeViewColumn *col;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2054 GtkCellRenderer *rend;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2055 GtkTreeSelection *sel;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2056 #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
2057 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
2058
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2059 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
2060 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
2061 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2062 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2063
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2064 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
2065 gtk_widget_show(tmp);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2066 #if GTK_MAJOR_VERSION > 1
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2067 store = gtk_tree_store_new(4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2068 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2069 gtk_object_set_data(GTK_OBJECT(tree), "_dw_tree_store", (gpointer)store);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2070 col = gtk_tree_view_column_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2071
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2072 rend = gtk_cell_renderer_pixbuf_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2073 gtk_tree_view_column_pack_start(col, rend, FALSE);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2074 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", 1);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2075 rend = gtk_cell_renderer_text_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2076 gtk_tree_view_column_pack_start(col, rend, TRUE);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2077 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2078
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2079 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2080 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2081 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2082
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2083 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2084 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2085 #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
2086 tree = gtk_tree_new();
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2087 #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
2088 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
2089 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2090 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
2091 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
2092 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
2093 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2094 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2095 #if GTK_MAJOR_VERSION < 2
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2096 /* 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
2097 gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2098 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2099 #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
2100
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2101 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
2102 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
2103
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2104 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
2105 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
2106 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2107
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2108
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2109 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2114 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 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
2122
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2123 /* 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
2124 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 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
2127 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2133 * 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
2134 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2135 * 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
2136 * 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
2137 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2138 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2139 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2140 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2141 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2142
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2143 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2144 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2145 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
2146 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2147 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2148 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2149 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
2150
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2151 /* 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
2152 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
2153 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
2154 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
2155 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2156 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2157 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2158
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2159 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2161 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2163 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2164 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2166 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 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
2170 #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
2171 tmpbox = gtk_scrolled_window_new (NULL, NULL);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2172 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tmpbox),
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2173 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2174 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2175 tmp = gtk_text_view_new();
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2176 gtk_container_add (GTK_CONTAINER(tmpbox), tmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2177 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2178 scroller = NULL;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2179 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2184 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185 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
2186 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
2187 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
2188 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
2189 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2191 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 return tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2198 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2204 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2205 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2208
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2210 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2238 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 * text: The default text to be in the combpbox widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 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
2254 SignalHandler *work = malloc(sizeof(SignalHandler));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2257 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2258 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 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
2264
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2265 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
2266 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
2267 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
2268
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2269 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
2270 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312 dw_window_set_bitmap(bitmap, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 tooltips = gtk_tooltips_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2321 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2322 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2323 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2325 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 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
2341 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2353 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2355 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2357 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 tmp = gtk_radio_button_new_with_label(NULL, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2372 * 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
2373 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2374 * 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
2375 * 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
2376 * 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
2377 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2378 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
2379 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2380 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
2381 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
2382 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
2383
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2384 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
2385 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
2386 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
2387 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
2388 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2389 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
2390 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
2391 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
2392 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
2393 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
2394 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
2395 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
2396 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
2397 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
2398 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2399
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2400 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2401 * Create a new scrollbar window (widget) to be packed.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2402 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2403 * vertical: TRUE or FALSE if scrollbar is vertical.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2404 * increments: Number of increments available.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2405 * id: An ID to be used with WinWindowFromID() or 0L.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2406 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2407 HWND dw_scrollbar_new(int vertical, int increments, ULONG id)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2408 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2409 GtkWidget *tmp;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2410 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2411 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2412
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2413 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2414 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2415 if(vertical)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2416 tmp = gtk_vscrollbar_new(adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2417 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2418 tmp = gtk_hscrollbar_new(adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2419 GTK_WIDGET_UNSET_FLAGS(tmp, GTK_CAN_FOCUS);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2420 gtk_widget_show(tmp);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2421 gtk_object_set_data(GTK_OBJECT(tmp), "adjustment", (gpointer)adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2422 gtk_object_set_data(GTK_OBJECT(adjustment), "scrollbar", (gpointer)tmp);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2423 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2424 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2425 return tmp;
196
3dc60d60007f Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 195
diff changeset
2426 }
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2427
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2428 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2429 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2433 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2436 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2443 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2471 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2503 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 GdkPixmap *icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 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
2508 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2517 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 void dw_window_set_bitmap(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2523 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2524 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 GdkPixmap *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 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
2529 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 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
2531 #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
2532 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
2533 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 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
2535 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 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
2556 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2557 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2558 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
2559 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2560 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
2561 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2563 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2565 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2566 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2574 #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
2575 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
2576 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 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
2578 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 return strdup(possible);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 }
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 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2619 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
2620 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2621 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
2622
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2623 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
2624 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2625 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
2626 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2627 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
2628 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2629 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2630 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2631 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
2632 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2633
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646 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
2647 #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
2648 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
2649 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650 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
2651 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2653 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654
120
7d2108cbcd3e Porting DW 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(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
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 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
2659 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
2660 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
2661
7d2108cbcd3e Porting DW 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 _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
2663
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2664 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
2665 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
2666 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
2667 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2668 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(impbuf);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2669 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
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 #else
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2672 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont");
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2673
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2675 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2676 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
2677 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
2678 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
2679
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2680 _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
2681
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682 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
2683 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684 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
2685 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 }
120
7d2108cbcd3e Porting DW 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 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2690 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2691 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2694 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2695 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2698 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2699 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2700 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2701 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2702 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2703 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2704 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2705
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 DW_MUTEX_LOCK;
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2707 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2708 if(GTK_IS_SCROLLED_WINDOW(handle))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2709 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2711 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2713 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2715 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2716 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2717 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2718 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2719 GtkTextIter start, end;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2720
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2721 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2722 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2723 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2724 text = gtk_text_iter_get_text(&start, &end);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2725 if(text) /* Should this get freed? */
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2726 strcpy(buffer, text);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2727 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2728 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2729 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2730 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2731 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2732 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 strcpy(buffer, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2738 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2747 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2748 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2749 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2750 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2751 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2752 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2753
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2754 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2755 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2756 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2757 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2758
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2759 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
2760 #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
2761 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
2762 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2763 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2764
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2765 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
2766 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2767 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
2768
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2769 if(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
2770 *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
2771 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
2772 *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
2773 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2774 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2775 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2778 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2783 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 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
2790
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2805 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 void dw_mle_delete(HWND handle, int startpoint, int length)
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
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2822 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2823 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2825 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2827 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2829 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2830 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2831 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2832 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2833 GtkTextIter start, end;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2834
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2835 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2836 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2837 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2838 gtk_text_buffer_delete(tbuffer, &start, &end);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2839 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2840 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 }
120
7d2108cbcd3e Porting DW 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 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
2847 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860 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
2861 #if GTK_MAJOR_VERSION > 1
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2862 if(GTK_IS_SCROLLED_WINDOW(handle))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2863 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2864 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2865
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2866 if(tmp && GTK_IS_TEXT_VIEW(tmp))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2867 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2868 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2869
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2870 length = -1;
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2871 gtk_text_buffer_set_text(buffer, "", length);
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2872 }
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2873 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2874 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2877 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2886 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2897 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2899
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2900 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
2901 #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
2902 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2905 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 dw_mle_query(handle, NULL, &lines);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2915 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918 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
2919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2921 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2922 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2924 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2925 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2928 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2929 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2930 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2931 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2932 * 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
2933 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2934 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2935 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2936 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2937
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2938 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
2939 #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
2940 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
2941 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2942 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2943
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2944 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
2945 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
2946 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2947 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2948 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2949 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2950 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2951
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2952 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2953 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
2954 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2955 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2956 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2957 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2958
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2959 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2960 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2961 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2962 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2963 * 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
2964 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2965 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
2966 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2967 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2968
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2969 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
2970 #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
2971 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
2972 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2973 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2974
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2975 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
2976 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
2977 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2978 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2979 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2980 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2981 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2982
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2983 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2984 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2985 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
2986 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
2987 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2988 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2989 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2990 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2991 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2992
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2993 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 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
3004 #if GTK_MAJOR_VERSION > 1
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3005 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3006 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3008 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3010 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3012 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3013 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3014 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3015 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3016 GtkTextIter iter;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3017
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3018 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3019 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3020 gtk_text_buffer_place_cursor(tbuffer, &iter);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3021 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3022 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3025 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3026 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3027
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3028 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
3029
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3030 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3031 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3032 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
3033
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3034 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
3035
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3036 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
3037 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3038 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3039 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3040 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3041 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3042 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3043 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3046 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 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
3058 #if GTK_MAJOR_VERSION > 1
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3059 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3060 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3061 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3062 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3063 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3064 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3065
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3066 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3067 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3068 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3069 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3070 GtkTextIter iter, found;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3071
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3072 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3073 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3074 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3075 retval = gtk_text_iter_get_offset(&found);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3076 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3077 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3078 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3079 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3080 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3081 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3083 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3085 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3113 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3116 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3117 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3128 {
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3129 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3132 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3133 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3135 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3142 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
3143 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 {
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3153 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3159 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3166 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
3167 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3171 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 * 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
3173 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3175 unsigned int dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 return 100;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3178 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3181 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 * 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
3183 * 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
3184 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3186 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3192 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3193 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3196 * 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
3197 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3198 * 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
3199 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3200 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
3201 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3202 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
3203 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
3204
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3205 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
3206 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
3207
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3208 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
3209 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
3210 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
3211 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3212 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
3213 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
3214
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3215 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
3216 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
3217 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3218 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
3219 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3220 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
3221 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
3222 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3223
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3224 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3225 * 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
3226 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3227 * 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
3228 * 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
3229 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3230 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
3231 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3232 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
3233 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
3234
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3235 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
3236 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3237
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3238 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
3239 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
3240 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
3241 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3242 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
3243
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3244 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
3245 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
3246 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3247 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
3248 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3249 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
3250 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3251
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3252 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3253 * Returns the position of the scrollbar.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3254 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3255 * handle: Handle to the scrollbar to be queried.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3256 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3257 unsigned int dw_scrollbar_query_pos(HWND handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3258 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3259 int val = 0, _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3260 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3261
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3262 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3263 return 0;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3264
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3265 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3266 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3267 if(adjustment)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3268 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3269 int max = _round_value(adjustment->upper) - 1;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3270 int thisval = _round_value(adjustment->value);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3271
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3272 if(GTK_IS_VSCROLLBAR(handle))
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3273 val = max - thisval;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3274 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3275 val = thisval;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3276 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3277 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3278 return val;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3279 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3280
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3281 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3282 * Sets the scrollbar position.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3283 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3284 * handle: Handle to the scrollbar to be set.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3285 * position: Position of the scrollbar withing the range.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3286 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3287 void dw_scrollbar_set_pos(HWND handle, unsigned int position)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3288 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3289 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3290 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3291
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3292 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3293 return;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3294
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3295 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3296 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3297 if(adjustment)
215
03e68274623d Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 214
diff changeset
3298 gtk_adjustment_set_value(adjustment, (gfloat)position);
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3299 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3300 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3301
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3302 /*
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3303 * Sets the scrollbar range.
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3304 * Parameters:
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3305 * handle: Handle to the scrollbar to be set.
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3306 * range: Maximum range value.
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3307 * visible: Visible area relative to the range.
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3308 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3309 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3310 {
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3311 int _locked_by_me = FALSE;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3312 GtkAdjustment *adjustment;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3313
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3314 if(!handle)
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3315 return;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3316
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3317 DW_MUTEX_LOCK;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3318 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "adjustment");
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3319 if(adjustment)
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3320 {
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3321 adjustment->upper = (gdouble)range;
216
bd06f8d123f0 Oops typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 215
diff changeset
3322 adjustment->page_increment = adjustment->page_size = (gdouble)visible;
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3323 }
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3324 DW_MUTEX_UNLOCK;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3325 }
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3326
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3327 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 curval = dw_spinbutton_query(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 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
3358 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3367 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3368 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 /* TODO: can this be done after the fact? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3370 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3374 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3377 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3388
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3421 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3422 * 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
3423 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3424 * 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
3425 * 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
3426 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3427 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3428 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3429 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3430 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3431 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
3432 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3433 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3434 GtkWidget *tree;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3435 GtkTreeIter *iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3436 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3437 GdkPixbuf *pixbuf;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3438 HWND retval = 0;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3439 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3440
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3441 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3442 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3443
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3444 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3445 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3446 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3447 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3448 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3449 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3450
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3451 pixbuf = _find_pixbuf(icon);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3452
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3453 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3454 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3455 g_object_unref(pixbuf);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3456 retval = (HWND)iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3457 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3458 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3459
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3460 return retval;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3461 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3462 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3463 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3464 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
3465 int position = -1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3466 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3467
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3468 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3469 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3470
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3471 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3472 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
3473 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3474 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3475 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3476 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3477 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3478
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3479 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3480 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
3481
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3482 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3483
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3484 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3485 label = gtk_label_new(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3486 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
3487 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
3488 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
3489 hbox = gtk_hbox_new(FALSE, 2);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3490 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
3491 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
3492 #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
3493 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
3494 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3495 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
3496 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3497 gtk_container_add(GTK_CONTAINER(newitem), hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3498 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
3499 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
3500 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3501 gtk_widget_show(pixmap);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3502 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3503
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3504 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3505 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3506 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
3507 if(!subtree)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3508 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3509 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
3510 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
3511
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3512 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3513
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3514 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3515 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
3516
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3517 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
3518 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
3519
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3520 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3521 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
3522
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3523 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
3524 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
3525 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
3526 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
3527 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
3528 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3529 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
3530 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
3531 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3532 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
3533 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
3534 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3535 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3536 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3537 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
3538 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
3539 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3540 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
3541 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
3542 gtk_widget_show(newitem);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3543 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3544 return newitem;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3545 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3546 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3547
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3548 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3549 * 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
3550 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3551 * 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
3552 * 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
3553 * 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
3554 * 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
3555 * 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
3556 */
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
3557 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
3558 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3559 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3560 GtkWidget *tree;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3561 GtkTreeIter *iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3562 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3563 GdkPixbuf *pixbuf;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3564 HWND retval = 0;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3565 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3566
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3567 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3568 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3569
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3570 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3571 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3572 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3573 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3574 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3575 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3576
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3577 pixbuf = _find_pixbuf(icon);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3578
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3579 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3580 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3581 g_object_unref(pixbuf);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3582 retval = (HWND)iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3583 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3584 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3585
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3586 return retval;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3587 #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
3588 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
3589 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3590 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
3591 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
3592
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3593 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3594 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3595
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3596 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
3597 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
3598 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
3599 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3600 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
3601 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
3602 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3603 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
3604 label = gtk_label_new(title);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3605 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
3606 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
3607 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
3608 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
3609 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
3610 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
3611 #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
3612 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
3613 #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
3614 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
3615 #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
3616 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
3617 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
3618 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
3619 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
3620 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
3621 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
3622
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3623 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
3624 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3625 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
3626 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
3627 {
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3628 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
3629 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
3630
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3631 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3632
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3633 if(thisfunc && work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3634 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
3635
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
3636 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
3637 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
3638
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3639 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
3640 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
3641
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3642 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
3643 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
3644 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
3645 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
3646 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
3647 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
3648 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
3649 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
3650 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3651 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
3652 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
3653 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3654 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3655 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3656 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
3657 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
3658 }
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
3659 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
3660 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
3661 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
3662 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
3663 return item;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3664 #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
3665 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3666
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3667 /*
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
3668 * 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
3669 * 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
3670 * 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
3671 * 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
3672 * 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
3673 * 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
3674 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3675 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
3676 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3677 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3678 GtkWidget *tree;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3679 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3680 GdkPixbuf *pixbuf;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3681 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3682
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3683 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3684 return;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3685
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3686 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3687 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3688 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3689 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3690 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3691 pixbuf = _find_pixbuf(icon);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3692
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3693 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3694 g_object_unref(pixbuf);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3695 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3696 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3697 #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
3698 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
3699 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3700 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
3701 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
3702 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
3703
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3704 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3705 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3706
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
3707 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
3708 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
3709 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
3710 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
3711 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
3712 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
3713 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
3714 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
3715 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
3716 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
3717 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
3718 #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
3719 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
3720 #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
3721 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
3722 #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
3723 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
3724 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
3725 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
3726 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
3727 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
3728 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
3729 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3730 #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
3731 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3732
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3733 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3734 * 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
3735 * 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
3736 * 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
3737 * 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
3738 * 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
3739 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3740 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
3741 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3742 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3743 GtkWidget *tree;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3744 GtkTreeStore *store;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3745 int _locked_by_me = FALSE;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3746
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3747 if(!handle || !item)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3748 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3749
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3750 DW_MUTEX_LOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3751 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3752 && GTK_IS_TREE_VIEW(tree) &&
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3753 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3754 gtk_tree_store_set(store, (GtkTreeIter *)item, 2, itemdata, -1);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3755 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3756 #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
3757 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
3758
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3759 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3760 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3761
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
3762 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
3763 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
3764 DW_MUTEX_UNLOCK;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3765 #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
3766 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3767
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3768 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3769 * 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
3770 * 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
3771 * 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
3772 * 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
3773 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3774 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
3775 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3776 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3777 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3778 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3779 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3780
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3781 if(!handle || !item)
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3782 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3783
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3784 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3785 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3786 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3787 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3788 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3789 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3790 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3791
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3792 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3793 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3794 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3795 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3796 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3797 #else
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
3798 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
3799 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
3800
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3801 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3802 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3803
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
3804 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
3805 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
3806 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
3807 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
3808 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
3809 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
3810 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
3811 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3812 #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
3813 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3814
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
3815 #if GTK_MAJOR_VERSION > 1
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3816 void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent)
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3817 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3818 void *data;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3819 GtkTreeIter iter;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3820
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3821 gtk_tree_model_get(store, &parent, 3, &data, -1);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3822 if(data)
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3823 free(data);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3824 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3825
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3826 if(gtk_tree_model_iter_children(store, &iter, &parent))
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3827 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3828 do {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3829 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3830 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3831 }
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3832 }
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
3833 #endif
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3834
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
3835 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3836 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3837 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3838 * 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
3839 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3840 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3841 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3842 #if GTK_MAJOR_VERSION > 1
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3843 GtkWidget *tree;
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3844 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3845 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3846
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3847 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3848 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3849
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3850 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3851 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3852 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3853 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3854 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3855 GtkTreeIter iter;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3856
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3857 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3858 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3859 do {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3860 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3861 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3862 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3863 gtk_tree_store_clear(store);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
3864 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3865 DW_MUTEX_UNLOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3866 #else
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3867 GtkWidget *tree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3868 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3869
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3870 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3871 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3872
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3873 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3874 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
3875 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3876 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3877 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3878 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3879 }
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
3880 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
3881 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
3882 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3883 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3884 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3885
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3886 /*
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3887 * 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
3888 * 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
3889 * 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
3890 * 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
3891 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3892 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
3893 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3894 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3895 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3896 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3897 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3898
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3899 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3900 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3901
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3902 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3903 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3904 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3905 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3906 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3907 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3908 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3909 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3910 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3911 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3912 #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
3913 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
3914
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3915 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3916 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3917
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3918 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
3919 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
3920 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
3921 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3922 #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
3923 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3924
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3925 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3926 * 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
3927 * 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
3928 * 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
3929 * 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
3930 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3931 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
3932 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3933 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3934 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3935 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3936 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3937
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3938 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3939 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3940
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3941 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3942 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3943 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3944 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3945 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3946 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3947 gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3948 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3949 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3950 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3951 #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
3952 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
3953
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3954 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3955 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3956
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
3957 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
3958 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
3959 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
3960 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3961 #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
3962 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3963
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3964 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3965 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3966 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3967 * 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
3968 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3969 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3970 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
3971 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3972 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3973 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3974 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3975 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3976
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3977 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3978 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3979
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3980 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3981 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3982 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3983 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3984 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3985 gtk_tree_store_remove(store, (GtkTreeIter *)item);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3986 free(item);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3987 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
3988 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3989 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3990 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3991 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3992
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3993 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
3994 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3995
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3996 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3997 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
3998 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3999 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4000 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4001 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4002 }
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
4003
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
4004 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
4005
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
4006 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
4007
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
4008 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4009 {
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
4010 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
4011 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
4012 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4013
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4014 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
4015 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
4016 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4017 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4018 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4019
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 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
4021 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4038 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
4039 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 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
4041 gtk_object_set_data(GTK_OBJECT(clist), "multi", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 gtk_widget_show(clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4070 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4071 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4078 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4079 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4080 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4081 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4082 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 char **newtitles = malloc(sizeof(char *) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 newtitles[0] = "Icon";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 newtitles[1] = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 memcpy(&newtitles[2], titles, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4096 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4098 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4099
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4100 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4101 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4102 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4105 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4106 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4107 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4108 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4109 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4110 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4111 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4112 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4127 /* 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
4128 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
4129 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4130 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
4131
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4132 if(list)
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4133 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
4134
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4135 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
4136
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
4137 _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
4138 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
4139 _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
4140 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4141
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4143 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 int z, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4152 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4175 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
4176 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 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
4181 if(fore)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4182 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
4183 if(back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4184 gtk_clist_set_background(GTK_CLIST(clist), z, back);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4186 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4200 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4222 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
4223 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
4224
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4243 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4244 CDATE cdate = *((CDATE *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4245
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4246 curtm.tm_mday = cdate.day;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4247 curtm.tm_mon = cdate.month - 1;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4248 curtm.tm_year = cdate.year - 1900;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4249
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4250 strftime(textbuffer, 100, "%x", &curtm);
46
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
4251
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4256 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4257 CTIME ctime = *((CTIME *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4258
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4259 curtm.tm_hour = ctime.hours;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4260 curtm.tm_min = ctime.minutes;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4261 curtm.tm_sec = ctime.seconds;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4262
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4263 strftime(textbuffer, 100, "%X", &curtm);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
4264
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4271 * Changes an existing item in specified row and column to the given data.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4272 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4273 * handle: Handle to the container window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4274 * column: Zero based column of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4275 * row: Zero based row of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4276 * data: Pointer to the data to be added.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4277 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4278 void dw_container_change_item(HWND handle, int column, int row, void *data)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4279 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4280 dw_container_set_item(handle, NULL, column, row, data);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4281 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4282
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4283 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292 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
4293 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309 dw_container_set_item(handle, pointer, column + 2, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4313 * 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
4314 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4315 * 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
4316 * 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
4317 * 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
4318 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4319 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
4320 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4321 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
4322 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
4323
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4324 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
4325 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
4326
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4327 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
4328 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
4329 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
4330 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4331
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4332 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4373 * 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
4374 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4375 * 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
4376 * 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
4377 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4378 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
4379 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4380 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
4381 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
4382
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4383 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
4384 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
4385 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
4386 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4387 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
4388
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4389 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
4390
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4391 _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
4392
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4393 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
4394 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
4395
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4396 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
4397 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
4398 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4399 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
4400
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4401 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
4402 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4403 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
4404 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4405
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4406 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 * 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
4410 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
4412 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4421 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 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
4423 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4438 * 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
4439 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4440 * 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
4441 * 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
4442 * 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
4443 * 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
4444 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4445 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
4446 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4447 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
4448 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
4449 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
4450
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4451 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
4452 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
4453 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
4454 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4455 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
4456 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
4457 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4458 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
4459 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4460 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
4461 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
4462 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4463 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
4464 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
4465 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4466 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4467 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
4468 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4469 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4470 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
4471 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4472
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4473 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4475 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4485 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4496
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4497 /* 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
4498 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4500 /* 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
4501 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
4502 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4503 g_list_free(list);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4504
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4505 /* 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
4506 * current selection list.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4507 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4508 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
4509 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
4510 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
4511 _dw_unselect(clist);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4512
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4513 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4514 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4515 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
4516 if(list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4517 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4518 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4519 retval = "";
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4520 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4521 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4522 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4523 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4524 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 }
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 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4538 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4539 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4540 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4541 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4542 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4543 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4544 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4546 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4547 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4549 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4555 /* 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
4556 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4558 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
4559
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4560 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4562 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
4563 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
4564
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4565 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4566 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4567 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4568 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4569 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4570
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4571 if(list && list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4572 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4573 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
4574 retval = "";
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4575 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4576 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4577 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4578 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4579 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
4580
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4581 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
4582 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4584 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4589 * 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
4590 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4591 * 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
4592 * 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
4593 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4594 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
4595 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4596 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
4597 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4598 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4599 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4600
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4601 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4602 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
4603
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4604 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4605 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4606 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4607 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4608 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4609 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
4610
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4611 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
4612 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4613 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
4614 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4615 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4616 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4617 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
4618
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4619 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4620
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4621 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
4622
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4623 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
4624 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
4625 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4626 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4627 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4628 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4629
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4630 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4631 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4632
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4633 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4634 * Deletes the item with the text speficied.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4635 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4636 * handle: Handle to the window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4637 * text: Text usually returned by dw_container_query().
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4638 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4639 void dw_container_delete_row(HWND handle, char *text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4640 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4641 int _locked_by_me = FALSE;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4642 GtkWidget *clist;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4643 int rowcount, z;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4644 char *rowdata;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4645
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4646 DW_MUTEX_LOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4647 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4648
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4649 if(!clist)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4650 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4651 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4652 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4653 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4654 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "rowcount");
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4655
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4656 for(z=0;z<rowcount;z++)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4657 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4658 rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4659 if(rowdata == text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4660 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4661 _dw_unselect(clist);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4662
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4663 gtk_clist_remove(GTK_CLIST(clist), z);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4664
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4665 rowcount--;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4666
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4667 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4668 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4669 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4670 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4671 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4672
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4673 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4674 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4675
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
4676 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4677 * 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
4678 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4679 * 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
4680 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4681 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
4682 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4683 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
4684 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4685 int colcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4686
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4687 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4688 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
4689
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4690 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4691 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4692 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4693 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4694 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4695 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
4696 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
4697 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4698 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
4699 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
4700 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4701 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4702 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4703
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
4704 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 | GDK_BUTTON_PRESS_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 | GDK_POINTER_MOTION_HINT_MASK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4729 /* Returns a GdkColor from a DW color */
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4730 GdkColor _internal_color(unsigned long value)
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4731 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4732 if(DW_RGB_COLOR & value)
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4733 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4734 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4735 return color;
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4736 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4737 else if (value < 16)
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4738 return _colors[value];
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4739 return _colors[0];
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4740 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4741
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4750 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4751 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4755 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4767 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
4768 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4772 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4778 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4779 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4780
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4781 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4782 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4786 gdk_gc_set_foreground(gc, &_foreground[index]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4787 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 return gc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4816
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 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
4827 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 DW_MUTEX_UNLOCK;
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 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 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
4854 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 GdkGC *gc = NULL;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4883 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4884 PangoFontDescription *font;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4885 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 GdkFont *font;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4887 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889
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
4890 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
4891 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
4892
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4906 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4907 font = pango_font_description_from_string(fontname);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4908 if(font)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4909 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4910 PangoContext *context = gdk_pango_context_get();
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4911
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4912 if(context)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4913 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4914 PangoLayout *layout = pango_layout_new(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4915
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4916 if(layout)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4917 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4918 pango_layout_set_font_description(layout, font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4919 pango_layout_set_text(layout, text, strlen(text));
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4920
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4921 gdk_draw_layout(handle ? handle->window : pixmap->pixmap, gc, x, y + 2, layout);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4922
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4923 g_object_unref(layout);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4924 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4925 g_object_unref(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4926 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4927 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4928 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4929 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 font = gdk_font_load(fontname);
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
4931 if(!font)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
4932 font = gdk_font_load("fixed");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 gint ascent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 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
4938 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
4939 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4941 #endif
149
6028f787f7c8 Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 148
diff changeset
4942 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946
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
4947 /* 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
4948 * 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
4949 * 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
4950 * 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
4951 * 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
4952 * 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
4953 * 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
4954 */
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
4955 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
4956 {
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
4957 int _locked_by_me = FALSE;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4958 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4959 PangoFontDescription *font;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4960 #else
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
4961 GdkFont *font;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4962 #endif
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
4963 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
4964
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
4965 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
4966 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
4967
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
4968 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
4969 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
4970 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
4971 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
4972 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
4973
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4974 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4975 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4976 if(font)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4977 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4978 PangoContext *context = gdk_pango_context_get();
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4979
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4980 if(context)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4981 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4982 PangoLayout *layout = pango_layout_new(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4983
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4984 if(layout)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4985 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4986 PangoRectangle rect;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4987
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4988 pango_layout_set_font_description(layout, font);
233
f2435b378aed We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 216
diff changeset
4989 pango_layout_set_text(layout, text, -1);
f2435b378aed We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 216
diff changeset
4990 pango_layout_get_pixel_extents(layout, NULL, &rect);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4991
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4992 if(width)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4993 *width = rect.width;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4994 if(height)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4995 *height = rect.height;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4996
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4997 g_object_unref(layout);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4998 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
4999 g_object_unref(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5000 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5001 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5002 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5003 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5004
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
5005 font = gdk_font_load(fontname ? fontname : "fixed");
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5006 if(!font)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5007 font = gdk_font_load("fixed");
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5008 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
5009 {
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
5010 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
5011 *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
5012 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
5013 *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
5014 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
5015 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5016 #endif
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5017 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
5018 }
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
5019
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
5039 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5061 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 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
5070 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
5073 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 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
5076 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 {
133
85f8ba78736d Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 132
diff changeset
5087 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 DW_MUTEX_UNLOCK;
133
85f8ba78736d Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 132
diff changeset
5093 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 gdk_pixmap_unref(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 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
5127 {
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
5128 /* 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
5129 * 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
5130 * 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
5131 * 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
5132 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135
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
5136 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 gc = _set_colors(src->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 gc = gdk_gc_new(srcp->pixmap);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5148
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5149 if(gc)
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5150 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
5151 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
5152 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5172 void _my_strlwr(char *buf)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5173 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5174 int z, len = strlen(buf);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5175
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5176 for(z=0;z<len;z++)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5177 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5178 if(buf[z] >= 'A' && buf[z] <= 'Z')
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5179 buf[z] -= 'A' - 'a';
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5180 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5181 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5182
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5183 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5184 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5185 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5186 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5187 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5188 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5189 int dw_module_load(char *name, HMOD *handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5190 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5191 int len;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5192 char *newname;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5193 char errorbuf[1024];
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5194
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5195
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5196 if(!handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5197 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5198
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5199 if((len = strlen(name)) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5200 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5201
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5202 /* Lenth + "lib" + ".so" + NULL */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5203 newname = malloc(len + 7);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5204
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5205 if(!newname)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5206 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5207
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5208 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5209 _my_strlwr(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5210
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5211 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5212 if(*handle == NULL)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5213 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5214 strncpy(errorbuf, dlerror(), 1024);
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
5215 printf("%s\n", errorbuf);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5216 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5217 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5218 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5219
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5220 free(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5221
163
0322836c5299 Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 162
diff changeset
5222 return (NULL == *handle) ? -1 : 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5223 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5224
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5225 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5226 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5227 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5228 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5229 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5230 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5231 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5232 int dw_module_symbol(HMOD handle, char *name, void**func)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5233 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5234 if(!func || !name)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5235 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5236
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5237 if(strlen(name) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5238 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5239
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5240 *func = (void*)dlsym(handle, name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5241 return (NULL == *func);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5242 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5243
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5244 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5245 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5246 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5247 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5248 int dw_module_close(HMOD handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5249 {
162
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5250 if(handle)
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5251 return dlclose(handle);
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
5252 return 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5253 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
5254
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5255 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5256 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5257 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5258 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5259 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5260 HMTX mutex = malloc(sizeof(pthread_mutex_t));
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5261
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5262 pthread_mutex_init(mutex, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5263 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5265
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5266 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5267 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5268 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5273 if(mutex)
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5274 {
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5275 pthread_mutex_destroy(mutex);
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5276 free(mutex);
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5277 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5279
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 {
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
5287 /* 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
5288 * 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
5289 */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
5290 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
5291 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
5292
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5293 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
5294
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
5295 /* 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
5296 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
5297 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
5307 pthread_mutex_unlock(mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5328 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5423 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5424 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5425 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5426 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5427 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5428 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5429
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5430 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5431
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5432 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5433 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5434 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5435 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5436 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5437 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5445 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5447 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5448
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5449 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5450 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5451
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5452 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5454 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5455
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5461 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5462 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5463
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5464 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5465 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5466 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5467 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5468 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5469 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5470 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5471
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5472 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5473 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5482 #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
5483
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5493 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5494 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5495 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
5496 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5497 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5498 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5499
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5500 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5501 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5502
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5503 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5505 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
5506 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5507
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5514 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5516 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
5517 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
5518
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5519 /* 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
5520 * 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
5521 * 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
5522 * 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
5523 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5524 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5525 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5526 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
5527
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5528 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5529 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5530 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5531 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
5532 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5533 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5534 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5535
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5536 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
5537 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
5538 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5539 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
5540
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5541 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
5542 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5543 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5544 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5545 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5546 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5547 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5552 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5562 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5563 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5564 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
5565
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5566 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5567 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5568 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5569 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
5570 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5571 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5572 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5573
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5574 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5575 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
5576 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5596 if(!handle)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5597 return;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5598
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 if(GTK_IS_WINDOW(handle))
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5601 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 _size_allocate(GTK_WINDOW(handle));
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5603 if(handle->window)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5604 gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height);
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5605 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height);
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5606 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608 gtk_widget_set_usize(handle, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5610 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5619
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5629 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646 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
5647 retval = gdk_visual_get_best_depth();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5661 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5664 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 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
5679 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5682 if(!handle)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5683 return;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5684
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5685 DW_MUTEX_LOCK;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5686 if(GTK_IS_WINDOW(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 _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
5689
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5690 gtk_widget_set_uposition(handle, x, y);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5691 if(handle->window)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5692 gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5693 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
5694 }
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5695 else if(handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 gdk_window_resize(handle->window, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5708 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 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
5713 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715 gint gx, gy, gwidth, gheight, gdepth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
5717 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5720
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 gdk_window_get_root_origin(handle->window, &gx, &gy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 *y = gy;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5727 if(GTK_IS_WINDOW(handle))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5728 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5729 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5730 *width = gwidth + _dw_border_width;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5731 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5732 *height = gheight + _dw_border_height;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5733 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5734 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5735 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5736 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5737 *width = gwidth;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5738 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5739 *height = gheight;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5740 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764 if(GTK_IS_CLIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 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
5767 {
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
5768 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
5769 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
5770 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 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
5772 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 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
5774 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
5775 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5776 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5777 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
5778 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5779 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
5780 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5781 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5782
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5783 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5784
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5785 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5786 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5787
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5788 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5789 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5790
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5791 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
5792 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5793 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5794 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
5795 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5805 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5806 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5807 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5808 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5809 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
5810 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5811
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5812 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
5813 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
5814
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5815 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
5816 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5817 for(z=0;z<256;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5818 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5819 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
5820 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5821 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
5822 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
5823
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5824 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
5825 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
5826
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5827 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
5828 /* 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
5829 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
5830 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
5831 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
5832 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5834 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 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
5836
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5841 /* 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
5842 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
5843 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5844 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
5845 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
5846
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5847 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
5848 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5849 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
5850 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5851 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
5852 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5853 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
5854 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
5855 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5856 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5857 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5858 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
5859 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5860
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5861 /* 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
5862 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
5863 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5864 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
5865 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
5866 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
5867
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5868 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
5869 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5870 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
5871 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5872 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
5873 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
5874 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5875 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5876 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
5877 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5878
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5883 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5884 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5885 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5886 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5887 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
5888 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5889
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5890 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
5891 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
5892 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
5893 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5894 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
5895 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
5896 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
5897 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5901 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5902 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5903 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5904 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5905 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5906 unsigned int dw_notebook_page_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5907 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5908 int retval, phys;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 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
5912 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
5913 retval = _get_logical_page(handle, phys);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5926 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 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
5929 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
5930 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
5931 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 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
5946 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 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
5949 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
5950 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
5951 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5952 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
5953 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
5954
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5955 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
5956 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
5957 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
5958 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5959
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5960 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
5961 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5962 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
5963 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
5964 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
5965 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
5990 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
5991 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
5992 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
5993 char ptext[100];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 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
5996 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
5997 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
5998 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
5999 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
6000
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6001 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
6002 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6003 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
6004 return;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6005 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6006
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6007 /* 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
6008 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
6009 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6010 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
6011 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6012 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
6013 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
6014 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6015 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
6016 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
6017 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
6018 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
6019 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
6020 break;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6021 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6022 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6023 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6024
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6025 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
6026
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6027 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
6028
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6029 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6030 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6031 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
6032 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6033 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6034
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6035 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
6036 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
6037 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
6038 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
6039 else
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6040 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6062 gtk_object_set_data(GTK_OBJECT(handle), "appending", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 GList *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 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
6068 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
6069 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6076 _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
6077 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
6078 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 }
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6096 gtk_object_set_data(GTK_OBJECT(handle), "appending", NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6113 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6114 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6115 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6116 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6117 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6118 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6134 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6135 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6136 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6138 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6157 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6158 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6159 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6160 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6161 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6170 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6171 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6173 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6174 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6175 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6176 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6178 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6179 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6180 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6181 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6182 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6183 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6184 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6185 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6186 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6187 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6189 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6190 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6191 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6192 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6193 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6194 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6195 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6196 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6197 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6198 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6199 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6200 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6202 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6204 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6205
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6206 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6207
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6208 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6209 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6210 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6211 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6212 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6214 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6215 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6216 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6217 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6218 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6219 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6226
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6227 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6228 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6229 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6230 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6231 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6232 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6233 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6234 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6235 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6236 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6237 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6238 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6239 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6240 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6246 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6247 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6259 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6261 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6262 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6274 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6275 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6276 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6277 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6279 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6280 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6281 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6282 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6293 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6303 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6304 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6305 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6306
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 if(counter == index)
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 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6320 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6344 #if GTK_MAJOR_VERSION < 2
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6345 /* Check if a GList item is in another GList */
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6346 int _dw_in_list(GList *item, GList *list)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6347 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6348 while(list)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6349 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6350 if(list->data == item->data)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6351 return TRUE;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6352
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6353 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6354 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6355 return FALSE;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6356 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6357 #endif
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6358
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6360 * 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
6361 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6362 * 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
6363 * 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
6364 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6365 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
6366 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6367 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6368 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6369 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6370
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6371 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6372 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6373 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6374 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
6375 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6376 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6377 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6378 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6379 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6380 #if GTK_MAJOR_VERSION > 1
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6381 int counter = 0;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6382 GList *list = GTK_LIST(handle2)->children;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6383
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6384 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6385 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6386 GtkItem *item = (GtkItem *)list->data;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6387
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6388 if(item &&
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6389 item->bin.container.widget.state == GTK_STATE_SELECTED
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6390 && counter > where)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6391 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6392 retval = counter;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6393 break;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6394 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6395
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6396
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6397 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6398 counter++;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6399 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6400 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6401 int counter = 0;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6402 GList *list = GTK_LIST(handle2)->children;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6403
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6404 while(list)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6405 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6406 if(counter > where && _dw_in_list(list, GTK_LIST(handle2)->selection))
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6407 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6408 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6409 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6410 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6411
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6412 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6413 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6414 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6415 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6416 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6417 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6418 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6419 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6420
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6421 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6422 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6423 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6436 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6437 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6438 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 GList *list = GTK_LIST(handle2)->children;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6449 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6450 GList *selection = GTK_LIST(handle2)->undo_unselection;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6451 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6452 GList *selection = GTK_LIST(handle2)->selection;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6453 #endif
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6454 if(selection)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6456 while(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6458 if(list->data == selection->data)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6459 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6460 retval = counter;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6461 break;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6462 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6463
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6464 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
6465 counter++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6482 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6483 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6485 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6489 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6490 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6491 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6492 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6493 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6494 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6495 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6496 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6497 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6498 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6511 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6512 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6513 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6514 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6515 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6516
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6517 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6518 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6519 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6520 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6521 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6522 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6523 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6524 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6525 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6526 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6527 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6528 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6529 gtk_list_clear_items(GTK_LIST(handle2), index, index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6530 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6531 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6532
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6533 /* 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
6534 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
6535 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6536 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
6537 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
6538 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
6539
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6540 /* 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
6541 if(!percent || (lastwidth == event->width && lastheight == event->height))
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6542 return FALSE;
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6543
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6544 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
6545
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6546 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
6547 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
6548
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6549 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
6550 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
6551 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
6552 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0)));
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6553 gtk_object_set_data(GTK_OBJECT(widget), "_dw_waiting", NULL);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6554 return FALSE;
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6555 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6556
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6557 #if GTK_MAJOR_VERSION > 1
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6558 /* Figure out the new percentage */
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6559 void _splitbar_accept_position(GObject *object, GParamSpec *pspec, gpointer data)
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6560 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6561 GtkWidget *widget = (GtkWidget *)data;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6562 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
6563 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget));
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6564
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6565 if(!percent || gtk_object_get_data(GTK_OBJECT(widget), "_dw_waiting"))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6566 return;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6567
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6568 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
6569 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
6570 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
6571 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
6572
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6573 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
6574 *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
6575 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6576 #endif
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6577
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6578 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6579 * 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
6580 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6581 * 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
6582 * 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
6583 * 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
6584 * Returns:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6585 * 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
6586 */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6587 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
6588 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6589 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
6590 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
6591 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
6592
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6593 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
6594 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
6595 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
6596 else
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6597 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
6598 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
6599 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
6600 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
6601 *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
6602 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent);
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6603 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_waiting", (gpointer)1);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6604 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
6605 #if GTK_MAJOR_VERSION > 1
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6606 g_signal_connect(G_OBJECT(tmp), "notify::position", (GCallback)_splitbar_accept_position, (gpointer)tmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6607 #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
6608 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
6609 #endif
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6610 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
6611 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
6612 return tmp;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6613 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6614
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6615 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6616 * 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
6617 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6618 * 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
6619 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6620 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
6621 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6622 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6623 int size = 0, position;
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6624
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6625 if(GTK_IS_VPANED(handle))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6626 size = handle->allocation.height;
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6627 else if(GTK_IS_HPANED(handle))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6628 size = handle->allocation.width;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6629
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6630 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
6631 *mypercent = percent;
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6632
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6633 if(size > 10)
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6634 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6635 position = (int)((float)size * (percent / 100.0));
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6636
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6637 gtk_paned_set_position(GTK_PANED(handle), position);
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
6638 }
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6639 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6640
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6641 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6642 * 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
6643 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
6644 * 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
6645 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6646 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
6647 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6648 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
6649
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6650 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
6651 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
6652 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6655 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666 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
6667 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6668 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6669 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6670
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6671 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6672 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6676 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
6677 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6678
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6685 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6687 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
6688 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
6689 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
6690
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6691 /* 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
6692 * 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
6693 * 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
6694 * 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
6695 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6696 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6697 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6698 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
6699
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6700 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6701 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6702 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6703 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
6704 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6705 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6706 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6707
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6708 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
6709 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6710 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6711 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6712 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
6713 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6714 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6715 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6716 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6717 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6718 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
6719 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6720
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6721 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
6722 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6734 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6742 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6743 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6744 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
6745
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6746 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6747 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6748 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6749 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
6750 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6751 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6752 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6753
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6754 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6755 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
6756 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6757 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6758
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6759 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6761 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6762 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6765 /*
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
6766 * 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
6767 * 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
6768 * 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
6769 * 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
6770 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6771 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
6772 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6773 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
6774
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6775 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
6776 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
6777
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6778 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
6779 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
6780 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
6781 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6782
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
6783 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6784 * 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
6785 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6786 * 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
6787 * 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
6788 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6789 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
6790 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6791 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
6792
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6793 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6794 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6795
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6796 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6797 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
6798 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6799 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6800
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
6801 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6805 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6808 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6809 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6810 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6811
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6812 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6814 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6815
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6816 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6817
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6818 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6819
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6820 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
6821 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
6822 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
6823 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
6824 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
6825
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6826 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6827 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6828 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6829 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6830 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6831 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6832 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6833 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6834 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6835 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6836 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6837 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6840 /* Internal function to handle the file OK press */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6841 gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6842 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6843 #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
6844 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
6845 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6846 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
6847 #endif
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
6848 char *tmpdup=NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6849
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6850 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6851 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6852
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
6853 if((tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data))))
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
6854 tmpdup = strdup(tmp);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6855 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
6856 _dw_file_active = 0;
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
6857 dw_dialog_dismiss(dwwait, (void *)tmpdup);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6858 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6859 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6860
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6861 /* Internal function to handle the file Cancel press */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6862 gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6863 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6864 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6865 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6866
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6867 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
6868 _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
6869 dw_dialog_dismiss(dwwait, NULL);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
6870 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6879 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6880 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6881 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6883 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 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
6889 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 /* The DW mutex should be sufficient for
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 * insuring no thread changes this unknowingly.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 if(_dw_file_active)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6898 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6900 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902 _dw_file_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6903
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6904 filew = gtk_file_selection_new(title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6905
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6906 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
6907
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6908 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
6909 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
6910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 if(defpath)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 gtk_widget_show(filew);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6918 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6922 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6923 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6924 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6925 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6926 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6941 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6942 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6954 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6955 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6962 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6963 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6983 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6988 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6989 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6990 /* Is there a way to find the webbrowser in Unix? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 char *execargs[3], *browser = "netscape";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7000 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7006 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7007 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7008
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7009 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7011 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7012
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7013 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7014 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7015 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7016 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7019 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7021 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7022 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7023 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7025 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7026 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7027 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7028 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7029 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7030 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7031
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7032 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7033
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7034 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7035 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7037
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7038 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7039 * 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
7040 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7041 * 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
7042 * 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
7043 * 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
7044 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7045 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
7046 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7047 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
7048
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7049 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
7050 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7051
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7052 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
7053 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
7054 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7055 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
7056 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7057 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
7058
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7059 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
7060 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
7061 }
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
7062 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
7063 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
7064 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
7065 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7066 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
7067 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7068
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7069 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7070 * 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
7071 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7072 * 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
7073 * 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
7074 * 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
7075 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7076 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
7077 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7078 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
7079 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
7080
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7081 if(!window)
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
7082 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
7083
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7084 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
7085 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
7086 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
7087 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
7088 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
7089 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
7090
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7091 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7092 * Add a callback to a timer event.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7093 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7094 * interval: Milliseconds to delay between calls.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7095 * sigfunc: The pointer to the function to be used as the callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7096 * data: User data to be passed to the handler function.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7097 * Returns:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7098 * Timer ID for use with dw_timer_disconnect(), 0 on error.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7099 */
199
b955228477b3 Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 198
diff changeset
7100 int API dw_timer_connect(int interval, void *sigfunc, void *data)
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7101 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7102 int tag, _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7103
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7104 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7105 tag = gtk_timeout_add(interval, (GtkFunction)sigfunc, data);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7106 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7107 return tag;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7108 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7109
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7110 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7111 * Removes timer callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7112 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7113 * id: Timer ID returned by dw_timer_connect().
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7114 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7115 void API dw_timer_disconnect(int id)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7116 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7117 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7118
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7119 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7120 gtk_timeout_remove(id);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7121 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7122 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7123
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
7124 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7130 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7131 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7134 SignalHandler *work = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7136 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7137 HWND thiswindow = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7138 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7141 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7144 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7146 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7148 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7150 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 thisfunc = _findsigfunc("container-context");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7156 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7157 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, "container-context") == 0)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7158 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7159 thisfunc = _findsigfunc("tree-context");
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7160
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7161 work->window = window;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7162 work->data = data;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7163 work->func = sigfunc;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7164
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7165 gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7166 gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7167 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7168 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7169 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7170 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, "tree-select") == 0)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7171 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7172 work->window = window;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7173 work->data = data;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7174 work->func = sigfunc;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7175
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7176 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7177 thisname = "changed";
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7178
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7179 g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7180 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7181 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7182 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7183 #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
7184 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
7185 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7186 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
7187
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7188 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
7189 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
7190 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
7191
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
7192 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
7193 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
7194 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
7195 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
7196 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
7197 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
7198 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7199 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7200 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7201 if(thisfunc)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7202 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7203 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7204 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7205 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7206 thisname = "select-child";
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7207 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
7208 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7211 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212 thisfunc = _findsigfunc("container-select");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213 }
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7214 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "tree-select") == 0)
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7215 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7216 thisname = "select_row";
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7217 thisfunc = (void *)_container_select_row;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
7218 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7219 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7220 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7222 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7224 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7226 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7227 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7228 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
7229 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
7230 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
7231 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
7232 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
7233 }
55
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
7234 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
7235 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
7236 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
7237 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
7238 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
7239 }
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
7240 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) ||
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
7241 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow))
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
7242 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
7243 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
7244 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7245
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 free(work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 work->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 work->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 work->func = sigfunc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7262 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7263 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7264 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7265 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7266 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7267 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7268 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7269 gtk_signal_disconnect_by_name(window, signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7270 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7273 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7274 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7275 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7276 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7277 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7278 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 gtk_signal_disconnect_by_window(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7285 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7286 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7287 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7288 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7289 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7291 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7292 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7293 dw_signal_disconnect_by_data(window, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7294 }
153
a371875d5486 Sync up with the latest F/X sources.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 151
diff changeset
7295