annotate gtk/dw.c @ 510:710f82598210

Change function names to be inline with Mark Hessling's Rexx/DW.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 09 Mar 2004 03:27:39 +0000
parents 078a40ba2e41
children 80dbd5a1f403
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like implementation of the PM GUI
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 * GTK forwarder module for portabilty.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 *
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
6 * (C) 2000-2003 Brian Smith <dbsoft@technologist.com>
369
39983df2b93d Updated the license information, and copyrights. Code to do background
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 364
diff changeset
7 * (C) 2003 Mark Hessling <m.hessling@qut.edu.au>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 #include "dw.h"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11 #include <string.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include <stdlib.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <sys/utsname.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <stdarg.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
15 #include <stdio.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
16 #include <unistd.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
17 #include <errno.h>
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
18 #include <sys/time.h>
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
19 #include <dirent.h>
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
20 #include <sys/stat.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
21 #include "config.h"
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
22 #include <gdk/gdkkeysyms.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
23 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
24 #include <gdk_imlib.h>
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
25 #endif
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
26 #if GTK_MAJOR_VERSION > 1
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
27 #include <gdk-pixbuf/gdk-pixbuf.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
28 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29
401
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
30 #include "gtk/messagebox_error.xpm"
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
31 #include "gtk/messagebox_warning.xpm"
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
32 #include "gtk/messagebox_information.xpm"
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
33 #include "gtk/messagebox_question.xpm"
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
34
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 /* These are used for resource management */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 extern DWResources _resources;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
41 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
42 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
43 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
44 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
45 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 { 0, 0x0000, 0xbbbb, 0xbbbb }, /* 6 cyan */
142
9560efb7bea2 Make DW_CLR_PALEGRAY a bit lighter.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 141
diff changeset
49 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
60 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
61
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
62 #ifndef max
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
63 # define max(a,b) (((a) > (b)) ? (a) : (b))
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
64 #endif
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
65
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
66 #ifndef min
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
67 # define min(a,b) (((a) < (b)) ? (a) : (b))
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
68 #endif
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
69
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
70 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
71 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
72 GdkColor _background[DW_THREAD_LIMIT];
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
73 int _transparent[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
74
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
75 GtkWidget *last_window = NULL, *popup = NULL;
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
76
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
77 static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0;
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
78 static pthread_t _dw_thread = (pthread_t)-1;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
79 static int _dw_mutex_locked[DW_THREAD_LIMIT];
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
80 /* Use default border size for the default enlightenment theme */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
81 static int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
82
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
83 #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
84 #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
85
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
86 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
87 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
88 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
89
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
90 static GdkColormap *_dw_cmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
91
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
92 /* Signal forwarder prototypes */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
93 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
94 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
95 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
96 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
97 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
98 static gint _generic_event(GtkWidget *widget, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
99 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
100 static gint _activate_event(GtkWidget *widget, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
101 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
102 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
103 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
104 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
105 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
106 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
107 static gint _value_changed_event(GtkAdjustment *adjustment, gpointer user_data);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
108 #if GTK_MAJOR_VERSION > 1
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
109 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
110 static gint _tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
111 #else
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
112 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
113 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
114 #endif
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
115 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data);
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
116 static gint _column_click_event(GtkWidget *widget, gint column_num, 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
117
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
118 typedef struct
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
119 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
120 GdkPixmap *pixmap;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
121 GdkBitmap *mask;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
122 int used;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
123 unsigned long width, height;
316
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
124 #if GTK_MAJOR_VERSION > 1
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
125 GdkPixbuf *pixbuf;
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
126 #endif
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
127 } DWPrivatePixmap;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
128
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
129 static DWPrivatePixmap *_PixmapArray = NULL;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
130 static int _PixmapCount = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
131
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
132 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
133 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
134 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
135 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
136
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
137 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
138
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
139 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
140 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
141 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
142 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
143 gpointer data;
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
144 gint cid;
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
145 void *intfunc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
146
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
147 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
148
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
149 #define SIGNALMAX 19
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
150
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
151 /* A list of signal forwarders, to account for paramater differences. */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
152 static SignalList SignalTranslate[SIGNALMAX] = {
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
153 { _configure_event, DW_SIGNAL_CONFIGURE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
154 { _key_press_event, DW_SIGNAL_KEY_PRESS },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
155 { _button_press_event, DW_SIGNAL_BUTTON_PRESS },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
156 { _button_release_event, DW_SIGNAL_BUTTON_RELEASE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
157 { _motion_notify_event, DW_SIGNAL_MOTION_NOTIFY },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
158 { _delete_event, DW_SIGNAL_DELETE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
159 { _expose_event, DW_SIGNAL_EXPOSE },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
160 { _activate_event, "activate" },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
161 { _generic_event, DW_SIGNAL_CLICKED },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
162 { _container_select_event, DW_SIGNAL_ITEM_ENTER },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
163 { _container_context_event, DW_SIGNAL_ITEM_CONTEXT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
164 { _tree_context_event, "tree-context" },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
165 { _item_select_event, DW_SIGNAL_LIST_SELECT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
166 { _tree_select_event, DW_SIGNAL_ITEM_SELECT },
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
167 { _set_focus_event, DW_SIGNAL_SET_FOCUS },
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
168 { _value_changed_event, DW_SIGNAL_VALUE_CHANGED },
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
169 { _switch_page_event, DW_SIGNAL_SWITCH_PAGE },
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
170 { _column_click_event, DW_SIGNAL_COLUMN_CLICK },
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
171 { _tree_expand_event, DW_SIGNAL_TREE_EXPAND }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
174 /* Alignment flags */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
175 #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
176 #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
177 #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
178
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
179 static void _dw_msleep(long period)
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
180 {
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
181 #ifdef __sun__
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
182 /* usleep() isn't threadsafe on Solaris */
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
183 struct timespec req;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
184
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
185 req.tv_sec = 0;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
186 req.tv_nsec = period * 10000000;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
187
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
188 nanosleep(&req, NULL);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
189 #else
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
190 usleep(period * 1000);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
191 #endif
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
192 }
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
193
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194 /* Finds the translation function for a given signal name */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
195 static void *_findsigfunc(char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
196 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
197 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
198
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
199 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
200 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
201 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
202 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
203 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
204 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
206
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
207 static SignalHandler _get_signal_handler(GtkWidget *widget, gpointer data)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
208 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
209 int counter = (int)data;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
210 SignalHandler sh;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
211 char text[100];
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
212
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
213 sprintf(text, "_dw_sigwindow%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
214 sh.window = (HWND)gtk_object_get_data(GTK_OBJECT(widget), text);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
215 sprintf(text, "_dw_sigfunc%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
216 sh.func = (void *)gtk_object_get_data(GTK_OBJECT(widget), text);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
217 sprintf(text, "_dw_intfunc%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
218 sh.intfunc = (void *)gtk_object_get_data(GTK_OBJECT(widget), text);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
219 sprintf(text, "_dw_sigdata%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
220 sh.data = gtk_object_get_data(GTK_OBJECT(widget), text);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
221 sprintf(text, "_dw_sigcid%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
222 sh.cid = (gint)gtk_object_get_data(GTK_OBJECT(widget), text);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
223
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
224 return sh;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
225 }
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
226
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
227 static void _remove_signal_handler(GtkWidget *widget, int counter)
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
228 {
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
229 char text[100];
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
230 gint cid;
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
231
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
232 sprintf(text, "_dw_sigcid%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
233 cid = (gint)gtk_object_get_data(GTK_OBJECT(widget), text);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
234 gtk_signal_disconnect(GTK_OBJECT(widget), cid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
235 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
236 sprintf(text, "_dw_sigwindow%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
237 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
238 sprintf(text, "_dw_sigfunc%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
239 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
240 sprintf(text, "_dw_intfunc%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
241 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
242 sprintf(text, "_dw_sigdata%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
243 gtk_object_set_data(GTK_OBJECT(widget), text, NULL);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
244 }
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
245
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
246 static int _set_signal_handler(GtkWidget *widget, HWND window, void *func, gpointer data, void *intfunc)
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
247 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
248 int counter = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_sigcounter");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
249 char text[100];
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
250
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
251 sprintf(text, "_dw_sigwindow%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
252 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)window);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
253 sprintf(text, "_dw_sigfunc%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
254 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)func);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
255 sprintf(text, "_dw_intfunc%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
256 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)intfunc);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
257 sprintf(text, "_dw_sigdata%d", counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
258 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)data);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
259
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
260 counter++;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
261 gtk_object_set_data(GTK_OBJECT(widget), "_dw_sigcounter", (gpointer)counter);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
262
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
263 return counter - 1;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
264 }
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
265
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
266 static void _set_signal_handler_id(GtkWidget *widget, int counter, gint cid)
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
267 {
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
268 char text[100];
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
269
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
270 sprintf(text, "_dw_sigcid%d", counter);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
271 gtk_object_set_data(GTK_OBJECT(widget), text, (gpointer)cid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
272 }
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
273
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
274 static gint _set_focus_event(GtkWindow *window, GtkWidget *widget, gpointer data)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
275 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
276 SignalHandler work = _get_signal_handler((GtkWidget *)window, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
277 int retval = FALSE;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
278
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
279 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
280 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
281 int (*setfocusfunc)(HWND, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
282
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
283 retval = setfocusfunc(work.window, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
284 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
285 return retval;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
286 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
287
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
288 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
289 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
290 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
291 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
292
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
293 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
294 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
295 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
296 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
297
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
298 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
299 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
300 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
301 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
302
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
303 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
304 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
305 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
306 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
307
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
308 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
309 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
310 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
311 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
312
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
313 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
314 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
315 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
316 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
317
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
318 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
319 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
320 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
321 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
322
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
323 retval = buttonfunc(work.window, event->x, event->y, mybutton, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
324 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
325 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
327
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
328 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
329 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
330 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
331 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
332
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
333 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
334 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
335 int (*motionfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
336 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
337 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
339 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
340 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
341 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
342 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
343 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
344 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
345 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
346 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
348 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
349 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
350 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
351 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
352 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
353 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
354
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
355 retval = motionfunc(work.window, x, y, keys, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
356 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
357 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
358 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
359
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
360 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
361 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
362 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
363 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
364
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
365 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
366 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
367 int (*closefunc)(HWND, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
368
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
369 retval = closefunc(work.window, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
370 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
371 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
372 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
373
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
374 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
375 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
376 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
377 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
378
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
379 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
380 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
381 int (*keypressfunc)(HWND, char, int, int, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
382
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
383 retval = keypressfunc(work.window, *event->string, event->keyval,
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
384 event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK), work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
385 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
386 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
387 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
388
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
389 static gint _generic_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
390 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
391 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
392 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
393
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
394 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
395 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
396 int (*genericfunc)(HWND, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
397
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
398 retval = genericfunc(work.window, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
399 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
400 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
401 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
402
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
403 static gint _activate_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
404 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
405 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
406 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
407
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
408 if(work.window && !_dw_ignore_click)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
409 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
410 int (*activatefunc)(HWND, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
411
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
412 retval = activatefunc(popup ? popup : work.window, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
413 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
414 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
415 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
416
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
417 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
418 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
419 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
420 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
421
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
422 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
423 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
424 int (*sizefunc)(HWND, int, int, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
425
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
426 retval = sizefunc(work.window, event->width, event->height, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
427 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
428 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
429 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
430
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
431 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
432 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
433 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
434 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
435
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
436 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
437 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
438 DWExpose exp;
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
439 int (*exposefunc)(HWND, DWExpose *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
440
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
441 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
442 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
443 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
444 exp.height = event->area.height;
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
445 retval = exposefunc(work.window, &exp, work.data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
446 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
447 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
448 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
449
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
450 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
451 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
452 SignalHandler work = _get_signal_handler(widget, data);
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
453 static int _dw_recursing = 0;
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
454 int retval = FALSE;
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
455
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
456 if(_dw_recursing)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
457 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
458
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
459 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
460 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
461 int (*selectfunc)(HWND, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
462 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
463 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
464
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
465 _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
466
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
467 if(GTK_IS_COMBO(work.window))
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
468 list = GTK_LIST(GTK_COMBO(work.window)->list)->children;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
469 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
470 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
471 else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
472 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
473
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
474 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
476 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
477 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
478 if(!gtk_object_get_data(GTK_OBJECT(work.window), "_dw_appending"))
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
479 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
480 gtk_object_set_data(GTK_OBJECT(work.window), "_dw_item", (gpointer)item);
115
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
481 if(selectfunc)
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
482 retval = selectfunc(work.window, item, work.data);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
483 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
484 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
485 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
486 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
487 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
488 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
489 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
490 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
491 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
492 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
493
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
494 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
495 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
496 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
497 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
498
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
499 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
500 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
501 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
502 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
503 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
504 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
505 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
506
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
507 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
509 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
510 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
511 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
512 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
513 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
514 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
515
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
516 static gint _tree_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
517 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
518 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
519 int retval = FALSE;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
520
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
521 if(work.window)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
522 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
523 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
524 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
525 #if GTK_MAJOR_VERSION > 1
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
526 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
527 char *text = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
528 void *itemdata = NULL;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
529
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
530 if(widget && GTK_IS_TREE_VIEW(widget))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
531 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
532 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
533 GtkTreeIter iter;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
534
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
535 if(sel && gtk_tree_selection_get_selected(sel, NULL, &iter))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
536 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
537 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
538 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, -1);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
539 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
540 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
541
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
542 retval = contextfunc(work.window, text, event->x, event->y, work.data, itemdata);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
543 #else
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
544 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
545 char *text = (char *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_text");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
546 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_itemdata");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
547
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
548 if(widget != work.window)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
549 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
550 GtkWidget *tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(work.window));
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
551
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
552 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
553 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
554 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
555
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
556 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
557 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
558 text = (char *)gtk_object_get_data(GTK_OBJECT(lastselect), "_dw_text");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
559 itemdata = (void *)gtk_object_get_data(GTK_OBJECT(lastselect), "_dw_itemdata");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
560 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
561 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
562 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
563
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
564 retval = contextfunc(work.window, text, event->x, event->y, work.data, itemdata);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
565 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
566 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
567 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
568 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
569 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
570
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
571 #if GTK_MAJOR_VERSION > 1
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
572 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data)
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
573 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
574 GtkWidget *item, *widget = (GtkWidget *)gtk_tree_selection_get_tree_view(sel);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
575 int retval = FALSE;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
576
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
577 if(widget)
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
578 {
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
579 SignalHandler work = _get_signal_handler(widget, data);
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
580
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
581 if(work.window)
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
582 {
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
583 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func;
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
584 GtkTreeIter iter;
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
585 char *text = NULL;
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
586 void *itemdata = NULL;
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
587
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
588 if(gtk_tree_selection_get_selected(sel, NULL, &iter))
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
589 {
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
590 GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
591 gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1);
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
592 retval = treeselectfunc(work.window, (HTREEITEM)item, text, work.data, itemdata);
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
593 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
594 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
595 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
596 return retval;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
597 }
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
598
480
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
599 static gint _tree_expand_event(GtkTreeView *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
600 {
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
601 SignalHandler work = _get_signal_handler((GtkWidget *)widget, data);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
602 int retval = FALSE;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
603
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
604 if(!_dw_ignore_expand && work.window)
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
605 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
606 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = work.func;
480
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
607 retval = treeexpandfunc(work.window, (HTREEITEM)iter, work.data);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
608 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
609 return retval;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
610 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
611 #else
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
612 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
613 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
614 SignalHandler work = _get_signal_handler((GtkWidget *)tree, data);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
615 GtkWidget *treeroot = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(child), "_dw_tree");
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
616 int retval = FALSE;
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
617
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
618 if(treeroot && GTK_IS_TREE(treeroot))
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
619 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
620 GtkWidget *lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(treeroot), "_dw_lastselect");
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
621 if(lastselect && GTK_IS_TREE_ITEM(lastselect))
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
622 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect));
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
623 gtk_object_set_data(GTK_OBJECT(treeroot), "_dw_lastselect", (gpointer)child);
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
624 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
625
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
626 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
627 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
628 int (*treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = work.func;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
629 char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "_dw_text");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
630 void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "_dw_itemdata");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
631 retval = treeselectfunc(work.window, (HTREEITEM)child, text, work.data, itemdata);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
632 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
633 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
634 }
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
635
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
636 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data)
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
637 {
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
638 SignalHandler work = _get_signal_handler((GtkWidget *)treeitem, data);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
639 int retval = FALSE;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
640
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
641 if(!_dw_ignore_expand && work.window)
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
642 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
643 int (*treeexpandfunc)(HWND, HTREEITEM, void *) = work.func;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
644 retval = treeexpandfunc(work.window, (HTREEITEM)treeitem, work.data);
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
645 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
646 return retval;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
647 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
648 #endif
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
649
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
650 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
651 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
652 SignalHandler work = _get_signal_handler(widget, data);
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
653 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
654
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
655 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
656 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
657 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
658 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
659 int (*contextfunc)(HWND, char *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
660 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
661 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
663 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
664
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
665 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), row);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
666 retval = contextfunc(work.window, text, work.data);
320
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
667 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
668 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
669 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
670 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
671 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
672
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
673 static gint _container_enter_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
674 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
675 SignalHandler work = _get_signal_handler(widget, data);
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
676 int retval = FALSE;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
677
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
678 if(work.window && event->keyval == VK_RETURN)
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
679 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
680 int (*contextfunc)(HWND, char *, void *) = work.func;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
681 char *text;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
682
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
683 text = (char *)gtk_clist_get_row_data(GTK_CLIST(widget), GTK_CLIST(widget)->focus_row);
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
684 retval = contextfunc(work.window, text, work.data);
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
685 }
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
686 return retval;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
687 }
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
688
345
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
689 /* Return the logical page id from the physical page id */
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
690 int _get_logical_page(HWND handle, unsigned long pageid)
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
691 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
692 int z;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
693 GtkWidget **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray");
345
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
694 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
695
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
696 if(pagearray && thispage)
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
697 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
698 for(z=0;z<256;z++)
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
699 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
700 if(thispage == pagearray[z])
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
701 return z;
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
702 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
703 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
704 return 256;
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
705 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
706
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
707
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
708 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data)
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
709 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
710 SignalHandler work = _get_signal_handler((GtkWidget *)notebook, data);
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
711 int retval = FALSE;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
712
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
713 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
714 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
715 int (*switchpagefunc)(HWND, unsigned long, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
716 retval = switchpagefunc(work.window, _get_logical_page(GTK_WIDGET(notebook), page_num), work.data);
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
717 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
718 return retval;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
719 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
720
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
721 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
722 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
723 SignalHandler work = _get_signal_handler(widget, data);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
724 int retval = FALSE;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
725
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
726 if(work.window)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
727 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
728 int (*clickcolumnfunc)(HWND, int, void *) = work.func;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
729 retval = clickcolumnfunc(work.window, column_num, work.data);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
730 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
731 return retval;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
732 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
733
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
734 static gint _container_select_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
735 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
736 SignalHandler work = _get_signal_handler(widget, data);
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
737 char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
738 int (*contextfunc)(HWND, HWND, char *, void *, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
739
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
740 if(!work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
741 return TRUE;
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
742
320
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
743 if(gtk_object_get_data(GTK_OBJECT(widget), "_dw_double_click"))
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
744 {
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
745 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)0);
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
746 return TRUE;
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
747 }
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
748 return contextfunc(work.window, 0, rowdata, work.data, 0);;
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
749 }
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
750
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
751 static int _round_value(gfloat val)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
752 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
753 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
754
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
755 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
756 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
757
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
758 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
759 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
760
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
761 static gint _value_changed_event(GtkAdjustment *adjustment, gpointer data)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
762 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
763 int max = _round_value(adjustment->upper);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
764 int val = _round_value(adjustment->value);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
765 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_slider");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
766 GtkWidget *scrollbar = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_scrollbar");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
767
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
768 if(slider)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
769 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
770 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
771
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
772 if(work.window)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
773 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
774 int (*valuechangedfunc)(HWND, int, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
775
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
776 if(GTK_IS_VSCALE(slider))
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
777 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
778 else
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
779 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
780 }
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
781 }
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
782 else if(scrollbar)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
783 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
784 SignalHandler work = _get_signal_handler((GtkWidget *)adjustment, data);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
785
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
786 if(work.window)
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
787 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
788 int (*valuechangedfunc)(HWND, int, void *) = work.func;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
789
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
790 valuechangedfunc(work.window, val, work.data);
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
791 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
792 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
793 return FALSE;
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
794 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
795
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
796 static gint _default_key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
797 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
798 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
799
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
800 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
801 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
802 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
803 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
804 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
805 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
806 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
807 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
808 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
809 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
810 return FALSE;
40
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
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
813 static GdkPixmap *_find_private_pixmap(GdkBitmap **bitmap, long id, unsigned long *userwidth, unsigned long *userheight)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
814 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
815 if(id < _PixmapCount && _PixmapArray[id].used)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
816 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
817 *bitmap = _PixmapArray[id].mask;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
818 if(userwidth)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
819 *userwidth = _PixmapArray[id].width;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
820 if(userheight)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
821 *userheight = _PixmapArray[id].height;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
822 return _PixmapArray[id].pixmap;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
823 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
824 return NULL;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
825 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
826
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
827 static GdkPixmap *_find_pixmap(GdkBitmap **bitmap, long id, HWND handle, unsigned long *userwidth, unsigned long *userheight)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
831
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
832 if(id & (1 << 31))
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
833 return _find_private_pixmap(bitmap, (id & 0xFFFFFF), userwidth, userheight);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
834
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
840 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
845 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
846 GdkPixmap *icon_pixmap = NULL;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
847 #if GTK_MAJOR_VERSION > 1
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
848 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)data);
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
849
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
850 if(userwidth)
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
851 *userwidth = gdk_pixbuf_get_width(icon_pixbuf);
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
852 if(userheight)
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
853 *userheight = gdk_pixbuf_get_height(icon_pixbuf);
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
854
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
855 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, bitmap, 1);
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
856 g_object_unref(icon_pixbuf);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
857 #elif defined(USE_IMLIB)
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
858 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 #else
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
860 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, bitmap, &_colors[DW_CLR_PALEGRAY], (char **)data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
862 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
867 #if GTK_MAJOR_VERSION > 1
316
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
868 static GdkPixbuf *_find_private_pixbuf(long id)
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
869 {
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
870 if(id < _PixmapCount && _PixmapArray[id].used)
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
871 return _PixmapArray[id].pixbuf;
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
872 return NULL;
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
873 }
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
874
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
875 static GdkPixbuf *_find_pixbuf(long id)
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
876 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
877 char *data = NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
878 int z;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
879
316
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
880 if(id & (1 << 31))
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
881 return _find_private_pixbuf((id & 0xFFFFFF));
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
882
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
883 for(z=0;z<_resources.resource_max;z++)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
884 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
885 if(_resources.resource_id[z] == id)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
886 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
887 data = _resources.resource_data[z];
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
888 break;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
889 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
890 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
891
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
892 if(data)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
893 return gdk_pixbuf_new_from_xpm_data((const char **)data);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
894 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
895 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
896 #endif
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
897
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
898 static void _size_allocate(GtkWindow *window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
902 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
903 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
904 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
905 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
906 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
907 sizehints.min_height = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
908
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
909 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
911 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
912 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
913 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
914 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
915 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
916
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
917 /* Find the index of a given thread */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
918 static int _find_thread_index(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
919 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
920 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
921
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
922 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
923 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
924 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
925 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
926 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
927 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
928 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
929
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
930 /* Add a thread id to the thread list */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
931 static void _dw_thread_add(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
932 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
933 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
934
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
935 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
936 {
264
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
937 if(_dw_thread_list[z] == tid)
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
938 return;
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
939
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
940 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
941 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
942 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
943 _foreground[z].pixel = _foreground[z].red =_foreground[z].green = _foreground[z].blue = 0;
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
944 _background[z].pixel = 1;
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
945 _background[z].red = _background[z].green = _background[z].blue = 0;
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
946 _transparent[z] = 1;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
947 return;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
948 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
949 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
950 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
951
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
952 /* Remove a thread id to the thread list */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
953 static void _dw_thread_remove(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
954 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
955 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
956
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
957 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
958 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
959 if(_dw_thread_list[z] == (DWTID)tid)
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
960 _dw_thread_list[z] = (DWTID)-1;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
961 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
962 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
963
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
964 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
965 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
970 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
973 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
978 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
979 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
980 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
981 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
982 g_thread_init(NULL);
135
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
983 #if GTK_MAJOR_VERSION > 1
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
984 gdk_threads_init();
f57ef391f104 For GTK to be thread safe in 2.0 we must call gdk_threads_init().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 134
diff changeset
985 #endif
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
986
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
987 gtk_init(argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
988 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
989 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
990 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
991 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
992 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
993 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
994 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
995
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
996 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
997 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
998 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
999 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1000 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1001 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1002
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1003 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1004 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1005
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
1006 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
1007
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1008 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1009 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1010
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1011 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1012 * Runs a message loop for Dynamic Windows.
150
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
1013 */
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
1014 void dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1015 {
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
1016 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1017 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1018 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1019 gtk_main();
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
1020 _dw_thread = (pthread_t)-1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1021 gdk_threads_leave();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1022 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1024 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1025 * 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
1026 * 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
1027 * 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
1028 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1029 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
1030 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1031 struct timeval tv, start;
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1032 pthread_t curr = pthread_self();
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1033
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1034 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1035
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1036 if(_dw_thread == (pthread_t)-1 || _dw_thread == curr)
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1037 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1038 pthread_t orig = _dw_thread;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1039
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1040 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
1041
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1042 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
1043 {
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1044 if(orig == (pthread_t)-1)
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1045 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1046 gdk_threads_enter();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1047 _dw_thread = curr;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1048 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1049 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1050 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1051 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1052 _dw_msleep(1);
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1053 if(orig == (pthread_t)-1)
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1054 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1055 _dw_thread = orig;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1056 gdk_threads_leave();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
1057 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1058 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1059 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1060 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1061 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1062 _dw_msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1063 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1064
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1065 /*
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1066 * Processes a single message iteration and returns.
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1067 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1068 void dw_main_iteration(void)
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1069 {
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
1070 gdk_threads_enter();
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1071 _dw_thread = pthread_self();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1072 _dw_thread_add(_dw_thread);
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1073 gtk_main_iteration();
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
1074 _dw_thread = (pthread_t)-1;
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1075 gdk_threads_leave();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1076 }
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1077
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
1078 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 free(ptr);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1091 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1095 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1096 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1098 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1099 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1100 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1101 tmp->done = FALSE;
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1102 tmp->method = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1103 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1104
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1105 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1106 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1107
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1117 dialog->result = result;
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1118 if(dialog->method)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1133 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1134 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
1135 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
1136
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1137 /* _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
1138 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
1139 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1140 _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
1141 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1142 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
1143 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1145 if(pthread_self() == _dw_thread)
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1146 {
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1147 dialog->method = TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1148 gtk_main();
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1149 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150 else
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1151 {
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1152 dialog->method = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 dw_event_wait(dialog->eve, -1);
494
edcf9ec12f8c Fixed a bug in the dialog system on Unix where, gtk_main() could exit
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 493
diff changeset
1154 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1156 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1157 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1158 _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
1159 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
1160 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
1161
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1168 static int _dw_ok_func(HWND window, void *data)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1169 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1170 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1171
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1172 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1173 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1174
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1175 dw_window_destroy((HWND)dwwait->data);
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1176 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_OK);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1177 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1178 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1179
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1180 int _dw_yes_func(HWND window, void *data)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1181 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1182 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
1183
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1184 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1185 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1186
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1187 dw_window_destroy((HWND)dwwait->data);
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1188 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_YES);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1189 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1190 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1191
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1192 int _dw_no_func(HWND window, void *data)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1193 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1194 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
1195
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1196 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1197 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1198
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1199 dw_window_destroy((HWND)dwwait->data);
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1200 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_NO);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1201 return FALSE;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1202 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1203
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1204 int _dw_cancel_func(HWND window, void *data)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1205 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1206 DWDialog *dwwait = (DWDialog *)data;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1207
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1208 if(!dwwait)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1209 return FALSE;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1210
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1211 dw_window_destroy((HWND)dwwait->data);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1212 dw_dialog_dismiss((DWDialog *)data, (void *)DW_MB_RETURN_CANCEL);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1213 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1214 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1215
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 * title: The title of the message box.
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1220 * flags: Defines buttons and icons to display
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1221 * format: printf style format string.
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1222 * ...: Additional variables for use in the format.
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1223 */
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1224 int dw_messagebox(char *title, int flags, char *format, ...)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1225 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1226 HWND entrywindow, texttargetbox, imagetextbox, mainbox, okbutton, nobutton, yesbutton, cancelbutton, buttonbox, stext;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1227 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
1228 DWDialog *dwwait;
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1229 va_list args;
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1230 char outbuf[1000];
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1231 char **xpm_data = NULL;
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1232 int x, y, extra_width=0,text_width,text_height;
464
3251fbca6fb3 dw_listbox_delete() needs index+1 for end arg
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 463
diff changeset
1233 int width,height;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1234
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1235 va_start(args, format);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1236 vsprintf(outbuf, format, args);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1237 va_end(args);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1238
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1239 entrywindow = dw_window_new(HWND_DESKTOP, title, flStyle);
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
1240 mainbox = dw_box_new(DW_VERT, 10);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1241 dw_box_pack_start(entrywindow, mainbox, 0, 0, TRUE, TRUE, 0);
401
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
1242
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
1243 /* determine if an icon is to be used - if so we need another HORZ box */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1244 if((flags & DW_MB_ERROR) | (flags & DW_MB_WARNING) | (flags & DW_MB_INFORMATION) | (flags & DW_MB_QUESTION))
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1245 {
401
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
1246 imagetextbox = dw_box_new(DW_HORZ, 0);
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1247 dw_box_pack_start(mainbox, imagetextbox, 0, 0, TRUE, TRUE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1248 texttargetbox = imagetextbox;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1249 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1250 else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1251 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1252 imagetextbox = NULL;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1253 texttargetbox = mainbox;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1254 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1255
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1256 if(flags & DW_MB_ERROR)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1257 xpm_data = (char **)_dw_messagebox_error;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1258 else if(flags & DW_MB_WARNING)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1259 xpm_data = (char **)_dw_messagebox_warning;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1260 else if(flags & DW_MB_INFORMATION)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1261 xpm_data = (char **)_dw_messagebox_information;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1262 else if(flags & DW_MB_QUESTION)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1263 xpm_data = (char **)_dw_messagebox_question;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1264
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
1265 if(xpm_data)
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
1266 extra_width = 32;
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
1267
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1268 if(texttargetbox == imagetextbox)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1269 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1270 GdkPixmap *icon_pixmap = NULL;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1271 GdkBitmap *bitmap = NULL;
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1272 HWND handle = dw_bitmap_new( 100 );
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1273 #if GTK_MAJOR_VERSION > 1
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1274 GdkPixbuf *icon_pixbuf = gdk_pixbuf_new_from_xpm_data((const char **)xpm_data);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1275
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1276 gdk_pixbuf_render_pixmap_and_mask(icon_pixbuf, &icon_pixmap, &bitmap, 1);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1277 g_object_unref(icon_pixbuf);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1278 #elif defined(USE_IMLIB)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1279 gdk_imlib_data_to_pixmap((char **)xpm_data, &icon_pixmap, &bitmap);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1280 #else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1281 icon_pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], (char **)xpm_data);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1282 #endif
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1283
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1284 #if GTK_MAJOR_VERSION > 1
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1285 gtk_image_set_from_pixmap(GTK_IMAGE(handle), icon_pixmap, bitmap);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1286 #else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1287 gtk_pixmap_set(GTK_PIXMAP(handle), icon_pixmap, bitmap);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1288 #endif
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1289
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1290 dw_box_pack_start( texttargetbox, handle, 32, 32, FALSE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1291 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1292
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1293 /* Create text */
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1294 text_width = 240;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1295 text_height = 0;
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1296 stext = dw_text_new(outbuf, 0);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1297 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK);
464
3251fbca6fb3 dw_listbox_delete() needs index+1 for end arg
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 463
diff changeset
1298 dw_font_text_extents(stext, NULL, outbuf, &width, &height);
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1299 height = height+3;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1300 if(width < text_width)
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1301 text_height = height*2;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1302 else if(width < text_width*2)
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1303 text_height = height*3;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1304 else if(width < text_width*3)
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1305 text_height = height*4;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1306 else /* width > (3*text_width) */
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1307 {
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1308 text_width = (width / 3) + 60;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1309 text_height = height*4;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1310 }
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1311 dw_box_pack_start(texttargetbox, stext, text_width, text_height, 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
1312
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1313 /* Buttons */
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
1314 buttonbox = dw_box_new(DW_HORZ, 10);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1315
429
f977c80a1dfa Check for inconsistent parameters in dw_box_pack_start() and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 427
diff changeset
1316 dw_box_pack_start(mainbox, buttonbox, 0, 40, 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
1317
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1318 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
1319
401
306ce9765a61 Fixes for new message box code. Also incorporated a fix from dw_window_set
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 399
diff changeset
1320 /* which buttons ? */
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1321 if(flags & DW_MB_OK)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1322 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1323 okbutton = dw_button_new("Ok", 1001L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1324 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1325 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1326 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1327 else if(flags & DW_MB_OKCANCEL)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1328 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1329 okbutton = dw_button_new("Ok", 1001L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1330 dw_box_pack_start(buttonbox, okbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1331 dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_ok_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1332 cancelbutton = dw_button_new("Cancel", 1002L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1333 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1334 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1335 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1336 else if(flags & DW_MB_YESNO)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1337 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1338 yesbutton = dw_button_new("Yes", 1001L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1339 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1340 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1341 nobutton = dw_button_new("No", 1002L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1342 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1343 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1344 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1345 else if(flags & DW_MB_YESNOCANCEL)
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1346 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1347 yesbutton = dw_button_new("Yes", 1001L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1348 dw_box_pack_start(buttonbox, yesbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1349 dw_signal_connect(yesbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_yes_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1350 nobutton = dw_button_new("No", 1002L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1351 dw_box_pack_start(buttonbox, nobutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1352 dw_signal_connect(nobutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_no_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1353 cancelbutton = dw_button_new("Cancel", 1003L);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1354 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1355 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
1356 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1357
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1358 height = max(50,text_height)+100;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1359 x = (dw_screen_width() - (text_width+60+extra_width))/2;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1360 y = (dw_screen_height() - height)/2;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1361
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
1362 dw_window_set_pos_size(entrywindow, x, y, (text_width+60+extra_width), height);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1363
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1364 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
1365
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
1366 return (int)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1370 * 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
1371 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1372 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1373 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1374 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1375 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1376 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1377
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1378 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1379 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1380
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1381 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1382 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
1383 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
1384 DefaultScreen (GDK_DISPLAY ()));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1385 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1386 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1387 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1388
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1389 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1390 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1391 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1392 * 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
1393 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1394 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
1395 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1396 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
1397
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1398 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1399 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1400
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1401 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1402 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
1403 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1404 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1405 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1406
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1407 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1408 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1409 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1410 * 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
1411 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1412 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
1413 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1414 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
1415
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1416 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1417 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1418
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1419 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1420 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
1421 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1422 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1423 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1424
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1425 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 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
1433 GtkWidget *defaultitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1434
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1435 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1436 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1437
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1438 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1439 gtk_widget_show(handle);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1440 if(GTK_WIDGET(handle)->window)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1441 {
272
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1442 int width = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_width");
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1443 int height = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_height");
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1444
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1445 if(width && height)
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1446 {
273
95bfcd2deb94 Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 272
diff changeset
1447 gtk_widget_set_usize(handle, width, height);
272
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1448 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", 0);
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1449 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", 0);
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1450 }
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1451
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1452 gdk_window_raise(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1453 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1454 gdk_window_show(GTK_WIDGET(handle)->window);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1455 gdk_flush();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
1456 }
273
95bfcd2deb94 Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 272
diff changeset
1457 defaultitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_defaultitem");
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
1458 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
1459 gtk_widget_grab_focus(defaultitem);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1460 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1461 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1462 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1463
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1464 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1465 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1466 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1467 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1468 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1469 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1470 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1471 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1472
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1473 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1474 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1475
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1476 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1477 gtk_widget_hide(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1478 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1479 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1480 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1481
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1482 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1483 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1484 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1485 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1491 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1492 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1493
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1494 DW_MUTEX_LOCK;
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
1495 if(GTK_IS_WIDGET(handle))
357
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1496 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1497 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_eventbox");
357
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1498
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1499 if(eventbox && GTK_IS_WIDGET(eventbox))
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1500 gtk_widget_destroy(eventbox);
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1501 else
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1502 gtk_widget_destroy(handle);
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
1503 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1504 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1505 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1507
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
1508 /* 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
1509 * 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
1510 * 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
1511 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1512 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
1513 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1514 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1515
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1521 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1524 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1525
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1526 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1527 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
1528 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1529 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1530
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1531 static int _set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1532 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1533 int retval = FALSE;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1534 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1535 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1536 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1547 #else
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1548 PangoFontDescription *font = pango_font_description_from_string(fontname);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1549
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1550 if(font)
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1551 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1552 gtk_widget_modify_font(handle, font);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1553 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1554 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1555 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1556 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1557 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1558
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1559 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1560 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 {
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1567 #if GTK_MAJOR_VERSION > 1
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1568 PangoFontDescription *pfont;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1569 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1570 GdkFont *gdkfont;
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1571 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1572 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1573 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1574 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1575 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1576
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1577 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1578 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1580 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1584 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1585
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1586 #if GTK_MAJOR_VERSION < 2
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1587 /* Free old font if it exists */
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1588 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1589 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1590 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
1591 gdkfont = gdk_font_load(fontname);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1592 if(!gdkfont)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1593 gdkfont = gdk_font_load("fixed");
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1594 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_gdkfont", (gpointer)gdkfont);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1595 #endif
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1596
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
1597 /* Free old font name if one is allocated */
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1598 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1600 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1601
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1602 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_fontname", (gpointer)font);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1603 #if GTK_MAJOR_VERSION > 1
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1604 pfont = pango_font_description_from_string(fontname);
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1605
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1606 if(pfont)
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1607 {
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1608 gtk_widget_modify_font(handle2, pfont);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1609 pango_font_description_free(pfont);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1610 }
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1611 #endif
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
1612 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1613 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1614 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1615
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1616 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1617 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1618 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk");
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1619
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1620 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1621 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1622
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1623 old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk");
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1624
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1625 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1626 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1627 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1628
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1629 /* Free old color pointers and allocate new ones */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1630 static void _save_gdk_colors(HWND handle, GdkColor fore, GdkColor back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1631 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1632 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1633 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1634
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1635 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1636
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1637 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1638 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1639
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1640 gtk_object_set_data(GTK_OBJECT(handle), "_dw_foregdk", (gpointer)foregdk);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1641 gtk_object_set_data(GTK_OBJECT(handle), "_dw_backgdk", (gpointer)backgdk);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1642 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1643
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1644 static int _set_color(HWND handle, unsigned long fore, unsigned long back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1646 /* Remember that each color component in X11 use 16 bit no matter
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1647 * what the destination display supports. (and thus GDK)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1648 */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1649 GdkColor forecolor, backcolor;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1650 #if GTK_MAJOR_VERSION < 2
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1651 GtkStyle *style = gtk_style_copy(gtk_widget_get_style(handle));
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1652 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1653
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1654 if(fore & DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1655 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1656 forecolor.pixel = 0;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1657 forecolor.red = DW_RED_VALUE(fore) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1658 forecolor.green = DW_GREEN_VALUE(fore) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1659 forecolor.blue = DW_BLUE_VALUE(fore) << 8;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1660
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1661 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1662
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1663 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1664 gtk_widget_modify_text(handle, 0, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1665 gtk_widget_modify_text(handle, 1, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1666 gtk_widget_modify_fg(handle, 0, &forecolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1667 gtk_widget_modify_fg(handle, 1, &forecolor);
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1668 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1669 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1670 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = forecolor;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1671 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1672 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1673 else if(fore != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1674 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1675 forecolor = _colors[fore];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1676
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1677 #if GTK_MAJOR_VERSION > 1
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1678 gtk_widget_modify_text(handle, 0, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1679 gtk_widget_modify_text(handle, 1, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1680 gtk_widget_modify_fg(handle, 0, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1681 gtk_widget_modify_fg(handle, 1, &_colors[fore]);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1682 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1683 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1684 style->text[0] = style->text[1] = style->fg[0] = style->fg[1] = _colors[fore];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1685 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1686 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1687 if(back & DW_RGB_COLOR)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1688 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1689 backcolor.pixel = 0;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1690 backcolor.red = DW_RED_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1691 backcolor.green = DW_GREEN_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1692 backcolor.blue = DW_BLUE_VALUE(back) << 8;
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1693
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1694 gdk_color_alloc(_dw_cmap, &backcolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1695
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1696 #if GTK_MAJOR_VERSION > 1
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1697 gtk_widget_modify_base(handle, 0, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1698 gtk_widget_modify_base(handle, 1, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1699 gtk_widget_modify_bg(handle, 0, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1700 gtk_widget_modify_bg(handle, 1, &backcolor);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1701 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1702 if(style)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1703 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = backcolor;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1704 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1705 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1706 else if(back != DW_CLR_DEFAULT)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1707 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1708 backcolor = _colors[back];
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1709
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1710 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1711 gtk_widget_modify_base(handle, 0, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1712 gtk_widget_modify_base(handle, 1, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1713 gtk_widget_modify_bg(handle, 0, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1714 gtk_widget_modify_bg(handle, 1, &_colors[back]);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1715 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1716 if(style)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1717 style->base[0] = style->base[1] = style->bg[0] = style->bg[1] = _colors[back];
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1718 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1719 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1720
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1721 _save_gdk_colors(handle, forecolor, backcolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1722
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1723 if(GTK_IS_CLIST(handle))
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1724 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1725 int z, rowcount = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_rowcount");
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1726
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1727 for(z=0;z<rowcount;z++)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1728 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1729 gtk_clist_set_foreground(GTK_CLIST(handle), z, &forecolor);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1730 gtk_clist_set_background(GTK_CLIST(handle), z, &backcolor);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1731 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1732 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1733
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1734 #if GTK_MAJOR_VERSION < 2
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1735 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1736 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1737 gtk_widget_set_style(handle, style);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1738 gtk_style_unref(style);
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1739 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
1740 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1747 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1751 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1752 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1753 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1754
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
1757 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1758 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1759 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1760 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1763 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1764 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1765 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_eventbox");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1766 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1767 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1768 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
1769
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1775
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1776 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1777 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1778 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1779 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1780 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1781 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1782 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1783 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1784 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1786 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1787
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1796
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1798 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
1799 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1800 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1801
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1802 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1803 * 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
1804 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1805 * 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
1806 * 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
1807 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
1808 void dw_window_set_pointer(HWND handle, int pointertype)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1809 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1810 int _locked_by_me = FALSE;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1811 GdkCursor *cursor;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1812
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1813 DW_MUTEX_LOCK;
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1814 if(pointertype & (1 << 31))
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1815 {
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1816 GdkBitmap *bitmap = NULL;
338
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
1817 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL);
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
1818 cursor = gdk_cursor_new_from_pixmap(pixmap, (GdkPixmap *)bitmap, &_colors[DW_CLR_WHITE], &_colors[DW_CLR_BLACK], 8, 8);
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1819 }
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1820 else
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
1821 cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1822 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1823 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
1824 gdk_cursor_destroy(cursor);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1825 DW_MUTEX_UNLOCK;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1826 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1827
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
1828 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1834
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1836 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 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
1851 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1853 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
1854 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1856 gtk_window_set_title(GTK_WINDOW(tmp), title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1857 if(!(flStyle & DW_FCF_SIZEBORDER))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1858 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1859
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1860 gtk_widget_realize(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1861
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1862 if(flStyle & DW_FCF_TITLEBAR)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1863 flags |= GDK_DECOR_TITLE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1864
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1865 if(flStyle & DW_FCF_MINMAX)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 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
1869 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
1870
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
1871 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 flags |= GDK_DECOR_BORDER;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1874 if(flStyle & DW_FCF_MAXIMIZE)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1875 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1876 flags &= ~DW_FCF_MAXIMIZE;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1877 #if GTK_MAJOR_VERSION > 1
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1878 gtk_window_maximize(GTK_WINDOW(tmp));
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1879 #endif
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1880 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1881 if(flStyle & DW_FCF_MINIMIZE)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1882 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1883 flags &= ~DW_FCF_MINIMIZE;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1884 #if GTK_MAJOR_VERSION > 1
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1885 gtk_window_iconify(GTK_WINDOW(tmp));
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1886 #endif
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1887 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1888
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1889 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
1890
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1891 if(hwndOwner)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1892 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893
272
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1894 if(flStyle & DW_FCF_SIZEBORDER)
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1895 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_size", (gpointer)1);
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
1896
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1897 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1902 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1903 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
1904 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1905 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1906 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1907 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1908 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1909 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1910 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1911
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1912 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
1913 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1914 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1915
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1916 gtk_widget_show(eventbox);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1917 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_eventbox", (gpointer)eventbox);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1918 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", (gpointer)type);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1919 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
1928 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1929 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1930 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1931 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1932 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1933 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1934 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1935 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1936
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1937 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1938 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1939 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
1940 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
1941 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1942 gtk_container_border_width(GTK_CONTAINER(tmp), pad);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1943 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxtype", (gpointer)type);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1944 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1945 gtk_object_set_data(GTK_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1946 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1947 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1948 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1949 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1950 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1954 * 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
1955 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1956 * 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
1957 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1958 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
1959 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1960 GtkWidget *tmp;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1961 int _locked_by_me = FALSE;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1962
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1963 DW_MUTEX_LOCK;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1964 tmp = gtk_vbox_new(FALSE, 0);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1965 DW_MUTEX_UNLOCK;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
1966 return tmp;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1967 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1968
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1969 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1970 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1971 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
1972 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 {
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1976 #if GTK_MAJOR_VERSION < 2
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1977 GdkPixmap *pixmap = NULL;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1978 GdkBitmap *bitmap = NULL;
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1979 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
1980 "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
1981 " 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
1982 ". 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
1983 "."};
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1984 #endif
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1985 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1989 #if GTK_MAJOR_VERSION > 1
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1990 tmp = gtk_image_new();
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1991 #elif defined(USE_IMLIB)
47
997e9ed670ef Fixes for box alignment problem on OS/2, crash in dw_bitmap_new() on unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 46
diff changeset
1992 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1993 #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
1994 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
1995
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
1996 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
1997 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
1998 #endif
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
1999 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 tmp = gtk_pixmap_new(pixmap, bitmap);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2001 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2003 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2004 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2005 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2006 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
2016 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2018
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2019 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 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
2025 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
2026 #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
2027 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
2028 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2030 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2031 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2039 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2044 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2045 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2046 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2047
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2048 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2049 tmp = gtk_menu_new();
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2050 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2051 accel_group = gtk_accel_group_new();
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2052 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2053 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2054 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2055 return tmp;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2059 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2060 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2061 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2067 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2068 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2069
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2070 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2071 tmp = gtk_menu_bar_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 box = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(location));
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2073 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2074 accel_group = gtk_accel_group_new();
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2075 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2076
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2077 if(box)
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2078 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2080 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2081 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2082 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2083
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2084 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2085 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2086 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2087 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2096 gtk_widget_destroy(*menu);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 DW_MUTEX_UNLOCK;
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
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2102 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2105 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2110 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2111 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2112 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2113 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2114 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2115 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2116 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2117 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2118 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2119 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2122 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2130 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 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
2137 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2139 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2140 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2141 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2142 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2144 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2151 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2152
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2153 accel_group = (GtkAccelGroup *)gtk_object_get_data(GTK_OBJECT(menu), "_dw_accel");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2154 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "_dw_submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2155
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2158 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2159 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2161 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2163 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2164 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2165 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2166 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
2167 #if 0 /* This isn't working right */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2168 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
2169 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2170 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2171 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2172 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2175 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2178 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2179 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2180 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2181 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2182 tmp_key = gtk_label_parse_uline(GTK_LABEL(GTK_BIN(tmphandle)->child), tempbuf);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
2183 #if 0 /* This isn't working right */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2184 gtk_widget_add_accelerator(tmphandle, "activate", accel_group, tmp_key, GDK_MOD1_MASK, 0);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
2185 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2186 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2187 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2188 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2189 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2195 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2196 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2197
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2198 sprintf(tempbuf, "_dw_submenu%d", submenucount);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2199 submenucount++;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2200 gtk_menu_item_set_submenu(GTK_MENU_ITEM(tmphandle), submenu);
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2201 gtk_object_set_data(GTK_OBJECT(menu), tempbuf, (gpointer)submenu);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2202 gtk_object_set_data(GTK_OBJECT(menu), "_dw_submenucount", (gpointer)submenucount);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2203 }
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2204
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2205 if(GTK_IS_MENU_BAR(menu))
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2206 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2207 else
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2208 gtk_menu_append(GTK_MENU(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2209
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2210 gtk_object_set_data(GTK_OBJECT(tmphandle), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2211 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2212 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2213 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2214 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2215
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2216 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2217 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2218 GtkWidget *tmp;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2219 int z, submenucount = (int)gtk_object_get_data(GTK_OBJECT(start), "_dw_submenucount");
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2220
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2221 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
2222 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2223
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2224 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2225 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2226 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2227 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2228
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2229 sprintf(tempbuf, "_dw_submenu%d", z);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2230
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2231 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
2232 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2233 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2234 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2235 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2236 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2237 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2238 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2239
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2240 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2241 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2242 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2247 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2253 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2256 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2257 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2258 tmphandle = _find_submenu_id(menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2259
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2260 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2261 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2262 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2263 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2264 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
2265 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2267 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2268 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2270 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2271 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2272 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2273 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
2285 popup = parent;
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
2286
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2287 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
2288 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2289 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2290 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2291 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2292
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2294 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2295 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2296 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2297 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2298 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 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
2304 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
2305
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
2306 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 *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
2310 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2311 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2312
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2313 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2314 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2315 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2316 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2317 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2318 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2319 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2320 {
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
2321 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
2322
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
2323 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2324 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
2325 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2328 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2329 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2330 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2331 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2332 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2333 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
2334 HWND dw_container_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2344 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_multi", (gpointer)multi);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2345 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2346 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2347
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2348 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2349 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2350 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2352 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2353 * 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
2354 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2355 * 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
2356 * 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
2357 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2358 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
2359 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2360 GtkWidget *tmp, *tree;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2361 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2362 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2363 GtkTreeViewColumn *col;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2364 GtkCellRenderer *rend;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2365 GtkTreeSelection *sel;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2366 #endif
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2367 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
2368
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2369 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
2370 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
2371 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2372 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2373
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2374 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2375 gtk_widget_show(tmp);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2376 #if GTK_MAJOR_VERSION > 1
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
2377 store = gtk_tree_store_new(4, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER, G_TYPE_POINTER);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2378 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store));
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2379 gtk_object_set_data(GTK_OBJECT(tree), "_dw_tree_store", (gpointer)store);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2380 col = gtk_tree_view_column_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2381
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2382 rend = gtk_cell_renderer_pixbuf_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2383 gtk_tree_view_column_pack_start(col, rend, FALSE);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2384 gtk_tree_view_column_add_attribute(col, rend, "pixbuf", 1);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2385 rend = gtk_cell_renderer_text_new();
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2386 gtk_tree_view_column_pack_start(col, rend, TRUE);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2387 gtk_tree_view_column_add_attribute(col, rend, "text", 0);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2388
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2389 gtk_tree_view_append_column(GTK_TREE_VIEW (tree), col);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2390 gtk_tree_view_set_expander_column(GTK_TREE_VIEW(tree), col);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2391 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2392
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2393 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
2394 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2395 #else
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2396 tree = gtk_tree_new();
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2397 #endif
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2398 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
2399 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2400 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
2401 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
2402 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
2403 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2404 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp), tree);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2405 #if GTK_MAJOR_VERSION < 2
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2406 /* 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
2407 gtk_tree_set_selection_mode (GTK_TREE(tree), GTK_SELECTION_SINGLE);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2408 gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
2409 #endif
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2410
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2411 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
2412 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
2413
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2414 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
2415 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
2416 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2417
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2418
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2419 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2422 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2423 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2424 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2425 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2426 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2427 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2428 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2430 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2431 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
2432
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2433 /* 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
2434 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2435 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2436 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2437 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2443 * 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
2444 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2445 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2446 * id: An ID to be used with dw_window_from_id() or 0L.
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2447 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2448 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2449 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2450 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2451 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2452
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2453 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2454 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2455 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
2456 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2457 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2458 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2459 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
2460
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2461 /* 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
2462 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2463 gtk_object_set_data(GTK_OBJECT(frame), "_dw_id", (gpointer)id);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2464 gtk_object_set_data(GTK_OBJECT(frame), "_dw_label", (gpointer)tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2465 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2466 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2467 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2468
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
2469 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2472 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2480 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2481 tmpbox = gtk_scrolled_window_new (NULL, NULL);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2482 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tmpbox),
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2483 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2484 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(tmpbox), GTK_SHADOW_ETCHED_IN);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2485 tmp = gtk_text_view_new();
144
c68bc269ed58 Updated dw_window_set_font() to use GTK 2.0 semantics. Also improved the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 143
diff changeset
2486 gtk_container_add (GTK_CONTAINER(tmpbox), tmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2487 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_NONE);
353
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
2488
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
2489 scroller = NULL;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2490 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 GTK_WIDGET_UNSET_FLAGS(scroller, GTK_CAN_FOCUS);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2497 gtk_box_pack_start(GTK_BOX(tmpbox), tmp, TRUE, TRUE, 0);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2498 gtk_box_pack_start(GTK_BOX(tmpbox), scroller, FALSE, TRUE, 0);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2499 gtk_widget_show(scroller);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2500 #endif
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2501 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
2502 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 return tmpbox;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2508
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2509 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2510 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2512 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2513 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2514 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2516 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2517 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2518 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2519
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2520 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2521 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2522
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2523 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2526 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2531
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2532 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 * text: The default text to be in the entryfield widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2536 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2544 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2548
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2550 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2556 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 * text: The default text to be in the combpbox widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2560 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2563 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2564 GtkWidget *tmp;
424
5cc81d3c2bca Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 423
diff changeset
2565 int sigid, _locked_by_me = FALSE;
5cc81d3c2bca Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 423
diff changeset
2566 gint cid;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2568 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2569 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2570 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2574 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
115
2d121d4d90c0 Run the _item_select_event() handler on comboboxes even if a handler
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 114
diff changeset
2575
424
5cc81d3c2bca Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 423
diff changeset
2576 sigid = _set_signal_handler(GTK_COMBO(tmp)->list, tmp, NULL, NULL, NULL);
5cc81d3c2bca Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 423
diff changeset
2577 cid = gtk_signal_connect(GTK_OBJECT(GTK_COMBO(tmp)->list), "select_child", GTK_SIGNAL_FUNC(_item_select_event), (gpointer)sigid);
5cc81d3c2bca Combobox code was using the old signal handler method. Updated it to thenew
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 423
diff changeset
2578 _set_signal_handler_id(GTK_COMBO(tmp)->list, sigid, cid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2583 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2586 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2587 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2588 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2589 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2597 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2606 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2607 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2608 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2609 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2610 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 {
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2621 dw_window_set_bitmap(bitmap, id, NULL);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2622 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2623 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2624 gtk_widget_show(tmp);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2625 if(text)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2626 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2627 tooltips = gtk_tooltips_new();
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2628 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2629 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2630 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2631 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2632 DW_MUTEX_UNLOCK;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2633 return tmp;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2634 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2635
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2636 /*
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2637 * Create a new bitmap button window (widget) to be packed from a file.
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2638 * Parameters:
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2639 * text: Bubble help text to be displayed.
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2640 * id: An ID to be used with dw_window_from_id() or 0L.
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2641 * filename: Name of the file, omit extention to have
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2642 * DW pick the appropriate file extension.
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2643 * (BMP on OS/2 or Windows, XPM on Unix)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2644 */
279
984db8aefd7f Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
2645 HWND dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename)
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2646 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2647 GtkWidget *tmp;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2648 GtkWidget *bitmap;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2649 GtkTooltips *tooltips;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2650 int _locked_by_me = FALSE;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2651
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2652 DW_MUTEX_LOCK;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2653 tmp = gtk_button_new();
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2654 bitmap = dw_bitmap_new(id);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2655
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2656 if(bitmap)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2657 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2658 dw_window_set_bitmap(bitmap, 0, filename);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2662 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 tooltips = gtk_tooltips_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2668 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670 return tmp;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2674 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2675 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2676 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2677 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2678 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2679 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2680 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2681 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 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
2687 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2690 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2691 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2694 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2695
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2696 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2697 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2698 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2699 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2700 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2701 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2702 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2703 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2704 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2705 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2706 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2707
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2709 tmp = gtk_radio_button_new_with_label(NULL, text);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2710 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 gtk_widget_show(tmp);
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 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2718 * 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
2719 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2720 * 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
2721 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2722 * id: An ID to be used with dw_window_from_id() or 0L.
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2723 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2724 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
2725 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2726 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
2727 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
2728 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
2729
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2730 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
2731 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
2732 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
2733 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
2734 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2735 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
2736 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
2737 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
2738 gtk_scale_set_digits(GTK_SCALE(tmp), 0);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2739 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2740 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_slider", (gpointer)tmp);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2741 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2742 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
2743 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
2744 }
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 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2747 * Create a new scrollbar window (widget) to be packed.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2748 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2749 * vertical: TRUE or FALSE if scrollbar is vertical.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2750 * increments: Number of increments available.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2751 * id: An ID to be used with dw_window_from_id() or 0L.
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2752 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2753 HWND dw_scrollbar_new(int vertical, int increments, ULONG id)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2754 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2755 GtkWidget *tmp;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2756 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2757 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2758
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2759 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2760 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, (gfloat)increments, 1, 1, 1);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2761 if(vertical)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2762 tmp = gtk_vscrollbar_new(adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2763 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2764 tmp = gtk_hscrollbar_new(adjustment);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2765 GTK_WIDGET_UNSET_FLAGS(tmp, GTK_CAN_FOCUS);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2766 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2767 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adjustment);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2768 gtk_object_set_data(GTK_OBJECT(adjustment), "_dw_scrollbar", (gpointer)tmp);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2769 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2770 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2771 return tmp;
196
3dc60d60007f Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 195
diff changeset
2772 }
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2773
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
2774 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2775 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2777 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
2779 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2780 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2781 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2782 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2783
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2784 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2785 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2786 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2787 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2789 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2791
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2792 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2793 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2794 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2795 * text: The text to be display by the static text widget.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2796 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2806 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 * Parameters:
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2814 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2817 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2818 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2819 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2820 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2821
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2822 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2823 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2824 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 gtk_widget_show(tmp);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2835 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2849 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 GdkPixmap *icon_pixmap;
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;
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
2854 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2858
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2859 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2860 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2862 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 * handle: Handle to the window.
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2866 * id: An ID to be used to specify the icon,
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2867 * (pass 0 if you use the filename param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2868 * filename: a path to a file (Bitmap on OS/2 or
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2869 * Windows and a pixmap on Unix, pass
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2870 * NULL if you use the id param)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2871 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2872 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2873 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
2874 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875 GdkPixmap *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2878 if(!id && !filename)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2879 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2880
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2881 DW_MUTEX_LOCK;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2882 if(id)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2883 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2884 else
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2885 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2886 char *file = alloca(strlen(filename) + 5);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2887 #if GTK_MAJOR_VERSION > 1
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2888 GdkPixbuf *pixbuf;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2889 #elif defined(USE_IMLIB)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2890 GdkImlibImage *image;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2891 #endif
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2892
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2893 if (!file)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2894 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2895 DW_MUTEX_UNLOCK;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2896 return;
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2897 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2898
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2899 strcpy(file, filename);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2900
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2901 /* check if we can read from this file (it exists and read permission) */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2902 if(access(file, 04) != 0)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2903 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2904 /* Try with .xpm extention */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2905 strcat(file, ".xpm");
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2906 if(access(file, 04) != 0)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2907 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2908 DW_MUTEX_UNLOCK;
279
984db8aefd7f Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
2909 return;
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2910 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2911 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2912 #if GTK_MAJOR_VERSION > 1
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2913 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2914
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2915 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2916 g_object_unref(pixbuf);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2917 #elif defined(USE_IMLIB)
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2918 image = gdk_imlib_load_image(file);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2919
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2920 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2921 tmp = gdk_imlib_copy_image(image);
282
916045924784 Fixed the mask in dw_window_set_bitmap() when using imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 279
diff changeset
2922 bitmap = gdk_imlib_copy_mask(image);
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2923 gdk_imlib_destroy_image(image);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2924 #else
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2925 tmp = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2926 #endif
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2927 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
2928
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 if(tmp)
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2930 #if GTK_MAJOR_VERSION > 1
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
2931 gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2932 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2934 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 * handle: Handle to the window.
407
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
2942 * text: The text associsated with a given window. f
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2943 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 gtk_label_set_text(GTK_LABEL(handle), text);
402
0f0183aa2b05 Fixed dw_window_set_text() to work on buttons.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 401
diff changeset
2955 else if(GTK_IS_BUTTON(handle))
403
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2956 {
407
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
2957 #if GTK_MAJOR_VERSION < 2
403
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2958 GtkWidget *label = GTK_BUTTON(handle)->child;
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2959
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2960 if(GTK_IS_LABEL(label))
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2961 gtk_label_set_text(GTK_LABEL(label), text);
407
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
2962 #else
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
2963 gtk_button_set_label(GTK_BUTTON(handle), text);
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
2964 #endif
403
6a3ef130962f Check that the child is actually a label before trying to operate on it.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 402
diff changeset
2965 }
420
0cc801c0f2b6 dw_window_set_text() on a toplevel widget from dw_window_new() now works.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 415
diff changeset
2966 else if(GTK_WIDGET_TOPLEVEL(handle))
0cc801c0f2b6 dw_window_set_text() on a toplevel widget from dw_window_new() now works.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 415
diff changeset
2967 gtk_window_set_title(GTK_WINDOW(handle), text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2968 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2969 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2970 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label");
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2971 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2972 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
2973 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2986 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2987 const char *possible = "";
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2988 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 char *possible = "";
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2990 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 return strdup(possible);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3026 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030
249
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3031 /*
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3032 * Gets the child window handle with specified ID.
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3033 * Parameters:
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3034 * handle: Handle to the parent window.
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3035 * id: Integer ID of the child.
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3036 */
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3037 HWND API dw_window_from_id(HWND handle, int id)
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3038 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3039 GList *orig = NULL, *list = NULL;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3040 int _locked_by_me = FALSE;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3041
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3042 DW_MUTEX_LOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3043 if(handle && GTK_IS_CONTAINER(handle))
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3044 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3045 #if GTK_MAJOR_VERSION > 1
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3046 orig = list = gtk_container_get_children(GTK_CONTAINER(handle));
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3047 #else
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3048 orig = list = gtk_container_children(GTK_CONTAINER(handle));
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3049 #endif
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3050 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3051 while(list)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3052 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3053 if(GTK_IS_WIDGET(list->data))
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3054 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3055 if(id == (int)gtk_object_get_data(GTK_OBJECT(list->data), "_dw_id"))
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3056 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3057 HWND ret = (HWND)list->data;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3058 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3059 DW_MUTEX_UNLOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3060 return ret;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3061 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3062 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3063 list = list->next;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3064 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3065 if(orig)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3066 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
3067 DW_MUTEX_UNLOCK;
249
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3068 return 0L;
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3069 }
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
3070
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3071 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
3072 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3073 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
3074
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3075 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
3076 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3077 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
3078 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3079 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
3080 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3081 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3082 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3083 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
3084 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3085
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3099 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3100 if(GTK_IS_SCROLLED_WINDOW(handle))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3101 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 if(GTK_IS_BOX(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3103 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3105 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3107 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3108 if(tmp && GTK_IS_TEXT_VIEW(tmp))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3109 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3110 char *impbuf = malloc(strlen(buffer)+1);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3111 GtkTextBuffer *tbuffer;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3112 GtkTextIter iter;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3113
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3114 _strip_cr(impbuf, buffer);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3115
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3116 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3117 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, startpoint);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3118 gtk_text_buffer_place_cursor(tbuffer, &iter);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3119 gtk_text_buffer_insert_at_cursor(tbuffer, impbuf, -1);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3120 tmppoint = (startpoint > -1 ? startpoint : 0) + strlen(impbuf);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3121 free(impbuf);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3122 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3123 #else
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3124 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont");
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3125
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3128 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3129 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_backgdk");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3130 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
3131
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3132 _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
3133
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3134 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
3135 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 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
3137 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3139 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 * buffer: Text buffer to be exported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158 DW_MUTEX_LOCK;
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3159 /* force the return value to nul in case the following tests fail */
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3160 if(buffer)
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3161 strcpy(buffer,"");
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3162 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3163 if(GTK_IS_SCROLLED_WINDOW(handle))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3164 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3166 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3168 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3170 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3171 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3172 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3173 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3174 GtkTextIter start, end;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3175
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3176 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3177 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3178 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3179 text = gtk_text_iter_get_text(&start, &end);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3180 if(text) /* Should this get freed? */
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3181 {
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3182 if(buffer)
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3183 strcpy(buffer, text);
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3184 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3185 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3186 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3187 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188 {
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3189 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), startpoint, startpoint + length - 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 {
427
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3192 if(buffer)
b0e2ba7c46c5 For message boxes that have icons, increase the size of the text area (and hence the
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 426
diff changeset
3193 strcpy(buffer, text);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3194 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3195 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3196 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3197 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3198 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3199 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3200 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3204 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3209 void dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3214 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3216 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3219 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3220 if(GTK_IS_SCROLLED_WINDOW(handle))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3221 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3222 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3223
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3224 if(tmp && GTK_IS_TEXT_VIEW(tmp))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3225 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3226 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3227
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3228 if(bytes)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3229 *bytes = gtk_text_buffer_get_char_count(buffer) + 1;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3230 if(lines)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3231 *lines = gtk_text_buffer_get_line_count(buffer) + 1;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3232 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3233 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3234 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3235 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3236 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3237 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3239 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3242 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3245 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3246
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3247 *lines = 0;
386
5326544ab2ec Change dw_mle_query() under GTK 1.2 so that it returns the correct number of lines.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 383
diff changeset
3248 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, gtk_text_get_length(GTK_TEXT(tmp)));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3249
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3250 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3251 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3252 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3263 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3264 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3278
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3279 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3280 #if GTK_MAJOR_VERSION > 1
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3281 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3282 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3284 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3286 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3288 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3289 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3290 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3291 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3292 GtkTextIter start, end;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3293
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3294 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3295 gtk_text_buffer_get_iter_at_offset(tbuffer, &start, startpoint);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3296 gtk_text_buffer_get_iter_at_offset(tbuffer, &end, startpoint + length);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3297 gtk_text_buffer_delete(tbuffer, &start, &end);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3298 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3299 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3305 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3306 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3309
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3310 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3311 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3312 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3320 #if GTK_MAJOR_VERSION > 1
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3321 if(GTK_IS_SCROLLED_WINDOW(handle))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3322 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3323 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3324
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3325 if(tmp && GTK_IS_TEXT_VIEW(tmp))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3326 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3327 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3328
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3329 length = -1;
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3330 gtk_text_buffer_set_text(buffer, "", length);
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3331 }
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
3332 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3333 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3336 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3340 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3344 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3345 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3347 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3355 void dw_mle_set_cursor_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3360 #if GTK_MAJOR_VERSION > 1
354
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3361 if(GTK_IS_SCROLLED_WINDOW(handle))
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3362 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3363 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3364
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3365 if(tmp && GTK_IS_TEXT_VIEW(tmp))
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3366 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3367 GtkTextBuffer *tbuffer;
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3368 GtkTextIter iter;
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3369 GtkTextMark *mark = (GtkTextMark *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mark");
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3370
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3371 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3372 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, 0);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3373 gtk_text_iter_set_line(&iter, line);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3374 if(!mark)
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3375 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3376 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3377 gtk_object_set_data(GTK_OBJECT(handle), "_dw_mark", (gpointer)mark);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3378 }
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3379 else
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3380 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3381 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3382 0, FALSE, 0, 0);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3383 }
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
3384 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3385 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3388 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3395 dw_mle_get_size(handle, NULL, &lines);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 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
3402
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3407 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3412 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3413 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3414 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3415 * 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
3416 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3417 void dw_mle_set_cursor_editable(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3418 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3419 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3420
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3421 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3422 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3423 if(GTK_IS_SCROLLED_WINDOW(handle))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3424 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3425 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3426
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3427 if(tmp && GTK_IS_TEXT_VIEW(tmp))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3428 gtk_text_view_set_editable(GTK_TEXT_VIEW(tmp), state);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3429 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3430 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3431 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3432 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3433 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3434
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3435 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3436 gtk_text_set_editable(GTK_TEXT(tmp), state);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3437 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3438 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3439 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3440 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3441
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3442 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3443 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3444 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3445 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3446 * 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
3447 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3448 void dw_mle_set_cursor_word_wrap(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3449 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3450 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3451
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3452 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3453 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3454 if(GTK_IS_SCROLLED_WINDOW(handle))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3455 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3456 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3457
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3458 if(tmp && GTK_IS_TEXT_VIEW(tmp))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3459 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(tmp), GTK_WRAP_WORD);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3460 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3461 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3462 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3463 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3464 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3465
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3466 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3467 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3468 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
3469 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
3470 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3471 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3472 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3473 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3474 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3475
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3476 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3477 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3478 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3479 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3480 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3482 void dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3484 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3487 #if GTK_MAJOR_VERSION > 1
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3488 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3489 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3491 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3492 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3493 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3494
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3495 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3496 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3497 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3498 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3499 GtkTextIter iter;
353
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3500 GtkTextMark *mark = (GtkTextMark *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mark");
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3501
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3502 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3503 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
353
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3504 if(!mark)
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3505 {
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3506 mark = gtk_text_buffer_create_mark(tbuffer, NULL, &iter, FALSE);
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3507 gtk_object_set_data(GTK_OBJECT(handle), "_dw_mark", (gpointer)mark);
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3508 }
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3509 else
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3510 gtk_text_buffer_move_mark(tbuffer, mark, &iter);
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3511 gtk_text_buffer_place_cursor(tbuffer, &iter);
353
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3512 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(tmp), mark,
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
3513 0, FALSE, 0, 0);
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3514 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3515 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3516 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3517 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3518 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3519 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3520
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3521 dw_mle_get_size(handle, &chars, NULL);
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3522
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3523 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3524 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3525 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
3526
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3527 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
3528
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
3529 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
3530 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3533 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3534 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 DW_MUTEX_LOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3551 #if GTK_MAJOR_VERSION > 1
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3552 if(GTK_IS_SCROLLED_WINDOW(handle))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3553 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 if(GTK_IS_BOX(handle))
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3555 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3557 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3559 #if GTK_MAJOR_VERSION > 1
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3560 if(tmp && GTK_IS_TEXT_VIEW(tmp))
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3561 {
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3562 GtkTextBuffer *tbuffer;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3563 GtkTextIter iter, found;
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3564
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3565 tbuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (tmp));
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3566 gtk_text_buffer_get_iter_at_offset(tbuffer, &iter, point);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3567 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3568 retval = gtk_text_iter_get_offset(&found);
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3569 }
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3570 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3571 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3572 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3579 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3580
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3581 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3582
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3608 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3609 #endif
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3610 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3613 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3614
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3615 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3618 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 {
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3622 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3623 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3624
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3628 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3635 DW_MUTEX_UNLOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3636 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 {
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3646 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
3652 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3656 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3657 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3658 }
130
54014258099a Added most of the missing code for the MLE's for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 122
diff changeset
3659 DW_MUTEX_UNLOCK;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
3660 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3664 * Returns the range of the percent bar.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 * 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
3666 * handle: Handle to the percent bar to be queried.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3668 unsigned int dw_percent_get_range(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3669 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 return 100;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3674 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 * 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
3676 * 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
3677 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3679 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3689 * 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
3690 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3691 * 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
3692 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3693 unsigned int dw_slider_get_pos(HWND handle)
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3694 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3695 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
3696 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
3697
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3698 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
3699 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
3700
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3701 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3702 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment");
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3703 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
3704 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3705 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
3706 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
3707
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3708 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
3709 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
3710 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3711 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
3712 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3713 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
3714 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
3715 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3716
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3717 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3718 * 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
3719 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3720 * 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
3721 * 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
3722 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3723 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
3724 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3725 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
3726 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
3727
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3728 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
3729 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3730
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3731 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3732 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment");
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3733 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
3734 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3735 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
3736
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3737 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
3738 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
3739 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3740 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
3741 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3742 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
3743 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3744
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3745 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3746 * Returns the position of the scrollbar.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3747 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3748 * handle: Handle to the scrollbar to be queried.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3749 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3750 unsigned int dw_scrollbar_get_pos(HWND handle)
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3751 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3752 int val = 0, _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3753 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3754
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3755 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3756 return 0;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3757
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3758 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3759 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment");
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3760 if(adjustment)
415
9ffdbfd83652 Don't distinguish between vertical and horizontal scrollbars in
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 410
diff changeset
3761 val = _round_value(adjustment->value);
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3762 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3763 return val;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3764 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3765
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3766 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3767 * Sets the scrollbar position.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3768 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3769 * handle: Handle to the scrollbar to be set.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3770 * position: Position of the scrollbar withing the range.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3771 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3772 void dw_scrollbar_set_pos(HWND handle, unsigned int position)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3773 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3774 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3775 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3776
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3777 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3778 return;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3779
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3780 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3781 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment");
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3782 if(adjustment)
215
03e68274623d Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 214
diff changeset
3783 gtk_adjustment_set_value(adjustment, (gfloat)position);
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3784 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3785 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3786
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3787 /*
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3788 * Sets the scrollbar range.
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3789 * Parameters:
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3790 * handle: Handle to the scrollbar to be set.
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3791 * range: Maximum range value.
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3792 * visible: Visible area relative to the range.
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3793 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3794 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3795 {
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3796 int _locked_by_me = FALSE;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3797 GtkAdjustment *adjustment;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3798
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3799 if(!handle)
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3800 return;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3801
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3802 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3803 adjustment = (GtkAdjustment *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_adjustment");
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3804 if(adjustment)
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3805 {
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3806 adjustment->upper = (gdouble)range;
216
bd06f8d123f0 Oops typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 215
diff changeset
3807 adjustment->page_increment = adjustment->page_size = (gdouble)visible;
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
3808 }
198
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3809 DW_MUTEX_UNLOCK;
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3810 }
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3811
11b5da6196c2 Implemented dw_scrollbar_set_range() on Unix and fixed a bug in the test
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 196
diff changeset
3812 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3813 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3840 curval = dw_spinbutton_get_pos(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 adj = (GtkAdjustment *)gtk_adjustment_new((gfloat)curval, (gfloat)lower, (gfloat)upper, 1.0, 5.0, 0.0);
447
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
3843 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(handle), adj);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 {
270
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3855 int _locked_by_me = FALSE;
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3856
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3857 DW_MUTEX_LOCK;
271
38d8908c4438 Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 270
diff changeset
3858 gtk_entry_set_max_length(GTK_ENTRY(handle), limit);
270
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
3859 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3867 long dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3876 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3877 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3878
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3879 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3880 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3882 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3883 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3884 int dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3885 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3886 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3887 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3888
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3889 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3890 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3891 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3893 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3894 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3895
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3896 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3897 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3898 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3899 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3900 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3901 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3902 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3903 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3904 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3905
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3906 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3907 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3908 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3910
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3911 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3912 * 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
3913 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3914 * 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
3915 * 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
3916 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3917 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3918 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3919 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3920 */
329
9b1953ed0bff Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
3921 HTREEITEM dw_tree_insert_after(HWND handle, HTREEITEM item, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3922 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3923 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3924 GtkWidget *tree;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3925 GtkTreeIter *iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3926 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3927 GdkPixbuf *pixbuf;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
3928 HTREEITEM retval = 0;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3929 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3930
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3931 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3932 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3933
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3934 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3935 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3936 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3937 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3938 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3939 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3940
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3941 pixbuf = _find_pixbuf(icon);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3942
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
3943 gtk_tree_store_insert_after(store, iter, (GtkTreeIter *)parent, (GtkTreeIter *)item);
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
3944 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
460
65bc397a7233 Don't unreference private pixbufs on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 450
diff changeset
3945 if(pixbuf && !(icon & (1 << 31)))
256
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
3946 g_object_unref(pixbuf);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
3947 retval = (HTREEITEM)iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3948 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3949 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3950
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3951 return retval;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3952 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3953 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3954 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3955 GdkBitmap *gdkbmp = NULL;
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
3956 int position = -1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3957 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3958
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3959 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3960 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3961
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3962 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3963 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
3964 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3965 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3966 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3967 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3968 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3969
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3970 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3971 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
3972
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3973 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3974
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3975 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3976 label = gtk_label_new(title);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3977 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_text", (gpointer)strdup(title));
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3978 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_itemdata", (gpointer)itemdata);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3979 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_tree", (gpointer)tree);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
3980 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_parent", (gpointer)parent);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3981 hbox = gtk_hbox_new(FALSE, 2);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3982 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_hbox", (gpointer)hbox);
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
3983 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3984 gtk_container_add(GTK_CONTAINER(newitem), hbox);
255
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3985 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3986 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3987 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3988 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3989 gtk_widget_show(pixmap);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
3990 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3991 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
3992 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3993 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3994
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
3995 {
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3996 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func");
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
3997 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data");
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
3998 SignalHandler work = _get_signal_handler(tree, mydata);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
3999
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4000 if(thisfunc && work.window)
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4001 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4002 int sigid = _set_signal_handler(newitem, work.window, work.func, work.data, thisfunc);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4003 gint cid =gtk_signal_connect(GTK_OBJECT(newitem), "expand", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4004 _set_signal_handler_id(newitem, sigid, cid);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4005 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4006 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4007
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4008 _dw_ignore_expand = 1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4009 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4010 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4011 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent));
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4012 if(!subtree || !GTK_IS_TREE(subtree))
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4013 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4014 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4015 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4016 SignalHandler work = _get_signal_handler(tree, mydata);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4017
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4018 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4019
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4020 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4021 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4022 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4023 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4024 _set_signal_handler_id(subtree, sigid, cid);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4025 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4026
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4027 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4028 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4029 work = _get_signal_handler(tree, mydata);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4030
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4031 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4032 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4033 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4034 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4035 _set_signal_handler_id(subtree, sigid, cid);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4036 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4037
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4038 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
4039 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
4040 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
4041 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4042 gtk_object_set_data(GTK_OBJECT(subtree), "_dw_parentitem", (gpointer)parent);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4043 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
4044 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4045 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
4046 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
4047 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4048 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_parenttree", (gpointer)subtree);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4049 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
4050 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4051 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4052 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4053 gtk_object_set_data(GTK_OBJECT(newitem), "_dw_parenttree", (gpointer)tree);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4054 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
4055 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4056 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
4057 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
4058 gtk_widget_show(newitem);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4059 _dw_ignore_expand = 0;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4060 DW_MUTEX_UNLOCK;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4061 return (HTREEITEM)newitem;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4062 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4063 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4064
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4065 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4066 * 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
4067 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4068 * 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
4069 * 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
4070 * 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
4071 * 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
4072 * 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
4073 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4074 HTREEITEM dw_tree_insert(HWND handle, char *title, unsigned long icon, HTREEITEM parent, void *itemdata)
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4075 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4076 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4077 GtkWidget *tree;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4078 GtkTreeIter *iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4079 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4080 GdkPixbuf *pixbuf;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4081 HTREEITEM retval = 0;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4082 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4083
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4084 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4085 return NULL;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4086
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4087 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4088 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4089 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4090 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4091 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4092 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4093
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4094 pixbuf = _find_pixbuf(icon);
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4095
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4096 gtk_tree_store_append (store, iter, (GtkTreeIter *)parent);
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4097 gtk_tree_store_set (store, iter, 0, title, 1, pixbuf, 2, itemdata, 3, iter, -1);
460
65bc397a7233 Don't unreference private pixbufs on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 450
diff changeset
4098 if(pixbuf && !(icon & (1 << 31)))
256
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
4099 g_object_unref(pixbuf);
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4100 retval = (HTREEITEM)iter;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4101 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4102 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4103
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4104 return retval;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4105 #else
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4106 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
4107 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4108 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
4109 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
4110
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4111 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4112 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4113
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4114 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
4115 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
4116 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
4117 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4118 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
4119 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
4120 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4121 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
4122 label = gtk_label_new(title);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4123 gtk_object_set_data(GTK_OBJECT(item), "_dw_text", (gpointer)strdup(title));
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4124 gtk_object_set_data(GTK_OBJECT(item), "_dw_itemdata", (gpointer)itemdata);
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4125 gtk_object_set_data(GTK_OBJECT(item), "_dw_tree", (gpointer)tree);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4126 gtk_object_set_data(GTK_OBJECT(item), "_dw_parent", (gpointer)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
4127 hbox = gtk_hbox_new(FALSE, 2);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4128 gtk_object_set_data(GTK_OBJECT(item), "_dw_hbox", (gpointer)hbox);
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
4129 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4130 gtk_container_add(GTK_CONTAINER(item), hbox);
255
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4131 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4132 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4133 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4134 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4135 gtk_widget_show(pixmap);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4136 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4137 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
4138 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
4139 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
4140
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4141 {
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4142 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_func");
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4143 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_item_expand_data");
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4144 SignalHandler work = _get_signal_handler(tree, mydata);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4145
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4146 if(thisfunc && work.window)
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4147 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4148 int sigid = _set_signal_handler(item, work.window, work.func, work.data, thisfunc);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4149 gint cid =gtk_signal_connect(GTK_OBJECT(item), "expand", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4150 _set_signal_handler_id(item, sigid, cid);
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4151 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4152 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4153
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4154 _dw_ignore_expand = 1;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4155 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
4156 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4157 subtree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(parent));
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4158 if(!subtree || !GTK_IS_TREE(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
4159 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4160 void *thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_func");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4161 void *mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_select_child_data");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4162 SignalHandler work = _get_signal_handler(tree, mydata);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4163
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4164 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4165
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4166 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4167 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4168 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4169 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "select-child", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4170 _set_signal_handler_id(subtree, sigid, cid);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4171 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4172
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4173 thisfunc = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_func");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4174 mydata = (void *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_container_context_data");
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4175 work = _get_signal_handler(tree, mydata);
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4176
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4177 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4178 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4179 int sigid = _set_signal_handler(subtree, work.window, work.func, work.data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4180 gint cid =gtk_signal_connect(GTK_OBJECT(subtree), "button_press_event", GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
4181 _set_signal_handler_id(subtree, sigid, cid);
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
4182 }
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
4183
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4184 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
4185 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
4186 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
4187 gtk_tree_item_set_subtree(GTK_TREE_ITEM(parent), subtree);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4188 gtk_object_set_data(GTK_OBJECT(subtree), "_dw_parentitem", (gpointer)parent);
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
4189 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
4190 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
4191 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
4192 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
4193 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4194 gtk_object_set_data(GTK_OBJECT(item), "_dw_parenttree", (gpointer)subtree);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4195 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
4196 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4197 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4198 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4199 gtk_object_set_data(GTK_OBJECT(item), "_dw_parenttree", (gpointer)tree);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4200 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
4201 }
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
4202 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
4203 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
4204 gtk_widget_show(item);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4205 _dw_ignore_expand = 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
4206 DW_MUTEX_UNLOCK;
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4207 return (HTREEITEM)item;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4208 #endif
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4209 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
4210
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4211 /*
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
4212 * 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
4213 * 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
4214 * 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
4215 * 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
4216 * 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
4217 * 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
4218 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4219 void dw_tree_item_change(HWND handle, HTREEITEM item, char *title, unsigned long icon)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4220 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4221 #if GTK_MAJOR_VERSION > 1
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4222 GtkWidget *tree;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4223 GtkTreeStore *store;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4224 GdkPixbuf *pixbuf;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4225 int _locked_by_me = FALSE;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4226
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4227 if(!handle)
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4228 return;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4229
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4230 DW_MUTEX_LOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4231 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4232 && GTK_IS_TREE_VIEW(tree) &&
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4233 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4234 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4235 pixbuf = _find_pixbuf(icon);
460
65bc397a7233 Don't unreference private pixbufs on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 450
diff changeset
4236
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4237 gtk_tree_store_set(store, (GtkTreeIter *)item, 0, title, 1, pixbuf, -1);
460
65bc397a7233 Don't unreference private pixbufs on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 450
diff changeset
4238 if(pixbuf && !(icon & (1 << 31)))
256
63d68387d924 Don't unref a non-existant pixmap. (GTK 2.x)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 255
diff changeset
4239 g_object_unref(pixbuf);
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4240 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4241 DW_MUTEX_UNLOCK;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4242 #else
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4243 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
4244 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4245 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
4246 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
4247 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
4248
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4249 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4250 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4251
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
4252 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4253 oldtext = (char *)gtk_object_get_data(GTK_OBJECT(item), "_dw_text");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4254 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
4255 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
4256 label = gtk_label_new(title);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4257 gtk_object_set_data(GTK_OBJECT(item), "_dw_text", (gpointer)strdup(title));
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4258 hbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_hbox");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4259 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
4260 hbox = gtk_hbox_new(FALSE, 2);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4261 gtk_object_set_data(GTK_OBJECT(item), "_dw_hbox", (gpointer)hbox);
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
4262 gdkpix = _find_pixmap(&gdkbmp, icon, hbox, NULL, NULL);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4263 gtk_container_add(GTK_CONTAINER(item), hbox);
255
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4264 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4265 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4266 pixmap = gtk_pixmap_new(gdkpix, gdkbmp);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4267 gtk_box_pack_start(GTK_BOX(hbox), pixmap, FALSE, TRUE, 0);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4268 gtk_widget_show(pixmap);
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
4269 }
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
4270 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
4271 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
4272 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
4273 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4274 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4275 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4276
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4277 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4278 * 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
4279 * 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
4280 * 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
4281 * 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
4282 * 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
4283 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4284 void dw_tree_item_change_data(HWND handle, HTREEITEM item, void *itemdata)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4285 {
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4286 #if GTK_MAJOR_VERSION > 1
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4287 GtkWidget *tree;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4288 GtkTreeStore *store;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4289 int _locked_by_me = FALSE;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4290
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4291 if(!handle || !item)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4292 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4293
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4294 DW_MUTEX_LOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4295 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4296 && GTK_IS_TREE_VIEW(tree) &&
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4297 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4298 gtk_tree_store_set(store, (GtkTreeIter *)item, 2, itemdata, -1);
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4299 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4300 #else
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4301 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
4302
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4303 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4304 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4305
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
4306 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4307 gtk_object_set_data(GTK_OBJECT(item), "_dw_itemdata", (gpointer)itemdata);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4308 DW_MUTEX_UNLOCK;
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4309 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4310 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4311
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4312 /*
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4313 * Gets the text an item in a tree window (widget).
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4314 * Parameters:
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4315 * handle: Handle to the tree containing the item.
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4316 * item: Handle of the item to be modified.
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4317 */
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4318 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4319 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4320 int _locked_by_me = FALSE;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4321 char *text = NULL;
501
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4322 #if GTK_MAJOR_VERSION > 1
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4323 GtkWidget *tree;
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4324 GtkTreeModel *store;
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4325 #endif
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4326
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4327 if(!handle || !item)
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
4328 return text;
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4329
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4330 DW_MUTEX_LOCK;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4331 #if GTK_MAJOR_VERSION > 1
501
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4332 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4333
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4334 if(tree && GTK_IS_TREE_VIEW(tree) &&
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4335 (store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4336 gtk_tree_model_get(store, (GtkTreeIter *)item, 0, &text, -1);
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4337 #else
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4338 text = (char *)gtk_object_get_data(GTK_OBJECT(item), "_dw_text");
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4339 #endif
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4340 DW_MUTEX_UNLOCK;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4341 return text;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4342 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4343
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4344 /*
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4345 * Gets the text an item in a tree window (widget).
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4346 * Parameters:
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4347 * handle: Handle to the tree containing the item.
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4348 * item: Handle of the item to be modified.
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4349 */
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4350 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4351 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4352 int _locked_by_me = FALSE;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4353 HTREEITEM parent = (HTREEITEM)0;
501
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4354 #if GTK_MAJOR_VERSION > 1
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4355 GtkWidget *tree;
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4356 GtkTreeModel *store;
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4357 #endif
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4358
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4359 if(!handle || !item)
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
4360 return parent;
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4361
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4362 DW_MUTEX_LOCK;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4363 #if GTK_MAJOR_VERSION > 1
501
8267a3066476 Move variable definitions to after first line of code so C compilers work.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 494
diff changeset
4364 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4365
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4366 if(tree && GTK_IS_TREE_VIEW(tree) &&
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4367 (store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4368 {
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4369 GtkTreeIter *p = malloc(sizeof(GtkTreeIter));
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4370
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4371 if(gtk_tree_model_iter_parent(store, p, (GtkTreeIter *)item))
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4372 parent = p;
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4373 else
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
4374 free(p);
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
4375 }
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4376 #else
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4377 parent = (HTREEITEM)gtk_object_get_data(GTK_OBJECT(item), "_dw_parent");
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4378 #endif
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4379 DW_MUTEX_UNLOCK;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4380 return parent;
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4381 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4382
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
4383 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4384 * Gets the item data of a tree item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4385 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4386 * handle: Handle to the tree containing the item.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4387 * item: Handle of the item to be modified.
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4388 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4389 void *dw_tree_item_get_data(HWND handle, HTREEITEM item)
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4390 {
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4391 void *ret = NULL;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4392 #if GTK_MAJOR_VERSION > 1
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4393 GtkWidget *tree;
322
78be9770960c Oops, used wrong type in GTK 2.x dw_tree_get_data(), thanks Mark.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 320
diff changeset
4394 GtkTreeModel *store;
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4395 int _locked_by_me = FALSE;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4396
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4397 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
4398 return NULL;
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4399
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4400 DW_MUTEX_LOCK;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4401 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4402 && GTK_IS_TREE_VIEW(tree) &&
322
78be9770960c Oops, used wrong type in GTK 2.x dw_tree_get_data(), thanks Mark.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 320
diff changeset
4403 (store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4404 gtk_tree_model_get(store, (GtkTreeIter *)item, 2, &ret, -1);
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4405 DW_MUTEX_UNLOCK;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4406 #else
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4407 int _locked_by_me = FALSE;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4408
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4409 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
4410 return NULL;
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4411
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4412 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4413 ret = (void *)gtk_object_get_data(GTK_OBJECT(item), "_dw_itemdata");
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4414 DW_MUTEX_UNLOCK;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4415 #endif
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4416 return ret;
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4417 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4418
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
4419 /*
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
4420 * 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
4421 * 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
4422 * 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
4423 * 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
4424 */
328
e00aff2b899e Tree item handles are now of the type HTREEITEM instead of HWND since they
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 322
diff changeset
4425 void dw_tree_item_select(HWND handle, HTREEITEM item)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4426 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4427 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4428 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4429 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4430 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4431
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4432 if(!handle || !item)
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4433 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4434
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4435 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4436 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4437 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4438 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4439 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4440 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4441 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4442
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4443 gtk_tree_view_set_cursor(GTK_TREE_VIEW(tree), path, NULL, FALSE);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4444 gtk_tree_selection_select_iter(sel, (GtkTreeIter *)item);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4445 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4446 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4447 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4448 #else
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
4449 GtkWidget *lastselect, *tree;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4450 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
4451
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4452 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4453 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4454
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
4455 DW_MUTEX_LOCK;
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
4456 tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4457 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect");
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4458 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
4459 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
4460 gtk_tree_item_select(GTK_TREE_ITEM(item));
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4461 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", (gpointer)item);
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4462 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4463 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4464 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4465
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
4466 #if GTK_MAJOR_VERSION > 1
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4467 static void _dw_recursive_free(GtkTreeModel *store, GtkTreeIter parent)
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4468 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4469 void *data;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4470 GtkTreeIter iter;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4471
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4472 gtk_tree_model_get(store, &parent, 3, &data, -1);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4473 if(data)
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4474 free(data);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4475 gtk_tree_store_set(GTK_TREE_STORE(store), &parent, 3, NULL, -1);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4476
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4477 if(gtk_tree_model_iter_children(store, &iter, &parent))
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4478 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4479 do {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4480 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4481 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4482 }
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4483 }
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
4484 #endif
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4485
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
4486 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4487 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4488 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4489 * 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
4490 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4491 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4492 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4493 #if GTK_MAJOR_VERSION > 1
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4494 GtkWidget *tree;
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4495 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4496 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4497
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4498 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4499 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4500
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4501 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4502 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4503 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4504 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4505 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4506 GtkTreeIter iter;
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4507
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4508 if(gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter))
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4509 {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4510 do {
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4511 _dw_recursive_free(GTK_TREE_MODEL(store), iter);
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4512 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter));
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4513 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4514 gtk_tree_store_clear(store);
141
36dc19aa7773 Added tree cleanup code for GTK 2.0, and disabled some of the accellerator
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 140
diff changeset
4515 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4516 DW_MUTEX_UNLOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4517 #else
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4518 GtkWidget *tree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4519 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4520
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4521 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4522 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4523
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4524 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4525 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
4526 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4527 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4528 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4529 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4530 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4531 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", NULL);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4532 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
4533 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4534 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4535 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4536
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4537 /*
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
4538 * 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
4539 * 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
4540 * 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
4541 * 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
4542 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4543 void dw_tree_item_expand(HWND handle, HTREEITEM item)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4544 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4545 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4546 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4547 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4548 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4549
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4550 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4551 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4552
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4553 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4554 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4555 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4556 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4557 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4558 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4559 gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path, FALSE);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4560 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4561 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4562 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4563 #else
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4564 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
4565
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4566 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4567 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4568
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
4569 DW_MUTEX_LOCK;
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4570 _dw_ignore_expand = 1;
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
4571 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
4572 gtk_tree_item_expand(GTK_TREE_ITEM(item));
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
4573 _dw_ignore_expand = 0;
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4574 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4575 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4576 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4577
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4578 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4579 * 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
4580 * 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
4581 * 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
4582 * 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
4583 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4584 void dw_tree_item_collapse(HWND handle, HTREEITEM item)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4585 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4586 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4587 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4588 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4589 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4590
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4591 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4592 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4593
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4594 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4595 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4596 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4597 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4598 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4599 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), (GtkTreeIter *)item);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4600 gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4601 gtk_tree_path_free(path);
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4602 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4603 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4604 #else
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4605 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
4606
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4607 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4608 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4609
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
4610 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
4611 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
4612 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
4613 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4614 #endif
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4615 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4616
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
4617 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4618 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4619 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4620 * 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
4621 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4622 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4623 void dw_tree_item_delete(HWND handle, HTREEITEM item)
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4624 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4625 #if GTK_MAJOR_VERSION > 1
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4626 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4627 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4628 int _locked_by_me = FALSE;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4629
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4630 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4631 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4632
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4633 DW_MUTEX_LOCK;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4634 if((tree = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle)))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4635 && GTK_IS_TREE_VIEW(tree) &&
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4636 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4637 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4638 gtk_tree_store_remove(store, (GtkTreeIter *)item);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
4639 free(item);
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4640 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
4641 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4642 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4643 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4644 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4645
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4646 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
4647 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4648
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4649 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4650 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
4651 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4652 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4653 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4654 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4655 }
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
4656
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4657 lastselect = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_lastselect");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4658
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4659 parenttree = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_parenttree");
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4660
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
4661 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4662 {
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
4663 gtk_tree_item_deselect(GTK_TREE_ITEM(lastselect));
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4664 gtk_object_set_data(GTK_OBJECT(tree), "_dw_lastselect", NULL);
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
4665 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4666
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4667 if(parenttree && GTK_IS_WIDGET(parenttree))
107
cd0e5cf92f6a Rewrote the Windows packing code so it is more like OS/2 to improve window
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 96
diff changeset
4668 gtk_container_remove(GTK_CONTAINER(parenttree), item);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4669 DW_MUTEX_UNLOCK;
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
4670 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4671 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
4672
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4673 static int _dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator, int extra)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4674 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4675 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4676 char numbuf[10];
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4677 int z, multi;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4678 int _locked_by_me = FALSE;
355
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4679 GtkJustification justification;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4680
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4681 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4682 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4683 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4684 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4688 multi = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_multi");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4689 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 gtk_clist_set_column_auto_resize(GTK_CLIST(clist), 0, TRUE);
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4692 if(multi)
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4693 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_EXTENDED);
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4694 else
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
4695 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 gtk_container_add(GTK_CONTAINER(handle), clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4698 gtk_widget_show(clist);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4699 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4700
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4701 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4702 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4703
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4704 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4705 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4706 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4707 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4708 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4709 gtk_object_set_data(GTK_OBJECT(clist), numbuf, (gpointer)flags[z]);
355
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4710 if(flags[z]&DW_CFA_RIGHT)
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4711 justification = GTK_JUSTIFY_RIGHT;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4712 else if(flags[z]&DW_CFA_CENTER)
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4713 justification = GTK_JUSTIFY_CENTER;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4714 else
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4715 justification = GTK_JUSTIFY_LEFT;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
4716 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4724 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4730 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4735 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4736 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4748 char **newtitles = malloc(sizeof(char *) * (count + 1));
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4749 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 1));
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4750
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4751 newtitles[0] = "Filename";
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4752
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4753 newflags[0] = DW_CFA_STRINGANDICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4754
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4755 memcpy(&newtitles[1], titles, sizeof(char *) * count);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4756 memcpy(&newflags[1], flags, sizeof(unsigned long) * count);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4757
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4758 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4759
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4760 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4761 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4762 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4773 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4774 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4775 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4776 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4777
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4778 /*
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4779 * Obtains an icon from a file.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4780 * Parameters:
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4781 * filename: Name of the file, omit extention to have
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4782 * DW pick the appropriate file extension.
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4783 * (ICO on OS/2 or Windows, XPM on Unix)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4784 */
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4785 unsigned long API dw_icon_load_from_file(char *filename)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4786 {
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4787 int found = -1, _locked_by_me = FALSE;
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4788 #if GTK_MAJOR_VERSION > 1
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4789 GdkPixbuf *pixbuf;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4790 #elif defined(USE_IMLIB)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4791 GdkImlibImage *image;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4792 #endif
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4793 char *file = alloca(strlen(filename) + 5);
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4794 unsigned long z, ret = 0;
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4795
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4796 if (!file)
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4797 return 0;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4798
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4799 strcpy(file, filename);
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4800
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4801 /* check if we can read from this file (it exists and read permission) */
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4802 if(access(file, 04) != 0)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4803 {
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4804 /* Try with .xpm extention */
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4805 strcat(file, ".xpm");
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4806 if(access(file, 04) != 0)
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4807 return 0;
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4808 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4809
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4810 DW_MUTEX_LOCK;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4811 /* Find a free entry in the array */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4812 for(z=0;z<_PixmapCount;z++)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4813 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4814 if(!_PixmapArray[z].used)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4815 {
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4816 ret = found = z;
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4817 break;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4818 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4819 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4820
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4821 /* If there are no free entries, expand the
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4822 * array.
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4823 */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4824 if(found == -1)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4825 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4826 DWPrivatePixmap *old = _PixmapArray;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4827
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4828 ret = found = _PixmapCount;
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4829 _PixmapCount++;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4830
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4831 _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4832
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4833 if(found)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4834 memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4835 if(old)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4836 free(old);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4837 _PixmapArray[found].used = 1;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4838 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4839 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4840
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4841 #if GTK_MAJOR_VERSION > 1
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4842 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4843
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4844 if(pixbuf)
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4845 {
316
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4846 _PixmapArray[found].pixbuf = pixbuf;
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4847 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4848 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4849
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4850 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4851 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4852 #elif defined(USE_IMLIB)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4853 image = gdk_imlib_load_image(file);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4854
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4855 if(image)
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4856 {
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4857 _PixmapArray[found].width = image->rgb_width;
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4858 _PixmapArray[found].height = image->rgb_height;
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4859
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4860 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4861 _PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4862 _PixmapArray[found].mask = gdk_imlib_copy_mask(image);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4863 gdk_imlib_destroy_image(image);
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4864 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4865 #else
296
d2392cf845e4 Fix crash if dw_icon_load_from_file() called before creating a toplevel
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 285
diff changeset
4866 if (last_window)
d2392cf845e4 Fix crash if dw_icon_load_from_file() called before creating a toplevel
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 285
diff changeset
4867 _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], file);
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4868 #endif
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4869 DW_MUTEX_UNLOCK;
265
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4870 if(!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4871 {
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4872 _PixmapArray[found].used = 0;
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4873 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4874 return 0;
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4875 }
84471d53ab58 Changes to dw_main_* so that the _dw_thread is set to -1 when the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 264
diff changeset
4876 return ret | (1 << 31);
257
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4877 }
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4878
9ea4ac9a097f Added dw_icon_load_from_file() on OS/2 and Windows. Added a stub on Unix
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 256
diff changeset
4879 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 {
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4886 /* If it is a private icon, find the item
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4887 * free the associated structures and set
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4888 * the entry to unused.
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4889 */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4890 if(handle & (1 << 31))
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4891 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4892 unsigned long id = handle & 0xFFFFFF;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4893
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4894 if(id < _PixmapCount && _PixmapArray[id].used)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4895 {
316
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4896 #if GTK_MAJOR_VERSION > 1
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4897 if(_PixmapArray[id].pixbuf)
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4898 {
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4899 g_object_unref(_PixmapArray[id].pixbuf);
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4900 _PixmapArray[id].pixbuf = NULL;
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4901 }
a07e08f708d6 Fixed icons in the tree control in GTK 2.x when loaded from a file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 312
diff changeset
4902 #endif
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4903 if(_PixmapArray[id].mask)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4904 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4905 gdk_bitmap_unref(_PixmapArray[id].mask);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4906 _PixmapArray[id].mask = NULL;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4907 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4908 if(_PixmapArray[id].pixmap)
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4909 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4910 gdk_pixmap_unref(_PixmapArray[id].pixmap);
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4911 _PixmapArray[id].pixmap = NULL;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4912 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4913 _PixmapArray[id].used = 0;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4914 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
4915 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4917
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4918 /* 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
4919 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
4920 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4921 gtk_clist_unselect_all(GTK_CLIST(clist));
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4922 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
4923
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4927 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 int z, count = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4934 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4939 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4946 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4954 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4955 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4956
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4957 fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_foregdk");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4958 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4959 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4960 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4961 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4962 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
4963 if(fore)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4964 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
4965 if(back)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4966 gtk_clist_set_background(GTK_CLIST(clist), z, back);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4967 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4968 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4969 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4970 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4971 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974 /*
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4975 * Internal representation of dw_container_set_item() extracted so we can pass
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4976 * two data pointers; icon and text for dw_filesystem_set_item().
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4977 */
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
4978 void _dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data, char *text)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
4999 GdkBitmap *bitmap = NULL;
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
5000 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL);
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
5001
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 }
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5005 else if(flag & DW_CFA_STRINGANDICON)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5006 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5007 long hicon = *((long *)data);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5008 GdkBitmap *bitmap = NULL;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5009 GdkPixmap *pixmap = _find_pixmap(&bitmap, hicon, clist, NULL, NULL);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5010
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5011 if(pixmap)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5012 gtk_clist_set_pixtext(GTK_CLIST(clist), row, column, text, 2, pixmap, bitmap);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5013 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5029 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5030 CDATE cdate = *((CDATE *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5031
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5032 curtm.tm_mday = cdate.day;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5033 curtm.tm_mon = cdate.month - 1;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5034 curtm.tm_year = cdate.year - 1900;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5035
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5036 strftime(textbuffer, 100, "%x", &curtm);
46
30d091bc7899 Fixed an error in the container date code on Windows and Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 41
diff changeset
5037
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5042 struct tm curtm;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5043 CTIME ctime = *((CTIME *)data);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5044
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5045 curtm.tm_hour = ctime.hours;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5046 curtm.tm_min = ctime.minutes;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5047 curtm.tm_sec = ctime.seconds;
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5048
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5049 strftime(textbuffer, 100, "%X", &curtm);
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
5050
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 /*
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5057 * Sets an item in specified row and column to the given data.
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5058 * Parameters:
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5059 * handle: Handle to the container window (widget).
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5060 * pointer: Pointer to the allocated memory in dw_container_alloc().
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5061 * column: Zero based column of data being set.
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5062 * row: Zero based row of data being set.
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5063 * data: Pointer to the data to be added.
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5064 */
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5065 void dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5066 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5067 _dw_container_set_item(handle, NULL, column, row, data, NULL);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5068 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5069
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5070 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5071 * Changes an existing item in specified row and column to the given data.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5072 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5073 * handle: Handle to the container window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5074 * column: Zero based column of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5075 * row: Zero based row of data being set.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5076 * data: Pointer to the data to be added.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5077 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5078 void dw_container_change_item(HWND handle, int column, int row, void *data)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5079 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5080 _dw_container_set_item(handle, NULL, column, row, data, NULL);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5081 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5082
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5083 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5084 * Changes an existing item in specified row and column to the given data.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5085 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5086 * handle: Handle to the container window (widget).
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5087 * column: Zero based column of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5088 * row: Zero based row of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5089 * data: Pointer to the data to be added.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5090 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5091 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5092 {
504
7061da3532d7 Fix minor error in new dw_filesystem_change_*() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 503
diff changeset
5093 dw_filesystem_set_item(handle, NULL, column, row, data);
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5094 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5095
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5096 /*
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5097 * Changes an item in specified row and column to the given data.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5098 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5099 * handle: Handle to the container window (widget).
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5100 * pointer: Pointer to the allocated memory in dw_container_alloc().
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5101 * column: Zero based column of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5102 * row: Zero based row of data being set.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5103 * data: Pointer to the data to be added.
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5104 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5105 void API dw_filesystem_change_file(HWND handle, int row, char *filename, unsigned long icon)
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5106 {
504
7061da3532d7 Fix minor error in new dw_filesystem_change_*() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 503
diff changeset
5107 dw_filesystem_set_file(handle, NULL, row, filename, icon);
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5108 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5109
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
5110 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 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
5120 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5121 _dw_container_set_item(handle, pointer, 0, row, (void *)&icon, filename);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5135 _dw_container_set_item(handle, pointer, column + 1, row, data, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5139 * Gets column type for a container column
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5140 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5141 * handle: Handle to the container window (widget).
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5142 * column: Zero based column.
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5143 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5144 int dw_container_get_column_type(HWND handle, int column)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5145 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5146 char numbuf[10];
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5147 int flag, rc;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5148 GtkWidget *clist;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5149 int _locked_by_me = FALSE;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5150
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5151 DW_MUTEX_LOCK;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5152 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5153 if(!clist)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5154 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5155 DW_MUTEX_UNLOCK;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5156 return 0;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5157 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5158
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5159 sprintf(numbuf, "%d", column);
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5160 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5161
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5162 if(flag & DW_CFA_BITMAPORICON)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5163 rc = DW_CFA_BITMAPORICON;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5164 else if(flag & DW_CFA_STRING)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5165 rc = DW_CFA_STRING;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5166 else if(flag & DW_CFA_ULONG)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5167 rc = DW_CFA_ULONG;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5168 else if(flag & DW_CFA_DATE)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5169 rc = DW_CFA_DATE;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5170 else if(flag & DW_CFA_TIME)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5171 rc = DW_CFA_TIME;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5172 else
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5173 rc = 0;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5174 DW_MUTEX_UNLOCK;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5175 return rc;
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5176 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5177
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5178 /*
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5179 * Gets column type for a filesystem container column
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5180 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5181 * handle: Handle to the container window (widget).
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5182 * column: Zero based column.
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5183 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5184 int API dw_filesystem_get_column_type(HWND handle, int column)
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5185 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5186 return dw_container_get_column_type( handle, column + 1 );
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5187 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5188
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
5189 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5190 * 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
5191 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5192 * 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
5193 * 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
5194 * 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
5195 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5196 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
5197 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5198 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
5199 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
5200
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5201 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
5202 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
5203
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5204 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
5205 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
5206 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
5207 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5208
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5209 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5210 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5211 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5212 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5220
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5230 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5241 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5246 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5249 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5250 * 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
5251 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5252 * 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
5253 * 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
5254 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5255 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
5256 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5257 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
5258 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
5259
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5260 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
5261 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
5262 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
5263 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5264 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
5265
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5266 rows = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount");
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5267
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5268 _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
5269
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5270 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
5271 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
5272
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5273 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
5274 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
5275 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5276 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
5277
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5278 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rows);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5279 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5280 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
5281 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5282
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5283 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5284 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5285 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5286 * 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
5287 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5288 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
5289 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5290 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5291 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5292 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5293
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5294 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5295 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5296 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5297 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5298 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5299 gtk_clist_clear(GTK_CLIST(clist));
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5300 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5306 * 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
5307 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5308 * 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
5309 * 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
5310 * 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
5311 * 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
5312 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5313 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
5314 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5315 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
5316 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
5317 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
5318
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5319 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
5320 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
5321 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
5322 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5323 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
5324 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
5325 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5326 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
5327 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5328 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
5329 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
5330 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5331 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
5332 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
5333 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5334 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5335 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
5336 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5337 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5338 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
5339 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5340
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5341 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5365 /* These should be separate but right now this will work */
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5366 if(flags & DW_CRA_SELECTED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 {
352
feed7567764f Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 350
diff changeset
5368 list = GTK_CLIST(clist)->selection;
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5369
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5370 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5371 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5372 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1);
352
feed7567764f Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 350
diff changeset
5373 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data));
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5374 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5375 }
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5376 else if(flags & DW_CRA_CURSORED)
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5377 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5378 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GTK_CLIST(clist)->focus_row);
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5379 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5380 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5381 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5382 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), 0);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5383 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5399 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5413 /* These should be separate but right now this will work */
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5414 if(flags & DW_CRA_SELECTED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 {
352
feed7567764f Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 350
diff changeset
5416 list = GTK_CLIST(clist)->selection;
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5417
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5418 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5420 int counter = 0, pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_querypos");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5421 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1);
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5422
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5423 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5424 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5425 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5426 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5427 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5428
352
feed7567764f Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 350
diff changeset
5429 if(list)
feed7567764f Rewrote the selection code. It is much more simple now and no longer
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 350
diff changeset
5430 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), GPOINTER_TO_UINT(list->data));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5432 }
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5433 else if(flags & DW_CRA_CURSORED)
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5434 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5435 /* There will only be one item cursored,
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5436 * retrieve it with dw_container_query_start()
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5437 */
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5438 retval = NULL;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
5439 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5440 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5441 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5442 int pos = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_querypos");
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5443
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5444 retval = (char *)gtk_clist_get_row_data(GTK_CLIST(clist), pos);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5445 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5447 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5448 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5452 * 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
5453 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5454 * 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
5455 * 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
5456 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5457 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
5458 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5459 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
5460 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5461 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5462 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5463
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5464 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5465 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
5466
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5467 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5468 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5469 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5470 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5471 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5472 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount");
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5473
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5474 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
5475 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5476 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
5477 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5478 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5479 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5480 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
5481
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5482 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
5483
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5484 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
5485
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5486 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
5487 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
5488 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5489 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5490 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5491 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5492
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5493 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5494 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5495
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5496 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5497 * Deletes the item with the text speficied.
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5498 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5499 * handle: Handle to the window (widget).
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5500 * text: Text usually returned by dw_container_query().
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5501 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5502 void dw_container_delete_row(HWND handle, char *text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5503 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5504 int _locked_by_me = FALSE;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5505 GtkWidget *clist;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5506 int rowcount, z;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5507 char *rowdata;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5508
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5509 DW_MUTEX_LOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5510 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5511
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5512 if(!clist)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5513 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5514 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5515 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5516 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5517 rowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount");
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5518
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5519 for(z=0;z<rowcount;z++)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5520 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5521 rowdata = gtk_clist_get_row_data(GTK_CLIST(clist), z);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5522 if(rowdata == text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5523 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5524 _dw_unselect(clist);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5525
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5526 gtk_clist_remove(GTK_CLIST(clist), z);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5527
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5528 rowcount--;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5529
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5530 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)rowcount);
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5531 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5532 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5533 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5534 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5535
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5536 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5537 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5538
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
5539 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5540 * 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
5541 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5542 * 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
5543 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5544 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
5545 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5546 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
5547 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5548 int colcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5549
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5550 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5551 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
5552
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5553 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5554 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5555 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5556 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5557 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5558 colcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount");
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5559 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
5560 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5561 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
5562 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
5563 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5564 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5565 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5566
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
5567 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5568 * Inserts an icon into the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5569 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5570 * handle: Window handle that will handle taskbar icon messages.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5571 * icon: Icon handle to display in the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5572 * bubbletext: Text to show when the mouse is above the icon.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5573 */
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5574 void dw_taskbar_insert(HWND handle, unsigned long icon, char *bubbletext)
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5575 {
491
fafd37119db4 Formatting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 487
diff changeset
5576 /* TODO */
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5577 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5578
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5579 /*
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5580 * Deletes an icon from the taskbar.
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5581 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5582 * handle: Window handle that was used with dw_taskbar_insert().
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5583 * icon: Icon handle that was used with dw_taskbar_insert().
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5584 */
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5585 void dw_taskbar_delete(HWND handle, unsigned long icon)
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5586 {
491
fafd37119db4 Formatting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 487
diff changeset
5587 /* TODO */
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5588 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5589
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
5590 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5596 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5597 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5598 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5599 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5600 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5602 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5603 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5604 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5605 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5606 | GDK_BUTTON_PRESS_MASK
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
5607 | GDK_KEY_PRESS_MASK
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5608 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5609 | GDK_POINTER_MOTION_HINT_MASK);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5610 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
5611 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5617 /* Returns a GdkColor from a DW color */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
5618 static GdkColor _internal_color(unsigned long value)
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5619 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5620 if(DW_RGB_COLOR & value)
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5621 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5622 GdkColor color = { 0, DW_RED_VALUE(value) << 8, DW_GREEN_VALUE(value) << 8, DW_BLUE_VALUE(value) << 8 };
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5623 return color;
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5624 }
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
5625 if (value < 16)
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5626 return _colors[value];
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5627 return _colors[0];
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5628 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5629
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5630 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5631 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5632 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5633 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5634 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5635 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5636 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5637 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5638 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5639 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 DW_MUTEX_LOCK;
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5642 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5643 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5644 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5645 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5646
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5647 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5648 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5649 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5650 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5651 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5652 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5653 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5654 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5655 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
5656 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5657
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5658 DW_MUTEX_LOCK;
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5659 gdk_color_alloc(_dw_cmap, &color);
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5660 if(value == DW_CLR_DEFAULT)
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5661 _transparent[index] = 1;
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5662 else
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5663 _transparent[index] = 0;
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5664
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5665 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5671 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5672 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
5673
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5675 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5676 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5677 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5678 {
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5679 gdk_gc_set_foreground(gc, &_foreground[index]);
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5680 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5681 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5682 return gc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5683 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5684
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5685 /* Draw a point on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5686 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5687 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5688 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5689 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5690 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5691 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5701 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5702 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5703 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5704 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5705 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5706 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5707 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5708 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5709
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5710 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5711 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5712 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5713 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5714 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5715 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 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
5720 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5728 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5742 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5743 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5744 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5745 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5746 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
5747 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5748 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5749 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5750
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5761 DW_MUTEX_UNLOCK;
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 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5765 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5766 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5767 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5768 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5769 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5770 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5771 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5772 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5773 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5774 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5775 GdkGC *gc = NULL;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5776 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5777 PangoFontDescription *font;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5778 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5779 GdkFont *font;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5780 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5781 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5782
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
5783 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
5784 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
5785
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5786 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5787 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5788 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5789 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5790 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5792 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5793 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5794 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5795 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5799 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5800 font = pango_font_description_from_string(fontname);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5801 if(font)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5802 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5803 PangoContext *context = gdk_pango_context_get();
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5804
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5805 if(context)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5806 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5807 PangoLayout *layout = pango_layout_new(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5808
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5809 if(layout)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5810 {
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
5811 int index = _find_thread_index(dw_thread_id());
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
5812
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
5813 gdk_pango_context_set_colormap(context, _dw_cmap);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5814 pango_layout_set_font_description(layout, font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5815 pango_layout_set_text(layout, text, strlen(text));
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5816
375
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5817 if(_transparent[index])
450
f9ba403b15ad Finally sort out correct location of text with dw_draw_text() under GTK 2.0
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 449
diff changeset
5818 gdk_draw_layout(handle ? handle->window : pixmap->pixmap, gc, x, y, layout);
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
5819 else
450
f9ba403b15ad Finally sort out correct location of text with dw_draw_text() under GTK 2.0
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 449
diff changeset
5820 gdk_draw_layout_with_colors(handle ? handle->window : pixmap->pixmap, gc, x, y, layout, &_foreground[index], &_background[index]);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5821
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5822 g_object_unref(layout);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5823 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5824 g_object_unref(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5825 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5826 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5827 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5828 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5829 font = gdk_font_load(fontname);
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5830 if(!font)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5831 font = gdk_font_load("fixed");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5832 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5833 {
379
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5834 gint ascent, descent, width, junk_ascent, junk_descent, junk_width;
375
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5835 int index = _find_thread_index(dw_thread_id());
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5836
379
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5837 /* gdk_text_extents() calculates ascent and descent based on the string, so
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5838 * a string without a character with a descent or without an ascent will have
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5839 * incorrect ascent/descent values
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5840 */
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5841 gdk_text_extents(font, text, strlen(text), NULL, NULL, &width, &junk_ascent, &junk_descent);
2e5f3cb38d19 Fix calculations of font heights under GTK 1.2. Unsure full ascent and descent
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 375
diff changeset
5842 /* force ascent/descent to be maximum values */
383
f040c24bcf26 Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 379
diff changeset
5843 gdk_text_extents(font, "(g", 2, NULL, NULL, &junk_width, &ascent, &descent);
375
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5844 if(!_transparent[index])
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5845 {
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5846 GdkGC *gc2 = NULL;
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5847
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5848 gc2 = gdk_gc_new(handle ? handle->window : pixmap->pixmap);
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5849 if(gc2)
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5850 {
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5851 gdk_gc_set_foreground(gc2, &_background[index]);
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5852 gdk_gc_set_background(gc2, &_background[index]);
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5853 }
383
f040c24bcf26 Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 379
diff changeset
5854 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc2, TRUE, x, y, width, ascent + descent + 1);
375
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5855 gdk_gc_unref(gc2);
84f79737b7d9 Manually draw the background rectangle with GTK 1.x since it doesn't appear
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 374
diff changeset
5856 }
383
f040c24bcf26 Slight change to determining font height under GTK 1.2. The solution may
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 379
diff changeset
5857 gdk_draw_text(handle ? handle->window : pixmap->pixmap, font, gc, x, y + ascent + 1, text, strlen(text));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5858 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5859 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5860 #endif
149
6028f787f7c8 Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 148
diff changeset
5861 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5862 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5863 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5864 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5865
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
5866 /* 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
5867 * 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
5868 * 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
5869 * 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
5870 * 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
5871 * 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
5872 * 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
5873 */
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
5874 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
5875 {
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
5876 int _locked_by_me = FALSE;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5877 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5878 PangoFontDescription *font;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5879 #else
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5880 GdkFont *font;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5881 #endif
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5882 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
5883
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
5884 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
5885 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
5886
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
5887 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
5888 if(handle)
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5889 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname");
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5890 else if(pixmap)
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5891 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname");
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5892
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5893 #if GTK_MAJOR_VERSION > 1
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5894 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5895 if(font)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5896 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5897 PangoContext *context = gdk_pango_context_get();
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5898
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5899 if(context)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5900 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5901 PangoLayout *layout = pango_layout_new(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5902
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5903 if(layout)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5904 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5905 PangoRectangle rect;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5906
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5907 pango_layout_set_font_description(layout, font);
233
f2435b378aed We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 216
diff changeset
5908 pango_layout_set_text(layout, text, -1);
f2435b378aed We should use the logical_rect not the ink_rect when querying the font
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 216
diff changeset
5909 pango_layout_get_pixel_extents(layout, NULL, &rect);
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5910
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5911 if(width)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5912 *width = rect.width;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5913 if(height)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5914 *height = rect.height;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5915
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5916 g_object_unref(layout);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5917 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5918 g_object_unref(context);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5919 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5920 pango_font_description_free(font);
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5921 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5922 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5923
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
5924 font = gdk_font_load(fontname ? fontname : "fixed");
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5925 if(!font)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
5926 font = gdk_font_load("fixed");
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5927 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
5928 {
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
5929 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
5930 *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
5931 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
5932 *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
5933 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
5934 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
5935 #endif
49
bf42d08d72d7 Added font text extent querying code, and made it so winmain.c can be used
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 48
diff changeset
5936 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
5937 }
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
5938
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5948 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5949 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5950 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
5958 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5971 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5972 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5973 * handle: Window handle the pixmap is associated with.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5974 * filename: Name of the file, omit extention to have
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5975 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5976 * (BMP on OS/2 or Windows, XPM on Unix)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5977 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5978 * A handle to a pixmap or NULL on failure.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5979 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5980 HPIXMAP dw_pixmap_new_from_file(HWND handle, char *filename)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5981 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5982 int _locked_by_me = FALSE;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5983 HPIXMAP pixmap;
244
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
5984 #ifndef USE_IMLIB
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5985 GdkBitmap *bitmap = NULL;
244
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
5986 #endif
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5987 #if GTK_MAJOR_VERSION > 1
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5988 GdkPixbuf *pixbuf;
244
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
5989 #elif defined(USE_IMLIB)
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
5990 GdkImlibImage *image;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5991 #endif
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5992 char *file = alloca(strlen(filename) + 5);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5993
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5994 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5995 return NULL;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5996
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5997 strcpy(file, filename);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5998
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
5999 /* check if we can read from this file (it exists and read permission) */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6000 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6001 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6002 /* Try with .xpm extention */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6003 strcat(file, ".xpm");
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6004 if(access(file, 04) != 0)
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6005 {
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6006 free(pixmap);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6007 return NULL;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6008 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6009 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6010
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6011 DW_MUTEX_LOCK;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6012 #if GTK_MAJOR_VERSION > 1
246
bdaaa06285fd Missing parameter to gdk_pixmap_new_from_file() for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 245
diff changeset
6013 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6014
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6015 pixmap->width = gdk_pixbuf_get_width(pixbuf);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6016 pixmap->height = gdk_pixbuf_get_height(pixbuf);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6017
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6018 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6019 g_object_unref(pixbuf);
244
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6020 #elif defined(USE_IMLIB)
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6021 image = gdk_imlib_load_image(file);
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6022
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6023 pixmap->width = image->rgb_width;
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6024 pixmap->height = image->rgb_height;
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6025
245
11baf43efbc2 Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 244
diff changeset
6026 gdk_imlib_render(image, pixmap->width, pixmap->height);
11baf43efbc2 Must call gdk_imlib_render() before gdk_imlib_copy_image().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 244
diff changeset
6027 pixmap->pixmap = gdk_imlib_copy_image(image);
244
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6028 gdk_imlib_destroy_image(image);
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6029 #else
68158098a092 Implemented dw_pixmap_new_from_file() for GTK 1.x with and without imlib.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 241
diff changeset
6030 pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6031 #endif
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6032 pixmap->handle = handle;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6033 DW_MUTEX_UNLOCK;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6034 return pixmap;
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6035 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6036
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
6037 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6045 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6046 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6047 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 DW_MUTEX_LOCK;
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
6056 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6057 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6058 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6059 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6060 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6061 pixmap->width = pvt->width; pixmap->height = pvt->height;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
6062 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6065 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6066 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6067
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6068 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6069 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6070 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6071 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6072 {
133
85f8ba78736d Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 132
diff changeset
6073 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6074 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6075
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6076 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6077 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6078 DW_MUTEX_UNLOCK;
133
85f8ba78736d Don't call gdk_flush() in GTK 2.0. It doesn't seem to be necessary and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 132
diff changeset
6079 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6080 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6081
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6082 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6092 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6093 gdk_pixmap_unref(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6094 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6095 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6096 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6098 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6099 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6100 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6111 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6112 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
6113 {
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
6114 /* 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
6115 * 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
6116 * 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
6117 * 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
6118 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121
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
6122 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6129 gc = _set_colors(src->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6130 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6131 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6132 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6133 gc = gdk_gc_new(srcp->pixmap);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6134
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6135 if(gc)
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6136 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
6137 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
6138 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6139 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6140 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6141 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6142
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6143 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6144 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6145 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6146 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6147 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6148 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6149 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6150 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6151 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6152
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6153 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6154 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6155 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6157
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6158 void _my_strlwr(char *buf)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6159 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6160 int z, len = strlen(buf);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6161
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6162 for(z=0;z<len;z++)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6163 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6164 if(buf[z] >= 'A' && buf[z] <= 'Z')
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6165 buf[z] -= 'A' - 'a';
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6166 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6167 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6168
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6169 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6170 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6171 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6172 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6173 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6174 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6175 int dw_module_load(char *name, HMOD *handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6176 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6177 int len;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6178 char *newname;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6179 char errorbuf[1024];
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6180
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6181
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6182 if(!handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6183 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6184
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6185 if((len = strlen(name)) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6186 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6187
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6188 /* Lenth + "lib" + ".so" + NULL */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6189 newname = malloc(len + 7);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6190
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6191 if(!newname)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6192 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6193
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6194 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6195 _my_strlwr(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6196
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6197 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6198 if(*handle == NULL)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6199 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6200 strncpy(errorbuf, dlerror(), 1024);
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
6201 printf("%s\n", errorbuf);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6202 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6203 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6204 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6205
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6206 free(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6207
163
0322836c5299 Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 162
diff changeset
6208 return (NULL == *handle) ? -1 : 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6209 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6210
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6211 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6212 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6213 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6214 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6215 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6216 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6217 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6218 int dw_module_symbol(HMOD handle, char *name, void**func)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6219 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6220 if(!func || !name)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6221 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6222
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6223 if(strlen(name) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6224 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6225
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6226 *func = (void*)dlsym(handle, name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6227 return (NULL == *func);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6228 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6229
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6230 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6231 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6232 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6233 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6234 int dw_module_close(HMOD handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6235 {
162
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
6236 if(handle)
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
6237 return dlclose(handle);
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
6238 return 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6239 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
6240
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6241 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6242 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6243 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6244 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6245 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6246 HMTX mutex = malloc(sizeof(pthread_mutex_t));
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6247
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6248 pthread_mutex_init(mutex, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6249 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6250 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6252 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6253 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6254 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6255 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6258 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6259 if(mutex)
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6260 {
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6261 pthread_mutex_destroy(mutex);
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6262 free(mutex);
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6263 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6272 {
96
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6273 /* If we are being called from an event handler we must release
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6274 * the GTK mutex so we don't deadlock.
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6275 */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6276 if(pthread_self() == _dw_thread)
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6277 gdk_threads_leave();
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6278
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6279 pthread_mutex_lock(mutex);
96
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6280
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6281 /* And of course relock it when we have acquired the mutext */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6282 if(pthread_self() == _dw_thread)
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
6283 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6286 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6287 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
6293 pthread_mutex_unlock(mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6298 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6299 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6303 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6304 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6305
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6306 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6307 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6308 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6309 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6310 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6317
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6318 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6319 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6320
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6321 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6337 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6348 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6349
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6350 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6351 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6352 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6353 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6354 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6355 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6356
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6372 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6373 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6375 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6376 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6377 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6378 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6379 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6380 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6385 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6390 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6400 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6401 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6402 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6403 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6404
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6405 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6406 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6408 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6409 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6410 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6411 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6412 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6413 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6414 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6415
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6416 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6417
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6418 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6419 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6420 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6421 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6422 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6423 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6424 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6432 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6433 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6434
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6435 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6436 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6437
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6438 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6439 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6440 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6441
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6442 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6443 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6444 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6451 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6452 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6453 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6454 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6455 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6456 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6457
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6458 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6463 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6464 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6468 #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
6469
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6478 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 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
6482 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6483 int warn = FALSE, _locked_by_me = FALSE;
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
6484 GtkWidget *tmp, *tmpitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6485
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6486 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6487 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6488
447
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6489 /*
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6490 * If you try and pack an item into itself VERY bad things can happen; like at least an
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6491 * infinite loop on GTK! Lets be safe!
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6492 */
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6493 if(box == item)
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6494 {
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6495 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!",box,item);
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6496 return;
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6497 }
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
6498
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6499 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6500
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6501 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle")))
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6502 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6503
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6507 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
6510 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle");
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
6511
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6512 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6513 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6514 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6515 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6516
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6517 /* 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
6518 * 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
6519 * 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
6520 * 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
6521 */
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
6522 if(GTK_IS_TABLE(item) || (tmpitem && GTK_IS_TABLE(tmpitem)))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6523 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6524 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6525
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6526 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6527 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6528 gtk_container_add(GTK_CONTAINER(eventbox), item);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6529 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6530 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6531 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6532 }
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6533 else
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6534 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6535 /* Only show warning if item is not a box */
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6536 warn = TRUE;
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6537 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6538
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
6539 if(boxtype == DW_VERT)
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6540 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
6541 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6542 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
6543
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6544 gtk_table_attach(GTK_TABLE(box), item, 0, 1, 0, 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6545 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6546 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6547 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6548 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6549 GSList *group;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6550 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6551
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6552 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 else
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6558 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6562 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6564
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
6565 if(GTK_IS_TABLE(item) || (tmpitem && GTK_IS_TABLE(tmpitem)))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6566 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6567 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6568
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6569 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6570 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6571 gtk_container_add(GTK_CONTAINER(eventbox), item);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6572 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6573 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6574 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6575 }
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6576 else
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6577 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6578 /* Only show warning if item is not a box */
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6579 warn = TRUE;
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
6580 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6581
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6582 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 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
6584 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 DW_MUTEX_UNLOCK;
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6591
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6592 if(warn)
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6593 {
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6594 if ( width == 0 && hsize == FALSE )
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6595 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6596 if ( height == 0 && vsize == FALSE )
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6597 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
6598 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6599 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6600
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6601 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6602 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6603 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6604 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6605 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6606 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6607 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
6608 void dw_window_set_size(HWND handle, unsigned long width, unsigned long height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6609 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6610 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6611
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6612 if(!handle)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6613 return;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6614
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6615 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6616 if(GTK_IS_WINDOW(handle))
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6617 {
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6618 _size_allocate(GTK_WINDOW(handle));
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6619 if(handle->window)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6620 gdk_window_resize(handle->window, width - _dw_border_width, height - _dw_border_height);
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6621 gtk_window_set_default_size(GTK_WINDOW(handle), width - _dw_border_width, height - _dw_border_height);
272
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6622 if(!gtk_object_get_data(GTK_OBJECT(handle), "_dw_size"))
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6623 {
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6624 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", (gpointer)width - _dw_border_width);
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6625 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", (gpointer)height - _dw_border_height);
49ac97060328 Fixes for default window size when the window does not have the sizeable
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 271
diff changeset
6626 }
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6627 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6628 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6629 gtk_widget_set_usize(handle, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6630 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6631 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6632
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6633 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6634 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6635 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6636 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6637 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6642 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6644 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6646
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6648 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6650 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6651 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6652 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6653 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6654
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6655 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6656 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6657 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6658 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6659 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6660
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6661 /* This should return the current color depth */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6662 unsigned long dw_color_depth(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6663 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6664 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6665 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6666
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6667 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
6668 retval = gdk_visual_get_best_depth();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6669 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6670 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6671 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6672
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6673 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6674 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6675 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6676 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6677 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6678 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6679 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6680 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6681 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6682 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6684 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6685 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6687 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6690 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6693 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6696 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699 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
6700 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6702
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6703 if(!handle)
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6704 return;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6705
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6706 DW_MUTEX_LOCK;
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6707 if(GTK_IS_WINDOW(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 {
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
6709 dw_window_set_size(handle, width, height);
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6710 gtk_widget_set_uposition(handle, x, y);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 }
148
830f591c87f1 dw_window_set_usize fixes and fallback to "fixed" on GTK 1.2 if pango
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 147
diff changeset
6712 else if(handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 gdk_window_resize(handle->window, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6715 gdk_window_move(handle->window, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6716 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6717 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6718 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6719
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6722 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6723 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6724 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6725 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6726 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6727 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 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
6730 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732 gint gx, gy, gwidth, gheight, gdepth;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
6734 if(handle && handle->window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6737
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 gdk_window_get_root_origin(handle->window, &gx, &gy);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 if(x)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 if(y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6743 *y = gy;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6744 if(GTK_IS_WINDOW(handle))
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6745 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6746 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6747 *width = gwidth + _dw_border_width;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6748 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6749 *height = gheight + _dw_border_height;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6750 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6751 else
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6752 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6753 if(width)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6754 *width = gwidth;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6755 if(height)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6756 *height = gheight;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6757 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6758 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6759 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6760 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6761
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6762 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6763 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6764 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6765 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6766 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6767 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6768 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6769 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6771 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6773
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6776 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780 }
426
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6781 else if(GTK_IS_FRAME(handle))
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6782 {
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6783 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label");
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6784 if(tmp && GTK_IS_LABEL(tmp))
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6785 handle2 = tmp;
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
6786 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
6787 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
6788 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6789 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
6790 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6791 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6792
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6793 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6794
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6795 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6796 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6797
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6798 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6799 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6800
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6801 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
6802 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6803 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
6804 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
6805 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6808
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6809 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6810 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6811 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6812 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6814 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6815 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6816 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6817 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6818 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6819 int _locked_by_me = FALSE;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6820 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6821
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6822 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6823 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray");
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6824
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6825 if(pagearray)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6826 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6827 for(z=0;z<256;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6828 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6829 if(!pagearray[z])
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6830 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6831 char text[100];
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6832 int num = z;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6833
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6834 if(front)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6835 num |= 1 << 16;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6836
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6837 sprintf(text, "_dw_page%d", z);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6838 /* Save the real id and the creation flags */
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6839 gtk_object_set_data(GTK_OBJECT(handle), text, (gpointer)num);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6840 DW_MUTEX_UNLOCK;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6841 return z;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6842 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6843 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6844 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6845 DW_MUTEX_UNLOCK;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6846
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6847 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6848 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6849 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6850
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6851 /* Return the physical page id from the logical page id */
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6852 int _get_physical_page(HWND handle, unsigned long pageid)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6853 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6854 int z;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6855 GtkWidget *thispage, **pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray");
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6856
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6857 if(pagearray)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6858 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6859 for(z=0;z<256;z++)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6860 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6861 if((thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z)))
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6862 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6863 if(thispage == pagearray[pageid])
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6864 return z;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6865 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6866 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6867 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6868 return 256;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6869 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6870
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6871 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6872 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6873 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6874 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6875 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6876 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6877 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6878 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6879 int realpage, _locked_by_me = FALSE;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6880 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6881
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6882 DW_MUTEX_LOCK;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6883 realpage = _get_physical_page(handle, pageid);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6884 if(realpage > -1 && realpage < 256)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6885 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6886 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), realpage);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6887 if((pagearray = gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray")))
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6888 pagearray[pageid] = NULL;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6889 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6895 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6896 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6897 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
6898 unsigned long dw_notebook_page_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6899 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6900 int retval, phys;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6901 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6902
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6903 DW_MUTEX_LOCK;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6904 phys = gtk_notebook_get_current_page(GTK_NOTEBOOK(handle));
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6905 retval = _get_logical_page(handle, phys);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6906 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6907 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6908 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6918 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 DW_MUTEX_LOCK;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6921 realpage = _get_physical_page(handle, pageid);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6922 if(realpage > -1 && realpage < 256)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6923 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6924 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6926
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 GtkWidget *child;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6938 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 DW_MUTEX_LOCK;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6941 realpage = _get_physical_page(handle, pageid);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6942 if(realpage < 0 || realpage > 255)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6943 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6944 char ptext[100];
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6945 int num;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6946
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6947 sprintf(ptext, "_dw_page%d", (int)pageid);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6948 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6949 realpage = 0xFF & num;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6950 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6951
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6952 if(realpage > -1 && realpage < 256)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6953 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6954 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), realpage);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6955 if(child)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6956 gtk_notebook_set_tab_label_text(GTK_NOTEBOOK(handle), child, text);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6957 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6962 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6963 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6967 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6968 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6969 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6970 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6971 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6972
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6973 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6982 GtkWidget *label, *child, *oldlabel, **pagearray;
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
6983 gchar *text = NULL;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6984 int num, z, realpage = -1, pad, _locked_by_me = FALSE;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6985 char ptext[100];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 DW_MUTEX_LOCK;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6988 sprintf(ptext, "_dw_page%d", (int)pageid);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6989 num = (int)gtk_object_get_data(GTK_OBJECT(handle), ptext);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6990 gtk_object_set_data(GTK_OBJECT(handle), ptext, NULL);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6991 pagearray = (GtkWidget **)gtk_object_get_data(GTK_OBJECT(handle), "_dw_pagearray");
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6992
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6993 if(!pagearray)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6994 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6995 DW_MUTEX_UNLOCK;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6996 return;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6997 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6998
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
6999 /* The page already exists... so get it's current page */
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7000 if(pagearray[pageid])
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7001 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7002 for(z=0;z<256;z++)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7003 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7004 child = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), z);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7005 if(child == pagearray[pageid])
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7006 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7007 oldlabel = gtk_notebook_get_tab_label(GTK_NOTEBOOK(handle), child);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7008 if(oldlabel)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7009 gtk_label_get(GTK_LABEL(oldlabel), &text);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7010 gtk_notebook_remove_page(GTK_NOTEBOOK(handle), z);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7011 realpage = z;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7012 break;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7013 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7014 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7015 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7016
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7017 pagearray[pageid] = page;
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7018
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7019 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
7020
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7021 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7022 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7023 pad = (int)gtk_object_get_data(GTK_OBJECT(page), "_dw_boxpad");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7024 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7025 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7026
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7027 if(realpage != -1)
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7028 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, realpage);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7029 else if(num & ~(0xFF))
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7030 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 0);
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7031 else
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
7032 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7033 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7036 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7037 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7038 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7039 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7040 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7041 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7042 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7043 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7044 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7045 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7046
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7047 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7048 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7049 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7050 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7051 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7052 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7053 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7054 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7055 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7056 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7057 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7058 GList *tmp;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7059 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_font");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7060 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_foregdk");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7061 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7062
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7063 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7065 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7066 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7067 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
7068 _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
7069 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
7070 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7071
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7072 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7073 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7074 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7075 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7076 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7077 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7078 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7079 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7080
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7081 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7082 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7083 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7084 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7085 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7086 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7087 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7088 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7089 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7090 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7091
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7092 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7093 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7094 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7095 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7096 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7097 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7098 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7099 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7100 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7101
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7102 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7103 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7104 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7105 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7106 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7107 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7108 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7109 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7110 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7111 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7112
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7113 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7114 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7115 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7116 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7117 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7118 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7119 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7120 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7121 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7122 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7123 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7124 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7130 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7131 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7134
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7135 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7136 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7137 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7138 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7139 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7141 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7144 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7146 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7148 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7150 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7157 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7158 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7159 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7160 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7161 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7162 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7163 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7164 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7165 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7166 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7167 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7168 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7170 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7171 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7174 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7176 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7177 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7179 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7180
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7181 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7182 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7184 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7185 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7186 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7187 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7188 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7189 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7190 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7191 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7192 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7194 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7195 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7196 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7197
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7198 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7199
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7205
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7207 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7211 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
7214 void dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7215 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7216 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7217 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7218
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7219 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7220 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7222 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7224 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7226 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7227 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7228 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7229 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7230 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7231 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7232 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7233 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7234
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7235 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7236 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7237 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7238 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7239 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7240
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7241 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7242 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7243 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7244
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7245 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7250 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7251 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7252
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7253 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7254 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7256 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7257 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7258 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7259 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7260
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7261 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7262 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7264 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7265 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7266 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7267 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7268 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7270
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7271 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7272 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7273 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7274 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7275 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7276 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7277 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7278 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7279 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7281 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7282
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7285 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7286 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7287 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7288 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7289 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7290 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7291 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7292 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7293 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7294 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7295 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7296 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7297 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7298
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7299 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7300 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7301 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7302 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7303
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7304 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7306 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7308 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7309 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7310 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7311
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7312 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7313 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7317 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7318 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7319 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7320 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7321 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7322 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7323 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7324 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7325 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7326 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7327 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7328 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7329 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7330 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7333 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7334 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7335
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7336 #if GTK_MAJOR_VERSION < 2
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7337 /* Check if a GList item is in another GList */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
7338 static int _dw_in_list(GList *item, GList *list)
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7339 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7340 while(list)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7341 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7342 if(list->data == item->data)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7343 return TRUE;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7344
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7345 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7346 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7347 return FALSE;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7348 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7349 #endif
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7350
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7351 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7352 * 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
7353 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7354 * 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
7355 * 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
7356 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7357 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
7358 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7359 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7360 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7361 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7362
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7363 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7364 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7365 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7366 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
7367 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7368 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7369 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7370 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7371 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7372 #if GTK_MAJOR_VERSION > 1
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7373 int counter = 0;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7374 GList *list = GTK_LIST(handle2)->children;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7375
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7376 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7377 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7378 GtkItem *item = (GtkItem *)list->data;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7379
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7380 if(item &&
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7381 item->bin.container.widget.state == GTK_STATE_SELECTED
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7382 && counter > where)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7383 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7384 retval = counter;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7385 break;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7386 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7387
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7388
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7389 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7390 counter++;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7391 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7392 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7393 int counter = 0;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7394 GList *list = GTK_LIST(handle2)->children;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7395
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7396 while(list)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7397 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7398 if(counter > where && _dw_in_list(list, GTK_LIST(handle2)->selection))
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7399 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7400 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7401 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7402 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7403
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7404 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7405 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7406 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7407 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7408 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7409 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7410 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7411 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7412
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7413 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7419 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7422 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7423
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7424 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7425 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7426 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7427 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7428 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7429 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7430 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7431 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7432 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7433 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7434 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7435 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7436 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7437 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7438 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7439 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7440 GList *list = GTK_LIST(handle2)->children;
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7441 #if GTK_MAJOR_VERSION > 1
423
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7442
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7443 while(list)
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7444 {
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7445 GtkItem *item = (GtkItem *)list->data;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7446
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7447 if(item && item->bin.container.widget.state == GTK_STATE_SELECTED)
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7448 {
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7449 retval = counter;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7450 break;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7451 }
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7452
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7453 list = list->next;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7454 counter++;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7455 }
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7456 #else
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7457 GList *selection = GTK_LIST(handle2)->selection;
423
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7458
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7459 if(selection)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7460 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7461 while(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7462 {
147
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7463 if(list->data == selection->data)
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7464 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7465 retval = counter;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7466 break;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7467 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7468
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7469 list = list->next;
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7470 counter++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7471 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7472 }
423
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
7473 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7474 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7475 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7476 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7477 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7478
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7479 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7480 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7481 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7482 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7483 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7484 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7485 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7486 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7487 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7488 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7489 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7490
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7491 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7492 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7493 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7494 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7495 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7496 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7497 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7498 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7500 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7501 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7502 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7503 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7504 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7505 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7506 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7507 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7509 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7510 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7511
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7512 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7513 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7514 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7515 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7516 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7517 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7518 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7519 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7520 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7521 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7522
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7523 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7524 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7525 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7526 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7527 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7528 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7529 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7530 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7531 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7532 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7533 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7534 if(GTK_IS_LIST(handle2))
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
7535 {
464
3251fbca6fb3 dw_listbox_delete() needs index+1 for end arg
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 463
diff changeset
7536 gtk_list_clear_items(GTK_LIST(handle2), index, index+1);
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
7537 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7538 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7539 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7540
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7541 /* Reposition the bar according to the percentage */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
7542 static gint _splitbar_size_allocate(GtkWidget *widget, GtkAllocation *event, gpointer data)
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7543 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7544 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent");
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7545 int lastwidth = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastwidth");
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7546 int lastheight = (int)gtk_object_get_data(GTK_OBJECT(widget), "_dw_lastheight");
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7547
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7548 /* Prevent infinite recursion ;) */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7549 if(!percent || (lastwidth == event->width && lastheight == event->height))
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7550 return FALSE;
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7551
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7552 lastwidth = event->width; lastheight = event->height;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7553
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7554 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastwidth", (gpointer)lastwidth);
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7555 gtk_object_set_data(GTK_OBJECT(widget), "_dw_lastheight", (gpointer)lastheight);
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7556
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7557 if(GTK_IS_HPANED(widget))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7558 gtk_paned_set_position(GTK_PANED(widget), (int)(event->width * (*percent / 100.0)));
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7559 if(GTK_IS_VPANED(widget))
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7560 gtk_paned_set_position(GTK_PANED(widget), (int)(event->height * (*percent / 100.0)));
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7561 gtk_object_set_data(GTK_OBJECT(widget), "_dw_waiting", NULL);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7562 return FALSE;
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7563 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7564
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7565 #if GTK_MAJOR_VERSION > 1
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7566 /* Figure out the new percentage */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
7567 static void _splitbar_accept_position(GObject *object, GParamSpec *pspec, gpointer data)
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7568 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7569 GtkWidget *widget = (GtkWidget *)data;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7570 float *percent = (float *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_percent");
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7571 int size = 0, position = gtk_paned_get_position(GTK_PANED(widget));
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7572
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7573 if(!percent || gtk_object_get_data(GTK_OBJECT(widget), "_dw_waiting"))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7574 return;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7575
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7576 if(GTK_IS_VPANED(widget))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7577 size = widget->allocation.height;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7578 else if(GTK_IS_HPANED(widget))
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7579 size = widget->allocation.width;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7580
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7581 if(size > 0)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7582 *percent = ((float)(position * 100) / (float)size);
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7583 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7584 #endif
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7585
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7586 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7587 * Creates a splitbar window (widget) with given parameters.
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7588 * Parameters:
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
7589 * type: Value can be DW_VERT or DW_HORZ.
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7590 * topleft: Handle to the window to be top or left.
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7591 * bottomright: Handle to the window to be bottom or right.
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7592 * Returns:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7593 * A handle to a splitbar window or NULL on failure.
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7594 */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7595 HWND dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id)
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7596 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7597 GtkWidget *tmp = NULL;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7598 int _locked_by_me = FALSE;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7599 float *percent = malloc(sizeof(float));
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7600
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7601 DW_MUTEX_LOCK;
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
7602 if(type == DW_HORZ)
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7603 tmp = gtk_hpaned_new();
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7604 else
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7605 tmp = gtk_vpaned_new();
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7606 gtk_paned_add1(GTK_PANED(tmp), topleft);
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7607 gtk_paned_add2(GTK_PANED(tmp), bottomright);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7608 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7609 *percent = 50.0;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7610 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_percent", (gpointer)percent);
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7611 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_waiting", (gpointer)1);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7612 gtk_signal_connect(GTK_OBJECT(tmp), "size-allocate", GTK_SIGNAL_FUNC(_splitbar_size_allocate), NULL);
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7613 #if GTK_MAJOR_VERSION > 1
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7614 g_signal_connect(G_OBJECT(tmp), "notify::position", (GCallback)_splitbar_accept_position, (gpointer)tmp);
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7615 #else
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7616 gtk_paned_set_handle_size(GTK_PANED(tmp), 3);
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7617 #endif
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7618 gtk_widget_show(tmp);
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7619 DW_MUTEX_UNLOCK;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7620 return tmp;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7621 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7622
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7623 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7624 * Sets the position of a splitbar (pecentage).
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7625 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7626 * handle: The handle to the splitbar returned by dw_splitbar_new().
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7627 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7628 void dw_splitbar_set(HWND handle, float percent)
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7629 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7630 float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7631 int size = 0, position;
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7632
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7633 if(GTK_IS_VPANED(handle))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7634 size = handle->allocation.height;
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7635 else if(GTK_IS_HPANED(handle))
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7636 size = handle->allocation.width;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7637
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7638 if(mypercent)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7639 *mypercent = percent;
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7640
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7641 if(size > 10)
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7642 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7643 position = (int)((float)size * (percent / 100.0));
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7644
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7645 gtk_paned_set_position(GTK_PANED(handle), position);
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
7646 }
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7647 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7648
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7649 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7650 * Gets the position of a splitbar (pecentage).
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7651 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7652 * handle: The handle to the splitbar returned by dw_splitbar_new().
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
7653 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7654 float dw_splitbar_get(HWND handle)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7655 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7656 float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7657
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7658 if(percent)
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7659 return *percent;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7660 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7661 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7662
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7663 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7666 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7667 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7668 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7669 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7670 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7671 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7672 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7673 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7674 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
7675 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7676 int warn = FALSE, _locked_by_me = FALSE;
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7677 GtkWidget *tmp, *tmpitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7678
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7679 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7680 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7681
447
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7682 /*
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7683 * If you try and pack an item into itself VERY bad things can happen; like at least an
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7684 * infinite loop on GTK! Lets be safe!
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7685 */
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7686 if(box == item)
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7687 {
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7688 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!",box,item);
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7689 return;
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7690 }
5a0779561d0f Add more tests for dw_pac*() functions. Throw up a messagebox if you try and
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 442
diff changeset
7691
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7692 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7693
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7694 if((tmp = gtk_object_get_data(GTK_OBJECT(box), "_dw_boxhandle")))
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7695 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
7696
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7697 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7698 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7699 item = gtk_label_new("");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7700 gtk_widget_show(item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7701 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7702
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7703 tmpitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxhandle");
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7704
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7705 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7706 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7707 int boxcount = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxcount");
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7708 int boxtype = (int)gtk_object_get_data(GTK_OBJECT(box), "_dw_boxtype");
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7709 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
7710
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7711 /* 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
7712 * 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
7713 * 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
7714 * 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
7715 */
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7716 if(GTK_IS_TABLE(item) || (tmpitem && GTK_IS_TABLE(tmpitem)))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7717 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7718 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7719
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7720 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7721 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7722 gtk_container_add(GTK_CONTAINER(eventbox), item);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7723 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7724 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7725 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7726 }
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7727 else
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7728 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7729 /* Only show warning if item is not a box */
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7730 warn = TRUE;
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7731 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7732
283
54aafc134652 BOXVERT is now DW_VERT and BOXHORZ is now DW_HORZ. Also code cleanups,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 282
diff changeset
7733 if(boxtype == DW_VERT)
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7734 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7735 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7736 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7737 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
7738 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7739 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7740 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7741 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7742 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7743 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
7744 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7745
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
7746 gtk_table_attach(GTK_TABLE(box), item, x, x + 1, y, y + 1, hsize ? DW_EXPAND : 0, vsize ? DW_EXPAND : 0, pad, pad);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7747 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7748 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7749 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7750 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7751 GSList *group;
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7752 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7753
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7754 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7755 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7756 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7757 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7758 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7759 else
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7760 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7761 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7762 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7763 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7764 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7765 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7766
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7767 if(GTK_IS_TABLE(item) || (tmpitem && GTK_IS_TABLE(tmpitem)))
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7768 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7769 GtkWidget *eventbox = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(item), "_dw_eventbox");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7770
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7771 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7772 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7773 gtk_container_add(GTK_CONTAINER(eventbox), item);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7774 pad = (int)gtk_object_get_data(GTK_OBJECT(item), "_dw_boxpad");
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7775 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7776 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7777 }
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7778 else
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7779 {
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7780 /* Only show warning if item is not a box */
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7781 warn = TRUE;
438
fac2afe7bda3 Only throw up the messagebox when expand and size are both 0 and the item
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 429
diff changeset
7782 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7783
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7784 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 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
7786 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7788
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7789 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7792 DW_MUTEX_UNLOCK;
442
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7793
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7794 if(warn)
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7795 {
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7796 if ( width == 0 && hsize == FALSE )
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7797 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Width and expand Horizonal both unset for box: %x item: %x",box,item);
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7798 if ( height == 0 && vsize == FALSE )
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7799 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Height and expand Vertical both unset for box: %x item: %x",box,item);
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
7800 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7801 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7802
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 /*
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
7804 * 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
7805 * 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
7806 * 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
7807 * 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
7808 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7809 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
7810 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7811 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
7812
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7813 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
7814 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
7815
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7816 DW_MUTEX_LOCK;
273
95bfcd2deb94 Slight change to get it to work on GTK 2.x, although there is a momentary
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 272
diff changeset
7817 gtk_object_set_data(GTK_OBJECT(window), "_dw_defaultitem", (gpointer)defaultitem);
34
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7818 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
7819 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7820
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
7821 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7822 * 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
7823 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7824 * 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
7825 * 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
7826 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7827 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
7828 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7829 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
7830
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7831 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7832 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7833
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7834 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7835 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
7836 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7837 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7838
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
7839 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7840 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7841 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7842 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7843 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7844 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7846 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7847 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7848 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7849
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7850 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7851 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7852 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7857
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
7858 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
7859 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
7860 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
7861 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
7862 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
7863
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7865 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7868 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7869 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7870 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7871 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7872 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7873 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7874 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7875 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7876 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7877
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7878 /* Internal function to handle the file OK press */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
7879 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7881 #if GTK_MAJOR_VERSION > 1
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7882 const char *tmp;
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7883 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 char *tmp;
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
7885 #endif
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
7886 char *tmpdup=NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7887
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7888 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7889 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7890
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
7891 if((tmp = gtk_file_selection_get_filename(GTK_FILE_SELECTION(dwwait->data))))
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
7892 tmpdup = strdup(tmp);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7893 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
7894 _dw_file_active = 0;
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
7895 dw_dialog_dismiss(dwwait, (void *)tmpdup);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7896 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7897 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 /* Internal function to handle the file Cancel press */
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
7900 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7902 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7903 return FALSE;
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7904
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
7905 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
7906 _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
7907 dw_dialog_dismiss(dwwait, NULL);
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
7908 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7911 /* The next few functions are support functions for the UNIX folder browser */
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7912 static void _populate_directory(HWND tree, HTREEITEM parent, char *path)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7913 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7914 struct dirent *dent;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7915 HTREEITEM item;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7916 DIR *hdir;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7917
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7918 if((hdir = opendir(path)))
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7919 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7920 while((dent = readdir(hdir)))
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7921 {
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7922 if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, ".."))
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7923 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7924 int len = strlen(path);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7925 char *folder = malloc(len + strlen(dent->d_name) + 2);
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7926 struct stat bleah;
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7927 HTREEITEM tempitem;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7928
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7929 strcpy(folder, path);
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7930 strcpy(&folder[len], dent->d_name);
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7931
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7932 stat(folder, &bleah);
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7933
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7934 if(S_IFDIR & bleah.st_mode)
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7935 {
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7936 item = dw_tree_insert(tree, dent->d_name, 0, parent, (void *)parent);
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7937 tempitem = dw_tree_insert(tree, "", 0, item, 0);
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
7938 dw_tree_item_change_data(tree, item, (void *)tempitem);
484
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
7939 }
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7940
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7941 free(folder);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7942 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7943 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7944 closedir(hdir);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7945 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7946 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7947
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7948 static int DWSIGNAL _dw_folder_ok_func(HWND window, void *data)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7949 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7950 DWDialog *dwwait = (DWDialog *)data;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7951 void *treedata;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7952
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7953 if(!dwwait)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7954 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7955
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7956 treedata = dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected");
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7957 dw_window_destroy((HWND)dwwait->data);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7958 dw_dialog_dismiss(dwwait, treedata);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7959 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7960 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7961
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7962 static int DWSIGNAL _dw_folder_cancel_func(HWND window, void *data)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7963 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7964 DWDialog *dwwait = (DWDialog *)data;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7965
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7966 if(!dwwait)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7967 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7968
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7969 dw_window_destroy((HWND)dwwait->data);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7970 dw_dialog_dismiss(dwwait, NULL);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7971 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7972 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7973
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7974 static char *_tree_folder(HWND tree, HTREEITEM item)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7975 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7976 char *folder=strdup("");
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7977 HTREEITEM parent = item;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7978
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7979 while(parent)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7980 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7981 char *temp, *text = dw_tree_get_title(tree, parent);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7982
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7983 if(text)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7984 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7985 temp = malloc(strlen(text) + strlen(folder) + 3);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7986 strcpy(temp, text);
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
7987 if(strcmp(text, "/"))
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7988 strcat(temp, "/");
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7989 strcat(temp, folder);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7990 free(folder);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7991 folder = temp;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7992 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7993 parent = dw_tree_get_parent(tree, parent);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7994 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7995 return folder;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7996 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7997
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7998 static int DWSIGNAL _item_select(HWND window, HTREEITEM item, char *text, void *data, void *itemdata)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
7999 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8000 DWDialog *dwwait = (DWDialog *)data;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8001 char *treedata = (char *)dw_window_get_data((HWND)dwwait->data, "_dw_tree_selected");
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8002
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8003 text = text; itemdata = itemdata;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8004 if(treedata)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8005 free(treedata);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8006
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8007 treedata = _tree_folder(window, item);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8008 dw_window_set_data((HWND)dwwait->data, "_dw_tree_selected", (void *)treedata);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8009
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8010 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8011 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8012
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8013 static int DWSIGNAL _tree_expand(HWND window, HTREEITEM item, void *data)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8014 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8015 DWDialog *dwwait = (DWDialog *)data;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8016 HWND tree = (HWND)dw_window_get_data((HWND)dwwait->data, "_dw_tree");
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8017 HTREEITEM tempitem = (HTREEITEM)dw_tree_item_get_data(tree, item);
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8018
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8019 if(tempitem)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8020 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8021 char *folder = _tree_folder(tree, item);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8022
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8023 dw_tree_item_change_data(tree, item, 0);
486
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
8024
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
8025 if(*folder)
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
8026 _populate_directory(tree, item, folder);
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
8027
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8028 #if GTK_MAJOR_VERSION > 1
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8029 /* FIXME: GTK 1.x tree control goes crazy when
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8030 * I delete the temporary item. The subtree
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8031 * it sits on ceases to be valid and attempts
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8032 * to delete or recreate it fail horribly.
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8033 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8034 dw_tree_item_delete(tree, tempitem);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8035 #endif
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8036 free(folder);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8037 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8038
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8039 return FALSE;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8040 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8041
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8042 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8043 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8044 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8045 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8046 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8047 * ext: Default file extention.
449
787cc1e27897 Add support for directory browsing under Win32. DW_DIRECTORY_OPEN can be
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 447
diff changeset
8048 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8049 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8050 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8051 * the file path on success.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8052 *
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8053 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8054 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8055 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8056 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8057 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
8058 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8059
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8060 if(flags == DW_DIRECTORY_OPEN)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8061 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8062 HWND window, hbox, vbox, tree, button;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8063 HTREEITEM item, tempitem;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8064
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8065 window = dw_window_new( HWND_DESKTOP, title, DW_FCF_SHELLPOSITION | DW_FCF_TITLEBAR | DW_FCF_SIZEBORDER | DW_FCF_MINMAX);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8066
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8067 vbox = dw_box_new(DW_VERT, 5);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8068
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8069 dw_box_pack_start(window, vbox, 0, 0, TRUE, TRUE, 0);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8070
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8071 tree = dw_tree_new(60);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8072
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8073 dw_box_pack_start(vbox, tree, 1, 1, TRUE, TRUE, 0);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8074 dw_window_set_data(window, "_dw_tree", (void *)tree);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8075
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8076 hbox = dw_box_new(DW_HORZ, 0);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8077
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8078 dw_box_pack_start(vbox, hbox, 0, 0, TRUE, FALSE, 0);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8079
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8080 dwwait = dw_dialog_new((void *)window);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8081
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8082 dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(_item_select), (void *)dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8083 dw_signal_connect(tree, DW_SIGNAL_TREE_EXPAND, DW_SIGNAL_FUNC(_tree_expand), (void *)dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8084
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8085 button = dw_button_new("Ok", 1001L);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8086 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8087 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_folder_ok_func), (void *)dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8088
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8089 button = dw_button_new("Cancel", 1002L);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8090 dw_box_pack_start(hbox, button, 50, 30, TRUE, FALSE, 3);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8091 dw_signal_connect(button, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_folder_cancel_func), (void *)dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8092
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8093 item = dw_tree_insert(tree, "/", 0, NULL, 0);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8094 tempitem = dw_tree_insert(tree, "", 0, item, 0);
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8095 dw_tree_item_change_data(tree, item, (void *)tempitem);
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8096
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8097 dw_window_set_size(window, 225, 300);
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8098 dw_window_show(window);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8099 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8100 else
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8101 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8102 DW_MUTEX_LOCK;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8103
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8104 /* The DW mutex should be sufficient for
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8105 * insuring no thread changes this unknowingly.
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8106 */
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8107 if(_dw_file_active)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8108 {
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8109 DW_MUTEX_UNLOCK;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8110 return NULL;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8111 }
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8112
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8113 _dw_file_active = 1;
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8114
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8115 filew = gtk_file_selection_new(title);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8116
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8117 dwwait = dw_dialog_new((void *)filew);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8118
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8119 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->ok_button), "clicked", (GtkSignalFunc) _gtk_file_ok, dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8120 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filew)->cancel_button), "clicked", (GtkSignalFunc) _gtk_file_cancel, dwwait);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8121
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8122 if(defpath)
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8123 gtk_file_selection_set_filename(GTK_FILE_SELECTION(filew), defpath);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8124
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8125 gtk_widget_show(filew);
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8126
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8127 DW_MUTEX_UNLOCK;
482
89b1b40d7e12 Initial port of the OS/2 folder browser to unix. dw_tree_get_parent()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 480
diff changeset
8128 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
8129 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8130 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8131
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8132
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8133 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8134 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8135 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8136 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8137 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8138 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8139 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8140 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8141 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8142 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8143 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8144 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8145
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8146 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8147 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8148 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8149
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8150 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8151 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8152 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8153 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8154 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8155 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8156 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8157 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8158 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8159 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8161 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8162 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8163 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8164 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8165 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8166 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8167 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8168 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8169
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8170 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8171 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8172 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8173 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8174 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8175 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8176 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8177 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8178 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8179 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8180 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8181 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8183 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8184 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8185 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8186 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8187 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8188 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8189 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8190 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8191 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8192 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8193
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8194 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8195 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8196 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8197 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8198 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8199 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8200 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8201 /* Is there a way to find the webbrowser in Unix? */
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
8202 char *execargs[3], *browser = "netscape", *tmp;
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
8203
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
8204 tmp = getenv( "DW_BROWSER" );
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
8205 if(tmp) browser = tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8206 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8207 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8208 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8209
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8210 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8211 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8212
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8213 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8214 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8215 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8216 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8217 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8218 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8220 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8222 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8223 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8224 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8225
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8226 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8227 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8228 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8229 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8231 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8233
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8234 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8235 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8236 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8237 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8238 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8239 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8240 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8241 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8242 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8243 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8244
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8245 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8246
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8247 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8248 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8249 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8250
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8251 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8252 * 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
8253 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8254 * 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
8255 * 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
8256 * 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
8257 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8258 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
8259 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8260 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
8261
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8262 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
8263 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8264
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8265 DW_MUTEX_LOCK;
112
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8266 if(GTK_IS_OBJECT(window))
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8267 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8268 if(GTK_IS_SCROLLED_WINDOW(window))
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8269 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8270 HWND thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8271
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8272 if(thiswindow && GTK_IS_OBJECT(thiswindow))
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8273 gtk_object_set_data(GTK_OBJECT(thiswindow), dataname, (gpointer)data);
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8274 }
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8275 if(GTK_IS_COMBO(window))
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8276 gtk_object_set_data(GTK_OBJECT(GTK_COMBO(window)->entry), dataname, (gpointer)data);
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8277 gtk_object_set_data(GTK_OBJECT(window), dataname, (gpointer)data);
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8278 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8279 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
8280 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8281
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8282 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8283 * 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
8284 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8285 * 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
8286 * 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
8287 * 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
8288 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8289 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
8290 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8291 int _locked_by_me = FALSE;
112
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8292 void *ret = NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8293
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8294 if(!window)
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
8295 return NULL;
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8296
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8297 DW_MUTEX_LOCK;
112
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8298 if(GTK_IS_OBJECT(window))
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
8299 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
8300 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
8301 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
8302 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
8303
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8304 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8305 * Add a callback to a timer event.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8306 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8307 * interval: Milliseconds to delay between calls.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8308 * sigfunc: The pointer to the function to be used as the callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8309 * data: User data to be passed to the handler function.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8310 * Returns:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8311 * Timer ID for use with dw_timer_disconnect(), 0 on error.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8312 */
199
b955228477b3 Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 198
diff changeset
8313 int API dw_timer_connect(int interval, void *sigfunc, void *data)
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8314 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8315 int tag, _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8316
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8317 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8318 tag = gtk_timeout_add(interval, (GtkFunction)sigfunc, data);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8319 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8320 return tag;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8321 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8322
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8323 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8324 * Removes timer callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8325 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8326 * id: Timer ID returned by dw_timer_connect().
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8327 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8328 void API dw_timer_disconnect(int id)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8329 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8330 int _locked_by_me = FALSE;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8331
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8332 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8333 gtk_timeout_remove(id);
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8334 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8335 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8336
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8337 /* Get the actual signal window handle not the user window handle
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8338 * Should mimic the code in dw_signal_connect() below.
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8339 */
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8340 static HWND _find_signal_window(HWND window, char *signame)
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8341 {
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8342 HWND thiswindow = window;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8343
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8344 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8345 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8346 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8347 thiswindow = GTK_COMBO(thiswindow)->list;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8348 else if(GTK_IS_COMBO(thiswindow) && signame && strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8349 thiswindow = GTK_COMBO(thiswindow)->entry;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8350 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) ||
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8351 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow))
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8352 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment");
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8353 #if GTK_MAJOR_VERSION > 1
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8354 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8355 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8356 #endif
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8357 return thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8358 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8359
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
8360 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8361 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8362 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8363 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8364 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8365 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8366 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8367 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8368 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8369 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8370 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8371 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8372 HWND thiswindow = window;
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8373 int sigid, _locked_by_me = FALSE;
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8374 gint cid;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8375
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8376 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8377 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8378 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8379 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8380 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8381
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8382 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8383 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8384 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8385 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8386 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8387 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8388 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8389 thisname = "button_press_event";
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8390 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8391 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8392 #if GTK_MAJOR_VERSION > 1
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8393 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8394 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8395 thisfunc = _findsigfunc("tree-context");
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8396 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8397 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8398 _set_signal_handler_id(thiswindow, sigid, cid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8399 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8400 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8401 _set_signal_handler_id(window, sigid, cid);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8402 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8403 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8404 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8405 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8406 {
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
8407 GtkWidget *treeview = thiswindow;
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
8408
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8409 thiswindow = (GtkWidget *)gtk_tree_view_get_selection(GTK_TREE_VIEW(thiswindow));
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8410 thisname = "changed";
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8411
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8412 sigid = _set_signal_handler(treeview, window, sigfunc, data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8413 cid = g_signal_connect(G_OBJECT(thiswindow), thisname, (GCallback)thisfunc, (gpointer)sigid);
422
3269c10bc243 Using GtkTreeSelection instead of GtkTreeView in the signal handler code
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 420
diff changeset
8414 _set_signal_handler_id(treeview, sigid, cid);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8415 DW_MUTEX_UNLOCK;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8416 return;
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8417 }
478
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
8418 else if(GTK_IS_TREE_VIEW(thiswindow) && strcmp(signame, DW_SIGNAL_TREE_EXPAND) == 0)
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
8419 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
8420 thisname = "row-expanded";
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
8421 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8422 #else
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8423 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8424 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
8425 thisfunc = _findsigfunc("tree-context");
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8426 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
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
8427
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8428 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_func", (gpointer)thisfunc);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8429 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_container_context_data", (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8430 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8431 _set_signal_handler_id(thiswindow, sigid, cid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8432 sigid = _set_signal_handler(window, window, sigfunc, data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8433 cid = gtk_signal_connect(GTK_OBJECT(window), "button_press_event", GTK_SIGNAL_FUNC(thisfunc), (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8434 _set_signal_handler_id(window, sigid, cid);
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
8435 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
8436 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
8437 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8438 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8439 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8440 if(thisfunc)
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8441 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8442 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8443 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_func", (gpointer)thisfunc);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8444 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_select_child_data", (gpointer)sigid);
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8445 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8446 thisname = "select-child";
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8447 }
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8448 else if(GTK_IS_TREE(thiswindow) && strcmp(signame, DW_SIGNAL_TREE_EXPAND) == 0)
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8449 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8450 if(thisfunc)
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8451 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8452 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8453 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_tree_item_expand_func", (gpointer)thisfunc);
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8454 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_tree_item_expand_data", (gpointer)sigid);
483
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8455 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8456 DW_MUTEX_UNLOCK;
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8457 return;
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
8458 }
140
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
8459 #endif
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8460 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8462 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, _container_enter_event);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8463 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), "key_press_event", GTK_SIGNAL_FUNC(_container_enter_event), (gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8464 _set_signal_handler_id(thiswindow, sigid, cid);
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
8465
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466 thisname = "button_press_event";
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8467 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_ENTER);
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8468 }
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8469 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_SELECT) == 0)
164
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
8470 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
8471 thisname = "select_row";
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
8472 thisfunc = (void *)_container_select_row;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
8473 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8474 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8475 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8476 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8477 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8478 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8479 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8480 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8481 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8482 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8483 else if(strcmp(signame, DW_SIGNAL_SET_FOCUS) == 0)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
8484 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
8485 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
8486 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
8487 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
8488 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8489 #if 0
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8490 else if(strcmp(signame, DW_SIGNAL_LOSE_FOCUS) == 0)
55
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
8491 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
8492 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
8493 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
8494 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
8495 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
8496 #endif
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
8497 else if(GTK_IS_VSCALE(thiswindow) || GTK_IS_HSCALE(thiswindow) ||
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
8498 GTK_IS_VSCROLLBAR(thiswindow) || GTK_IS_HSCROLLBAR(thiswindow))
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
8499 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8500 thiswindow = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_adjustment");
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
8501 }
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
8502 else if(GTK_IS_NOTEBOOK(thiswindow) && strcmp(signame, DW_SIGNAL_SWITCH_PAGE) == 0)
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
8503 {
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
8504 thisname = "switch-page";
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
8505 }
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
8506 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_COLUMN_CLICK) == 0)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
8507 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
8508 thisname = "click-column";
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
8509 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8513 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8514 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8515 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8517 sigid = _set_signal_handler(thiswindow, window, sigfunc, data, thisfunc);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8518 cid = gtk_signal_connect(GTK_OBJECT(thiswindow), thisname, GTK_SIGNAL_FUNC(thisfunc),(gpointer)sigid);
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8519 _set_signal_handler_id(thiswindow, sigid, cid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8521 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8522
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8523 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8524 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8525 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8528 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8529 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8530 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8531 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8532 void *thisfunc;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8533 int _locked_by_me = FALSE;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8534
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8535 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8536 thiswindow = _find_signal_window(window, signame);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8537 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8538 thisfunc = _findsigfunc(signame);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8539
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8540 for(z=0;z<count;z++)
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8541 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8542 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8543
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8544 if(sh.intfunc == thisfunc)
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8545 _remove_signal_handler(thiswindow, z);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8546 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8547 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8548 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8549
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8550 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8551 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8553 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8557 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8558 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8559 int _locked_by_me = FALSE;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8560
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8561 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8562 thiswindow = _find_signal_window(window, NULL);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8563 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8564
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8565 for(z=0;z<count;z++)
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8566 _remove_signal_handler(thiswindow, z);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8567 gtk_object_set_data(GTK_OBJECT(thiswindow), "_dw_sigcounter", NULL);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8568 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8569 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8570
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8571 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8572 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8573 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8574 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8576 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8577 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8579 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8580 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8581 int _locked_by_me = FALSE;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8582
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8583 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8584 thiswindow = _find_signal_window(window, NULL);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8585 count = (int)gtk_object_get_data(GTK_OBJECT(thiswindow), "_dw_sigcounter");
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8586
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8587 for(z=0;z<count;z++)
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8588 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8589 SignalHandler sh = _get_signal_handler(thiswindow, (gpointer)z);
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8590
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
8591 if(sh.data == data)
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8592 _remove_signal_handler(thiswindow, z);
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8593 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8594 DW_MUTEX_UNLOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8595 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
8596