annotate gtk/dw.c @ 91:67cd8e97ef8c

Ick.. fixed typos in the GTK code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 22 Apr 2002 08:36:26 +0000
parents eeb98f881663
children 0a085f295e81
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>
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
22 #elif defined(USE_PIXBUF)
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
23 #include <gdk-pixbuf/gdk-pixbuf.h>
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-xlibrgb.h>
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
25 #include <gdk-pixbuf/gdk-pixbuf-xlib.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
26 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 /* These are used for resource management */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 extern DWResources _resources;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
31 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
32
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
33 char monthlist[][4] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug",
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34 "Sep", "Oct", "Nov", "Dec" };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 { 0, 0xaaaa, 0xaaaa, 0xaaaa }, /* 7 white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
55 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
56
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
57 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
58 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
59 GdkColor _background[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
60
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
61 GtkWidget *last_window = NULL;
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
62
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
63 int _dw_file_active = 0, _dw_ignore_click = 0, _dw_unselecting = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
64 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
65 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
66 /* 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
67 int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68
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
69 #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
70 #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
71
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
72 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
73 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
74 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
75
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
76 GdkColormap *_dw_cmap = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
77
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
78 /* Signal forwarder prototypes */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
79 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
80 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
81 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
83 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
84 gint _generic_event(GtkWidget *widget, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
85 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
86 void _activate_event(GtkWidget *widget, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
87 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
88 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
89 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
90 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
91 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
92 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
93 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
94 void _value_changed_event(GtkAdjustment *adjustment, gpointer user_data);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
95
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
96
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
97 void msleep(long period);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
98
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
99 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
100 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
101 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
102 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
104 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
106 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
107 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
108 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
109 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
110 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
111
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
112 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
113
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
114 #define SIGNALMAX 16
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
116 /* A list of signal forwarders, to account for paramater differences. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
117 SignalList SignalTranslate[SIGNALMAX] = {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
118 { _configure_event, "configure_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
119 { _key_press_event, "key_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
120 { _button_press_event, "button_press_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
121 { _button_release_event, "button_release_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
122 { _motion_notify_event, "motion_notify_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
123 { _delete_event, "delete_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
124 { _expose_event, "expose_event" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
125 { _activate_event, "activate" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
126 { _generic_event, "clicked" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
127 { _container_select_event, "container-select" },
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
128 { _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
129 { _tree_context_event, "tree-context" },
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
130 { _item_select_event, "item-select" },
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
131 { _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
132 { _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
133 { _value_changed_event, "value_changed" }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
136 /* Alignment flags */
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_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
138 #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
139 #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
140
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 /* Finds the translation function for a given signal name */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 void *_findsigfunc(char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
144 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
149 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
152 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
153
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
154 void _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
155 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
156 SignalHandler *work = (SignalHandler *)data;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
157
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
158 if(work)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
159 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
160 int (*setfocusfunc)(HWND, void *) = work->func;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
161
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
162 setfocusfunc((HWND)window, work->data);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
163 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
164 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
165
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166 gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
179
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
180 buttonfunc(widget, event->x, event->y, mybutton, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
184
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185 gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
187 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
189 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
190 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
191 int (*buttonfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
192 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
195 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 buttonfunc(widget, event->x, event->y, mybutton, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
209 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
210 int (*motionfunc)(HWND, int, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
211 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
212 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
214 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
215 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
216 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
217 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
218 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
219 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
220 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
221 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
223 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
224 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
225 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
226 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
227 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
228 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
229
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
230 motionfunc(widget, x, y, keys, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
231 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
232 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
233 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
234
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
235 gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
236 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
237 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
239 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
240 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
241 int (*closefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
242
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
243 closefunc(widget, work->data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
244 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
245 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
246 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
247
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
248 gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
249 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
250 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
252 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
253 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
254 int (*keypressfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
256 keypressfunc(widget, *event->string, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
257 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
258 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
259 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
261 gint _generic_event(GtkWidget *widget, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
262 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
263 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
264
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
265 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
266 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
267 int (*genericfunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
268
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
269 genericfunc(widget, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
270 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
271 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
274 void _activate_event(GtkWidget *widget, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
275 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
276 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
277
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
278 if(work && !_dw_ignore_click)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
279 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
280 void (*activatefunc)(HWND, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
282 activatefunc(work->window, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
283 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
284 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
285 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
286
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
287 gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
288 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
290
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
291 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
293 int (*sizefunc)(HWND, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
294
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
295 sizefunc(widget, event->width, event->height, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 void _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
303
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
304 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 DWExpose exp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307 int (*exposefunc)(HWND, DWExpose *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
308
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
310 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
311 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312 exp.height = event->area.height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
313 exposefunc(widget, &exp, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
315 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 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
320 static int _dw_recursing = 0;
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
321
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
322 if(_dw_recursing)
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
323 return;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
325 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327 int (*selectfunc)(HWND, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
328 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
330
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
331 _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
332
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
333 if(GTK_IS_COMBO(work->window))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
334 list = GTK_LIST(GTK_COMBO(work->window)->list)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
335 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 gtk_object_set_data(GTK_OBJECT(work->window), "item", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 selectfunc(work->window, item, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
351 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
354
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
355 void _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
356 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
357 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
362 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
363 void (*contextfunc)(HWND, char *, int, int, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
365 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
366
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
367 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
369 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
370 contextfunc(work->window, text, event->x, event->y, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
371 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
374
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
375 void _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
376 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
377 SignalHandler *work = (SignalHandler *)data;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
378
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
379 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
380 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
381 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
382 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
383 void (*contextfunc)(HWND, char *, int, int, void *, void *) = work->func;
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
384 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
385 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
386
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
387 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
388 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
389 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
390
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
391 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
392 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
393 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
394
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
395 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
396 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
397 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
398 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
399 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
400 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
401 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
402
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
403 contextfunc(work->window, text, event->x, event->y, work->data, itemdata);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
404 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
405 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
406 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
407
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
408 void _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
409 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
410 SignalHandler *work = (SignalHandler *)data;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
411
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
412 if(work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
413 {
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
414 void (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
415 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
416 void *itemdata = (char *)gtk_object_get_data(GTK_OBJECT(child), "itemdata");
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
417 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "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
418
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
419 if(treeroot && GTK_IS_TREE(treeroot))
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
420 gtk_object_set_data(GTK_OBJECT(treeroot), "lastselect", (gpointer)child);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
421 treeselectfunc(work->window, child, text, itemdata, work->data);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
422 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
423 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
424
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
425 void _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
426 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
427 SignalHandler *work = (SignalHandler *)data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
428
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
429 if(work)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
430 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
431 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
433 void (*contextfunc)(HWND, char *, void *) = work->func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
434 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
436
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
439 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440 contextfunc(work->window, text, work->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
445 void _select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
446 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
447 GList *tmp = (GList *)gtk_object_get_data(GTK_OBJECT(widget), "selectlist");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
448 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
449 int multi = (int)gtk_object_get_data(GTK_OBJECT(widget), "multi");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 if(rowdata)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
452 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
453 if(!multi)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
454 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
455 g_list_free(tmp);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
456 tmp = NULL;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
457 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
458
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
459 tmp = g_list_append(tmp, rowdata);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
460 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
461 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
462
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
464
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
465 void _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
466 {
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
467 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
468 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
469
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
470 if(_dw_unselecting)
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
471 return;
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
472
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
473 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
474 rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
475
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
476 if(rowdata && tmp)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 {
76
ce0f5528bab0 Fixed clist crashing problems on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 75
diff changeset
478 tmp = g_list_remove(tmp, rowdata);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
479 gtk_object_set_data(GTK_OBJECT(widget), "selectlist", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
481 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
482
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
483 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
484 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
485 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
486
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
487 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
488 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
489
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
490 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
491 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
492
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
493 void _value_changed_event(GtkAdjustment *adjustment, gpointer data)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
494 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
495 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "slider");
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
496 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
497
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
498 if(slider && work)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
499 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
500 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
501 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
502 int val = _round_value(adjustment->value);
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
503 static int lastval = -1;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
504 static GtkWidget *lastwidget = 0;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
505
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
506 if(lastval != val || lastwidget != slider)
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
507 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
508 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
509 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
510 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
511 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
512 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
513 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
514 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
515
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
516 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
517 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
518 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
519
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
520 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
521 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
522 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
523 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
524 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
525 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
526 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
527 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
528 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
529 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
530 return TRUE;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
531 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
532
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
533 GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
534 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
535 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
536 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
538 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
539 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
540 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
541 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
542 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
543 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
544 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
547 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
548 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
549 GdkPixmap *icon_pixmap = 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
550 #ifdef USE_IMLIB
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
551 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
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
552 #elif defined(USE_PIXBUF)
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
553 icon_pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
554 #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
555 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], &data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
556 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
557 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
558 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
559 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
560 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
562 void _size_allocate(GtkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
563 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
564 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
566 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
567 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
568 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
569 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
570 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
571 sizehints.min_height = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
573 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
574
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
575 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
576 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
577 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
578 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
579 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
580
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
581 /* Find the index of a given thread */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
582 int _find_thread_index(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
583 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
584 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
585
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
586 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
587 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
588 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
589 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
590 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
591 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
592 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
593
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
594 /* Add a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
595 void _dw_thread_add(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
596 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
597 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
598
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
599 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
600 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
601 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
602 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
603 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
604 _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
605 _background[z].pixel = 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
606 _background[z].red = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
607 _background[z].green = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
608 _background[z].blue = 0xaaaa;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
609 return;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
610 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
611 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
612 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
613
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
614 /* Remove a thread id to the thread list */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
615 void _dw_thread_remove(DWTID tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
616 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
617 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
618
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
619 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
620 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
621 if(_dw_thread_list[z] == (DWTID)tid)
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
622 _dw_thread_list[z] = (DWTID)-1;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
623 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
624 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
625
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
626 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
627 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
628 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
629 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
630 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
631 */
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
632 int dw_int_init(DWResources *res, int newthread, int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
633 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
634 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
635 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
636
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
637 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
638 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
639 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
640 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
641 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
643 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
644 g_thread_init(NULL);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
645
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
646 gtk_init(&argc, &argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
647 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
648 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
649 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
650 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
651 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
652 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
653 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
654
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
655 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
656 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
657 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
658 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
659 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
660 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
661
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
662 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
663 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
664
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
665 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
666
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
667 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
670 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
671 * Runs a message loop for Dynamic Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
672 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
673 * currenthab: The handle to the current anchor block
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
674 * or NULL if this DW is handling the message loop.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
675 * func: Function pointer to the message filter function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
676 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
677 void dw_main(HAB currenthab, void *func)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
678 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
679 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
680 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
681 gdk_threads_enter();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
682 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
683 gdk_threads_leave();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
684 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
685
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
686 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
687 * 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
688 * 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
689 * 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
690 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
691 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
692 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
693 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
694
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
695 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
696
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
697 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
698 {
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
699 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
700
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
701 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
702 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
703 gdk_threads_enter();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
704 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
705 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
706 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
707 msleep(1);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
708 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
709 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
710 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
711 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
712 else
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
713 msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
714 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
715
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
716 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
717 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
725 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
728 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
732 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
736 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
737 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
738 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
739 tmp->done = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
740 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
741
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
742 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
743 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
744
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
745 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
746 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
747 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754 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
755 if(pthread_self() == _dw_thread || _dw_thread == (pthread_t)-1)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
756 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
757 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
758 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
759 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
769 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
770 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
771 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
772 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
773
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
774 /* _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
775 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
776 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
777 _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
778 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
779 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
780 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
781
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 if(pthread_self() == _dw_thread)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 gtk_main();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 dw_event_wait(dialog->eve, -1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
787 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
788 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
789 _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
790 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
791 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
792
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 void _delete(GtkWidget *widget, GtkWidget *event, gpointer param)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 gtk_widget_destroy(GTK_WIDGET(param));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804 void _delete2(GtkWidget *widget, gpointer param)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 gtk_widget_destroy(GTK_WIDGET(param));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
810 void _dw_ok_func(HWND window, void *data)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
811 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
812 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
813
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
814 if(!dwwait)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
815 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
816
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
817 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
818 dw_dialog_dismiss((DWDialog *)data, (void *)0);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
819 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
820
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
823 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825 * format: printf style format string.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826 * ...: Additional variables for use in the format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828 int dw_messagebox(char *title, char *format, ...)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
830 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
831 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
832 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 va_list args;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834 char outbuf[256];
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
835 int x, y;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
836
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 va_start(args, format);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 vsprintf(outbuf, format, args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 va_end(args);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
841 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
842 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
843 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
844
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
845 /* Archive Name */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
846 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
847 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
848
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
849 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
850
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
851 /* Buttons */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
852 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
853
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
854 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
855
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
856 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
857
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
858 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
859
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
860 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
861
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
862 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
863
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
864 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
865 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
866
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
867 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
868
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
869 dw_window_show(entrywindow);
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
870
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
871 dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
872
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
873 return strlen(outbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
875
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
876 void _dw_yes_func(HWND window, void *data)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
877 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
878 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
879
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
880 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
881 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
882
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
883 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
884 dw_dialog_dismiss((DWDialog *)data, (void *)1);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
885 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
886
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
887 void _dw_no_func(HWND window, void *data)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
888 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
889 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
890
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
891 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
892 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
893
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
894 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
895 dw_dialog_dismiss((DWDialog *)data, (void *)0);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
896 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
897
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 * title: The title of the message box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 * text: The text to display in the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 * True if YES False of NO.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 int dw_yesno(char *title, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
908 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
909 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
910 DWDialog *dwwait;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
911 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
912
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
913 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
914
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
915 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
916
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
917 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
918
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
919 /* 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
920 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
921 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
922
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
923 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
924
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
925 /* Buttons */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
926 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
927
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
928 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
929
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
930 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
931
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
932 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
933
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
934 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
935
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
936 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
937
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
938 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
939
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
940 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
941 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
942
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
943 x = (dw_screen_width() - 220)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
944 y = (dw_screen_height() - 110)/2;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
945
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
946 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
947
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
948 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
949
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
950 return (int)dw_dialog_wait(dwwait);;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
951 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
952
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
953 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
954 * 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
955 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
956 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
957 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
958 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
959 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
960 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
961
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
962 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
963 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
964
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
965 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
966 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
967 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
968 DefaultScreen (GDK_DISPLAY ()));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
969 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
970 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
971 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
972
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
973 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
974 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
975 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
976 * 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
977 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
978 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
979 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
980 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
981
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
982 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
983 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
984
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
985 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
986 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
987 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
988 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
989 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
990
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 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
993 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
994 * 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
995 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
996 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
997 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
998 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
999
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1000 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1001 return 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 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1004 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
1005 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1006 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1007 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1008
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1009 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1013 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1014 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1015 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1016 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
1017 GtkWidget *defaultitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1018
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1019 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1020 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1021
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023 gtk_widget_show(handle);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1024 if(GTK_WIDGET(handle)->window)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1025 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1026 gdk_window_raise(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1027 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1028 gdk_window_show(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1029 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1030 }
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
1031 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
1032 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
1033 gtk_widget_grab_focus(defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1041 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1047 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1048 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1049
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 gtk_widget_hide(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1060 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1065 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1066 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1067
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 DW_MUTEX_LOCK;
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1069 if(GTK_IS_WIDGET(handle))
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1070 gtk_widget_destroy(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1073 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074
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
1075 /* 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
1076 * 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
1077 * 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
1078 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1079 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
1080 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1081 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1082
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1091 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1092
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1093 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1094 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
1095 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098 int _set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1102 int retval = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1117 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 gpointer data;
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1128 GdkFont *gdkfont;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1135 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1137 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1138
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1139 /* 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
1140 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
1141 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1142 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
1143 gdkfont = gdk_font_load(fontname);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1144 gtk_object_set_data(GTK_OBJECT(handle2), "gdkfont", (gpointer)gdkfont);
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1145
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1146 /* Free old font name if one is allocated */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1147 data = gtk_object_get_data(GTK_OBJECT(handle2), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 gtk_object_set_data(GTK_OBJECT(handle2), "fontname", (gpointer)font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1154
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1156 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1159 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1160 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1161 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
1162
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1163 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1164 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1165
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1166 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
1167
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1168 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1169 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1170 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1171
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1172 /* 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
1173 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
1174 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1175 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1176 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1177
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1178 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1179
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1180 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1181 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1182
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1183 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
1184 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
1185 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1186
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1187 int _set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1188 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1189 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1190
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1191 if(fore & DW_RGB_COLOR || back & DW_RGB_COLOR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1192 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1193 /* Remember that each color component in X11 use 16 bit no matter
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1194 * what the destination display supports. (and thus GDK)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1195 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 GdkColor forecolor = { 0, DW_RED_VALUE(fore) << 8, DW_GREEN_VALUE(fore) << 8, DW_BLUE_VALUE(fore) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197 GdkColor backcolor = { 0, DW_RED_VALUE(back) << 8, DW_GREEN_VALUE(back) << 8, DW_BLUE_VALUE(back) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 gdk_color_alloc(_dw_cmap, &backcolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1202 style = gtk_style_copy(gtk_widget_get_style(handle));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1203 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1204 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1205 gtk_widget_set_style(handle, style);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1206
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1207 _save_gdk_colors(handle, forecolor, backcolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1208
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1209 if(GTK_IS_CLIST(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1210 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1211 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1212
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1213 for(z=0;z<rowcount;z++)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1214 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1215 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1216 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1217 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1218 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1222 style = gtk_style_copy(gtk_widget_get_style(handle));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1223 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore];
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1224 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 gtk_widget_set_style(handle, style);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1226
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1227 _save_gdk_colors(handle, _colors[fore], _colors[back]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1228
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1229 if(GTK_IS_CLIST(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1230 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1231 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "rowcount");
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1232
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1233 for(z=0;z<rowcount;z++)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1234 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1235 gtk_clist_set_foreground(GTK_CLIST(handle), z, &_colors[fore]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1236 gtk_clist_set_background(GTK_CLIST(handle), z, &_colors[back]);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1237 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1238 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1239 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1263 else if(GTK_IS_BOX(handle))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1264 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1265 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1266 if(tmp)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1267 handle2 = tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1268 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1269 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1270 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1271 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
1272 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1273 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1274 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1275
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1287 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1304 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
1305 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1306 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1308 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1309 * 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
1310 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1311 * 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
1312 * 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
1313 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1314 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
1315 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1316 GdkCursor *cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1317 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1318 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
1319 gdk_cursor_destroy(cursor);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1320 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1321
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1322 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1324 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1325 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1326 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1327 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1328
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1330 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1331 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1334 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1335 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1336 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1337 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1338 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1339 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1342 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 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
1345 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1347 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
1348 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350 gtk_window_set_title(GTK_WINDOW(tmp), title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 if(!(flStyle & DW_FCF_SIZEBORDER))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 gtk_widget_realize(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 if(flStyle & DW_FCF_TITLEBAR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 flags |= GDK_DECOR_TITLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359 if(flStyle & DW_FCF_MINMAX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1362 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
1363 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
1364
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
1365 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 flags |= GDK_DECOR_BORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368 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
1369
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1370 if(hwndOwner)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1371 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1377 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1378 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1379 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1380 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1381 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1382 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1384 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1385 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1386 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 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
1389 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1390 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1391
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1392 gtk_widget_show(eventbox);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1393 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
1394 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
1395 gtk_object_set_data(GTK_OBJECT(tmp), "boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1398 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1403 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1404 * type: Either BOXVERT (vertical) or BOXHORZ (horizontal).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1405 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1406 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1407 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1408 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1410 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1411 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1412
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1413 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1414 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1415 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
1416 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
1417 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1418 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
1419 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
1420 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
1421 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
1422 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1423 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1424 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1425 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1426 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1430 * 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
1431 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1432 * 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
1433 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1434 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
1435 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1436 return gtk_vbox_new(FALSE, 0);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1437 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1438
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1439 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1440 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1441 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1442 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1443 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1444 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1445 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1446 GdkPixmap *pixmap= NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1447 GdkBitmap *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1448 GtkWidget *tmp;
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
1449 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
1450 "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
1451 " 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
1452 ". 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
1453 "."};
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1454 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1455
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1456 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
1457 #ifdef USE_IMLIB
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
1458 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
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
1459 #elif defined(USE_PIXBUF)
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
1460 pixmap = (GdkPixmap *)gdk_pixbuf_new_from_xpm_data((const char **)test_xpm);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1461 #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
1462 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
1463
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
1464 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
1465 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
1466 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 tmp = gtk_pixmap_new(pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1473
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1474 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1475 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1479 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1480 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1481 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1482 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1483 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1484
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1485 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490 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
1491 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
1492 #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
1493 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
1494 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1498 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1499 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1501 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1502 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1503 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1508 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1509 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1510 HMENUI tmp = malloc(sizeof(struct _hmenui));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1511 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1513 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 tmp->menu = gtk_menu_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 gtk_widget_show(tmp->menu);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1519 accel_group = gtk_accel_group_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 gtk_object_set_data(GTK_OBJECT(tmp->menu), "id", (gpointer)id);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1521 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1524 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1525
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1526 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1527 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1528 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1530 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1531 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1532 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1533 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1534 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1535 HMENUI tmp = malloc(sizeof(struct _hmenui));
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1536 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 if(!tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 tmp->menu = gtk_menu_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 gtk_widget_show(tmp->menu);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1545 accel_group = gtk_accel_group_new();
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1546 gtk_object_set_data(GTK_OBJECT(tmp->menu), "accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1548 if(box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1549 gtk_box_pack_end(GTK_BOX(box), tmp->menu, FALSE, FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1550
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1551 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1552 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1554
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1555 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1560 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 gtk_widget_destroy((*menu)->menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1574 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1575 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1576 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1577 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1578
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1582 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1583 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1584 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1585 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1586 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1587 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1588 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1589 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1590 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1591 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1594 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1596
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1602 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1603 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1604 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1605 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1606 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1607 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1608 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
1609 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1610 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1611 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1612 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1613 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1614 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616 if(!menu || !menu->menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1617 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1622 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1623 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1624
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1625 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu->menu), "accel");
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1626 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu->menu), "submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1628 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1629 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1630 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1631 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1632 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1633 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1634 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1635 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1636 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1637 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1638 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1639 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1640 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1641 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1642 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644 sprintf(numbuf, "%lu", id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 gtk_object_set_data(GTK_OBJECT(menu->menu), numbuf, (gpointer)tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1648 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1649 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1650 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1651 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1652 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1653 gtk_widget_add_accelerator(tmphandle, "activate_item", accel_group, tmp_key, GDK_MOD1_MASK, 0);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1654 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1655 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1656 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1657 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1659
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1663 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1664 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1665
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1666 sprintf(tempbuf, "submenu%d", submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1667 submenucount++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1668 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu->menu);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1669 gtk_object_set_data(GTK_OBJECT(menu->menu), tempbuf, (gpointer)submenu->menu);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1670 gtk_object_set_data(GTK_OBJECT(menu->menu), "submenucount", (gpointer)submenucount);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1671 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 if(GTK_IS_MENU_BAR(menu->menu))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674 gtk_menu_bar_append(GTK_MENU_BAR(menu->menu), tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 gtk_menu_append(GTK_MENU(menu->menu), tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 gtk_object_set_data(GTK_OBJECT(tmphandle), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1679 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1680 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1684 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1685 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1686 GtkWidget *tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1687 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
1688
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1689 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
1690 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1691
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1692 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1693 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1694 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1695 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1696
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1697 sprintf(tempbuf, "submenu%d", z);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1698
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1699 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
1700 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1701 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1702 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1703 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1704 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1705 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1706 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1707
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1715 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 if(!menu || !menu->menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1725 sprintf(numbuf, "%lu", id);
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1726 tmphandle = _find_submenu_id(menu->menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1727
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1728 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1729 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1730 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1731 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 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
1733 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1734 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1735 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1737
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1738 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1739 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754 gtk_menu_popup(GTK_MENU((*menu)->menu), NULL, NULL, NULL, NULL, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 free(*menu);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 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
1771 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
1772
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
1773 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 *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
1777 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787 {
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
1788 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
1789
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
1790 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 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
1792 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801 HWND dw_container_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1803 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1804 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1805
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1806 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1807 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1808 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1809 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1810
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1811 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1812 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1813
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1814 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1815 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1819 * 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
1820 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1821 * 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
1822 * 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
1823 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1824 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
1825 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1826 GtkWidget *tmp, *tree;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1827 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
1828
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1829 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
1830 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
1831 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1832 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1833
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1834 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
1835 gtk_widget_show(tmp);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1836 tree = gtk_tree_new();
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1837 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
1838 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1839 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
1840 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
1841 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
1842 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1843 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1844 gtk_tree_set_selection_mode(GTK_TREE(tree), GTK_SELECTION_SINGLE);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1845 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1846 /* 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
1847 gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1848
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1849 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
1850 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
1851
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1852 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
1853 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
1854 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1855
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1856
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1857 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1862 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1863 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1864 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1865 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1869 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
1870
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1871 /* 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
1872 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1874 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
1875 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1878 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1879
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1880 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1881 * 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
1882 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1883 * 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
1884 * 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
1885 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1886 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1887 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1888 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1889 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1890
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1891 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1892 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1893 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
1894 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1895 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1896 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1897 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
1898
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1899 /* 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
1900 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
1901 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
1902 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
1903 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1904 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1905 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1906
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
1907 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1908 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1909 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1912 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1913 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1914 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1915 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1916
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1917 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 gtk_object_set_data(GTK_OBJECT(tmpbox), "mle", (gpointer)tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1928 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929 gtk_widget_show(scroller);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 return tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1934
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1935 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1936 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1937 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1938 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1939 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1940 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1941 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1942 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1948
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1949 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1954 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1955 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1956 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1957
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1958 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 * text: The default text to be in the entryfield widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1968
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1969 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1978 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 * text: The default text to be in the combpbox widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1994 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1995 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1996 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001 return tmp;
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 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2025 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2026 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2028 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2030 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 dw_window_set_bitmap(bitmap, id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2045 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2046 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2047 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2048 tooltips = gtk_tooltips_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2049 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2050 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2051 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2052 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2053 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2056
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2057 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2058 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 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
2071 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2073 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2074 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2075 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2078 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 tmp = gtk_radio_button_new_with_label(NULL, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2099 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2101 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2102 * 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
2103 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2104 * 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
2105 * 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
2106 * 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
2107 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2108 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
2109 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2110 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
2111 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
2112 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
2113
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2114 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
2115 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
2116 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
2117 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
2118 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2119 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
2120 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
2121 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
2122 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
2123 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
2124 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
2125 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
2126 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
2127 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
2128 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2129
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2130 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2131 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2135 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2151 * text: The text to be display by the static text widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2152 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2153 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2154 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2155 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2159 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2161 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2163 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2164 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 * id: An ID to be used with WinWindowFromID() or 0L.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2173 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2180 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2181 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2182
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2183 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2184 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2186 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2187 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2188 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2189 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 }
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 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2202 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2203 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2204 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2205 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2206 GdkPixmap *icon_pixmap;
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 icon_pixmap = _find_pixmap(&bitmap, id, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2216 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2217
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 void dw_window_set_bitmap(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2225 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2226 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 GdkPixmap *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231 tmp = _find_pixmap(&bitmap, id, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2232 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2233 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2234 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2235 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2236
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2237 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2238 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2239 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 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
2254 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2255 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2256 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
2257 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2258 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
2259 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2262
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2265 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 char *possible = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 return strdup(possible);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2286 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2288 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2310 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2313 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
2314 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2315 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
2316
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2317 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
2318 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2319 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
2320 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2321 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
2322 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2323 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2324 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2325 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
2326 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2327
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2334 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2344 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "gdkfont");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2348 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
2349 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
2350 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
2351
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2352 _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
2353
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2354 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
2355 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2356 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
2357 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2358 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2368 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2369 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2370 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2371 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2372 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2373 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2374 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2375 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2377 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2378 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2383 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387 strcpy(buffer, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2401 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2402 void dw_mle_query(HWND handle, unsigned long *bytes, unsigned long *lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2403 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2404 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2406 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2407 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2408 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2409 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2410
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2411 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2412 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2413 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2414 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2416 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2417 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2419 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2422 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2423
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2424 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 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
2426
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2428 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2429 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2432 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2433 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2434 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2436 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2447 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2448 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2449 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2457 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2458 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2459
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 gtk_text_forward_delete(GTK_TEXT(tmp), length);
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 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 void dw_mle_set_visible(HWND handle, int line)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2513 dw_mle_query(handle, NULL, &lines);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2516 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2517 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519 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
2520
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2523 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2529 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2530 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2531 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2532 * 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
2533 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2534 void dw_mle_set_editable(HWND handle, int state)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2535 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2536 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2537
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2538 DW_MUTEX_LOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2539 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2540 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2541 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2542
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2543 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2544 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2545 gtk_text_set_editable(GTK_TEXT(tmp), state);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2546 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2547 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2548 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2549 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2550
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2551 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2552 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2553 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2554 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2555 * 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
2556 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2557 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
2558 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2559 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2560
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2561 DW_MUTEX_LOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2562 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2563 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2564 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2565
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2566 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2567 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2568 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
2569 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
2570 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2571 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2572 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2573 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2574
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2575 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 void dw_mle_set(HWND handle, int point)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2592 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2593 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2594
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2595 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
2596
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2597 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2598 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2599 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
2600
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2601 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
2602
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2603 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
2604 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2641 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2642 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2643 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2644 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2645 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2651 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2653 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2671
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2672 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2673 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2675 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2676 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2677 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2678 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2679 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2680
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2681 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2690 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2691 DW_MUTEX_UNLOCK;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2695 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2698 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2699 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2700 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2701 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2703 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2704 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2705 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "mle");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2709 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2713 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2717 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718 * 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
2719 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2720 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2721 unsigned int dw_percent_query_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2722 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2723 return 100;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2724 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2725
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2726 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2727 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2728 * 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
2729 * 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
2730 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2731 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2732 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2733 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2734 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2736 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2742 * 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
2743 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2744 * 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
2745 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2746 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
2747 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2748 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
2749 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
2750
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2751 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
2752 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
2753
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2754 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
2755 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
2756 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
2757 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2758 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
2759 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
2760
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2761 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
2762 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
2763 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2764 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
2765 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2766 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
2767 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
2768 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2769
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2770 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2771 * 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
2772 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2773 * 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
2774 * 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
2775 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2776 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
2777 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2778 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
2779 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
2780
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2781 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
2782 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2783
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2784 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
2785 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
2786 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
2787 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2788 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
2789
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2790 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
2791 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
2792 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2793 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
2794 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2795 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
2796 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2797
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2798 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826 curval = dw_spinbutton_query(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 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
2829 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 /* TODO: can this be done after the fact? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 long dw_spinbutton_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2853 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2854 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2862 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 int dw_checkbox_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2866 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2867 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2868 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2869
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2886
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2892 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2893 * 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
2894 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2895 * 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
2896 * 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
2897 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2898 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2899 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2900 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2901 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2902 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
2903 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2904 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2905 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2906 GdkBitmap *gdkbmp = NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2907 int position = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2908 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2909
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2910 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2911 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2912
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2913 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2914 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
2915 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2916 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2917 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2918 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2919 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2920
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2921 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2922 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
2923
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2924 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2925
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2926 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2927 label = gtk_label_new(title);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2928 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
2929 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
2930 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
2931 hbox = gtk_hbox_new(FALSE, 2);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2932 gtk_object_set_data(GTK_OBJECT(newitem), "hbox", (gpointer)hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2933 gdkpix = _find_pixmap(&gdkbmp, icon, hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2934 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2935 gtk_container_add(GTK_CONTAINER(newitem), hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2936 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
2937 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
2938 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2939 gtk_widget_show(pixmap);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2940 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2941
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2942 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2943 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2944 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
2945 if(!subtree)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2946 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2947 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
2948 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
2949
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2950 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2951
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2952 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2953 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
2954
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2955 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
2956 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
2957
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2958 if(thisfunc && work)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2959 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
2960
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2961 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
2962 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
2963 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
2964 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
2965 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
2966 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2967 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
2968 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
2969 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2970 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
2971 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
2972 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2973 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2974 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2975 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
2976 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
2977 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2978 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
2979 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
2980 gtk_widget_show(newitem);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2981 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2982 return newitem;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2983 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2984
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2985 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2986 * 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
2987 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2988 * 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
2989 * 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
2990 * 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
2991 * 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
2992 * 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
2993 */
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
2994 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
2995 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2996 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
2997 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2998 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
2999 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
3000
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3001 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3002 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3003
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3004 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
3005 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
3006 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
3007 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3008 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
3009 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
3010 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3011 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
3012 label = gtk_label_new(title);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3013 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
3014 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
3015 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
3016 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
3017 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)hbox);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3018 gdkpix = _find_pixmap(&gdkbmp, icon, hbox);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3019 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3020 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
3021 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
3022 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
3023 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
3024 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
3025 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
3026
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3027 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
3028 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3029 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
3030 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
3031 {
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3032 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
3033 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
3034
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3035 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3036
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3037 if(thisfunc && work)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3038 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
3039
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
3040 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
3041 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
3042
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3043 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
3044 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
3045
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3046 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
3047 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
3048 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
3049 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
3050 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
3051 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
3052 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
3053 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
3054 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3055 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
3056 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
3057 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3058 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3059 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3060 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
3061 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
3062 }
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
3063 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
3064 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
3065 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
3066 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
3067 return item;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3068 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3069
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3070 /*
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
3071 * 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
3072 * 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
3073 * 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
3074 * 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
3075 * 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
3076 * 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
3077 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3078 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
3079 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3080 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
3081 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3082 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
3083 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
3084 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
3085
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3086 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3087 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3088
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
3089 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
3090 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
3091 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
3092 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
3093 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
3094 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
3095 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
3096 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
3097 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
3098 gtk_object_set_data(GTK_OBJECT(item), "hbox", (gpointer)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
3099 gdkpix = _find_pixmap(&gdkbmp, icon, 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
3100 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3101 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
3102 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
3103 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
3104 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
3105 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
3106 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
3107 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
3108 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3109
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3110 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3111 * 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
3112 * 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
3113 * 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
3114 * 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
3115 * 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
3116 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3117 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
3118 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3119 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
3120
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3121 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3122 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3123
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
3124 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
3125 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
3126 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
3127 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3128
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3129 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3130 * 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
3131 * 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
3132 * 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
3133 * 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
3134 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3135 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
3136 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3137 GtkWidget *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
3138 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
3139
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3140 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3141 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3142
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3143 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
3144 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "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
3145 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
3146 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
3147 gtk_tree_item_select(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
3148 gtk_object_set_data(GTK_OBJECT(handle), "lastselect", (gpointer)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
3149 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
3150 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3151
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3152 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3153 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3154 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3155 * 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
3156 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3157 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3158 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3159 GtkWidget *tree;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3160 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3161
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3162 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3163 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3164
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3165 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3166 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
3167 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3168 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3169 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3170 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3171 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3172 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
3173 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3174 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3175
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3176 /*
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
3177 * 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
3178 * 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
3179 * 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
3180 * 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
3181 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3182 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
3183 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3184 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
3185
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3186 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3187 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3188
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
3189 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
3190 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
3191 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
3192 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
3193 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3194
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3195 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3196 * 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
3197 * 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
3198 * 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
3199 * 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
3200 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3201 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
3202 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3203 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
3204
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3205 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3206 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3207
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
3208 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
3209 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
3210 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
3211 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
3212 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3213
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3214 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3215 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3216 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3217 * 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
3218 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3219 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3220 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
3221 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3222 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3223 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3224
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3225 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
3226 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3227
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3228 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3229 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
3230 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3231 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3232 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3233 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3234 }
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
3235
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
3236 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "lastselect");
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3237
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
3238 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3239 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3240 if(lastselect && GTK_IS_WIDGET(lastselect))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3241 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3242 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(lastselect), "parenttree");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3243 if(parenttree && GTK_IS_TREE(parenttree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3244 gtk_tree_unselect_child(GTK_TREE(parenttree), lastselect);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3245 }
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
3246 gtk_object_set_data(GTK_OBJECT(handle), "lastselect", NULL);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3247 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3248
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3249 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "parenttree");
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3250
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3251 if(parenttree && GTK_IS_WIDGET(parenttree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3252 gtk_tree_remove_item(GTK_TREE(parenttree), item);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3253 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3254 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
3255
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 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
3257 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3264 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 gtk_signal_connect(GTK_OBJECT(clist), "select_row", GTK_SIGNAL_FUNC(_select_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 gtk_signal_connect(GTK_OBJECT(clist), "unselect_row", GTK_SIGNAL_FUNC(_unselect_row), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 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
3275 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 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
3277 gtk_object_set_data(GTK_OBJECT(clist), "multi", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 gtk_widget_show(clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3280 gtk_object_set_data(GTK_OBJECT(clist), "colcount", (gpointer)count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3309 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3310 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3312 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3320 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3321 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3322 char **newtitles = malloc(sizeof(char *) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3323 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 newtitles[0] = "Icon";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 newtitles[1] = "Filename";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_CENTER | DW_CFA_HORZSEPARATOR | DW_CFA_SEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 newflags[1] = DW_CFA_STRING | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 memcpy(&newtitles[2], titles, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 _dw_container_setup(handle, newflags, newtitles, count + 2, 2, 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 void dw_icon_free(unsigned long handle)
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
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3363 /* 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
3364 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
3365 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3366 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
3367
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3368 if(list)
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3369 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
3370
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3371 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
3372
c629838d9805 Updated to latest DW, and updated the Makefile to install the header files
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 72
diff changeset
3373 _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
3374 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
3375 _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
3376 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3377
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 int z, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3388 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "colcount");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3411 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
3412 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416 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
3417 if(fore)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3418 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
3419 if(back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3420 gtk_clist_set_background(GTK_CLIST(clist), z, back);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3422 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)rowcount);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3435 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3436 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3449 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3450 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3451
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3452 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3453 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3454
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3455 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3456 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3457 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3458 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3459 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3461 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3462 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3463 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3475 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3476 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3478 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 CDATE fdate = *((CDATE *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480
87
1eb72c0e8c79 Fixed a problem with the date type in the containers... month should be
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 86
diff changeset
3481 if(fdate.month > -1 && fdate.month < 12 && fdate.day > 0 && fdate.year > 0)
1eb72c0e8c79 Fixed a problem with the date type in the containers... month should be
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 86
diff changeset
3482 sprintf(textbuffer, "%s %d, %d", monthlist[fdate.month], fdate.day, fdate.year);
46
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3483 else
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3484 strcpy(textbuffer, "");
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
3485
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 CTIME ftime = *((CTIME *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3491
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 if(ftime.hours > 12)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3493 sprintf(textbuffer, "%d:%s%dpm", ftime.hours - 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3495 sprintf(textbuffer, "%d:%s%dam", ftime.hours ? ftime.hours : 12, (ftime.minutes < 10) ? "0" : "", ftime.minutes);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3496 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3498 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3499 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3500
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3501 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 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
3511 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3517 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3519 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3525 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3526 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3527 dw_container_set_item(handle, pointer, column + 2, row, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3528 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3531 * 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
3532 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3533 * 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
3534 * 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
3535 * 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
3536 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3537 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
3538 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3539 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
3540 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
3541
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3542 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
3543 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
3544
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3545 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
3546 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
3547 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
3548 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3549
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3550 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3551 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3562 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3563 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3564
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3565 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3566 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3567 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3568 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3570 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 /*
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 * 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
3592 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3593 * 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
3594 * 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
3595 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3596 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
3597 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3598 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
3599 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
3600
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3601 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
3602 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
3603 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
3604 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3605 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
3606
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3607 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
3608
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3609 _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
3610
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3611 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
3612 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
3613
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3614 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
3615 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
3616 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3617 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
3618
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_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
3620 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3621 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
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
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3624 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 * 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
3628 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
3630 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3639 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 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
3641 gtk_object_set_data(GTK_OBJECT(clist), "rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 * handle: Handle to the window (widget) to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 void dw_container_set_view(HWND handle, unsigned long flags, int iconwidth, int iconheight)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3656 * 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
3657 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3658 * 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
3659 * 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
3660 * 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
3661 * 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
3662 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3663 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
3664 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3665 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
3666 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
3667 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
3668
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3669 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
3670 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
3671 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
3672 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3673 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
3674 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
3675 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3676 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
3677 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3678 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
3679 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
3680 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3681 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
3682 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
3683 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3684 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3685 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
3686 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3687 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3688 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
3689 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3690
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3691 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3715 /* 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
3716 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3718 /* 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
3719 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
3720 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3721 g_list_free(list);
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3722
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3723 /* 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
3724 * current selection list.
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3725 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3726 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
3727 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
3728 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
3729 _dw_unselect(clist);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3730
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3731 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3732 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3733 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
3734 if(list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3735 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3736 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3737 retval = "";
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3738 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3739 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3740 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3741 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3742 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3743 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3744 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3745 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3746 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3747 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3748
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3749 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3750 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3751 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3752 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3753 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3754 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3755 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3756 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3757 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3766
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3770 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3773 /* 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
3774 if(flags & DW_CRA_SELECTED || flags & DW_CRA_CURSORED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3776 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
3777
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3778 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 {
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3780 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
3781 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
3782
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3783 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3784 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3785 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3786 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3787 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3788
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3789 if(list && list->data)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3790 retval = list->data;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3791 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
3792 retval = "";
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3793 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3794 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3795 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3796 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3797 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
3798
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3799 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
3800 gtk_object_set_data(GTK_OBJECT(clist), "querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3807 * 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
3808 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3809 * 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
3810 * 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
3811 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3812 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
3813 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3814 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
3815 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3816 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3817 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3818
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3819 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3820 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
3821
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3822 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3823 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3824 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3825 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3826 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3827 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
3828
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3829 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
3830 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3831 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
3832 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3833 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3834 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3835 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
3836
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3837 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
3838
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3839 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
3840
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3841 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
3842 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
3843 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3844 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3845 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3846 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3847
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3848 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3849 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3850
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3851 /*
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3852 * 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
3853 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3854 * 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
3855 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3856 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
3857 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3858 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
3859 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3860 int colcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3861
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3862 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3863 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
3864
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3865 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3866 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3867 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3868 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3869 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3870 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
3871 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
3872 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3873 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
3874 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
3875 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3876 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3877 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3878
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
3879 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3883 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3884 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895 | GDK_BUTTON_PRESS_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 | GDK_POINTER_MOTION_HINT_MASK);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 gtk_object_set_data(GTK_OBJECT(tmp), "id", (gpointer)id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3911 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3912 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3913 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3914
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3915 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3916 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3917 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3918 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3919 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3922 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3924 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3929 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3932 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3934 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3940 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3941 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3942
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3948 gdk_gc_set_foreground(gc, &_foreground[index]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3949 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951 return gc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3961 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3962 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3980 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 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
3989 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3999 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4002 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4003 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4004 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4005
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4006 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4007 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4009 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4011 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 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
4016 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4022 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4026 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4027 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4028 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4030 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4032
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4033 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4034 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4035 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4036 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4037 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4038 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4039 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4040 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4041 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045 GdkFont *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047
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
4048 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
4049 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
4050
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "fontname");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4063 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4067 gint ascent;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4069 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
4070 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
4071 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4072 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4073 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4074 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4075 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4076 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4077
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
4078 /* 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
4079 * 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
4080 * 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
4081 * 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
4082 * 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
4083 * 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
4084 * 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
4085 */
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
4086 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
4087 {
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
4088 int _locked_by_me = FALSE;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
4089 GdkFont *font;
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
4090 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
4091
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
4092 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
4093 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
4094
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
4095 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
4096 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
4097 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
4098 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
4099 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
4100
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
4101 font = gdk_font_load(fontname ? fontname : "fixed");
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
4102 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
4103 {
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
4104 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
4105 *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
4106 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
4107 *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
4108 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
4109 }
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
4110 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
4111 }
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
4112
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4113 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4114 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4115 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4116 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4117 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4118 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4119 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4120 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
4132 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4134 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4135
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4136
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4137 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4138 pixmap->handle = handle;
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
4139 #ifdef USE_PIXBUF
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
4140 pixmap->pixmap = (GdkPixmap *)gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, depth, width, height);
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4141 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4142 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4143 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4158 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4162 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 pixmap->pixmap = _find_pixmap(&bitmap, id, handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 pixmap->width = pvt->width; pixmap->height = pvt->height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4185 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4186 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4187 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4195 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4196 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4197 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4199 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
4200 #ifdef USE_PIXBUF
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
4201 gdk_pixbuf_unref((GdkPixbuf *)pixmap->pixmap);
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4202 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 gdk_pixmap_unref(pixmap->pixmap);
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4204 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4208
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4212 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4213 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 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
4224 {
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
4225 /* 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
4226 * 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
4227 * 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
4228 * 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
4229 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232
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
4233 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 gc = _set_colors(src->window);
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
4241 #ifndef USE_PIXBUF
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4243 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 gc = gdk_gc_new(srcp->pixmap);
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4246 #endif
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4247
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
4248 if(gc
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
4249 #ifdef USE_PIXBUF
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
4250 || (!dest && !src)
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4251 #endif
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4252 )
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 {
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
4254 #ifndef USE_PIXBUF
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 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
4256 #else
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
4257 if(dest && srcp)
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
4258 gdk_pixbuf_xlib_render_to_drawable(dest->window, gc, (GdkPixbuf *)srcp->pixmap, xsrc, ysrc, xdest, ydest, width, height, XLIB_RGB_DITHER_NONE, 0, 0);
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
4259
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
4260 if(gc)
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
4261 #endif
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
4262 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4271 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4272 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4273 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4274 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4275 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4276
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4277 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4278 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4279 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4282 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4283 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4284 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4285 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4286 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4287 HMTX mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4288
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4289 pthread_mutex_init(&mutex, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4290 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4293 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 pthread_mutex_destroy(&mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4304 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4305 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4306 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4307 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4308 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4309 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4310 pthread_mutex_lock(&mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4311 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4312
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4313 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4314 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4315 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4316 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 pthread_mutex_unlock(&mutex);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4323 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4339 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4340
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4341 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4343 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4345 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4360 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4361 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4362 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4363 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4364 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4365
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4368 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4369 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4370 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4371 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4372 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4373 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4375 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4399 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4400 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4401
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4402 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4403 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4404 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4406 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4415 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4419 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4420 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4421 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4422 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4423 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4425 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4426 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4429 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4432 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4436 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4437 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4438 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4439 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4440 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4441 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4442
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4443 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4444
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4445 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4446 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4447 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4448 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4449 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4450 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4460 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4461
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4462 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4463 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4464
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4465 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4467 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4468
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4469 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4470 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4471 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4472 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4473 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4474 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4475 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4476
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4477 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4478 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4479 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4480 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4481 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4482 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4483 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4484
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4485 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4490 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4495 #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
4496
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4497 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 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
4509 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4511 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4512
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4518 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
4519 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4520
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4527 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4529 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
4530 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
4531
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4532 /* 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
4533 * 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
4534 * 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
4535 * 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
4536 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4537 if(GTK_IS_TABLE(item))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4538 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4539 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
4540
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4541 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4542 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4543 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4544 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
4545 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4546 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4547 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4548
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4549 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
4550 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
4551 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4552 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
4553
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4554 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
4555 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4568 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4570 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4571 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4572 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4573 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4574
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4575 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4576 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4577 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
4578
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4579 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4580 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4581 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4582 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
4583 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4584 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4585 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4586
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4587 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 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
4589 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4603 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 void dw_window_set_usize(HWND handle, unsigned long width, unsigned long height)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4608
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4609 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4610 if(GTK_IS_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4611 _size_allocate(GTK_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4612 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4613 gtk_window_set_default_size(GTK_WINDOW(handle), width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4614 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4615 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4616 gtk_widget_set_usize(handle, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4617 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4618 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4619
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4620 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4650 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 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
4655 retval = gdk_visual_get_best_depth();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4667 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4671 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4672 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4673 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4677 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4679 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 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
4687 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4691 if(handle && GTK_IS_WINDOW(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 _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
4694
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4695 gtk_widget_set_uposition(handle, x, y);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4696 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
4697 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4698 else if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4699 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700 gdk_window_resize(handle->window, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4710 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4711 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4712 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4713 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715 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
4716 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 gint gx, gy, gwidth, gheight, gdepth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
4720 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4723
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 gdk_window_get_root_origin(handle->window, &gx, &gy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 *y = gy;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4730 if(GTK_IS_WINDOW(handle))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4731 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4732 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4733 *width = gwidth + _dw_border_width;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4734 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4735 *height = gheight + _dw_border_height;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4736 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4737 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4738 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4739 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4740 *width = gwidth;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4741 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4742 *height = gheight;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4743 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4748 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4749 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4750 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4751 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4752 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4753 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4754 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4755 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4756 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4757 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4758 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 if(GTK_IS_CLIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 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
4770 {
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
4771 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
4772 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
4773 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 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
4775 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 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
4777 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
4778 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4780 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
4781 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4782 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
4783 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4784 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4785
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4786 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4787
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4788 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4789 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4790
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4791 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4792 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4793
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4794 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
4795 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4796 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
4797 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
4798 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4799 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4800 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4803 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4805 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4807 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4808 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4809 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4810 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 for(z=0;z<256;z++)
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4816 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 if(!gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 return z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4822 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4842 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4844
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 unsigned int dw_notebook_page_query(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 retval = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4870
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 GtkWidget *child;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 if(child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4900 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4907
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4908 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4912 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4914 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4915 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 {
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4917 GtkWidget *label, *child, *oldlabel;
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4918 gchar *text = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4919 int pad, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 DW_MUTEX_LOCK;
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4922 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4923 if(child)
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4924 {
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4925 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4926 if(oldlabel)
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4927 gtk_label_get(GTK_LABEL(oldlabel), &text);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4928 }
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4929
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4930 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
4931
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4932 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4933 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4934 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
4935 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4936 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
4937
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4938 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, pageid);
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4939 if(child)
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
4940 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), pageid+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4957 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4958 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4963 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4964 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4965 GList *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4966 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
4967 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
4968 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4975 _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
4976 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
4977 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5010 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5078 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5081 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5096 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 }
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 the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 void dw_listbox_query_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5149 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5150
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5151 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5152 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5153 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5154
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5155 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5156 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5157 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5169 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5170 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5171 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5172 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5173 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5174 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5175 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5177 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5178 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5179 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5180 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5181 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5182 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5183 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5196 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5197 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5198 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5199 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5200 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5201 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5202 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5203 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5204
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5205 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5206 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5207 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5208 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5209
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5243 * 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
5244 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5245 * 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
5246 * 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
5247 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5248 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
5249 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5250 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5251 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5252 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5253
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5254 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5255 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5256 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5257 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
5258 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5259 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5260 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5261 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5262 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5263 int counter = 0;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5264 GList *list = GTK_LIST(handle2)->selection;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5265 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5266 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5267 if(counter > where)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5268 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5269 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5270 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5271 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5272
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5273 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5274 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5275 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5276 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5277 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5278 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5279 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5280
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5281 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5283 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5287 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5289 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5298 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "item");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 {
19
3e5bff3e55ff Fixed a problem in dw_listbox_selected().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 17
diff changeset
5311 if(list->data == GTK_LIST(handle2)->selection->data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 retval = counter;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5319 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5323 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5325 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5326 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5327 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5328 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5329 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5330 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5331 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5332 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5333 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5334 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5335 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 gtk_list_clear_items(GTK_LIST(handle2), index, index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * Pack a splitbar (sizer) into the specified box from the start.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 void dw_box_pack_splitbar_start(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 * Pack a splitbar (sizer) into the specified box from the end.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 void dw_box_pack_splitbar_end(HWND box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 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
5418 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 int _locked_by_me = FALSE;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5420 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5427 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
5428 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5429
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5436 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 {
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5438 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
5439 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
5440 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
5441
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5442 /* 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
5443 * 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
5444 * 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
5445 * 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
5446 */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5447 if(GTK_IS_TABLE(item))
48
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 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
5450
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5451 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5452 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5453 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5454 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
5455 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5456 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5457 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5458
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5459 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
5460 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5461 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5462 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5463 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
5464 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5465 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5466 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5467 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5468 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5469 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
5470 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5471
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
5472 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
5473 gtk_object_set_data(GTK_OBJECT(box), "boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5474 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5475 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5476 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5477 GSList *group;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5478 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "group");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5486 gtk_object_set_data(GTK_OBJECT(box), "group", (gpointer)item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5487 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5488 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5489 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5490 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5491 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5492
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5493 if(GTK_IS_TABLE(item))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5494 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5495 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
5496
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5497 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5498 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5499 gtk_container_add(GTK_CONTAINER(eventbox), item);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5500 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
5501 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5502 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5503 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5504
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5505 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 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
5507 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5509
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 /*
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
5517 * 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
5518 * 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
5519 * 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
5520 * 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
5521 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5522 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
5523 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5524 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
5525
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5526 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
5527 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
5528
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5529 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
5530 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
5531 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
5532 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5533
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
5534 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5535 * 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
5536 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5537 * 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
5538 * 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
5539 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5540 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
5541 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5542 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
5543
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5544 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5545 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5546
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5547 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5548 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
5549 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5550 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5551
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
5552 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5553 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5555 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5566
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5567 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5568
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5569 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5570
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
5571 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
5572 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
5573 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
5574 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
5575 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
5576
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5577 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 /* Internal function to handle the file OK press */
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5592 void _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 char *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5596 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5597 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5598
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5599 tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data));
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5600 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
5601 _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
5602 dw_dialog_dismiss(dwwait, (void *)(tmp ? strdup(tmp) : NULL));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 /* Internal function to handle the file Cancel press */
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5606 void _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5607 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5608 if(!dwwait)
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5609 return;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5610
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5611 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
5612 _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
5613 dw_dialog_dismiss(dwwait, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5619 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 * ext: Default file extention.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5623 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5624 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5625 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5626 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5627 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5628 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5629 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 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
5632 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 /* The DW mutex should be sufficient for
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 * insuring no thread changes this unknowingly.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5638 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5639 if(_dw_file_active)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 _dw_file_active = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 filew = gtk_file_selection_new(title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5649 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
5650
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5651 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
5652 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
5653
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 if(defpath)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5655 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5656
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657 gtk_widget_show(filew);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5659 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5660
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5661 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5662 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5663
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5664
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5679 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5680 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5682 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5708 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 /* Is there a way to find the webbrowser in Unix? */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 char *execargs[3], *browser = "netscape";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 }
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 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5747 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5763
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5764 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5773 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5774
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5775 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5776
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5777 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5778 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5780
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5781 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5782 * 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
5783 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5784 * 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
5785 * 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
5786 * 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
5787 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5788 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
5789 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5790 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
5791
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5792 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
5793 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5794
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5795 DW_MUTEX_LOCK;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5796 gtk_object_set_data(GTK_OBJECT(window), dataname, (gpointer)data);
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5797 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
5798 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5799
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5800 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5801 * 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
5802 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5803 * 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
5804 * 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
5805 * 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
5806 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5807 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
5808 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5809 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
5810 void *ret;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5811
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5812 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
5813 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5814
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5815 DW_MUTEX_LOCK;
91
67cd8e97ef8c Ick.. fixed typos in the GTK code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 90
diff changeset
5816 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
5817 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
5818 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
5819 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
5820
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5821 #ifndef NO_SIGNALS
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5822 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5823 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5824 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5825 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5826 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5827 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5828 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5830 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5831 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 SignalHandler *work = malloc(sizeof(SignalHandler));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5834 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5835 HWND thiswindow = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5836 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, "clicked") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5847 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5848 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5849 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-context") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5850 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5851 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5852 thisfunc = _findsigfunc("container-context");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5853 }
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
5854 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
5855 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5856 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
5857
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5858 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
5859 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
5860 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
5861
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5862 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
5863 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
5864 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
5865 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
5866 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
5867 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
5868 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5869 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, "container-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5870 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5871 thisname = "button_press_event";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5872 thisfunc = _findsigfunc("container-select");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5873 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5874 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5875 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5876 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5877 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5878 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, "item-select") == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5881 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5882 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
5883 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
5884 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5885 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
5886 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
5887 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
5888 }
55
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
5889 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
5890 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
5891 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
5892 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
5893 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
5894 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5895 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5896 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5897 if(thisfunc)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5898 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5899 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-func", (gpointer)thisfunc);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5900 gtk_object_set_data(GTK_OBJECT(thiswindow), "select-child-data", (gpointer)work);
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5901 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5902 thisname = "select-child";
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5903 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
5904 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow))
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
5905 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
5906 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
5907 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5908
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5909 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5910 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5911 free(work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5912 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5915
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 work->window = window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5917 work->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918 work->func = sigfunc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc), work);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5926 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5927 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5930 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5931 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 gtk_signal_disconnect_by_name(window, signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933 #endif
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 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 #if 0
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 gtk_signal_disconnect_by_window(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 dw_signal_disconnect_by_data(window, data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 #ifdef TEST
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 HWND mainwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 listbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 okbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 cancelbutton,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 lbbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 stext,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 buttonbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 testwindow,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 testbox,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 testok,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 testcancel,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 testbox2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 testok2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 testcancel2,
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 notebook;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 int count = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 int test_callback(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 dw_window_destroy((HWND)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 /* Return -1 to allow the default handlers to return. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 count--;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 exit(0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5986 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5989 * Let's demonstrate the functionality of this library. :)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5990 */
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5991 int main(int argc, char *argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5992 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5993 unsigned long flStyle = DW_FCF_SYSMENU | DW_FCF_TITLEBAR |
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5994 DW_FCF_SHELLPOSITION | DW_FCF_TASKLIST | DW_FCF_DLGBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5995 int pageid;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5996
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5997 dw_init(TRUE, argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 /* Try a little server dialog. :) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 mainwindow = dw_window_new(DW_DESKTOP, "Server", flStyle | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002 lbbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004 dw_box_pack_start(mainwindow, lbbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 stext = dw_text_new("Choose a server:", 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 dw_window_set_style(stext, DW_DT_VCENTER, DW_DT_VCENTER);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 dw_box_pack_start(lbbox, stext, 130, 15, FALSE, FALSE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 listbox = dw_listbox_new(100L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 dw_box_pack_start(lbbox, listbox, 130, 200, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 buttonbox = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 dw_box_pack_start(lbbox, buttonbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 okbutton = dw_button_new("Ok", 1001L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6021
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6023
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 cancelbutton = dw_button_new("Cancel", 1002L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6026 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, TRUE, 5);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6027
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 dw_window_set_color(lbbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 dw_window_set_color(buttonbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 dw_window_set_font(stext, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6032 dw_window_set_color(stext, DW_CLR_BLACK, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 dw_window_set_font(listbox, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 dw_window_set_font(okbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035 dw_window_set_font(cancelbutton, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 dw_window_show(mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 dw_window_set_usize(mainwindow, 170, 340);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 /* Another small example */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 flStyle |= DW_FCF_MINMAX | DW_FCF_SIZEBORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 testwindow = dw_window_new(DW_DESKTOP, "Wow a test dialog! :) yay!", flStyle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 testbox = dw_box_new(BOXVERT, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6047
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 dw_box_pack_start(testwindow, testbox, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 notebook = dw_notebook_new(1010L, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 dw_box_pack_start(testbox, notebook, 100, 100, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 testbox = dw_box_new(BOXVERT, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 pageid = dw_notebook_page_new(notebook, 0L, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 dw_notebook_pack(notebook, pageid, testbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6059
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 dw_notebook_page_set_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 dw_notebook_page_set_status_text(notebook, pageid, "Test page");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 testok = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 dw_box_pack_start(testbox, testok, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067 testcancel = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 dw_box_pack_start(testbox, testcancel, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 testbox2 = dw_box_new(BOXHORZ, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6073 dw_box_pack_start(testbox, testbox2, 0, 0, TRUE, TRUE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075 testok2 = dw_button_new("Ok", 1003L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 dw_box_pack_start(testbox2, testok2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6079 dw_box_pack_splitbar_start(testbox2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081 testcancel2 = dw_button_new("Cancel", 1004L);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 dw_box_pack_start(testbox2, testcancel2, 60, 40, TRUE, TRUE, 10);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 /* Set some nice fonts and colors */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 dw_window_set_color(testbox, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 dw_window_set_color(testbox2, DW_CLR_PALEGRAY, DW_CLR_PALEGRAY);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 dw_window_set_font(testok, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 dw_window_set_font(testcancel, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 dw_window_set_font(testok2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 dw_window_set_font(testcancel2, "9.WarpSans");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 dw_window_show(testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 /* Setup the function callbacks */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097 dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 dw_signal_connect(testok, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 dw_signal_connect(testcancel, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 dw_signal_connect(testok2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 dw_signal_connect(testcancel2, "clicked", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)mainwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 dw_signal_connect(testwindow, "delete_event", DW_SIGNAL_FUNC(test_callback), (void *)testwindow);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 dw_main(0L, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 }
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
6109 #endif
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
6110