annotate gtk/dw.c @ 612:c5e5671dec8f

Modify Calendar widget Amke Mac port actually compile and run Add Clipboard support for GTK and Win Add *from_data() contructors allowing icons, bitmaps to be created from embedded data.
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 23 Mar 2008 04:54:30 +0000
parents 2bff0dbae0e5
children fb59f9eeeecd
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 *
516
caa7ed17c132 Updated copyrights and license file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 515
diff changeset
6 * (C) 2000-2004 Brian Smith <dbsoft@technologist.com>
caa7ed17c132 Updated copyrights and license file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 515
diff changeset
7 * (C) 2003-2004 Mark Hessling <m.hessling@qut.edu.au>
524
55c9fa60af78 Included Nickolay V. Shmyrev's full name in the license and source files.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 521
diff changeset
8 * (C) 2002 Nickolay V. Shmyrev <shmyrev@yandex.ru>
3
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>
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
21 #include <signal.h>
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
22 #include <sys/socket.h>
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
23 #include <sys/un.h>
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
24 #include <sys/mman.h>
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
25 #include <fcntl.h>
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
26 #include <unistd.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
27 #include "config.h"
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
28 #include <gdk/gdkkeysyms.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
29 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
30 #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
31 #endif
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
32 #ifdef USE_GTKMOZEMBED
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
33 #include <gtkmozembed.h>
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
34 #undef GTK_TYPE_MOZ_EMBED
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
35 #define GTK_TYPE_MOZ_EMBED (_dw_moz_embed_get_type())
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
36 #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
37 #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
38 #include <gdk-pixbuf/gdk-pixbuf.h>
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
39 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
40
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
41 #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
42 #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
43 #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
44 #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
45
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
46 /* These are used for resource management */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
47 #if defined(DW_RESOURCES) && !defined(BUILD_DLL)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
48 extern DWResources _resources;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
49 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
50
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
51 GdkColor _colors[] =
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
52 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
53 { 0, 0x0000, 0x0000, 0x0000 }, /* 0 black */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
54 { 0, 0xbbbb, 0x0000, 0x0000 }, /* 1 red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
55 { 0, 0x0000, 0xbbbb, 0x0000 }, /* 2 green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
56 { 0, 0xaaaa, 0xaaaa, 0x0000 }, /* 3 yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
57 { 0, 0x0000, 0x0000, 0xcccc }, /* 4 blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
58 { 0, 0xbbbb, 0x0000, 0xbbbb }, /* 5 magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
59 { 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
60 { 0, 0xbbbb, 0xbbbb, 0xbbbb }, /* 7 white */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
61 { 0, 0x7777, 0x7777, 0x7777 }, /* 8 grey */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
62 { 0, 0xffff, 0x0000, 0x0000 }, /* 9 bright red */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
63 { 0, 0x0000, 0xffff, 0x0000 }, /* 10 bright green */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
64 { 0, 0xeeee, 0xeeee, 0x0000 }, /* 11 bright yellow */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
65 { 0, 0x0000, 0x0000, 0xffff }, /* 12 bright blue */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
66 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
67 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
68 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
69 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
70
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
71 #define NUM_EXTS 5
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
72 char *image_exts[NUM_EXTS] =
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
73 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
74 ".xpm",
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
75 ".png",
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
76 ".bmp",
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
77 ".jpg",
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
78 ".ico",
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
79 };
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
80
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
81 #define DW_THREAD_LIMIT 50
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
82
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
83 #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
84 # 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
85 #endif
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
86
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
87 #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
88 # 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
89 #endif
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
90
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
91 DWTID _dw_thread_list[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
92 GdkColor _foreground[DW_THREAD_LIMIT];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
93 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
94 int _transparent[DW_THREAD_LIMIT];
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
95 GtkClipboard *_clipboard_object[DW_THREAD_LIMIT];
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
96 gchar *_clipboard_contents[DW_THREAD_LIMIT];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
97
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
98 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
99
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
100 static int _dw_file_active = 0, _dw_ignore_click = 0, _dw_ignore_expand = 0, _dw_color_active = 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
101 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
102 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
103 /* 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
104 static int _dw_border_width = 12, _dw_border_height = 28;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
105
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
106 #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
107 #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
108
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
109 #define DEFAULT_SIZE_WIDTH 12
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
110 #define DEFAULT_SIZE_HEIGHT 6
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
111 #define DEFAULT_TITLEBAR_HEIGHT 22
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
112
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
113 static GdkColormap *_dw_cmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
114
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
115 /* 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
116 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
117 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
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130 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
131 #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
132 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
133 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
134 #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
135 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
136 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
137 #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
138 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
139 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
140
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
141 /* Embedable Mozilla functions*/
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
142 #ifdef USE_GTKMOZEMBED
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
143 void (*_gtk_moz_embed_go_back)(GtkMozEmbed *) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
144 void (*_gtk_moz_embed_go_forward)(GtkMozEmbed *) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
145 void (*_gtk_moz_embed_load_url)(GtkMozEmbed *, const char *) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
146 void (*_gtk_moz_embed_reload)(GtkMozEmbed *, guint32) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
147 void (*_gtk_moz_embed_stop_load)(GtkMozEmbed *) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
148 void (*_gtk_moz_embed_render_data)(GtkMozEmbed *, const char *, guint32, const char *, const char *) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
149 GtkWidget *(*_gtk_moz_embed_new)(void) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
150 GtkType (*_dw_moz_embed_get_type)(void) = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
151 #endif
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
152
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
153 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
154 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
155 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
156 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
157 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
158 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
159 #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
160 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
161 #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
162 } DWPrivatePixmap;
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
163
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
164 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
165 static int _PixmapCount = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
166
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
167 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
168 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
169 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
170 char name[30];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
171
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
172 } SignalList;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
173
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
174 typedef struct
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
175 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
176 HWND window;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
177 void *func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
178 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
179 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
180 void *intfunc;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
181
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
182 } SignalHandler;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
183
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
184 #define SIGNALMAX 19
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
185
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
186 /* 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
187 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
188 { _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
189 { _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
190 { _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
191 { _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
192 { _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
193 { _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
194 { _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
195 { _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
196 { _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
197 { _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
198 { _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
199 { _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
200 { _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
201 { _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
202 { _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
203 { _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
204 { _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
205 { _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
206 { _tree_expand_event, DW_SIGNAL_TREE_EXPAND }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
207 };
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
208
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
209 /* Alignment flags */
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
210 #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
211 #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
212 #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
213
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
214 /* MDI Support Code */
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
215 #if GTK_MAJOR_VERSION > 1
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
216 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
217 #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
218 #define GTK_IS_MDI(obj) GTK_CHECK_TYPE (obj, gtk_mdi_get_type ())
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
219
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
220 typedef struct _GtkMdi GtkMdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
221 typedef struct _GtkMdiClass GtkMdiClass;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
222 typedef struct _GtkMdiDragInfo GtkMdiDragInfo;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
223 typedef enum _GtkMdiChildState GtkMdiChildState;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
224
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
225 enum _GtkMdiChildState
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
226 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
227 CHILD_NORMAL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
228 CHILD_MAXIMIZED,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
229 CHILD_ICONIFIED
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
230 };
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
231
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
232 struct _GtkMdi
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
233 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
234 GtkContainer container;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
235 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
236
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
237 GdkPoint drag_start;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
238 gint drag_button;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
239 };
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
240
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
241 struct _GtkMdiClass
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
242 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
243 GtkContainerClass parent_class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
244
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
245 void (*mdi) (GtkMdi * mdi);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
246 };
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
247
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
248 #include "gtk/maximize.xpm"
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
249 #include "gtk/minimize.xpm"
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
250 #include "gtk/kill.xpm"
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
251
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
252 #define GTK_MDI_BACKGROUND "Grey70"
517
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
253 #define GTK_MDI_LABEL_BACKGROUND "RoyalBlue4"
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
254 #define GTK_MDI_LABEL_FOREGROUND "white"
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
255 #define GTK_MDI_DEFAULT_WIDTH 0
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
256 #define GTK_MDI_DEFAULT_HEIGHT 0
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
257 #define GTK_MDI_MIN_HEIGHT 22
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
258 #define GTK_MDI_MIN_WIDTH 55
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
259
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
260 typedef struct _GtkMdiChild GtkMdiChild;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
261
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
262 struct _GtkMdiChild
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
263 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
264 GtkWidget *widget;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
265
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
266 GtkWidget *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
267 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
268
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
269 gint x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
270 gint y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
271 gint width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
272 gint height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
273
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
274 GtkMdiChildState state;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
275 };
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
276
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
277 static void gtk_mdi_class_init(GtkMdiClass *klass);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
278 static void gtk_mdi_init(GtkMdi *mdi);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
279
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
280 static void gtk_mdi_realize(GtkWidget *widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
281 static void gtk_mdi_size_request(GtkWidget *widget, GtkRequisition *requisition);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
282 static void gtk_mdi_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
283 static gint gtk_mdi_expose(GtkWidget *widget, GdkEventExpose *event);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
284
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
285 /* Callbacks */
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
286 static gboolean move_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
287 static gboolean resize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
288 static gboolean iconify_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
289 static gboolean maximize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
290 static gboolean kill_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
291
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
292 static void gtk_mdi_add(GtkContainer *container, GtkWidget *widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
293 static void gtk_mdi_remove_true(GtkContainer *container, GtkWidget *widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
294 static void gtk_mdi_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
295
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
296 static GtkMdiChild *get_child(GtkMdi *mdi, GtkWidget * widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
297
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
298 static GtkType gtk_mdi_get_type(void)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
299 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
300 static GType mdi_type = 0;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
301
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
302 if (!mdi_type)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
303 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
304
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
305 static const GTypeInfo mdi_info =
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
306 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
307 sizeof (GtkMdiClass),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
308 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
309 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
310 (GClassInitFunc) gtk_mdi_class_init,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
311 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
312 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
313 sizeof (GtkMdi),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
314 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
315 (GInstanceInitFunc) gtk_mdi_init,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
316 };
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
317
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
318 mdi_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkMdi", &mdi_info, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
319 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
320
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
321 return mdi_type;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
322 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
323
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
324 /* Local data */
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
325 static GtkWidgetClass *parent_class = NULL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
326
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
327 static void gtk_mdi_class_init(GtkMdiClass *class)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
328 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
329 GObjectClass *object_class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
330 GtkWidgetClass *widget_class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
331 GtkContainerClass *container_class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
332
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
333 object_class = (GObjectClass *) class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
334 widget_class = (GtkWidgetClass *) class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
335 container_class = (GtkContainerClass *) class;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
336
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
337 parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
338
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
339 widget_class->realize = gtk_mdi_realize;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
340 widget_class->expose_event = gtk_mdi_expose;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
341 widget_class->size_request = gtk_mdi_size_request;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
342 widget_class->size_allocate = gtk_mdi_size_allocate;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
343
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
344 container_class->add = gtk_mdi_add;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
345 container_class->remove = gtk_mdi_remove_true;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
346 container_class->forall = gtk_mdi_forall;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
347 class->mdi = NULL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
348 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
349
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
350 static void gtk_mdi_init(GtkMdi *mdi)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
351 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
352 mdi->drag_button = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
353 mdi->children = NULL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
354 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
355
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
356 static GtkWidget *gtk_mdi_new(void)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
357 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
358 GtkWidget *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
359 GdkColor background;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
360
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
361 mdi = GTK_WIDGET (g_object_new (gtk_mdi_get_type (), NULL));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
362 gdk_color_parse (GTK_MDI_BACKGROUND, &background);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
363 gtk_widget_modify_bg (mdi, GTK_STATE_NORMAL, &background);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
364
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
365 return mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
366 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
367
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
368 static void gtk_mdi_put(GtkMdi *mdi, GtkWidget *child_widget, gint x, gint y, GtkWidget *label)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
369 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
370 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
371
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
372 GtkWidget *table;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
373 GtkWidget *button[3];
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
374
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
375 GtkWidget *child_box;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
376 GtkWidget *top_event_box;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
377 GtkWidget *bottom_event_box;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
378 GtkWidget *child_widget_box;
517
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
379 GtkWidget *image;
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
380
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
381 GdkColor color;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
382 gint i, j;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
383 GdkCursor *cursor;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
384 GdkColormap *colormap;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
385 GdkPixmap *pixmap;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
386 GdkBitmap *mask;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
387 GtkStyle *style;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
388
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
389 child_box = gtk_event_box_new ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
390 child_widget_box = gtk_event_box_new ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
391 top_event_box = gtk_event_box_new ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
392 bottom_event_box = gtk_event_box_new ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
393 table = gtk_table_new (4, 7, FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
394 gtk_table_set_row_spacings (GTK_TABLE (table), 1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
395 gtk_table_set_col_spacings (GTK_TABLE (table), 1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
396 gtk_table_set_row_spacing (GTK_TABLE (table), 3, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
397 gtk_table_set_col_spacing (GTK_TABLE (table), 6, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
398 gtk_table_set_row_spacing (GTK_TABLE (table), 2, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
399 gtk_table_set_col_spacing (GTK_TABLE (table), 5, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
400
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
401 for (i = 0; i < 3; i++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
402 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
403 button[i] = gtk_event_box_new ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
404 gtk_widget_set_events (button[0], GDK_BUTTON_PRESS_MASK);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
405 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
406
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
407 gdk_color_parse (GTK_MDI_LABEL_BACKGROUND, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
408
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
409 gtk_widget_modify_bg (top_event_box, GTK_STATE_NORMAL, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
410 gtk_widget_modify_bg (bottom_event_box, GTK_STATE_NORMAL, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
411 gtk_widget_modify_bg (child_box, GTK_STATE_NORMAL, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
412 for (i = GTK_STATE_NORMAL; i < GTK_STATE_ACTIVE; i++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
413 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
414 for (j = 0; j < 3; j++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
415 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
416 gtk_widget_modify_bg (button[j], i, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
417 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
418 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
419 gdk_color_parse (GTK_MDI_LABEL_FOREGROUND, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
420 gtk_widget_modify_fg (label, GTK_STATE_NORMAL, &color);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
421 gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
422
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
423 gtk_container_add (GTK_CONTAINER (top_event_box), label);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
424 gtk_container_add (GTK_CONTAINER (child_widget_box), child_widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
425 gtk_widget_set_size_request (bottom_event_box, 2, 2);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
426
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
427
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
428 style = gtk_widget_get_default_style ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
429 colormap = gdk_colormap_get_system ();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
430 pixmap = gdk_pixmap_colormap_create_from_xpm_d (NULL, colormap, &mask,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
431 &style->bg[GTK_STATE_NORMAL],
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
432 (gchar **) minimize_xpm);
517
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
433 image = gtk_image_new_from_pixmap (pixmap, mask);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
434 gtk_widget_show(image);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
435 gtk_container_add (GTK_CONTAINER (button[0]), image);
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
436 pixmap = gdk_pixmap_colormap_create_from_xpm_d (GTK_WIDGET (mdi)->window, colormap, &mask,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
437 &style->bg[GTK_STATE_NORMAL],
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
438 (gchar **) maximize_xpm);
517
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
439 image = gtk_image_new_from_pixmap (pixmap, mask);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
440 gtk_widget_show(image);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
441 gtk_container_add (GTK_CONTAINER (button[1]), image);
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
442 pixmap = gdk_pixmap_colormap_create_from_xpm_d (GTK_WIDGET (mdi)->window, colormap, &mask,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
443 &style->bg[GTK_STATE_NORMAL],
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
444 (gchar **) kill_xpm);
517
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
445 image = gtk_image_new_from_pixmap (pixmap, mask);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
446 gtk_widget_show(image);
63e5812d64ba Need to show the images for the MDI window buttons, since we don't use
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 516
diff changeset
447 gtk_container_add (GTK_CONTAINER (button[2]), image);
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
448
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
449 gtk_table_attach (GTK_TABLE (table), child_widget_box, 1, 6, 2, 3,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
450 GTK_EXPAND | GTK_SHRINK | GTK_FILL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
451 GTK_EXPAND | GTK_SHRINK | GTK_FILL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
452 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
453 gtk_table_attach (GTK_TABLE (table), top_event_box, 1, 2, 1, 2,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
454 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
455 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
456 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
457 gtk_table_attach (GTK_TABLE (table), bottom_event_box, 6, 7, 3, 4,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
458 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
459 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
460 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
461 gtk_table_attach (GTK_TABLE (table), button[0], 2, 3, 1, 2,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
462 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
463 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
464 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
465 gtk_table_attach (GTK_TABLE (table), button[1], 3, 4, 1, 2,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
466 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
467 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
468 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
469 gtk_table_attach (GTK_TABLE (table), button[2], 4, 5, 1, 2,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
470 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
471 0,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
472 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
473
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
474 gtk_container_add (GTK_CONTAINER (child_box), table);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
475
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
476 child = g_new (GtkMdiChild, 1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
477 child->widget = child_box;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
478 child->x = x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
479 child->y = y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
480 child->width = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
481 child->height = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
482 child->child = child_widget;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
483 child->mdi = mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
484 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
485
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
486 gtk_widget_set_parent (child_box, GTK_WIDGET (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
487 mdi->children = g_list_append (mdi->children, child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
488
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
489 gtk_widget_show (child_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
490 gtk_widget_show (table);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
491 gtk_widget_show (top_event_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
492 gtk_widget_show (bottom_event_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
493 gtk_widget_show (child_widget_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
494 for (i = 0; i < 3; i++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
495 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
496 gtk_widget_show (button[i]);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
497 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
498
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
499 cursor = gdk_cursor_new (GDK_HAND1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
500 gtk_widget_realize (top_event_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
501 gdk_window_set_cursor (top_event_box->window, cursor);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
502 cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
503 gtk_widget_realize (bottom_event_box);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
504 gdk_window_set_cursor (bottom_event_box->window, cursor);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
505
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
506 g_signal_connect (G_OBJECT (top_event_box), "event",
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
507 G_CALLBACK (move_child_callback),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
508 child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
509 g_signal_connect (G_OBJECT (bottom_event_box), "event",
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
510 G_CALLBACK (resize_child_callback),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
511 child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
512 g_signal_connect (G_OBJECT (button[0]), "button_press_event",
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
513 G_CALLBACK (iconify_child_callback),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
514 child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
515 g_signal_connect (G_OBJECT (button[1]), "button_press_event",
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
516 G_CALLBACK (maximize_child_callback),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
517 child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
518 g_signal_connect (G_OBJECT (button[2]), "button_press_event",
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
519 G_CALLBACK (kill_child_callback),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
520 child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
521 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
522
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
523 static void gtk_mdi_move(GtkMdi *mdi, GtkWidget *widget, gint x, gint y)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
524 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
525 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
526
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
527 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
528 g_return_if_fail (GTK_IS_WIDGET (widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
529
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
530 child = get_child (mdi, widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
531 g_return_if_fail (child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
532
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
533 child->x = x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
534 child->y = y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
535 if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (mdi))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
536 gtk_widget_queue_resize (GTK_WIDGET (widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
537 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
538
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
539 static void gtk_mdi_get_pos(GtkMdi *mdi, GtkWidget *widget, gint *x, gint *y)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
540 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
541 GtkMdiChild *child;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
542
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
543 g_return_if_fail (GTK_IS_MDI (mdi));
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
544 g_return_if_fail (GTK_IS_WIDGET (widget));
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
545
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
546 child = get_child (mdi, widget);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
547 g_return_if_fail (child);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
548
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
549 *x = child->x;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
550 *y = child->y;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
551 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
552
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
553 static void gtk_mdi_tile(GtkMdi *mdi)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
554 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
555 int i, n;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
556 int width, height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
557 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
558 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
559
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
560 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
561
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
562 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
563 n = g_list_length (children);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
564 width = GTK_WIDGET (mdi)->allocation.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
565 height = GTK_WIDGET (mdi)->allocation.height / n;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
566 for (i = 0; i < n; i++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
567 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
568 child = (GtkMdiChild *) children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
569 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
570 child->x = 0;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
571 child->y = i * height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
572 gtk_widget_set_size_request (child->widget, width, height);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
573 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
574 child->width = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
575 child->height = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
576 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
577 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (mdi)))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
578 gtk_widget_queue_resize (GTK_WIDGET (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
579 return;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
580 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
581 static void gtk_mdi_cascade(GtkMdi *mdi)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
582 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
583 int i, n;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
584 int width, height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
585 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
586 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
587
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
588 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
589 if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (mdi)))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
590 return;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
591
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
592 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
593 n = g_list_length (children);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
594 width = GTK_WIDGET (mdi)->allocation.width / (2 * n - 1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
595 height = GTK_WIDGET (mdi)->allocation.height / (2 * n - 1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
596 for (i = 0; i < n; i++)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
597 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
598 child = (GtkMdiChild *) children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
599 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
600 child->x = i * width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
601 child->y = i * height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
602 gtk_widget_set_size_request (child->widget, width * n, height * n);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
603 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
604 child->width = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
605 child->height = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
606 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
607 if (GTK_WIDGET_VISIBLE (GTK_WIDGET (mdi)))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
608 gtk_widget_queue_resize (GTK_WIDGET (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
609 return;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
610 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
611
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
612 static GtkMdiChildState gtk_mdi_get_state(GtkMdi *mdi, GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
613 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
614 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
615
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
616 g_return_val_if_fail (GTK_IS_MDI (mdi), CHILD_NORMAL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
617 g_return_val_if_fail (GTK_IS_WIDGET (widget), CHILD_NORMAL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
618
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
619 child = get_child (mdi, widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
620 g_return_val_if_fail (child, CHILD_NORMAL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
621
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
622 return child->state;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
623 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
624
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
625 static void gtk_mdi_set_state(GtkMdi *mdi, GtkWidget *widget, GtkMdiChildState state)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
626 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
627 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
628
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
629 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
630 g_return_if_fail (GTK_IS_WIDGET (widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
631
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
632 child = get_child (mdi, widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
633 g_return_if_fail (child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
634
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
635 child->state = state;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
636 if (GTK_WIDGET_VISIBLE (child->widget) && GTK_WIDGET_VISIBLE (mdi))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
637 gtk_widget_queue_resize (GTK_WIDGET (child->widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
638 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
639
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
640 static void gtk_mdi_remove(GtkMdi *mdi, GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
641 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
642 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
643
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
644 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
645 child = get_child (mdi, widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
646 g_return_if_fail (child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
647 gtk_mdi_remove_true (GTK_CONTAINER (mdi), child->widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
648 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
649
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
650 static void gtk_mdi_realize(GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
651 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
652 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
653 GdkWindowAttr attributes;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
654 gint attributes_mask;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
655
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
656 mdi = GTK_MDI (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
657
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
658 g_return_if_fail (widget != NULL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
659 g_return_if_fail (GTK_IS_MDI (mdi));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
660
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
661 GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
662
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
663 attributes.x = widget->allocation.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
664 attributes.y = widget->allocation.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
665 attributes.width = widget->allocation.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
666 attributes.height = widget->allocation.height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
667 attributes.wclass = GDK_INPUT_OUTPUT;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
668 attributes.window_type = GDK_WINDOW_CHILD;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
669 attributes.event_mask = gtk_widget_get_events (widget) |
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
670 GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK |
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
671 GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK |
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
672 GDK_POINTER_MOTION_HINT_MASK;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
673 attributes.visual = gtk_widget_get_visual (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
674 attributes.colormap = gtk_widget_get_colormap (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
675
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
676 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
677 widget->window = gdk_window_new (widget->parent->window, &attributes, attributes_mask);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
678
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
679 widget->style = gtk_style_attach (widget->style, widget->window);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
680
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
681 gdk_window_set_user_data (widget->window, widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
682
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
683 gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
684 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
685
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
686 static void gtk_mdi_size_request (GtkWidget *widget, GtkRequisition *requisition)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
687 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
688 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
689 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
690 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
691 GtkRequisition child_requisition;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
692
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
693 mdi = GTK_MDI (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
694 requisition->width = GTK_MDI_DEFAULT_WIDTH;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
695 requisition->height = GTK_MDI_DEFAULT_HEIGHT;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
696
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
697 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
698 while (children)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
699 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
700 child = children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
701 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
702
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
703 if (GTK_WIDGET_VISIBLE (child->widget))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
704 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
705 gtk_widget_size_request (child->widget, &child_requisition);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
706 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
707 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
708 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
709
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
710 static void gtk_mdi_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
711 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
712 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
713 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
714 GtkAllocation child_allocation;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
715 GtkRequisition child_requisition;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
716 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
717
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
718 mdi = GTK_MDI (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
719
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
720 widget->allocation = *allocation;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
721
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
722 if (GTK_WIDGET_REALIZED (widget))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
723 gdk_window_move_resize (widget->window,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
724 allocation->x,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
725 allocation->y,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
726 allocation->width,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
727 allocation->height);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
728
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
729
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
730 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
731 while (children)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
732 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
733 child = children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
734 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
735
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
736 if (GTK_WIDGET_VISIBLE (child->widget))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
737 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
738 gtk_widget_get_child_requisition (child->widget, &child_requisition);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
739 child_allocation.x = 0;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
740 child_allocation.y = 0;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
741 switch (child->state)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
742 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
743 case CHILD_NORMAL:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
744 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
745 if ((child->width < 0) && (child->height < 0))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
746 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
747 child_allocation.width = child_requisition.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
748 child_allocation.height = child_requisition.height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
749 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
750 else
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
751 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
752 child_allocation.width = child->width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
753 child_allocation.height = child->height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
754 child->width = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
755 child->height = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
756 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
757 child_allocation.x += child->x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
758 child_allocation.y += child->y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
759 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
760 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
761 case CHILD_MAXIMIZED:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
762 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
763 if ((child->width < 0) && (child->height < 0))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
764 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
765 child->width = child_requisition.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
766 child->height = child_requisition.height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
767 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
768 child_allocation.width = allocation->width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
769 child_allocation.height = allocation->height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
770 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
771 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
772 case CHILD_ICONIFIED:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
773 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
774 if ((child->width < 0) && (child->height < 0))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
775 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
776 child->width = child_requisition.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
777 child->height = child_requisition.height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
778 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
779 child_allocation.x += child->x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
780 child_allocation.y += child->y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
781 child_allocation.width = child_requisition.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
782 child_allocation.height = GTK_MDI_MIN_HEIGHT;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
783 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
784 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
785 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
786 gtk_widget_size_allocate (child->widget, &child_allocation);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
787 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
788 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
789 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
790
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
791 static gint gtk_mdi_expose(GtkWidget *widget, GdkEventExpose *event)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
792 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
793 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
794 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
795 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
796
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
797 g_return_val_if_fail (widget != NULL, FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
798 g_return_val_if_fail (GTK_IS_MDI (widget), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
799 g_return_val_if_fail (event != NULL, FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
800
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
801 mdi = GTK_MDI (widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
802 for (children = mdi->children; children; children = children->next)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
803 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
804 child = (GtkMdiChild *) children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
805 gtk_container_propagate_expose (GTK_CONTAINER (mdi),
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
806 child->widget,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
807 event);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
808 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
809 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
810 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
811
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
812 static void gtk_mdi_add(GtkContainer *container, GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
813 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
814 GtkWidget *label;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
815 label = gtk_label_new ("");
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
816 gtk_mdi_put (GTK_MDI (container), widget, 0, 0, label);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
817 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
818
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
819 static void gtk_mdi_remove_true(GtkContainer *container, GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
820 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
821 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
822 GtkMdiChild *child = NULL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
823 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
824
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
825 mdi = GTK_MDI (container);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
826
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
827 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
828 while (children)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
829 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
830 child = children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
831 if (child->widget == widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
832 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
833
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
834 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
835 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
836
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
837 if(child)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
838 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
839 gtk_widget_unparent (child->widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
840 g_free (child);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
841 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
842 mdi->children = g_list_remove_link (mdi->children, children);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
843 g_list_free (children);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
844 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
845
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
846 static void gtk_mdi_forall(GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
847 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
848 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
849 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
850 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
851
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
852 g_return_if_fail (callback != NULL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
853
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
854 mdi = GTK_MDI (container);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
855
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
856 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
857 while (children)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
858 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
859 child = children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
860 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
861
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
862 (*callback) (child->widget, callback_data);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
863 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
864 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
865
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
866 static gboolean move_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
867 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
868 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
869 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
870
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
871 child = (GtkMdiChild *) data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
872 mdi = child->mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
873
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
874 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
875 g_return_val_if_fail (GTK_IS_EVENT_BOX (widget), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
876
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
877
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
878 switch (event->type)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
879 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
880 case GDK_2BUTTON_PRESS:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
881 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
882 gdk_window_raise (child->widget->window);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
883 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
884 case GDK_BUTTON_PRESS:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
885 if (child->state == CHILD_MAXIMIZED)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
886 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
887 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
888 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
889 if (gdk_pointer_grab (event->button.window,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
890 FALSE,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
891 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
892 GDK_BUTTON_RELEASE_MASK,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
893 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
894 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
895 event->button.time) != GDK_GRAB_SUCCESS)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
896 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
897
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
898 mdi->drag_button = event->button.button;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
899
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
900 mdi->drag_start.x = event->button.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
901 mdi->drag_start.y = event->button.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
902 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
903 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
904
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
905 case GDK_BUTTON_RELEASE:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
906 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
907 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
908
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
909 if (mdi->drag_button == event->button.button)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
910 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
911 int x, y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
912
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
913 gdk_pointer_ungrab (event->button.time);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
914 mdi->drag_button = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
915
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
916 x = event->button.x + child->x - mdi->drag_start.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
917 y = event->button.y + child->y - mdi->drag_start.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
918
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
919 gtk_mdi_move (mdi, child->child, x, y);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
920 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
921 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
922
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
923 case GDK_MOTION_NOTIFY:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
924 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
925 int x, y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
926
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
927 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
928 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
929
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
930 gdk_window_get_pointer (widget->window, &x, &y, NULL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
931
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
932
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
933 x = x - mdi->drag_start.x + child->x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
934 y = y - mdi->drag_start.y + child->y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
935
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
936
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
937 gtk_mdi_move (mdi, child->child, x, y);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
938 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
939 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
940
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
941 default:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
942 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
943 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
944
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
945 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
946 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
947
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
948 static gboolean resize_child_callback(GtkWidget *widget, GdkEvent *event, gpointer data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
949 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
950 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
951 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
952
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
953 child = (GtkMdiChild *) data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
954 mdi = child->mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
955
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
956 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
957 g_return_val_if_fail (GTK_IS_EVENT_BOX (widget), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
958
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
959 switch (event->type)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
960 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
961 case GDK_BUTTON_PRESS:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
962 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
963 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
964 if (gdk_pointer_grab (event->button.window,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
965 FALSE,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
966 GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
967 GDK_BUTTON_RELEASE_MASK,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
968 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
969 NULL,
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
970 event->button.time) != GDK_GRAB_SUCCESS)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
971 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
972
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
973 mdi->drag_button = event->button.button;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
974 if ((child->state == CHILD_MAXIMIZED) || (child->state == CHILD_ICONIFIED))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
975 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
976 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
977 child->x = child->widget->allocation.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
978 child->y = child->widget->allocation.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
979 child->width = child->widget->allocation.width;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
980 child->height = child->widget->allocation.height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
981 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
982
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
983 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
984 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
985
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
986 case GDK_BUTTON_RELEASE:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
987 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
988 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
989
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
990 if (mdi->drag_button == event->button.button)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
991 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
992 int width, height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
993
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
994 gdk_pointer_ungrab (event->button.time);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
995 mdi->drag_button = -1;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
996
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
997 width = event->button.x + widget->allocation.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
998 height = event->button.y + widget->allocation.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
999
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1000 width = MAX (width, GTK_MDI_MIN_WIDTH);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1001 height = MAX (height, GTK_MDI_MIN_HEIGHT);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1002
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1003 gtk_widget_set_size_request (child->widget, width, height);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1004 gtk_widget_queue_resize (child->widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1005 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1006 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1007
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1008 case GDK_MOTION_NOTIFY:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1009 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1010 int x, y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1011 int width, height;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1012
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1013 if (mdi->drag_button < 0)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1014 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1015
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1016 gdk_window_get_pointer (widget->window, &x, &y, NULL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1017
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1018 width = x + widget->allocation.x;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1019 height = y + widget->allocation.y;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1020
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1021 width = MAX (width, GTK_MDI_MIN_WIDTH);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1022 height = MAX (height, GTK_MDI_MIN_HEIGHT);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1023
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1024 gtk_widget_set_size_request (child->widget, width, height);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1025 gtk_widget_queue_resize (child->widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1026 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1027 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1028
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1029 default:
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1030 break;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1031 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1032
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1033 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1034 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1035
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1036 static gboolean iconify_child_callback (GtkWidget *widget, GdkEvent *event, gpointer data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1037 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1038 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1039 child = (GtkMdiChild *) data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1040 if (child->state == CHILD_ICONIFIED)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1041 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1042 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1043 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1044 else
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1045 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1046 child->state = CHILD_ICONIFIED;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1047 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1048 if (GTK_WIDGET_VISIBLE (child->widget))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1049 gtk_widget_queue_resize (GTK_WIDGET (child->widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1050 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1051 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1052
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1053 static gboolean maximize_child_callback (GtkWidget *widget, GdkEvent * event, gpointer data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1054 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1055 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1056 child = (GtkMdiChild *) data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1057 if (child->state == CHILD_MAXIMIZED)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1058 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1059 child->state = CHILD_NORMAL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1060 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1061 else
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1062 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1063 child->state = CHILD_MAXIMIZED;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1064 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1065 if (GTK_WIDGET_VISIBLE (child->widget))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1066 gtk_widget_queue_resize (GTK_WIDGET (child->widget));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1067 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1068 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1069
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1070 static gboolean kill_child_callback (GtkWidget *widget, GdkEvent *event, gpointer data)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1071 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1072 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1073 GtkMdi *mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1074
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1075 child = (GtkMdiChild *) data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1076 mdi = child->mdi;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1077
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1078 g_return_val_if_fail (GTK_IS_MDI (mdi), FALSE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1079
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1080 gtk_mdi_remove_true (GTK_CONTAINER (mdi), child->widget);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1081 return FALSE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1082 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1083
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1084 static GtkMdiChild *get_child (GtkMdi *mdi, GtkWidget *widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1085 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1086 GList *children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1087
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1088 children = mdi->children;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1089 while (children)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1090 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1091 GtkMdiChild *child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1092
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1093 child = children->data;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1094 children = children->next;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1095
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1096 if (child->child == widget)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1097 return child;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1098 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1099
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1100 return NULL;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1101 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1102 #endif
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
1103
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1104 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
1105 {
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1106 #ifdef __sun__
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1107 /* 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
1108 struct timespec req;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1109
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1110 req.tv_sec = 0;
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1111 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
1112
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1113 nanosleep(&req, NULL);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1114 #else
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1115 usleep(period * 1000);
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1116 #endif
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1117 }
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
1118
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 /* 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
1120 static void *_findsigfunc(char *signame)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1121 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1122 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124 for(z=0;z<SIGNALMAX;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 if(strcasecmp(signame, SignalTranslate[z].name) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 return SignalTranslate[z].func;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1131
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1132 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
1133 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1134 int counter = (int)data;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1135 SignalHandler sh;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1136 char text[100];
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1137
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1138 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
1139 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
1140 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
1141 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
1142 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
1143 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
1144 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
1145 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
1146 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
1147 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
1148
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1149 return sh;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1150 }
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1151
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1152 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
1153 {
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1154 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
1155 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
1156
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1157 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
1158 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
1159 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
1160 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
1161 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
1162 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
1163 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
1164 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
1165 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
1166 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
1167 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
1168 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
1169 }
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1170
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1171 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
1172 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1173 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
1174 char text[100];
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1175
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1176 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
1177 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
1178 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
1179 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
1180 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
1181 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
1182 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
1183 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
1184
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1185 counter++;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1186 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
1187
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1188 return counter - 1;
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1189 }
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1190
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1191 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
1192 {
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1193 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
1194
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1195 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
1196 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
1197 }
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
1198
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1199 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
1200 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1201 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
1202 int retval = FALSE;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1203
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1204 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1205 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1206 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
1207
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1208 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
1209 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1210 return retval;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1211 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1212
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1213 static gint _button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1214 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1215 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
1216 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1218 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1219 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1220 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1228 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
1229 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1230 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1231 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1232
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1233 static gint _button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1234 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1235 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
1236 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1237
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1238 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1239 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1240 int (*buttonfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1241 int mybutton = event->button;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 mybutton = 2;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 else if(event->button == 2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 mybutton = 3;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1248 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
1249 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1250 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1253 static gint _motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1255 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
1256 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1258 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1259 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1260 int (*motionfunc)(HWND, int, int, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 int keys = 0, x, y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264 if (event->is_hint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 gdk_window_get_pointer (event->window, &x, &y, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 x = event->x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 y = event->y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 state = event->state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 if (state & GDK_BUTTON1_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 keys = DW_BUTTON1_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 if (state & GDK_BUTTON3_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 keys |= DW_BUTTON2_MASK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1277 if (state & GDK_BUTTON2_MASK)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 keys |= DW_BUTTON3_MASK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1279
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1280 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
1281 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1282 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1285 static gint _delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1287 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
1288 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1290 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1291 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1292 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
1293
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1294 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
1295 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1296 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1299 static gint _key_press_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1301 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
1302 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1304 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1305 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1306 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
1307
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1308 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
1309 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
1310 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1311 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1312 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1313
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1314 static gint _generic_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1315 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1316 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
1317 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1318
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1319 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1320 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1321 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
1322
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1323 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
1324 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1325 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1326 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1327
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1328 static gint _activate_event(GtkWidget *widget, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1329 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1330 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
1331 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1332
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1333 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
1334 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1335 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
1336
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1337 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
1338 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1339 return retval;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1341
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1342 static gint _configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1344 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
1345 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1346
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1347 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1348 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1349 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
1350
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1351 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
1352 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1353 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1354 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1355
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1356 static gint _expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1358 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
1359 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1361 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1362 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 DWExpose exp;
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1364 int (*exposefunc)(HWND, DWExpose *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1365
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1366 exp.x = event->area.x;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 exp.y = event->area.y;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368 exp.width = event->area.width;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 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
1370 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
1371 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1372 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1373 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1374
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1375 static gint _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1377 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
1378 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
1379 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
1380
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1381 if(_dw_recursing)
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1382 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1383
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1384 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1385 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1386 int (*selectfunc)(HWND, int, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1387 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1388 int item = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1389
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1390 _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
1391
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1392 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
1393 list = GTK_LIST(GTK_COMBO(work.window)->list)->children;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 else if(GTK_IS_LIST(widget))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 list = GTK_LIST(widget)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396 else
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1397 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 if(list->data == (gpointer)child)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1402 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1403 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
1404 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1405 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
1406 if(selectfunc)
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1407 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
1408 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1409 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1410 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1411 item++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1412 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1413 }
39
3aa9ef0b3996 Added focus fixes and set-focus fixes on all three platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 37
diff changeset
1414 _dw_recursing = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1415 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1416 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1417 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1418
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1419 static gint _container_context_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1420 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1421 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
1422 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1423
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1424 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426 if(event->button == 3)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1428 int (*contextfunc)(HWND, char *, int, int, void *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1429 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1433
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1434 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
1435 retval = contextfunc(work.window, text, event->x, event->y, work.data, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1436 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1437 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1438 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1439 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1440
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1441 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
1442 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1443 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
1444 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
1445
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1446 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
1447 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1448 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
1449 {
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
1450 #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
1451 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
1452 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
1453 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
1454
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1455 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
1456 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1457 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
1458 GtkTreeIter iter;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
1459
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
1460 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
1461 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1462 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
1463 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
1464 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1465 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1466
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1467 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
1468 #else
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1469 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
1470 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
1471 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
1472
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1473 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
1474 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1475 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
1476
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1477 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
1478 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1479 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
1480
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1481 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
1482 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1483 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
1484 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
1485 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1486 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1487 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1488
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1489 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
1490 #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
1491 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
1492 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1493 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1494 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1495
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
1496 #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
1497 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
1498 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1499 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
1500 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
1501
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1502 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
1503 {
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1504 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
1505
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1506 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
1507 {
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1508 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
1509 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
1510 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
1511 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
1512
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1513 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
1514 {
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
1515 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
1516 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
1517 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
1518 }
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
1519 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1520 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
1521 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
1522 }
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
1523
480
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
1524 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
1525 {
8832ad52486f New tree code fixes for GTK 2.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 479
diff changeset
1526 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
1527 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
1528
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
1529 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
1530 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
1531 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
1532 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
1533 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
1534 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
1535 }
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
1536 #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
1537 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
1538 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1539 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
1540 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
1541 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
1542
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
1543 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
1544 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
1545 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
1546 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
1547 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
1548 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
1549 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
1550
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1551 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1552 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1553 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
1554 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
1555 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
1556 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
1557 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1558 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1559 }
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
1560
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
1561 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
1562 {
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
1563 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
1564 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
1565
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
1566 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
1567 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
1568 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
1569 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
1570 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
1571 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
1572 }
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
1573 #endif
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1574
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1575 static gint _container_select_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1576 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1577 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
1578 int retval = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1579
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1580 if(work.window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1581 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1582 if(event->button == 1 && event->type == GDK_2BUTTON_PRESS)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1583 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1584 int (*contextfunc)(HWND, char *, void *) = work.func;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1585 char *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1586 int row, col;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588 gtk_clist_get_selection_info(GTK_CLIST(widget), event->x, event->y, &row, &col);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 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
1591 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
1592 gtk_object_set_data(GTK_OBJECT(widget), "_dw_double_click", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1595 return retval;
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1596 }
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1597
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1598 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
1599 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1600 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
1601 int retval = FALSE;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1602
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1603 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
1604 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1605 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
1606 char *text;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1607
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1608 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
1609 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
1610 }
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1611 return retval;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1612 }
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
1613
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
1614 /* 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
1615 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
1616 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1617 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
1618 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
1619 GtkWidget *thispage = gtk_notebook_get_nth_page(GTK_NOTEBOOK(handle), pageid);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
1620
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
1621 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
1622 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1623 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
1624 {
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1625 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
1626 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
1627 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1628 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1629 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
1630 }
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1631
599644ca9064 Use _get_logical_page() to get the logical page from the physical page.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 340
diff changeset
1632
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
1633 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
1634 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1635 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
1636 int retval = FALSE;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
1637
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1638 if(work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1639 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1640 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
1641 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
1642 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
1643 return retval;
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
1644 }
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
1645
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1646 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
1647 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1648 SignalHandler work = _get_signal_handler(widget, data);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1649 int retval = FALSE;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1650
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1651 if(work.window)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1652 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1653 int (*clickcolumnfunc)(HWND, int, void *) = work.func;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1654 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
1655 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1656 return retval;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1657 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
1658
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1659 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
1660 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1661 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
1662 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
1663 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
1664
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1665 if(!work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1666 return TRUE;
311
24c1dfffe97e Unified the callback functions for tree and container widgets.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 310
diff changeset
1667
320
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
1668 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
1669 {
ae5b1eecea12 Don't send a DW_SIGNAL_ITEM_SELECT after DW_SIGNAL_ENTER.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 319
diff changeset
1670 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
1671 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
1672 }
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1673 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
1674 }
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
1675
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1676 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
1677 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1678 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
1679
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1680 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
1681 newval++;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1682
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1683 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
1684 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1685
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1686 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
1687 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1688 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
1689 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
1690 GtkWidget *slider = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_slider");
592
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
1691 GtkWidget *spinbutton = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(adjustment), "_dw_spinbutton");
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1692 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
1693
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1694 if(slider)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1695 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1696 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
1697
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1698 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
1699 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1700 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
1701
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1702 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
1703 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
1704 else
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1705 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
1706 }
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1707 }
592
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
1708 else if(scrollbar || spinbutton)
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1709 {
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1710 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
1711
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1712 if(work.window)
208
5349a0735fda Hopefully fixed value_changed signal handler on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 205
diff changeset
1713 {
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1714 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
1715
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
1716 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
1717 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1718 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1719 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
1720 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
1721
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1722 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
1723 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1724 GtkWidget *next = (GtkWidget *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1725
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1726 if(next)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1727 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1728 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
1729 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1730 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
1731 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
1732 else
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1733 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
1734 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1735 }
131
594307469c79 Signal handler code cleanups for GTK 2.0.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 130
diff changeset
1736 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1737 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
1738
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1739 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
1740 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1741 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
1742 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1743 *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
1744 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
1745 *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
1746 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
1747 *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
1748 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
1749 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1750 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
1751 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1752
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1753 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
1754 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1755 char *data = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1756 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1757
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1758 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
1759 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
1760
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1761 for(z=0;z<_resources.resource_max;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1762 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1763 if(_resources.resource_id[z] == id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1764 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 data = _resources.resource_data[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 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
1773 #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
1774 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
1775
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1776 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
1777 *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
1778 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
1779 *userheight = gdk_pixbuf_get_height(icon_pixbuf);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
1780
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
1781 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
1782 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
1783 #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
1784 gdk_imlib_data_to_pixmap((char **)data, &icon_pixmap, bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1785 #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
1786 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
1787 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 return icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1793 #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
1794 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
1795 {
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
1796 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
1797 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
1798 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
1799 }
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
1800
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1801 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
1802 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1803 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
1804 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
1805
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
1806 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
1807 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
1808
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1809 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
1810 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1811 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
1812 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1813 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
1814 break;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1815 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1816 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1817
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1818 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
1819 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
1820 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
1821 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1822 #endif
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
1823
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
1824 static void _size_allocate(GtkWindow *window)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 XSizeHints sizehints;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1827
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1828 sizehints.base_width = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1829 sizehints.base_height = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1830 sizehints.width_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1831 sizehints.height_inc = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1832 sizehints.min_width = 8;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1833 sizehints.min_height = 8;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
1834
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1835 sizehints.flags = (PBaseSize|PMinSize|PResizeInc);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
1836
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1837 XSetWMNormalHints (GDK_DISPLAY(),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1838 GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1839 &sizehints);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1840 gdk_flush ();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1842
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1843 /* 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
1844 static int _find_thread_index(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1845 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1846 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1847
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1848 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1849 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1850 if(_dw_thread_list[z] == tid)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1851 return z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1852 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1853 return 0;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1854 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1855
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1856 /* 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
1857 static void _dw_thread_add(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1858 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1859 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1860
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1861 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1862 {
264
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
1863 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
1864 return;
20becf7df38a Prevent duplicate thread IDs from getting added to the thread list.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 259
diff changeset
1865
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1866 if(_dw_thread_list[z] == (DWTID)-1)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1867 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1868 _dw_thread_list[z] = tid;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1869 _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
1870 _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
1871 _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
1872 _transparent[z] = 1;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1873 _clipboard_contents[z] = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1874 _clipboard_object[z] = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1875 return;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1876 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1877 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1878 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1879
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1880 /* 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
1881 static void _dw_thread_remove(DWTID tid)
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1882 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1883 int z;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1884
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1885 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1886 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1887 if(_dw_thread_list[z] == (DWTID)tid)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1888 {
51
d97de82f0b6e Fix warning on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 49
diff changeset
1889 _dw_thread_list[z] = (DWTID)-1;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1890 if ( _clipboard_contents[z] != NULL )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1891 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1892 g_free( _clipboard_contents[z] );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1893 _clipboard_contents[z] = NULL;;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1894 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1895 _clipboard_object[z] = NULL;;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
1896 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1897 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1898 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
1899
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1900 /* Try to load the mozilla embed shared libary */
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1901 #ifdef USE_GTKMOZEMBED
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1902 #include <ctype.h>
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1903
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1904 static char _dw_mozdir[1024];
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1905
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1906 void init_mozembed(void)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1907 {
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1908 void *handle = NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1909 FILE *fp = popen("pkg-config --libs-only-L mozilla-gtkmozembed", "r");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1910
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1911 /* First we try to get the correct location
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1912 * from pkg-config.
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1913 */
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1914 if(fp)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1915 {
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1916 fgets(_dw_mozdir, 1024, fp);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1917
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1918 if(_dw_mozdir[0] == '-' && _dw_mozdir[1] == 'L')
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1919 {
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1920 int x, len = strlen(_dw_mozdir);
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1921
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1922 for(x=len;x>0;x--)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1923 {
592
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
1924 if(!isalpha(_dw_mozdir[x]) && !isdigit(_dw_mozdir[x]) && _dw_mozdir[x] != '/')
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1925 _dw_mozdir[x] = 0;
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1926 }
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1927 strncat(_dw_mozdir, "/libgtkembedmoz.so", 1024);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1928 handle = dlopen(&_dw_mozdir[2], RTLD_NOW);
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1929 }
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1930 fclose(fp);
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1931 }
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1932 /* Try the default path */
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1933 if(!handle)
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1934 {
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1935 strncpy(_dw_mozdir, "libgtkembedmoz.so", 1024);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1936 handle = dlopen(_dw_mozdir, RTLD_NOW);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1937 }
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1938 /* Finally try some common locations */
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1939 if(!handle)
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1940 {
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1941 strncpy(_dw_mozdir, "/usr/X11R6/lib/mozilla/libgtkembedmoz.so", 1024);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1942 handle = dlopen(_dw_mozdir, RTLD_NOW);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1943 }
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1944 if(!handle)
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1945 {
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1946 strncpy(_dw_mozdir, "/usr/lib/mozilla/libgtkembedmoz.so", 1024);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1947 handle = dlopen(_dw_mozdir, RTLD_NOW);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1948 }
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1949 if(!handle)
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1950 {
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1951 strncpy(_dw_mozdir, "/usr/local/lib/mozilla/libgtkembedmoz.so", 1024);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1952 handle = dlopen(_dw_mozdir, RTLD_NOW);
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1953 }
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1954
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1955 /* If we loaded it, grab the symbols we want */
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1956 if(handle)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1957 {
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1958 _gtk_moz_embed_go_back = dlsym(handle, "gtk_moz_embed_go_back");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1959 _gtk_moz_embed_go_forward = dlsym(handle, "gtk_moz_embed_go_forward");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1960 _gtk_moz_embed_load_url = dlsym(handle, "gtk_moz_embed_load_url");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1961 _gtk_moz_embed_reload = dlsym(handle, "gtk_moz_embed_reload");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1962 _gtk_moz_embed_stop_load = dlsym(handle, "gtk_moz_embed_stop_load");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1963 _gtk_moz_embed_render_data = dlsym(handle, "gtk_moz_embed_render_data");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1964 _dw_moz_embed_get_type = dlsym(handle, "gtk_moz_embed_get_type");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1965 _gtk_moz_embed_new = dlsym(handle, "gtk_moz_embed_new");
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1966 }
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1967 else
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
1968 _dw_mozdir[0] = 0;
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1969 }
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1970 #endif
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
1971
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1972 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1973 * Initializes the Dynamic Windows engine.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1974 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1975 * newthread: True if this is the only thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1976 * False if there is already a message loop running.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1977 */
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1978 int dw_int_init(DWResources *res, int newthread, int *argc, char **argv[])
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1979 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1980 int z;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
1981 char *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 if(res)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 _resources.resource_max = res->resource_max;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 _resources.resource_id = res->resource_id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 _resources.resource_data = res->resource_data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 gtk_set_locale();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990 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
1991 #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
1992 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
1993 #endif
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
1994
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
1995 gtk_init(argc, argv);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1996 #ifdef USE_IMLIB
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1997 gdk_imlib_init();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1998 #endif
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1999 /* Add colors to the system colormap */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2000 _dw_cmap = gdk_colormap_get_system();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2001 for(z=0;z<16;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2002 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
2003
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2004 tmp = getenv("DW_BORDER_WIDTH");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2005 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2006 _dw_border_width = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2007 tmp = getenv("DW_BORDER_HEIGHT");
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2008 if(tmp)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2009 _dw_border_height = atoi(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2010
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2011 for(z=0;z<DW_THREAD_LIMIT;z++)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2012 _dw_thread_list[z] = (DWTID)-1;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2013
77
002da4d18ac6 Set tooltip background color to yellow.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 76
diff changeset
2014 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
2015
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
2016 #ifdef USE_GTKMOZEMBED
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
2017 init_mozembed();
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
2018 #endif
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
2019
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2020 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2021 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2022
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2023 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2024 * 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
2025 */
2a0d7b57a6da Removed unnecessary parameters from dw_main().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 149
diff changeset
2026 void dw_main(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2027 {
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
2028 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2029 _dw_thread = pthread_self();
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2030 _dw_thread_add(_dw_thread);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 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
2032 _dw_thread = (pthread_t)-1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 gdk_threads_leave();
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 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2037 * 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
2038 * 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
2039 * 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
2040 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2041 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
2042 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2043 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
2044 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
2045
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2046 gettimeofday(&start, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2047
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2048 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
2049 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2050 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
2051
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2052 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
2053
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2054 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
2055 {
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2056 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
2057 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2058 gdk_threads_enter();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2059 _dw_thread = curr;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2060 }
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2061 if(gtk_events_pending())
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2062 gtk_main_iteration();
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2063 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
2064 _dw_msleep(1);
340
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2065 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
2066 {
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2067 _dw_thread = orig;
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2068 gdk_threads_leave();
eff674cb4935 Test fix for Mark's dw_main_sleep() hang.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 338
diff changeset
2069 }
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
2070 gettimeofday(&tv, NULL);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2071 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2072 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2073 else
237
efa724294b5f Use an internal sleep function to avoid needing dwcompat.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 233
diff changeset
2074 _dw_msleep(milliseconds);
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2075 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2076
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2077 /*
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
2078 * 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
2079 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
2080 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
2081 {
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
2082 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
2083 _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
2084 _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
2085 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
2086 _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
2087 gdk_threads_leave();
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
2088 }
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
2089
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
2090 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 * Free's memory allocated by dynamic windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 * ptr: Pointer to dynamic windows allocated
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 * memory to be free()'d.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 void dw_free(void *ptr)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 free(ptr);
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2102 * Allocates and initializes a dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2103 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2104 * data: User defined data to be passed to functions.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2105 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2106 DWDialog *dw_dialog_new(void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2107 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2108 DWDialog *tmp = malloc(sizeof(DWDialog));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2110 tmp->eve = dw_event_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2111 dw_event_reset(tmp->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2112 tmp->data = data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2113 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
2114 tmp->method = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 tmp->result = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 * Accepts a dialog struct and returns the given data to the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122 * initial called of dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 * result: Data to be returned by dw_dialog_wait().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2127 int dw_dialog_dismiss(DWDialog *dialog, void *result)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2128 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2129 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
2130 if(dialog->method)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2131 gtk_main_quit();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2132 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2133 dw_event_post(dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2134 dialog->done = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2135 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2136 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2137
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2138 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2139 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2140 * called by a signal handler with the given dialog struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2141 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2142 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144 void *dw_dialog_wait(DWDialog *dialog)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 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
2147 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
2148
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2149 /* _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
2150 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
2151 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2152 _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
2153 newprocess = 1;
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2154 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
2155 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2156
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2157 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
2158 {
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
2159 dialog->method = TRUE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2160 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
2161 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2162 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
2163 {
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
2164 dialog->method = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2165 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
2166 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167
41
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2168 if(newprocess)
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2169 {
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2170 _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
2171 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
2172 }
af0a78aa0d45 More updates, and a more comprehensive unix install scheme. Use target
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 40
diff changeset
2173
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 dw_event_close(&dialog->eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 tmp = dialog->result;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 free(dialog);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2177 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2178 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2179
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
2180 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
2181 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2182 DWDialog *dwwait = (DWDialog *)data;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2183
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2184 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2185 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2186
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2187 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
2188 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
2189 return FALSE;
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2190 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2191
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2192 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
2193 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2194 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
2195
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2196 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2197 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
2198
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2199 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
2200 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
2201 return FALSE;
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2202 }
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2203
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2204 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
2205 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2206 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
2207
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2208 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
2209 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
2210
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2211 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
2212 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
2213 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
2214 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2215
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2216 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
2217 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2218 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
2219
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2220 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
2221 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
2222
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2223 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
2224 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
2225 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
2226 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2227
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2229 * Displays a Message Box with given text and title..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2230 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2231 * 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
2232 * 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
2233 * 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
2234 * ...: 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
2235 */
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2236 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
2237 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2238 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
2239 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
2240 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
2241 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
2242 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
2243 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
2244 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
2245 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
2246
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2247 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
2248 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
2249 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
2250
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2251 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
2252 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
2253 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
2254
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
2255 /* 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
2256 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
2257 {
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
2258 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
2259 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
2260 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
2261 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2262 else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2263 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2264 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
2265 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
2266 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2267
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2268 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
2269 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
2270 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
2271 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
2272 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
2273 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
2274 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
2275 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
2276
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
2277 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
2278 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
2279
399
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2280 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
2281 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2282 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
2283 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
2284 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
2285 #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
2286 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
2287
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2288 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
2289 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
2290 #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
2291 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
2292 #else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2293 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
2294 #endif
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2295
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2296 #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
2297 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
2298 #else
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2299 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
2300 #endif
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2301
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2302 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
2303 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2304
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2305 /* 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
2306 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
2307 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
2308 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
2309 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK);
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
2310 dw_font_text_extents_get(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
2311 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
2312 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
2313 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
2314 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
2315 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
2316 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
2317 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
2318 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
2319 {
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
2320 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
2321 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
2322 }
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
2323 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
2324
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2325 /* 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
2326 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
2327
556
f4093dce8155 Fixed a minor packing error in dw_messagebox().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 550
diff changeset
2328 dw_box_pack_start(mainbox, buttonbox, 0, 0, TRUE, FALSE, 0);
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2329
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2330 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
2331
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
2332 /* 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
2333 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
2334 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2335 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
2336 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
2337 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
2338 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2339 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
2340 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2341 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
2342 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
2343 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
2344 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
2345 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
2346 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
2347 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2348 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
2349 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2350 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
2351 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
2352 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
2353 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
2354 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
2355 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
2356 }
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2357 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
2358 {
a7a561103eac Add flags parameter to dw_messagebox() to specify buttons and icon displayed.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 386
diff changeset
2359 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
2360 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
2361 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
2362 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
2363 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
2364 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
2365 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
2366 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
2367 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
2368 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2369
463
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
2370 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
2371 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
2372 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
2373
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
2374 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
2375
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2376 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
2377
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
2378 return (int)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2379 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2380
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2382 * 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
2383 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2384 * handle: The window handle to minimize.
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2385 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2386 int dw_window_minimize(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2387 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2388 int _locked_by_me = FALSE;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2389 #if GTK_MAJOR_VERSION > 1
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2390 GtkWidget *mdi = NULL;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2391 #endif
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2392
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2393 if(!handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2394 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2395
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2396 DW_MUTEX_LOCK;
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2397 #if GTK_MAJOR_VERSION > 1
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2398 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2399 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2400 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_ICONIFIED);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2401 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2402 else
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2403 #endif
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2404 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2405 XIconifyWindow(GDK_WINDOW_XDISPLAY(GTK_WIDGET(handle)->window),
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2406 GDK_WINDOW_XWINDOW(GTK_WIDGET(handle)->window),
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2407 DefaultScreen (GDK_DISPLAY ()));
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2408 }
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2409 DW_MUTEX_UNLOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2410 return 0;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2411 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2412
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2413 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2414 * Makes the window topmost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2415 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2416 * 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
2417 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2418 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
2419 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2420 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
2421
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2422 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2423 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2424
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2425 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2426 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
2427 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2428 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2429 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2430
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2431 /*
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2432 * Makes the window bottommost.
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2433 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2434 * 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
2435 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2436 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
2437 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2438 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
2439
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2440 if(!handle)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2441 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2442
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2443 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2444 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
2445 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2446 return 0;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2447 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2448
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
2449 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2450 * Makes the window visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2451 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2452 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2453 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2454 int dw_window_show(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2455 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2456 int _locked_by_me = FALSE;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2457 GtkWidget *defaultitem;
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2458 #if GTK_MAJOR_VERSION > 1
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2459 GtkWidget *mdi;
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2460 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2462 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2463 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2464
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 gtk_widget_show(handle);
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2467 #if GTK_MAJOR_VERSION > 1
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2468 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2469 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2470 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_NORMAL);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2471 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2472 else
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2473 #endif
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2474 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2475 if(GTK_WIDGET(handle)->window)
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2476 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2477 int width = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_width");
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2478 int height = (int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_height");
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2479
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2480 if(width && height)
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2481 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2482 gtk_widget_set_usize(handle, width, height);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2483 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", 0);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2484 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", 0);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2485 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2486
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2487 gdk_window_raise(GTK_WIDGET(handle)->window);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2488 gdk_flush();
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2489 gdk_window_show(GTK_WIDGET(handle)->window);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2490 gdk_flush();
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2491 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2492 defaultitem = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_defaultitem");
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2493 if(defaultitem)
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2494 gtk_widget_grab_focus(defaultitem);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2495 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 * Makes the window invisible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 * handle: The window handle to make visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2505 int dw_window_hide(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2506 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2507 int _locked_by_me = FALSE;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2508 #if GTK_MAJOR_VERSION > 1
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2509 GtkWidget *mdi = NULL;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2510 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2511
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2512 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2513 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2514
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2515 DW_MUTEX_LOCK;
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2516 #if GTK_MAJOR_VERSION > 1
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2517 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2518 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2519 gtk_mdi_set_state(GTK_MDI(mdi), handle, CHILD_ICONIFIED);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2520 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2521 else
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2522 #endif
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2523 gtk_widget_hide(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2524 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529 * Destroys a window and all of it's children.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2531 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2532 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 int dw_window_destroy(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2535 int _locked_by_me = FALSE;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2536 #if GTK_MAJOR_VERSION > 1
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2537 GtkWidget *mdi = NULL;
520
2fe16658d18b Eliminate warnings on GTK 1.x
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 518
diff changeset
2538 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2540 if(!handle)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2541 return 0;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2542
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 DW_MUTEX_LOCK;
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2544 #if GTK_MAJOR_VERSION > 1
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2545 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2546 {
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2547 gtk_mdi_remove(GTK_MDI(mdi), handle);
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2548 }
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2549 #endif
17
f26eced21a30 Some more updates.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 15
diff changeset
2550 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
2551 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2552 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
2553
5df54ebc44dd Fixed a bug where the eventbox associated with a box was not destroyed
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 355
diff changeset
2554 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
2555 gtk_widget_destroy(eventbox);
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2556 else
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
2557 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
2558 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2560 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2561 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2562
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
2563 /* 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
2564 * 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
2565 * 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
2566 */
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2567 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
2568 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2569 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
2570
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2571 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2572 * Changes a window's parent to newparent.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2573 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 * handle: The window handle to destroy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2575 * newparent: The window's new parent window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 void dw_window_reparent(HWND handle, HWND newparent)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2579 int _locked_by_me = FALSE;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2580
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2581 DW_MUTEX_LOCK;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2582 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
2583 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2584 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2585
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
2586 static int _set_font(HWND handle, char *fontname)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2587 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2588 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
2589 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2590 GtkStyle *style;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2591 GdkFont *font = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2592
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2593 font = gdk_font_load(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2595 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597 style = gtk_widget_get_style(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 style->font = font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 gtk_widget_set_style(handle, style);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 retval = TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2602 #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
2603 PangoFontDescription *font = pango_font_description_from_string(fontname);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
2604
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2605 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
2606 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2607 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
2608 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
2609 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
2610 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2611 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2612 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2613
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2614 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2615 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2616 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2617 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2618 * fontname: Name and size of the font in the form "size.fontname"
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2619 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2620 int dw_window_set_font(HWND handle, char *fontname)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 {
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
2622 #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
2623 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
2624 #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
2625 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
2626 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 char *font;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 gpointer data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2631
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2632 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2633 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2634 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2635 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2636 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2637 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2638 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2639 font = strdup(fontname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2640
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
2641 #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
2642 /* 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
2643 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
2644 if(gdkfont)
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2645 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
2646 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
2647 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
2648 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
2649 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
2650 #endif
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2651
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
2652 /* 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
2653 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654 if(data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655 free(data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2657 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
2658 #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
2659 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
2660
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
2661 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
2662 {
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
2663 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
2664 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
2665 }
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
2666 #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
2667 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2668 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2669 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2670
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2671 void _free_gdk_colors(HWND handle)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2672 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2673 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
2674
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2675 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2676 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2677
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2678 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
2679
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2680 if(old)
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2681 free(old);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2682 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2683
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2684 /* 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
2685 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
2686 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2687 GdkColor *foregdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2688 GdkColor *backgdk = malloc(sizeof(GdkColor));
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2689
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2690 _free_gdk_colors(handle);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2691
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2692 *foregdk = fore;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2693 *backgdk = back;
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2694
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2695 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
2696 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
2697 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
2698
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
2699 static int _set_color(HWND handle, unsigned long fore, unsigned long back)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2700 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2701 /* 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
2702 * 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
2703 */
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2704 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
2705 #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
2706 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
2707 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2709 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
2710 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2711 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
2712 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
2713 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
2714 forecolor.blue = DW_BLUE_VALUE(fore) << 8;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 gdk_color_alloc(_dw_cmap, &forecolor);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717
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
2718 #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
2719 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
2720 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
2721 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
2722 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
2723 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2724 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2725 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
2726 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2727 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2728 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
2729 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2730 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
2731
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2732 #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
2733 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
2734 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
2735 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
2736 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
2737 #else
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2738 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2739 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
2740 #endif
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2741 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2742 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
2743 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2744 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
2745 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
2746 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
2747 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
2748
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2749 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
2750
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2751 #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
2752 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
2753 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
2754 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
2755 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
2756 #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
2757 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
2758 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
2759 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2760 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2761 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
2762 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2763 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
2764
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
2765 #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
2766 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
2767 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
2768 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
2769 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
2770 #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
2771 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
2772 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
2773 #endif
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2774 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2775
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2776 _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
2777
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2778 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
2779 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2780 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
2781
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2782 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
2783 {
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2784 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
2785 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
2786 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2787 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2788
155
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2789 #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
2790 if(style)
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2791 {
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2792 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
2793 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
2794 }
840c54766306 Another sync of sources, enhancements to dw_window_set_color() ... works
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 153
diff changeset
2795 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2796 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2797 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2798 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2799 * Sets the colors used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2800 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2801 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2802 * fore: Foreground color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2803 * back: Background color in RGB format.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805 int dw_window_set_color(HWND handle, unsigned long fore, unsigned long back)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811
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
2812 if(GTK_IS_SCROLLED_WINDOW(handle) || GTK_IS_BOX(handle))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2818 else if(GTK_IS_TABLE(handle))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2819 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
2820 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
2821 if(tmp)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2822 handle2 = tmp;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2823 }
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
2824
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2825 _set_color(handle2, fore, back);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2826
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2827 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2828 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2829 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832 * Sets the font used by a specified window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 * handle: The window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 * border: Size of the window border in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 int dw_window_set_border(HWND handle, int border)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 /* TODO */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 * Captures the mouse input to this window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 * handle: Handle to receive mouse input.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2848 void dw_window_capture(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2850 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2851
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2852 DW_MUTEX_LOCK;
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
2853 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
2854 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2855 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2856
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2857 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2858 * 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
2859 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2860 * 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
2861 * 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
2862 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
2863 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
2864 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
2865 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
2866 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
2867
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
2868 DW_MUTEX_LOCK;
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
2869 if(pointertype & (1 << 31))
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
2870 {
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
2871 GdkBitmap *bitmap = NULL;
338
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
2872 GdkPixmap *pixmap = _find_private_pixmap(&bitmap, (pointertype & 0xFFFFFF), NULL, NULL);
44e2bdacd8f3 Minor fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 337
diff changeset
2873 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
2874 }
533
a284fde5d471 Correctly implemented DW_POINTER_DEFAULT on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
2875 else if(!pointertype)
a284fde5d471 Correctly implemented DW_POINTER_DEFAULT on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
2876 cursor = NULL;
337
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
2877 else
e9a424e641ff Some pointer changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 331
diff changeset
2878 cursor = gdk_cursor_new(pointertype);
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
2879 if(handle && handle->window)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
2880 gdk_window_set_cursor(handle->window, cursor);
533
a284fde5d471 Correctly implemented DW_POINTER_DEFAULT on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
2881 if(cursor)
a284fde5d471 Correctly implemented DW_POINTER_DEFAULT on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 526
diff changeset
2882 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
2883 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
2884 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2885
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
2886 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 * Releases previous mouse capture.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 void dw_window_release(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2890 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 gdk_pointer_ungrab(GDK_CURRENT_TIME);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2897
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2899 * Create a new Window Frame.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2900 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2901 * owner: The Owner's window handle or HWND_DESKTOP.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2902 * title: The Window title.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 * flStyle: Style flags, see the PM reference.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 HWND dw_window_new(HWND hwndOwner, char *title, unsigned long flStyle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2906 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908 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
2909 int flags = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911 DW_MUTEX_LOCK;
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
2912 #if GTK_MAJOR_VERSION > 1
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2913 if(hwndOwner && GTK_IS_MDI(hwndOwner))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2914 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2915 GtkWidget *label;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2916
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2917 tmp = dw_box_new(DW_VERT, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2918
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2919 label = gtk_label_new(title);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2920 gtk_widget_show(label);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2921 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_mdi_child", (gpointer)1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2922 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_mdi_title", (gpointer)label);
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
2923 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_mdi", (gpointer)hwndOwner);
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2924
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2925 gtk_mdi_put(GTK_MDI(hwndOwner), tmp, 100, 75, label);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2926 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2927 else
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
2928 #endif
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2929 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2930 last_window = tmp = gtk_window_new(GTK_WINDOW_TOPLEVEL);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2931
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2932 gtk_window_set_title(GTK_WINDOW(tmp), title);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2933 if(!(flStyle & DW_FCF_SIZEBORDER))
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2934 gtk_window_set_policy(GTK_WINDOW(tmp), FALSE, FALSE, TRUE);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2935
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2936 gtk_widget_realize(tmp);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2937
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2938 if(flStyle & DW_FCF_TITLEBAR)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2939 flags |= GDK_DECOR_TITLE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2940
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2941 if(flStyle & DW_FCF_MINMAX)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2942 flags |= GDK_DECOR_MINIMIZE | GDK_DECOR_MAXIMIZE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2943
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2944 if(flStyle & DW_FCF_SIZEBORDER)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2945 flags |= GDK_DECOR_RESIZEH | GDK_DECOR_BORDER;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2946
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2947 if(flStyle & DW_FCF_BORDER || flStyle & DW_FCF_DLGBORDER)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2948 flags |= GDK_DECOR_BORDER;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2949
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2950 if(flStyle & DW_FCF_MAXIMIZE)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2951 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2952 flags &= ~DW_FCF_MAXIMIZE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2953 #if GTK_MAJOR_VERSION > 1
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2954 gtk_window_maximize(GTK_WINDOW(tmp));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2955 #endif
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2956 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2957 if(flStyle & DW_FCF_MINIMIZE)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2958 {
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2959 flags &= ~DW_FCF_MINIMIZE;
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2960 #if GTK_MAJOR_VERSION > 1
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2961 gtk_window_iconify(GTK_WINDOW(tmp));
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2962 #endif
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2963 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2964
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2965 gdk_window_set_decorations(tmp->window, flags);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2966
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2967 if(hwndOwner)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2968 gdk_window_reparent(GTK_WIDGET(tmp)->window, GTK_WIDGET(hwndOwner)->window, 0, 0);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2969
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2970 if(flStyle & DW_FCF_SIZEBORDER)
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2971 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_size", (gpointer)1);
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2972 }
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
2973 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_style", (gpointer)flStyle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 * Create a new Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980 * 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
2981 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 HWND dw_box_new(int type, int pad)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2986 GtkWidget *tmp, *eventbox;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989 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
2990 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2991 eventbox = gtk_event_box_new();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2992
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
2993 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
2994 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
2995 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
2996 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_boxpad", (gpointer)pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 }
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 * Create a new Group Box to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004 * 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
3005 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 * pad: Number of pixels to pad around the box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 * title: Text to be displayined in the group outline.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009 HWND dw_groupbox_new(int type, int pad, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3011 GtkWidget *tmp, *frame;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3012 int _locked_by_me = FALSE;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3013
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3014 DW_MUTEX_LOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3015 frame = gtk_frame_new(NULL);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3016 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
3017 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
3018 tmp = gtk_table_new(1, 1, FALSE);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
3019 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
3020 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
3021 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
3022 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
3023 gtk_container_add(GTK_CONTAINER(frame), tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3024 gtk_widget_show(tmp);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3025 gtk_widget_show(frame);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3026 DW_MUTEX_UNLOCK;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
3027 return frame;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3030 /*
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3031 * 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
3032 * Parameters:
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3033 * 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
3034 */
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3035 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
3036 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
3037 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
3038 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
3039
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
3040 DW_MUTEX_LOCK;
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
3041 #if GTK_MAJOR_VERSION > 1
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
3042 tmp = gtk_mdi_new();
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
3043 #else
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
3044 tmp = gtk_vbox_new(FALSE, 0);
515
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
3045 #endif
c3c5d8e36aa3 Implemented MDI Window in Window code on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 514
diff changeset
3046 gtk_widget_show(tmp);
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
3047 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
3048 return tmp;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3049 }
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3050
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3051 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 * Create a bitmap object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 * 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
3054 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056 HWND dw_bitmap_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 {
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
3058 #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
3059 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
3060 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
3061 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
3062 "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
3063 " 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
3064 ". 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
3065 "."};
121
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
3066 #endif
d8af32b1b1cd Switch back to using pixmaps and bitmaps, only use pixbufs for doing
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 120
diff changeset
3067 GtkWidget *tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3068 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3069
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3070 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
3071 #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
3072 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
3073 #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
3074 gdk_imlib_data_to_pixmap(test_xpm, &pixmap, &bitmap);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3075 #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
3076 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
3077
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
3078 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
3079 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
3080 #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
3081 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3082 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
3083 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3084 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
3085 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3086 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3087 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3088 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 * Create a notebook object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 HWND dw_notebook_new(unsigned long id, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
3098 GtkWidget *tmp, **pagearray = calloc(sizeof(GtkWidget *), 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 tmp = gtk_notebook_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 if(top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(tmp), GTK_POS_TOP);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 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
3107 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
3108 #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
3109 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
3110 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 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
3112 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
3113 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_pagearray", (gpointer)pagearray);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3114 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3115 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3116 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3117
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3118 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3119 * Create a menu object to be popped up.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 HMENUI dw_menu_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3127 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3128 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3129
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3130 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3131 tmp = gtk_menu_new();
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3132 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3133 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
3134 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
3135 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3136 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3137 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3138 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3139
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3140 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3141 * Create a menubar on a window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3142 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3143 * location: Handle of a window frame to be attached to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3144 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 HMENUI dw_menubar_new(HWND location)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 GtkWidget *box;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 int _locked_by_me = FALSE;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3149 GtkAccelGroup *accel_group;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3150 HMENUI tmp;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3151
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3152 DW_MUTEX_LOCK;
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3153 tmp = gtk_menu_bar_new();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 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
3155 gtk_widget_show(tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3156 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
3157 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_accel", (gpointer)accel_group);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3158
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3159 if(box)
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3160 gtk_box_pack_end(GTK_BOX(box), tmp, FALSE, FALSE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3163 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3164 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3166 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3167 * Destroys a menu created with dw_menubar_new or dw_menu_new.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3168 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3169 * menu: Handle of a menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3170 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3171 void dw_menu_destroy(HMENUI *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3172 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3173 if(menu && *menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3174 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3175 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3176
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3177 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3178 gtk_widget_destroy(*menu);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3179 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3180 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3181 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3182 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3183
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3184 char _removetilde(char *dest, char *src)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3185 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3186 int z, cur=0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3187 char accel = '\0';
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3189 for(z=0;z<strlen(src);z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3190 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3191 if(src[z] != '~')
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3192 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3193 dest[cur] = src[z];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3194 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3195 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3196 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3197 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3198 dest[cur] = '_';
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3199 accel = src[z+1];
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3200 cur++;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3201 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3202 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3203 dest[cur] = 0;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3204 return accel;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3205 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3206
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3207 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3208 * Adds a menuitem or submenu to an existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3209 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3210 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3211 * title: The title text on the menu item to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3212 * id: An ID to be used for message passing.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3213 * flags: Extended attributes to set on the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3214 * end: If TRUE memu is positioned at the end of the menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3215 * check: If TRUE menu is "check"able.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3216 * submenu: Handle to an existing menu to be a submenu or NULL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3217 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3218 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
3219 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220 GtkWidget *tmphandle;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3221 char accel, *tempbuf = malloc(strlen(title)+1);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3222 int _locked_by_me = FALSE, submenucount;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3223 guint tmp_key;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3224 GtkAccelGroup *accel_group;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3225
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3226 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3227 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3228 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3229 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3230 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3231
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3232 DW_MUTEX_LOCK;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3233 accel = _removetilde(tempbuf, title);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3234
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3235 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
3236 submenucount = (int)gtk_object_get_data(GTK_OBJECT(menu), "_dw_submenucount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3237
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3238 if(strlen(tempbuf) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3239 tmphandle=gtk_menu_item_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3240 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3241 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3242 if(check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3243 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3244 char numbuf[10];
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3245 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3246 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3247 tmphandle=gtk_check_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3248 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
3249 #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
3250 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
3251 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3252 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3253 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3254 tmphandle=gtk_check_menu_item_new_with_label(tempbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 gtk_check_menu_item_set_show_toggle(GTK_CHECK_MENU_ITEM(tmphandle), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3257 gtk_object_set_data(GTK_OBJECT(menu), numbuf, (gpointer)tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3260 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3261 if(accel && accel_group)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3262 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3263 tmphandle=gtk_menu_item_new_with_label("");
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3264 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
3265 #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
3266 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
3267 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3268 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3269 else
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3270 tmphandle=gtk_menu_item_new_with_label(tempbuf);
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3271 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 gtk_widget_show(tmphandle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 if(submenu)
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3277 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3278 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3279
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3280 sprintf(tempbuf, "_dw_submenu%d", submenucount);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3281 submenucount++;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3282 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
3283 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
3284 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
3285 }
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3286
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3287 if(GTK_IS_MENU_BAR(menu))
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3288 gtk_menu_bar_append(GTK_MENU_BAR(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 else
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3290 gtk_menu_append(GTK_MENU(menu), tmphandle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3292 gtk_object_set_data(GTK_OBJECT(tmphandle), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 free(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3294 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3295 return tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3298 GtkWidget *_find_submenu_id(GtkWidget *start, char *name)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3299 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3300 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
3301 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
3302
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3303 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
3304 return tmp;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3305
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3306 for(z=0;z<submenucount;z++)
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3307 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3308 char tempbuf[100];
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3309 GtkWidget *submenu, *menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3310
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3311 sprintf(tempbuf, "_dw_submenu%d", z);
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3312
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3313 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
3314 {
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3315 if((menuitem = _find_submenu_id(submenu, name)))
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3316 return menuitem;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3317 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3318 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3319 return NULL;
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3320 }
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3321
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3322 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3323 * Sets the state of a menu item check.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3324 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3325 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3326 * id: Menuitem id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3327 * check: TRUE for checked FALSE for not checked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3328 */
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3329 void dw_menu_item_set_check(HMENUI menu, unsigned long id, int check)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 char numbuf[10];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 GtkWidget *tmphandle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3335 if(!menu)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 DW_MUTEX_LOCK;
12
26e2130135b9 Many Win32 and GTK fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 7
diff changeset
3339 sprintf(numbuf, "%lu", id);
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3340 tmphandle = _find_submenu_id(menu, numbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3341
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3342 if(tmphandle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3343 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3344 _dw_ignore_click = 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3345 if(GTK_CHECK_MENU_ITEM(tmphandle)->active != check)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3346 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
3347 _dw_ignore_click = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3348 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3349 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3350 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3352 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 * Pops up a context menu at given x and y coordinates.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 * menu: The handle the the existing menu.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 * parent: Handle to the window initiating the popup.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 void dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 if(!menu || !*menu)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3365 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3366
93
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
3367 popup = parent;
98cce029a611 Changed handling of menu item click events.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 92
diff changeset
3368
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3369 DW_MUTEX_LOCK;
185
f55677513954 Updated the menu code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 167
diff changeset
3370 gtk_menu_popup(GTK_MENU(*menu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3371 *menu = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3372 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3373 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3375
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3376 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3377 * Returns the current X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3378 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3379 * x: Pointer to variable to store X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3380 * y: Pointer to variable to store Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382 void dw_pointer_query_pos(long *x, long *y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 GdkModifierType state;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 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
3386 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
3387
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
3388 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 gdk_window_get_pointer (GDK_ROOT_PARENT(), &gx, &gy, &state);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 *x = gx;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 *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
3392 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3393 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 * Sets the X and Y coordinates of the mouse pointer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 void dw_pointer_set_pos(long x, long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 {
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
3403 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
3404
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
3405 DW_MUTEX_LOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 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
3407 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408 }
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 * Create a container object to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 * id: An ID to be used for getting the resource from the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 * resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 */
350
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
3416 HWND dw_container_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 tmp = gtk_scrolled_window_new (NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3426 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
3427 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3429
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3430 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3431 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3432 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3433
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3434 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3435 * 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
3436 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3437 * 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
3438 * 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
3439 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3440 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
3441 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3442 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
3443 #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
3444 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
3445 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
3446 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
3447 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
3448 #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
3449 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
3450
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3451 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
3452 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
3453 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
3454 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
3455
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3456 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
3457 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
3458 #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
3459 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
3460 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
3461 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
3462 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
3463
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3464 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
3465 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
3466 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
3467 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
3468 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
3469 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
3470
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
3471 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
3472 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
3473 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
3474
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
3475 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
3476 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
3477 #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
3478 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
3479 #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
3480 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
3481 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3482 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
3483 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
3484 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
3485 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3486 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
3487 #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
3488 /* 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
3489 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
3490 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
3491 #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
3492
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3493 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
3494 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
3495
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3496 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
3497 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
3498 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3499
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3500
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
3501 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3502 * Create a new static text window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3503 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3504 * 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
3505 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 HWND dw_text_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 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
3514
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3515 /* 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
3516 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3517 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
3518 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
3519 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3520 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3521 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3522 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3523
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3524 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3525 * 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
3526 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3527 * 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
3528 * 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
3529 */
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3530 HWND dw_status_text_new(char *text, ULONG id)
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3531 {
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3532 GtkWidget *tmp, *frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3533 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3534
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3535 DW_MUTEX_LOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3536 frame = gtk_frame_new(NULL);
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3537 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
3538 tmp = gtk_label_new(text);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3539 gtk_container_add(GTK_CONTAINER(frame), tmp);
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3540 gtk_widget_show(tmp);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3541 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
3542
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
3543 /* 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
3544 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
3545 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
3546 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
3547 DW_MUTEX_UNLOCK;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
3548 return frame;
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3549 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3550
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
3551 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 * Create a new Multiline Editbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 * 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
3554 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3555 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3556 HWND dw_mle_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3557 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3558 GtkWidget *tmp, *tmpbox, *scroller;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3559 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3560
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3561 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
3562 #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
3563 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
3564 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
3565 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
3566 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
3567 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
3568 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
3569 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
3570
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
3571 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
3572 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3573 tmpbox = gtk_hbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3574 tmp = gtk_text_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3575 gtk_text_set_word_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3576 gtk_text_set_line_wrap(GTK_TEXT(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3577 scroller = gtk_vscrollbar_new(GTK_TEXT(tmp)->vadj);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3578 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
3579 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
3580 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
3581 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
3582 #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
3583 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
3584 gtk_object_set_user_data(GTK_OBJECT(tmpbox), (gpointer)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 gtk_widget_show(tmpbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 return tmpbox;
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 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 * Create a new Entryfield window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3593 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 * 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
3595 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3597 HWND dw_entryfield_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3598 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3599 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3600 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3601
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3602 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3603 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3604
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3605 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3607 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
3608 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3609
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3610 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3611 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3612 }
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 * Create a new Entryfield (password) window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3616 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3617 * 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
3618 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3619 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3620 HWND dw_entryfield_password_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3621 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3622 GtkWidget *tmp;
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 tmp = gtk_entry_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628 gtk_entry_set_visibility(GTK_ENTRY(tmp), FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 gtk_entry_set_text(GTK_ENTRY(tmp), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 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
3632 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636 }
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 * Create a new Combobox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 * 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
3642 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 HWND dw_combobox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646 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
3647 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
3648 gint cid;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 tmp = gtk_combo_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(tmp)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 gtk_combo_set_use_arrows(GTK_COMBO(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 gtk_object_set_user_data(GTK_OBJECT(tmp), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3655 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
3656 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
3657
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
3658 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
3659 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
3660 _set_signal_handler_id(GTK_COMBO(tmp)->list, sigid, cid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3661 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3662 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3663 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3664
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3665 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3666 * Create a new button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3667 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3668 * 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
3669 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671 HWND dw_button_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 tmp = gtk_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 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
3679 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3680 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3681 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3682 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3683
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3684 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3685 * Create a new bitmap button window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3686 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3687 * text: Bubble help text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3688 * id: An ID of a bitmap in the resource file.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3689 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3690 HWND dw_bitmapbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3691 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3692 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 GtkWidget *bitmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694 GtkTooltips *tooltips;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 tmp = gtk_button_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 bitmap = dw_bitmap_new(id);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 if(bitmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 {
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3703 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
3704 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
3705 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3706 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
3707 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
3708 {
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3709 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
3710 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
3711 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
3712 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
3713 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
3714 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
3715 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
3716 }
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3717
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3718 /*
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3719 * 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
3720 * Parameters:
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3721 * label_text: Text to display on button. TBD when Windows works
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
3722 * 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
3723 * 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
3724 * 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
3725 * 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
3726 * (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
3727 */
279
984db8aefd7f Build fixes for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 278
diff changeset
3728 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
3729 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3730 GtkWidget *bitmap;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3731 GtkWidget *box;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3732 GtkWidget *label;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3733 GtkWidget *button;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3734 GtkTooltips *tooltips;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3735 char *label_text=NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3736 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3737
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3738 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3739
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3740 /* Create box for image and label */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3741 box = gtk_hbox_new (FALSE, 0);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3742 gtk_container_set_border_width (GTK_CONTAINER (box), 2);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3743
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3744 /* Now on to the image stuff */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3745 bitmap = dw_bitmap_new(id);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3746 if ( bitmap )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3747 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3748 dw_window_set_bitmap( bitmap, 0, filename );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3749 /* Pack the image into the box */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3750 gtk_box_pack_start( GTK_BOX(box), bitmap, TRUE, FALSE, 3 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3751 gtk_widget_show( bitmap );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3752 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3753 if ( label_text )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3754 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3755 /* Create a label for the button */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3756 label = gtk_label_new( label_text );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3757 /* Pack the label into the box */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3758 gtk_box_pack_start( GTK_BOX(box), label, TRUE, FALSE, 3 );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3759 gtk_widget_show( label );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3760 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3761 /* Create a new button */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3762 button = gtk_button_new();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3763
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3764 /* Pack and show all our widgets */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3765 gtk_widget_show( box );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3766 gtk_container_add( GTK_CONTAINER(button), box );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3767 gtk_widget_show( button );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3768 if ( text )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3769 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3770 tooltips = gtk_tooltips_new();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3771 gtk_tooltips_set_tip( tooltips, button, text, NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3772 gtk_object_set_data( GTK_OBJECT(button), "tooltip", (gpointer)tooltips );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3773 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3774 gtk_object_set_data( GTK_OBJECT(button), "_dw_id", (gpointer)id );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3775 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3776 return button;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3777 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3778
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3779 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3780 * Create a new bitmap button window (widget) to be packed from data.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3781 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3782 * text: Bubble help text to be displayed.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3783 * id: An ID to be used with dw_window_from_id() or 0L.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3784 * data: Raw data of image.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3785 * (BMP on OS/2 or Windows, XPM on Unix)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3786 * len: Length of raw data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3787 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3788 HWND dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3789 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3790 GtkWidget *tmp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3791 GtkWidget *bitmap;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3792 GtkTooltips *tooltips;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3793 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3794
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3795 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3796 tmp = gtk_button_new();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3797 bitmap = dw_bitmap_new(id);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3798
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3799 if ( bitmap )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3800 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3801 dw_window_set_bitmap_from_data(bitmap, 0, data, len);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3802 gtk_container_add (GTK_CONTAINER(tmp), bitmap);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3803 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3804 gtk_widget_show(tmp);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3805 if(text)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3806 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3807 tooltips = gtk_tooltips_new();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3808 gtk_tooltips_set_tip(tooltips, tmp, text, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3809 gtk_object_set_data(GTK_OBJECT(tmp), "tooltip", (gpointer)tooltips);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3810 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3811 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3812 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
3813 return tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3814 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3815
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817 * Create a new spinbutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 * 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
3820 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 HWND dw_spinbutton_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3823 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3827
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829 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
3830 tmp = gtk_spin_button_new (adj, 0, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 gtk_widget_show(tmp);
592
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
3834 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_adjustment", (gpointer)adj);
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
3835 gtk_object_set_data(GTK_OBJECT(adj), "_dw_spinbutton", (gpointer)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
3836 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3837 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3841 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 * Create a new radiobutton window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 * 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
3845 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 HWND dw_radiobutton_new(char *text, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 /* This will have to be fixed in the future. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 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
3855 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859 return tmp;
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 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3863 * 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
3864 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3865 * 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
3866 * 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
3867 * 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
3868 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3869 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
3870 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3871 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
3872 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
3873 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
3874
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3875 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
3876 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
3877 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
3878 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
3879 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3880 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
3881 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
3882 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
3883 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
3884 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
3885 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
3886 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
3887 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
3888 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
3889 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3890
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
3891 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3892 * 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
3893 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3894 * 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
3895 * 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
3896 * 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
3897 */
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
3898 HWND dw_scrollbar_new(int vertical, ULONG id)
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3899 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3900 GtkWidget *tmp;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3901 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3902 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
3903
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3904 DW_MUTEX_LOCK;
511
80dbd5a1f403 Removed the increments parameter from dw_scrollbar_new().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 510
diff changeset
3905 adjustment = (GtkAdjustment *)gtk_adjustment_new(0, 0, 0, 1, 1, 1);
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3906 if(vertical)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3907 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
3908 else
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3909 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
3910 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
3911 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
3912 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
3913 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
3914 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
3915 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3916 return tmp;
196
3dc60d60007f Fixed a missing bracket.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 195
diff changeset
3917 }
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3918
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
3919 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3920 * Create a new percent bar window (widget) to be packed.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3921 * 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
3922 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3923 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
3924 HWND dw_percent_new(unsigned long id)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3925 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3926 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3927 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3928
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3929 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3930 tmp = gtk_progress_bar_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3931 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
3932 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3933 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3934 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3935 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3937 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3938 * Create a new checkbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3939 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3940 * 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
3941 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3942 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3943 HWND dw_checkbox_new(char *text, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3944 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3945 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3946 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3947
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3948 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3949 tmp = gtk_check_button_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3950 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
3951 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 * Create a new listbox window (widget) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 * 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
3959 * id: An ID to be used with dw_window_from_id() or 0L.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 * multi: Multiple select TRUE or FALSE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3961 */
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3962 HWND dw_listbox_new(unsigned long id, int multi)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 GtkWidget *tmp, *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3965 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3966
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3967 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3968 tmp = gtk_scrolled_window_new(NULL, NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3969 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW (tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3970 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3971
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3972 list = gtk_list_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3973 gtk_list_set_selection_mode(GTK_LIST(list), multi ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3974
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3975 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(tmp),
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3976 list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3977 gtk_object_set_user_data(GTK_OBJECT(tmp), list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3978 gtk_widget_show(list);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3979 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
3980 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3981
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 * Sets the icon used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 * id: An ID to be used to specify the icon.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3992 void dw_window_set_icon(HWND handle, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
3994 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 GdkPixmap *icon_pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3996 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3998 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
3999 icon_pixmap = _find_pixmap(&bitmap, id, handle, NULL, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4000
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4001 if(handle->window && icon_pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4002 gdk_window_set_icon(handle->window, NULL, icon_pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4004 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4005 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4006
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4007 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4008 * Sets the bitmap used for a given static window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4009 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4010 * 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
4011 * 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
4012 * (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
4013 * 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
4014 * 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
4015 * 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
4016 */
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
4017 void dw_window_set_bitmap(HWND handle, unsigned long id, char *filename)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4019 GdkBitmap *bitmap = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4020 GdkPixmap *tmp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4021 int found_ext = 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4022 int i;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4023 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4024
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4025 if(!id && !filename)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4026 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4027
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4028 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4029 if(id)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4030 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4031 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4032 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4033 char *file = alloca(strlen(filename) + 5);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4034 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4035 GdkPixbuf *pixbuf;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4036 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4037 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4038 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4039
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4040 if (!file)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4041 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4042 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4043 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4044 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4045
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4046 strcpy(file, filename);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4047
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4048 /* check if we can read from this file (it exists and read permission) */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4049 if ( access(file, 04 ) != 0 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4050 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4051 /* Try with .xpm extention */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4052 for ( i = 0; i < NUM_EXTS; i++ )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4053 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4054 strcpy( file, filename );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4055 strcat( file, image_exts[i] );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4056 if ( access( file, 04 ) == 0 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4057 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4058 found_ext = 1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4059 break;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4060 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4061 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4062 if ( found_ext == 0 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4063 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4064 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4065 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4066 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4067 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4068 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4069 pixbuf = gdk_pixbuf_new_from_file(file, NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4070 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4071 g_object_unref(pixbuf);
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
4072 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4073 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4074 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4075 tmp = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4076 bitmap = gdk_imlib_copy_mask(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4077 gdk_imlib_destroy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4078 #else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4079 tmp = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4080 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4081 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4082
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4083 if(tmp)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4084 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4085 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4086 gtk_image_set_from_pixmap(GTK_IMAGE(handle), tmp, bitmap);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4087 #else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4088 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4089 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4090 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4091 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4092 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4093
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4094 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4095 * Sets the bitmap used for a given static window.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4096 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4097 * handle: Handle to the window.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4098 * id: An ID to be used to specify the icon,
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4099 * (pass 0 if you use the filename param)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4100 * data: the image data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4101 * Bitmap on Windows and a pixmap on Unix, pass
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4102 * NULL if you use the id param)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4103 * len: length of data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4104 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4105 void dw_window_set_bitmap_from_data(HWND handle, unsigned long id, char *data, int len)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4106 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4107 GdkBitmap *bitmap = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4108 GdkPixmap *tmp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4109 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4110 char *file;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4111 FILE *fp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4112
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4113 if (!id && !data)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4114 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4115
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4116 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4117 if (id)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4118 tmp = _find_pixmap(&bitmap, id, handle, NULL, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4119 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4120 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4121 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4122 GdkPixbuf *pixbuf;
278
df0665ba147f Initial code for dw_bitmapbutton_new_from_file and added filename parameter
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 273
diff changeset
4123 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4124 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4125 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4126 if (!data)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4127 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4128 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4129 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4130 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4131 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4132 * A real hack; create a temporary file and write the contents
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4133 * of the data to the file
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4134 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4135 file = tmpnam( NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4136 fp = fopen( file, "wb" );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4137 if ( fp )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4138 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4139 fwrite( data, len, 1, fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4140 fclose( fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4141 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4142 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4143 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4144 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4145 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4146 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4147 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4148 pixbuf = gdk_pixbuf_new_from_file(file, NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4149 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &tmp, &bitmap, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4150 g_object_unref(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4151 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4152 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4153 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4154 tmp = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4155 bitmap = gdk_imlib_copy_mask(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4156 gdk_imlib_destroy_image(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
4157 #else
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4158 tmp = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], mydata);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4159 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4160 /* remove our temporary file */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4161 unlink (file );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4162 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4163
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4164 if(tmp)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4165 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4166 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4167 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
4168 #else
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4169 gtk_pixmap_set(GTK_PIXMAP(handle), tmp, bitmap);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4170 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4171 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4172 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 * Sets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 * handle: Handle to the window.
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
4179 * text: The text associated with a given window.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 void dw_window_set_text(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 int _locked_by_me = FALSE;
518
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
4184 GtkWidget *tmp;
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
4185
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
4186 DW_MUTEX_LOCK;
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
4187 if((tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi_title")))
7efc5f99c4cc Implemented dw_window_show/hide/minimize/destroy/set_text for MDI children.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 517
diff changeset
4188 handle = tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4189 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4190 gtk_entry_set_text(GTK_ENTRY(handle), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4191 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4192 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle)->entry), text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4193 else if(GTK_IS_LABEL(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4194 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
4195 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
4196 {
407
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
4197 #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
4198 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
4199
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
4200 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
4201 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
4202 #else
a8124a9561c7 Fix for dw_window_set_text() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 403
diff changeset
4203 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
4204 #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
4205 }
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
4206 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
4207 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
4208 else if(GTK_IS_FRAME(handle))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4209 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4210 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
4211 if(tmp && GTK_IS_LABEL(tmp))
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
4212 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
4213 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4214 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4215 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4216
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4217 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4218 * Gets the text used for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4219 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4220 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4221 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4222 * text: The text associsated with a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4223 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4224 char *dw_window_get_text(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4225 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4226 #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
4227 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
4228 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 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
4230 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 if(GTK_IS_ENTRY(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 possible = gtk_entry_get_text(GTK_ENTRY(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4236 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4237 possible = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle)->entry));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4238
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4239 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4240 return strdup(possible);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4241 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4242
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4243 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4244 * Disables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4245 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4246 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4247 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4248 void dw_window_disable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4249 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4250 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4251
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4252 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4253 gtk_widget_set_sensitive(handle, FALSE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4254 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4255 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4257 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 * Enables given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 void dw_window_enable(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4264 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4265
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4266 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 gtk_widget_set_sensitive(handle, TRUE);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4270
249
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
4271 /*
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
4272 * 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
4273 * Parameters:
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
4274 * 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
4275 * 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
4276 */
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
4277 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
4278 {
267
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4279 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
4280 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
4281
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4282 DW_MUTEX_LOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4283 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
4284 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4285 #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
4286 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
4287 #else
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4288 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
4289 #endif
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4290 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4291 while(list)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4292 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4293 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
4294 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4295 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
4296 {
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4297 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
4298 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4299 DW_MUTEX_UNLOCK;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4300 return ret;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4301 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4302 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4303 list = list->next;
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4304 }
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4305 if(orig)
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4306 g_list_free(orig);
bf8b907f8a29 Added initial version of updated key_press_event callback.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 265
diff changeset
4307 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
4308 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
4309 }
5a594058687f Added empty dw_window_from_id()... will try to implement it shortly.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 246
diff changeset
4310
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4311 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
4312 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4313 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
4314
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4315 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
4316 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4317 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
4318 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4319 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
4320 x++;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4321 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4322 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4323 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
4324 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4325
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 * Adds text to an MLE box and returns the current point.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4330 * buffer: Text buffer to be imported.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4331 * startpoint: Point to start entering text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4332 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4333 unsigned int dw_mle_import(HWND handle, char *buffer, int startpoint)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4334 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4335 unsigned int tmppoint = startpoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4336 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4337
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4338 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
4339 #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
4340 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
4341 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4342 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
4343 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4344 {
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
4345 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4347 #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
4348 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
4349 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4350 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
4351 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
4352 GtkTextIter iter;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
4353
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4354 _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
4355
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4356 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
4357 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
4358 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
4359 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
4360 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
4361 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
4362 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4363 #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
4364 GdkFont *font = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_gdkfont");
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
4365
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4366 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4367 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
4368 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
4369 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
4370 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
4371
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
4372 _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
4373
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4374 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
4375 gtk_text_insert(GTK_TEXT(tmp), font, fore, back, impbuf, -1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 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
4377 free(impbuf);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4379 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 return tmppoint;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 * Grabs text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 * handle: Handle to the MLE to be queried.
608
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4389 * buffer: Text buffer to be exported. MUST allow for trailing nul character.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 * startpoint: Point to start grabbing text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4391 * length: Amount of text to be grabbed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4392 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4393 void dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4394 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4395 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4396 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4397
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4398 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
4399 /* 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
4400 if(buffer)
608
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4401 buffer[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
4402 #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
4403 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
4404 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4405 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
4406 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 {
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
4408 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409
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
4410 #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
4411 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
4412 {
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
4413 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
4414 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
4415
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
4416 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
4417 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
4418 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
4419 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
4420 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
4421 {
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
4422 if(buffer)
610
2bff0dbae0e5 Fix introduced compilation error.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 608
diff changeset
4423 strcpy(buffer, text);
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
4424 }
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
4425 }
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
4426 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4427 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4428 {
608
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4429 text = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, -1); /* get the complete contents */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4430 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4431 {
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
4432 if(buffer)
608
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4433 {
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4434 len = strlen(text);
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4435 if(startpoint < len)
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4436 {
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4437 max = min(length, len - startpoint);
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4438 memcpy(buffer, &text[startpoint], max);
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4439 buffer[max] = '\0';
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4440 }
e49524bc2f07 Fix trailing junk on dw_mle_export()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 592
diff changeset
4441 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444 }
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
4445 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 * Obtains information about an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 * handle: Handle to the MLE to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454 * bytes: A pointer to a variable to return the total bytes.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 * lines: A pointer to a variable to return the number of lines.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4457 void dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4460
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 if(bytes)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 *bytes = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4464 *lines = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4465
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4466 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
4467 #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
4468 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
4469 {
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
4470 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
4471
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4472 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
4473 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4474 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
4475
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4476 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
4477 *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
4478 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
4479 *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
4480 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4481 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4482 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 {
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
4485 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4489 if(bytes)
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4490 *bytes = gtk_text_get_length(GTK_TEXT(tmp)) + 1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4491 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4492 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4493 gchar *text;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4494
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4495 *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
4496 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
4497
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4498 if(text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4499 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4500 int z, len = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4501
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4502 for(z=0;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504 if(text[z] == '\n')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 (*lines)++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 g_free(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4512 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4513 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4514 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4515
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4516 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4517 * Deletes text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4518 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4519 * handle: Handle to the MLE to be deleted from.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4520 * startpoint: Point to start deleting text.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4521 * length: Amount of text to be deleted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4522 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4523 void dw_mle_delete(HWND handle, int startpoint, int length)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4524 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4525 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527 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
4528 #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
4529 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
4530 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 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
4532 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 {
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
4534 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535
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
4536 #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
4537 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
4538 {
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
4539 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
4540 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
4541
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
4542 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
4543 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
4544 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
4545 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
4546 }
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
4547 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4548 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4549 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4550 gtk_text_set_point(GTK_TEXT(tmp), startpoint);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4551 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4553 #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
4554 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 * Clears all text from an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 void dw_mle_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 int length, _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4567 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
4568 #if GTK_MAJOR_VERSION > 1
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4569 if(GTK_IS_SCROLLED_WINDOW(handle))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4570 {
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
4571 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
4572
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4573 if(tmp && GTK_IS_TEXT_VIEW(tmp))
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4574 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4575 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tmp));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
4576
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4577 length = -1;
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4578 gtk_text_buffer_set_text(buffer, "", length);
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4579 }
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
4580 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4581 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4582 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4583 {
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
4584 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4585
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4586 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4587 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 length = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 gtk_text_set_point(GTK_TEXT(tmp), 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 gtk_text_forward_delete(GTK_TEXT(tmp), length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4593 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4597 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 * Sets the visible line of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4599 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 * handle: Handle to the MLE.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 * line: Line to be visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
4603 void dw_mle_set_visible(HWND handle, int line)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4604 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4605 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4606
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4607 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
4608 #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
4609 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
4610 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4611 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
4612
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4613 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
4614 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4615 GtkTextBuffer *tbuffer;
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4616 GtkTextIter iter;
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4617 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
4618
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4619 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
4620 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
4621 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
4622 if(!mark)
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4623 {
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4624 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
4625 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
4626 }
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4627 else
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4628 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
4629 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
4630 0, FALSE, 0, 0);
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4631 }
3a51ecc8383a Implemented dw_mle_set_visible() for GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 353
diff changeset
4632 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4633 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635 {
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
4636 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 unsigned long lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4643 dw_mle_get_size(handle, NULL, &lines);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 if(lines)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4646 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4647 ratio = (float)line/(float)lines;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4649 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
4650
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4651 gtk_adjustment_set_value(GTK_TEXT(tmp)->vadj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4652 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4653 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4654 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4655 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4656 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4657 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4658
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 /*
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4660 * Sets the editablity of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4661 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4662 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4663 * 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
4664 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
4665 void dw_mle_set_editable(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4666 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4667 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4668
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4669 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
4670 #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
4671 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
4672 {
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
4673 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
4674
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4675 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
4676 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
4677 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4678 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4679 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4680 {
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
4681 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
4682
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4683 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4684 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
4685 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4686 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4687 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4688 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4689
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4690 /*
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4691 * Sets the word wrap state of an MLE box.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4692 * Parameters:
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4693 * handle: Handle to the MLE.
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4694 * 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
4695 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
4696 void dw_mle_set_word_wrap(HWND handle, int state)
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4697 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4698 int _locked_by_me = FALSE;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4699
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4700 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
4701 #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
4702 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
4703 {
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
4704 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
4705
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4706 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
4707 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
4708 }
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4709 #else
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4710 if(GTK_IS_BOX(handle))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4711 {
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
4712 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
4713
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4714 if(tmp && GTK_IS_TEXT(tmp))
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4715 {
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4716 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
4717 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
4718 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4719 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4720 #endif
7
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4721 DW_MUTEX_UNLOCK;
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4722 }
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4723
005fa766e8c2 Updates to latest build.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 3
diff changeset
4724 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4725 * Sets the current cursor position of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4726 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4727 * handle: Handle to the MLE to be positioned.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4728 * point: Point to position cursor.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4729 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4730 void dw_mle_set_cursor(HWND handle, int point)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4731 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4732 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4733
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4734 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
4735 #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
4736 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
4737 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738 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
4739 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 {
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
4741 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742
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
4743 #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
4744 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
4745 {
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
4746 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
4747 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
4748 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
4749
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
4750 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
4751 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
4752 if(!mark)
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
4753 {
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
4754 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
4755 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
4756 }
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
4757 else
08e56a0f9541 dw_mle_set() now moves the viewport to the cursor location.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 352
diff changeset
4758 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
4759 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
4760 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
4761 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
4762 }
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
4763 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 {
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4766 unsigned long chars;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4767 float pos, ratio;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4768
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4769 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
4770
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4771 if(chars)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4772 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4773 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
4774
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4775 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
4776
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
4777 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
4778 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4779 gtk_text_set_point(GTK_TEXT(tmp), point);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4780 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4781 #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
4782 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4783 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4784 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 * Finds text in an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 * handle: Handle to the MLE to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 * text: Text to search for.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 * point: Start point of search.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 * flags: Search specific flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 int dw_mle_search(HWND handle, char *text, int point, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4796 int _locked_by_me = FALSE, retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4797
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4798 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
4799 #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
4800 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
4801 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4802 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
4803 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4804 {
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
4805 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4806
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
4807 #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
4808 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
4809 {
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
4810 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
4811 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
4812
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
4813 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
4814 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
4815 gtk_text_iter_forward_search(&iter, text, GTK_TEXT_SEARCH_TEXT_ONLY, &found, NULL, NULL);
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
4816 retval = gtk_text_iter_get_offset(&found);
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
4817 }
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
4818 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 int len = gtk_text_get_length(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 gchar *tmpbuf;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 tmpbuf = gtk_editable_get_chars(GTK_EDITABLE(&(GTK_TEXT(tmp)->editable)), 0, len);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 if(tmpbuf)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 int z, textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 textlen = strlen(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 if(flags & DW_MLE_CASESENSITIVE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4833 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4834 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4835 if(strncmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4836 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4839 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4840 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4841 for(z=point;z<(len-textlen) && !retval;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4842 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4843 if(strncasecmp(&tmpbuf[z], text, textlen) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4844 retval = z + textlen;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4845 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 if(retval)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 gtk_text_set_point(GTK_TEXT(tmp), retval - textlen);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 gtk_editable_select_region(&(GTK_TEXT(tmp)->editable), retval - textlen, retval);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 g_free(tmpbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4855 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
4857 #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
4858 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4859 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4860 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4861 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4862
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4863 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4864 * Stops redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4865 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4866 * handle: Handle to the MLE to freeze.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4867 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4868 void dw_mle_freeze(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4869 {
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
4870 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4871 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4872
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4873 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4874 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 {
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
4876 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 gtk_text_freeze(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 }
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
4883 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
4884 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888 * Resumes redrawing of an MLE box.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 * handle: Handle to the MLE to thaw.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 void dw_mle_thaw(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 {
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
4894 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898 if(GTK_IS_BOX(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4899 {
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
4900 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4901
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4902 if(tmp && GTK_IS_TEXT(tmp))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4903 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4904 gtk_text_thaw(GTK_TEXT(tmp));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4906 }
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
4907 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
4908 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4909 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4910
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4911 /*
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
4912 * Sets the percent bar position.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4913 * 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
4914 * 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
4915 * position: Position of the percent bar withing the range.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4916 */
33
72675de7d229 Renamed slider class to percent class. Implemented my own percent widget
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 30
diff changeset
4917 void dw_percent_set_pos(HWND handle, unsigned int position)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4918 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4919 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 gtk_progress_bar_update(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 /*
63
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4927 * 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
4928 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4929 * 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
4930 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4931 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
4932 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4933 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
4934 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
4935
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4936 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
4937 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
4938
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4939 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
4940 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
4941 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
4942 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4943 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
4944 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
4945
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4946 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
4947 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
4948 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4949 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
4950 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4951 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
4952 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
4953 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4954
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4955 /*
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4956 * 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
4957 * Parameters:
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4958 * 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
4959 * 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
4960 */
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4961 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
4962 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4963 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
4964 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
4965
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4966 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
4967 return;
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4968
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4969 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
4970 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
4971 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
4972 {
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4973 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
4974
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4975 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
4976 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
4977 else
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4978 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
4979 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4980 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
4981 }
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4982
a6801a2260af Synched up with the latest dynamic windows, has new slider support and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 60
diff changeset
4983 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4984 * 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
4985 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4986 * 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
4987 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
4988 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
4989 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4990 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
4991 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4992
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4993 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4994 return 0;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4995
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
4996 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
4997 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
4998 if(adjustment)
415
9ffdbfd83652 Don't distinguish between vertical and horizontal scrollbars in
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 410
diff changeset
4999 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
5000 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5001 return val;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5002 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5003
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5004 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5005 * 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
5006 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5007 * 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
5008 * 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
5009 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5010 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
5011 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5012 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
5013 GtkAdjustment *adjustment;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5014
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5015 if(!handle)
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5016 return;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5017
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5018 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
5019 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
5020 if(adjustment)
215
03e68274623d Two scrollbar fixes for GTK... one from Mark Hessling.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 214
diff changeset
5021 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
5022 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5023 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5024
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
5025 /*
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
5026 * 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
5027 * 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
5028 * 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
5029 * 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
5030 * 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
5031 */
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
5032 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
5033 {
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
5034 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
5035 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
5036
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
5037 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
5038 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
5039
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
5040 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
5041 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
5042 if(adjustment)
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
5043 {
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
5044 adjustment->upper = (gdouble)range;
216
bd06f8d123f0 Oops typo.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 215
diff changeset
5045 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
5046 }
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
5047 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
5048 }
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
5049
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
5050 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 * Sets the spinbutton value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 void dw_spinbutton_set_pos(HWND handle, long position)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 gtk_spin_button_set_value(GTK_SPIN_BUTTON(handle), (gfloat)position);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 * Sets the spinbutton limits.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5068 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5069 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5070 * position: Current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5071 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5072 void dw_spinbutton_set_limits(HWND handle, long upper, long lower)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5073 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5074 long curval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5075 GtkAdjustment *adj;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5076 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5077
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5078 curval = dw_spinbutton_get_pos(handle);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5079 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5080 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
5081 gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(handle), adj);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5082 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5083 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086 * Sets the entryfield character limit.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 * handle: Handle to the spinbutton to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * limit: Number of characters the entryfield will take.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 void dw_entryfield_set_limit(HWND handle, ULONG limit)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5092 {
270
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
5093 int _locked_by_me = FALSE;
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
5094
d2a80e648d33 Implemented dw_entryfield_set_limit() on GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 269
diff changeset
5095 DW_MUTEX_LOCK;
271
38d8908c4438 Corrected incorrect typecast.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 270
diff changeset
5096 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
5097 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 * Returns the current value of the spinbutton.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5103 * handle: Handle to the spinbutton to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5105 long dw_spinbutton_get_pos(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5107 long retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 retval = (long)gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118 * Returns the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5122 int dw_checkbox_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 retval = GTK_TOGGLE_BUTTON(handle)->active;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 * Sets the state of the checkbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5136 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 * handle: Handle to the checkbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 * value: TRUE for checked, FALSE for unchecked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5140 void dw_checkbox_set(HWND handle, int value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5141 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5142 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5143
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5144 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5145 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(handle), value);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5146 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5147 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5148
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5149 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5150 * 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
5151 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5152 * 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
5153 * 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
5154 * title: The text title of the entry.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5155 * icon: Handle to coresponding icon.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5156 * parent: Parent handle or 0 if root.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5157 * itemdata: Item specific data.
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5158 */
329
9b1953ed0bff Oops missed one parameter change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 328
diff changeset
5159 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
5160 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5161 #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
5162 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
5163 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
5164 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
5165 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
5166 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
5167 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
5168
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5169 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
5170 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
5171
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5172 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
5173 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
5174 && 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
5175 (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
5176 {
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
5177 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5178
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5179 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
5180
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
5181 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
5182 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
5183 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
5184 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
5185 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
5186 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5187 DW_MUTEX_UNLOCK;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5188
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5189 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
5190 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5191 GtkWidget *newitem, *tree, *subtree, *label, *hbox, *pixmap;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5192 GdkPixmap *gdkpix;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5193 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
5194 int position = -1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5195 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5196
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5197 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5198 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5199
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5200 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5201 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
5202 if(!tree || !GTK_IS_TREE(tree))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5203 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5204 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5205 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5206 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5207
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5208 if(item && GTK_IS_TREE_ITEM(item))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5209 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
5210
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5211 position++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5212
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5213 newitem = gtk_tree_item_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5214 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
5215 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
5216 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
5217 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
5218 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
5219 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
5220 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
5221 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
5222 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
5223 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5224 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5225 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
5226 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
5227 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
5228 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5229 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
5230 gtk_widget_show(label);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5231 gtk_widget_show(hbox);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5232
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
5233 {
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5234 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
5235 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
5236 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
5237
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5238 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
5239 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5240 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
5241 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
5242 _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
5243 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5244 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5245
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5246 _dw_ignore_expand = 1;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5247 if(parent)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5248 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5249 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
5250 if(!subtree || !GTK_IS_TREE(subtree))
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5251 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5252 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
5253 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
5254 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
5255
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5256 subtree = gtk_tree_new();
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5257
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5258 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5259 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
5260 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
5261 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
5262 _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
5263 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5264
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5265 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
5266 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
5267 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
5268
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5269 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5270 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
5271 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
5272 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
5273 _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
5274 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5275
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5276 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
5277 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
5278 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
5279 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
5280 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
5281 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
5282 gtk_widget_show(subtree);
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5283 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
5284 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
5285 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5286 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
5287 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
5288 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5289 else
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5290 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5291 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
5292 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
5293 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5294 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
5295 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
5296 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
5297 _dw_ignore_expand = 0;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5298 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
5299 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
5300 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5301 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5302
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5303 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5304 * 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
5305 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5306 * 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
5307 * 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
5308 * 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
5309 * 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
5310 * 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
5311 */
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
5312 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
5313 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5314 #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
5315 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
5316 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
5317 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
5318 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
5319 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
5320 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
5321
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5322 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
5323 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
5324
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5325 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
5326 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
5327 && 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
5328 (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
5329 {
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
5330 iter = (GtkTreeIter *)malloc(sizeof(GtkTreeIter));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5331
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5332 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
5333
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
5334 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
5335 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
5336 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
5337 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
5338 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
5339 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5340 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
5341
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5342 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
5343 #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
5344 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
5345 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5346 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
5347 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
5348
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5349 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5350 return NULL;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5351
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5352 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
5353 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
5354 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
5355 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5356 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
5357 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
5358 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5359 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
5360 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
5361 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
5362 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
5363 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
5364 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
5365 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
5366 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
5367 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
5368 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
5369 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5370 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5371 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
5372 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
5373 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
5374 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5375 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
5376 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
5377 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
5378
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
5379 {
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5380 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
5381 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
5382 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
5383
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5384 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
5385 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5386 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
5387 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
5388 _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
5389 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5390 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5391
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
5392 _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
5393 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
5394 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5395 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
5396 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
5397 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5398 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
5399 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
5400 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
5401
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5402 subtree = gtk_tree_new();
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5403
361
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5404 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5405 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
5406 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
5407 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
5408 _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
5409 }
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5410
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5411 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
5412 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
5413 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
5414
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5415 if(thisfunc && work.window)
8c0212f70914 Signal handler changes to avoid a memory leak.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 359
diff changeset
5416 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
5417 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
5418 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
5419 _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
5420 }
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
5421
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5422 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
5423 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
5424 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
5425 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
5426 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
5427 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
5428 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
5429 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
5430 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
5431 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5432 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
5433 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
5434 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5435 else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5436 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5437 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
5438 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
5439 }
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
5440 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
5441 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
5442 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
5443 _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
5444 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
5445 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
5446 #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
5447 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
5448
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5449 /*
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
5450 * 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
5451 * 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
5452 * 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
5453 * 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
5454 * 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
5455 * 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
5456 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5457 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
5458 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5459 #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
5460 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
5461 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
5462 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
5463 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
5464
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5465 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
5466 return;
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5467
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5468 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
5469 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
5470 && 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
5471 (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
5472 {
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5473 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
5474
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5475 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
5476 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
5477 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
5478 }
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5479 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
5480 #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
5481 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
5482 GdkPixmap *gdkpix;
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5483 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
5484 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
5485 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
5486
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5487 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5488 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5489
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
5490 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
5491 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
5492 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
5493 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
5494 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
5495 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
5496 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
5497 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
5498 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
5499 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
5500 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
5501 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
5502 if(gdkpix)
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5503 {
a167001c56df Check that _find_pixmap() returns a pixmap handle before packing the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 249
diff changeset
5504 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
5505 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
5506 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
5507 }
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
5508 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
5509 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
5510 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
5511 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
5512 #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
5513 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5514
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5515 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5516 * 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
5517 * 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
5518 * 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
5519 * 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
5520 * 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
5521 */
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
5522 void dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
54
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5523 {
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
5524 #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
5525 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
5526 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
5527 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
5528
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
5529 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
5530 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
5531
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
5532 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
5533 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
5534 && 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
5535 (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
5536 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
5537 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
5538 #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
5539 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
5540
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5541 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5542 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5543
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
5544 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
5545 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
5546 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
5547 #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
5548 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5549
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5550 /*
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
5551 * 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
5552 * 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
5553 * 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
5554 * 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
5555 */
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5556 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
5557 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5558 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
5559 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
5560 #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
5561 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
5562 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
5563 #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
5564
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5565 if(!handle || !item)
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
5566 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
5567
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5568 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
5569 #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
5570 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
5571
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
5572 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
5573 (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
5574 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
5575 #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
5576 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
5577 #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
5578 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
5579 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
5580 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5581
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5582 /*
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5583 * 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
5584 * 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
5585 * 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
5586 * 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
5587 */
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5588 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
5589 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5590 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
5591 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
5592 #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
5593 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
5594 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
5595 #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
5596
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5597 if(!handle || !item)
479
61e2973ad093 Minor compile fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 478
diff changeset
5598 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
5599
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5600 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
5601 #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
5602 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
5603
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
5604 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
5605 (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
5606 {
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
5607 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
5608
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
5609 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
5610 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
5611 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
5612 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
5613 }
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
5614 #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
5615 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
5616 #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
5617 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
5618 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
5619 }
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5620
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
5621 /*
317
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5622 * 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
5623 * Parameters:
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5624 * 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
5625 * 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
5626 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5627 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
5628 {
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5629 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
5630 #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
5631 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
5632 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
5633 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
5634
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5635 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
5636 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
5637
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5638 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
5639 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
5640 && 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
5641 (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
5642 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
5643 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
5644 #else
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5645 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
5646
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5647 if(!handle || !item)
319
aed5d742896d Fixed errant returns on failure.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 317
diff changeset
5648 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
5649
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5650 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
5651 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
5652 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
5653 #endif
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5654 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
5655 }
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5656
83edbd751da9 Added dw_tree_get_data() to get a tree item's data.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 316
diff changeset
5657 /*
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
5658 * 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
5659 * 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
5660 * 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
5661 * 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
5662 */
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
5663 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
5664 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5665 #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
5666 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5667 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5668 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
5669
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
5670 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
5671 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5672
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5673 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
5674 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
5675 && 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
5676 (store = (GtkTreeStore *)gtk_object_get_data(GTK_OBJECT(tree), "_dw_tree_store")))
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5677 {
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5678 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
5679 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5680
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5681 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
5682 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
5683 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
5684 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5685 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
5686 #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
5687 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
5688 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
5689
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5690 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5691 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5692
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
5693 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
5694 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
5695 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
5696 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
5697 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
5698 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
5699 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
5700 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
5701 #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
5702 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5703
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
5704 #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
5705 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
5706 {
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
5707 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
5708 GtkTreeIter iter;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5709
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
5710 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
5711 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
5712 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
5713 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
5714
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
5715 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
5716 {
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
5717 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
5718 _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
5719 } 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
5720 }
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
5721 }
143
1d57c27e4adc Moved _dw_recursive_free into GTK 2.0 #ifdefs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 142
diff changeset
5722 #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
5723
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
5724 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5725 * Removes all nodes from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5726 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5727 * 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
5728 */
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5729 void dw_tree_clear(HWND handle)
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5730 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5731 #if GTK_MAJOR_VERSION > 1
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
5732 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
5733 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5734 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
5735
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5736 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5737 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5738
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5739 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
5740 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
5741 && 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
5742 (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
5743 {
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
5744 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
5745
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
5746 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
5747 {
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
5748 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
5749 _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
5750 } 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
5751 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5752 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
5753 }
139
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5754 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
5755 #else
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5756 GtkWidget *tree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5757 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5758
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5759 if(!handle)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5760 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5761
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5762 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5763 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
5764 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5765 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5766 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5767 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5768 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5769 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
5770 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
5771 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
5772 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5773 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5774
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5775 /*
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
5776 * 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
5777 * 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
5778 * 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
5779 * 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
5780 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5781 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
5782 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5783 #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
5784 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5785 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5786 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
5787
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5788 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5789 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5790
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5791 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
5792 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
5793 && 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
5794 (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
5795 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5796 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
5797 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
5798 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
5799 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5800 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
5801 #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
5802 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
5803
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5804 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5805 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5806
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
5807 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
5808 _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
5809 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
5810 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
5811 _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
5812 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
5813 #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
5814 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5815
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5816 /*
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5817 * 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
5818 * 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
5819 * 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
5820 * 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
5821 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5822 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
5823 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5824 #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
5825 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5826 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5827 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
5828
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5829 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5830 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5831
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5832 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
5833 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
5834 && 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
5835 (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
5836 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5837 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
5838 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
5839 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
5840 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5841 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
5842 #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
5843 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
5844
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5845 if(!handle || !item)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5846 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5847
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
5848 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
5849 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
5850 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
5851 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
5852 #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
5853 }
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5854
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
5855 /*
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5856 * Removes a node from a tree.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5857 * Parameters:
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5858 * 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
5859 * item: Handle to node to be deleted.
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5860 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
5861 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
5862 {
138
d22b50184e3b Initial tree code for GTK 2.0, populating finished. Signal handlers and
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 135
diff changeset
5863 #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
5864 GtkWidget *tree;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5865 GtkTreeStore *store;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5866 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
5867
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5868 if(!handle)
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5869 return;
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5870
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5871 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
5872 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
5873 && 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
5874 (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
5875 {
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5876 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
5877 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
5878 }
ccf210251c99 Implemented GTK 2.0 tree delete etc. just signal handlers left.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 138
diff changeset
5879 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
5880 #else
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5881 GtkWidget *tree, *lastselect, *parenttree;
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5882 int _locked_by_me = FALSE;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5883
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5884 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
5885 return;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5886
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5887 DW_MUTEX_LOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5888 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
5889 if(!tree || !GTK_IS_TREE(tree))
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5890 {
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5891 DW_MUTEX_UNLOCK;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5892 return;
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5893 }
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
5894
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5895 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
5896
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5897 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
5898
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
5899 if(lastselect == item)
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5900 {
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
5901 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
5902 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
5903 }
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5904
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
5905 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
5906 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
5907 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
5908 #endif
30
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5909 }
b1d7e8a28dfa Added tree view functions and signal.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 22
diff changeset
5910
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
5911 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
5912 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5913 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5914 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
5915 int z, multi;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5916 int _locked_by_me = FALSE;
355
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5917 GtkJustification justification;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5918
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5919 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5920 clist = gtk_clist_new_with_titles(count, (gchar **)titles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5921 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5922 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5923 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5924 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5925 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
5926 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
5927 gtk_object_set_data(GTK_OBJECT(handle), "_dw_multi", (gpointer)multi);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5928
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5929 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
5930 if(multi)
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5931 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
5932 else
2216e65ad2ae Removed slider flags and container selection flags from the header file.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 346
diff changeset
5933 gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_SINGLE);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 gtk_container_add(GTK_CONTAINER(handle), clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935 gtk_object_set_user_data(GTK_OBJECT(handle), (gpointer)clist);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 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
5937 gtk_object_set_data(GTK_OBJECT(clist), "_dw_colcount", (gpointer)count);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 if(extra)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 gtk_clist_set_column_width(GTK_CLIST(clist), 1, 120);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 for(z=0;z<count;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5943 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5944 if(!extra || z > 1)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5945 gtk_clist_set_column_width(GTK_CLIST(clist), z, 50);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5946 sprintf(numbuf, "%d", z);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5947 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
5948 if(flags[z]&DW_CFA_RIGHT)
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5949 justification = GTK_JUSTIFY_RIGHT;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5950 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
5951 justification = GTK_JUSTIFY_CENTER;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5952 else
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5953 justification = GTK_JUSTIFY_LEFT;
3a71623fc219 Changes to implement justification on container columns.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 354
diff changeset
5954 gtk_clist_set_column_justification(GTK_CLIST(clist),z,justification);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5961 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5962 * Sets up the container columns.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5963 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5964 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5965 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 * separator: The column number that contains the main separator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5969 * (this item may only be used in OS/2)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5970 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5971 int dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5972 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 return _dw_container_setup(handle, flags, titles, count, separator, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 * handle: Handle to the container to be configured.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 * flags: An array of unsigned longs with column flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 * titles: An array of strings with column text titles.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5982 * count: The number of columns (this should match the arrays).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5983 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5984 int dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5985 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5986 char **newtitles = malloc(sizeof(char *) * (count + 1));
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5987 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
5988
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5989 newtitles[0] = "Filename";
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5990
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5991 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
5992
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5993 memcpy(&newtitles[1], titles, sizeof(char *) * count);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5994 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
5995
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
5996 _dw_container_setup(handle, newflags, newtitles, count + 1, 1, 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5997
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5998 free(newtitles);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5999 free(newflags);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6000 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6001 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6002
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6003 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6004 * Obtains an icon from a module (or header in GTK).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6005 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6006 * module: Handle to module (DLL) in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6007 * id: A unsigned long id int the resources on OS/2 and
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6008 * Windows, on GTK this is converted to a pointer
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 * to an embedded XPM.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 unsigned long dw_icon_load(unsigned long module, unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 return id;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 /*
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
6017 * 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
6018 * 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
6019 * 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
6020 * 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
6021 * (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
6022 */
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
6023 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
6024 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6025 int found = -1, _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6026 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6027 GdkPixbuf *pixbuf;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6028 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6029 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6030 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6031 char *file = alloca(strlen(filename) + 5);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6032 unsigned long z, ret = 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6033
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6034 if (!file)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6035 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6036
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6037 strcpy(file, filename);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6038
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6039 /* check if we can read from this file (it exists and read permission) */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6040 if (access(file, 04) != 0)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6041 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6042 /* Try with .xpm extention */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6043 strcat(file, ".xpm");
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6044 if(access(file, 04) != 0)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6045 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6046 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6047
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6048 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6049 /* Find a free entry in the array */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6050 for (z=0;z<_PixmapCount;z++)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6051 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6052 if (!_PixmapArray[z].used)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6053 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6054 ret = found = z;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6055 break;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6056 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6057 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6058
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6059 /* If there are no free entries, expand the
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6060 * array.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6061 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6062 if (found == -1)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6063 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6064 DWPrivatePixmap *old = _PixmapArray;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6065
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6066 ret = found = _PixmapCount;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6067 _PixmapCount++;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6068
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6069 _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6070
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6071 if (found)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6072 memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6073 if (old)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6074 free(old);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6075 _PixmapArray[found].used = 1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6076 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6077 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6078
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6079 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6080 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6081 if (pixbuf)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6082 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6083 _PixmapArray[found].pixbuf = pixbuf;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6084 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6085 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6086
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6087 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6088 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6089 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6090 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6091 if (image)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6092 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6093 _PixmapArray[found].width = image->rgb_width;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6094 _PixmapArray[found].height = image->rgb_height;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6095
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6096 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6097 _PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6098 _PixmapArray[found].mask = gdk_imlib_copy_mask(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6099 gdk_imlib_destroy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6100 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6101 #else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6102 if (last_window)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6103 _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6104 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6105 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6106 if (!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6107 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6108 _PixmapArray[found].used = 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6109 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6110 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6111 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6112 return ret | (1 << 31);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6113 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6114
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6115 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6116 * Obtains an icon from data.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6117 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6118 * data: Source of data for image.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6119 * len: length of data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6120 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6121 unsigned long API dw_icon_load_from_data(char *data, int len)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6122 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6123 int found = -1, _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6124 char *file;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6125 FILE *fp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6126 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6127 GdkPixbuf *pixbuf;
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6128 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6129 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6130 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6131 unsigned long z, ret = 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6132
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6133 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6134 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6135 * A real hack; create a temporary file and write the contents
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6136 * of the data to the file
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6137 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6138 file = tmpnam( NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6139 fp = fopen( file, "wb" );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6140 if ( fp )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6141 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6142 fwrite( data, len, 1, fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6143 fclose( fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6144 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6145 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6146 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6147 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6148 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6149 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6150 /* Find a free entry in the array */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6151 for (z=0;z<_PixmapCount;z++)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6152 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6153 if(!_PixmapArray[z].used)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6154 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6155 ret = found = z;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6156 break;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6157 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6158 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6159
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6160 /* If there are no free entries, expand the
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6161 * array.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6162 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6163 if (found == -1)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6164 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6165 DWPrivatePixmap *old = _PixmapArray;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6166
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6167 ret = found = _PixmapCount;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6168 _PixmapCount++;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6169
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6170 _PixmapArray = malloc(sizeof(DWPrivatePixmap) * _PixmapCount);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6171
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6172 if (found)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6173 memcpy(_PixmapArray, old, sizeof(DWPrivatePixmap) * found);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6174 if (old)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6175 free(old);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6176 _PixmapArray[found].used = 1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6177 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6178 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6179
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6180 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6181 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6182 if (pixbuf)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6183 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6184 _PixmapArray[found].pixbuf = pixbuf;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6185 _PixmapArray[found].width = gdk_pixbuf_get_width(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6186 _PixmapArray[found].height = gdk_pixbuf_get_height(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6187
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6188 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &_PixmapArray[found].pixmap, &_PixmapArray[found].mask, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6189 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6190 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6191 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6192
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6193 if (image)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6194 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6195 _PixmapArray[found].width = image->rgb_width;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6196 _PixmapArray[found].height = image->rgb_height;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6197
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6198 gdk_imlib_render(image, image->rgb_width, image->rgb_height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6199 _PixmapArray[found].pixmap = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6200 _PixmapArray[found].mask = gdk_imlib_copy_mask(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6201 gdk_imlib_destroy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6202 }
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6203 #else
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6204 if (last_window)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6205 _PixmapArray[found].pixmap = gdk_pixmap_create_from_xpm_d(last_window->window, &_PixmapArray[found].mask, &_colors[DW_CLR_PALEGRAY], data);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6206 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6207 /* remove our temporary file */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6208 unlink (file );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6209 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6210 if (!_PixmapArray[found].pixmap || !_PixmapArray[found].mask)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6211 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6212 _PixmapArray[found].used = 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6213 _PixmapArray[found].pixmap = _PixmapArray[found].mask = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6214 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6215 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
6216 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
6217 }
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
6218
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
6219 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6220 * Frees a loaded resource in OS/2 and Windows.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6221 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6222 * handle: Handle to icon returned by dw_icon_load().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6223 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6224 void dw_icon_free(unsigned long handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6225 {
258
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6226 /* 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
6227 * 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
6228 * 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
6229 */
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6230 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
6231 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6232 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
6233
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6234 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
6235 {
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
6236 #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
6237 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
6238 {
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
6239 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
6240 _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
6241 }
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
6242 #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
6243 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
6244 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6245 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
6246 _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
6247 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6248 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
6249 {
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6250 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
6251 _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
6252 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6253 _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
6254 }
b2c436c84e5d Added code to create a lookup table for icon data loaded in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 257
diff changeset
6255 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6256 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6257
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6258 /* 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
6259 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
6260 {
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6261 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
6262 }
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6263
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6264 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6265 * Allocates memory used to populate a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6266 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6267 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6268 * rowcount: The number of items to be populated.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6269 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6270 void *dw_container_alloc(HWND handle, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6271 {
575
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6272 int z, count = 0, prevrowcount = 0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6273 GtkWidget *clist;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6274 GdkColor *fore, *back;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6275 char **blah;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6276 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6277
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6278 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6279 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6280 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6281 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6282 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6283 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6284 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6285
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6286 count = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_colcount");
575
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6287 prevrowcount = (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_rowcount");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6288
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6289 if(!count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6290 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6291 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6292 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6293 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6294
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6295 blah = malloc(sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6296 memset(blah, 0, sizeof(char *) * count);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6297
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6298 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
6299 back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(clist), "_dw_backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6300 gtk_clist_freeze(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6301 for(z=0;z<rowcount;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6302 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6303 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
6304 if(fore)
575
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6305 gtk_clist_set_foreground(GTK_CLIST(clist), z + prevrowcount, fore);
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
6306 if(back)
575
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6307 gtk_clist_set_background(GTK_CLIST(clist), z + prevrowcount, back);
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6308 }
576
fa710b6cbba5 Ok, the fix was a bit more complex, here is part 2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 575
diff changeset
6309 gtk_object_set_data(GTK_OBJECT(clist), "_dw_insertpos", (gpointer)prevrowcount);
575
e72f61a8f492 Hopefully fixes an error with wrong indexes in the containers on GTK after
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 571
diff changeset
6310 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)(rowcount + prevrowcount));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6311 free(blah);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6312 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6313 return (void *)handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6315
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6316 /*
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6317 * 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
6318 * 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
6319 */
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6320 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
6321 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6322 char numbuf[10], textbuffer[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6323 int flag = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6324 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6325 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6326
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6327 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6328 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6329 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6330 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6331 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6332 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6334
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6335 sprintf(numbuf, "%d", column);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6336 flag = (int)gtk_object_get_data(GTK_OBJECT(clist), numbuf);
576
fa710b6cbba5 Ok, the fix was a bit more complex, here is part 2. :)
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 575
diff changeset
6337 row += (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 if(flag & DW_CFA_BITMAPORICON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6341 long hicon = *((long *)data);
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
6342 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
6343 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
6344
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 gtk_clist_set_pixmap(GTK_CLIST(clist), row, column, pixmap, bitmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6347 }
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6348 else if(flag & DW_CFA_STRINGANDICON)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6349 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6350 long hicon = *((long *)data);
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6351 GdkBitmap *bitmap = NULL;
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6352 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
6353
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6354 if(pixmap)
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6355 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
6356 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6357 else if(flag & DW_CFA_STRING)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6358 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6359 char *tmp = *((char **)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6360 gtk_clist_set_text(GTK_CLIST(clist), row, column, tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6361 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6362 else if(flag & DW_CFA_ULONG)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6363 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6364 ULONG tmp = *((ULONG *)data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6365
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6366 sprintf(textbuffer, "%lu", tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6368 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6370 else if(flag & DW_CFA_DATE)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6371 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6372 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
6373 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
6374
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6375 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
6376 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
6377 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
6378
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6379 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
6380
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6381 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6382 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6383 else if(flag & DW_CFA_TIME)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6384 {
165
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6385 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
6386 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
6387
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6388 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
6389 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
6390 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
6391
d03716228b7f Use strftime to display time and date on Windows and unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 164
diff changeset
6392 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
6393
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 gtk_clist_set_text(GTK_CLIST(clist), row, column, textbuffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6396 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6397 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6399 /*
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6400 * 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
6401 * Parameters:
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6402 * handle: Handle to the container window (widget).
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6403 * 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
6404 * 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
6405 * 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
6406 * 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
6407 */
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6408 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
6409 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6410 _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
6411 }
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6412
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6413 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6414 * 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
6415 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6416 * 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
6417 * 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
6418 * 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
6419 * 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
6420 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6421 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
6422 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6423 _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
6424 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6425
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6426 /*
503
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6427 * 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
6428 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6429 * 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
6430 * 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
6431 * 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
6432 * 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
6433 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6434 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
6435 {
504
7061da3532d7 Fix minor error in new dw_filesystem_change_*() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 503
diff changeset
6436 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
6437 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6438
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6439 /*
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6440 * 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
6441 * Parameters:
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6442 * 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
6443 * 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
6444 * 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
6445 * 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
6446 * 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
6447 */
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6448 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
6449 {
504
7061da3532d7 Fix minor error in new dw_filesystem_change_*() code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 503
diff changeset
6450 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
6451 }
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6452
f3ed8dda02f8 Added dw_filesystem_change_*() and testcase code from Mark in dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 501
diff changeset
6453 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6458 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6459 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6460 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6461 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6462 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
6463 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6464 _dw_container_set_item(handle, pointer, 0, row, (void *)&icon, filename);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6465 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6466
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6467 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6468 * Sets an item in specified row and column to the given data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6469 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6470 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6471 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6472 * column: Zero based column of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6473 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6474 * data: Pointer to the data to be added.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6475 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6476 void dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6477 {
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
6478 _dw_container_set_item(handle, pointer, column + 1, row, data, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6479 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6480
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6481 /*
508
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6482 * 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
6483 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6484 * 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
6485 * 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
6486 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6487 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
6488 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6489 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
6490 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
6491 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
6492 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
6493
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6494 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
6495 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
6496 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
6497 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6498 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
6499 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
6500 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6501
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6502 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
6503 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
6504
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6505 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
6506 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
6507 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
6508 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
6509 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
6510 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
6511 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
6512 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
6513 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
6514 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
6515 else
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6516 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
6517 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
6518 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
6519 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6520
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6521 /*
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6522 * 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
6523 * Parameters:
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6524 * 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
6525 * 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
6526 */
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6527 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
6528 {
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6529 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
6530 }
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6531
078a40ba2e41 Added dw_container_get_column_type and dw_filesystem_get_column_type.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 504
diff changeset
6532 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6533 * 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
6534 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6535 * 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
6536 * 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
6537 * 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
6538 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6539 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
6540 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6541 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
6542 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
6543
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6544 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
6545 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
6546
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6547 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
6548 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
6549 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
6550 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6551
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6552 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6553 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6554 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6555 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6556 * row: Zero based row of data being set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6557 * title: String title of the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6558 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6559 void dw_container_set_row_title(void *pointer, int row, char *title)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6560 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6561 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6562 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6563
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6564 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6565 clist = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(pointer));
577
ac067e8ea2b4 Same fix also needed in dw_container_set_row_title().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 576
diff changeset
6566 row += (int)gtk_object_get_data(GTK_OBJECT(clist), "_dw_insertpos");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6567
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6568 if(clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6569 gtk_clist_set_row_data(GTK_CLIST(clist), row, (gpointer)title);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6570 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6571 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6573 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6574 * Sets the title of a row in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6575 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6576 * handle: Handle to the container window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6577 * pointer: Pointer to the allocated memory in dw_container_alloc().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6578 * rowcount: The number of rows to be inserted.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6579 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6580 void dw_container_insert(HWND handle, void *pointer, int rowcount)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6581 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6582 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6583 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6584
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6585 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6586 clist = gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6588 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6589 gtk_clist_thaw(GTK_CLIST(clist));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6590 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6591 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6592
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6593 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6594 * 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
6595 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6596 * 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
6597 * 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
6598 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6599 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
6600 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6601 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
6602 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
6603
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6604 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
6605 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
6606 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
6607 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6608 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
6609
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6610 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
6611
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6612 _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
6613
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6614 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
6615 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
6616
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6617 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
6618 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
6619 else
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6620 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
6621
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6622 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
6623 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6624 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
6625 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6626
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6627 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6628 * Removes all rows from a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6629 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6630 * 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
6631 * redraw: TRUE to cause the container to redraw immediately.
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6632 */
52
0804483f6320 Added a redraw parameter to dw_container_clear().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 51
diff changeset
6633 void dw_container_clear(HWND handle, int redraw)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6634 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6635 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6636 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6637
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6638 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6639 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6640 if(clist && GTK_IS_CLIST(clist))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6641 {
72
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6642 _dw_unselect(clist);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6643 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
6644 gtk_object_set_data(GTK_OBJECT(clist), "_dw_rowcount", (gpointer)0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6645 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6646 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6647 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6648
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6649 /*
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6650 * 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
6651 * Parameters:
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6652 * 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
6653 * 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
6654 * 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
6655 * 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
6656 */
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6657 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
6658 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6659 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
6660 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
6661 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
6662
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6663 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
6664 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
6665 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
6666 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6667 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
6668 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
6669 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6670 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
6671 {
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6672 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
6673 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
6674 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6675 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
6676 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
6677 break;
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6678 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6679 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
6680 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6681 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6682 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
6683 }
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6684
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
6685 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6686 * Starts a new query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6687 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6688 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6689 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6690 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6691 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6692 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6693 char *dw_container_query_start(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6694 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6695 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6696 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6697 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6698 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6699
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6700 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6701 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6702
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6703 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6704 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6705 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6706 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6707 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6709 /* 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
6710 if(flags & DW_CRA_SELECTED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 {
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
6712 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
6713
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6714 if(list)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6715 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6716 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
6717 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
6718 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6719 }
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6720 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
6721 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6722 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
6723 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6724 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6725 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6726 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
6727 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6728 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6729 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6730 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6731 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6732
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6733 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6734 * Continues an existing query of a container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6735 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6736 * handle: Handle to the window (widget) to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6737 * flags: If this parameter is DW_CRA_SELECTED it will only
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6738 * return items that are currently selected. Otherwise
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6739 * it will return all records in the container.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6740 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6741 char *dw_container_query_next(HWND handle, unsigned long flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6742 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6743 GtkWidget *clist;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6744 GList *list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6745 char *retval = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6746 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6748 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 clist = (GtkWidget*)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6750
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6751 if(!clist)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6752 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6753 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6754 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6755 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6756
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6757 /* 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
6758 if(flags & DW_CRA_SELECTED)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6759 {
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
6760 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
6761
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6762 if(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6763 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6764 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
6765 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
6766
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6767 while(list && counter < pos)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6768 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6769 list = list->next;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6770 counter++;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6771 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6772
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
6773 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
6774 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
6775 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6776 }
364
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6777 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
6778 {
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6779 /* 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
6780 * 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
6781 */
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6782 retval = NULL;
aa827971da39 Handle ENTER keypress on the container control. Also make
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 362
diff changeset
6783 }
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6784 else
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6785 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6786 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
6787
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6788 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
6789 gtk_object_set_data(GTK_OBJECT(clist), "_dw_querypos", (gpointer)pos+1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6790 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6791 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6792 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6793 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6794
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6795 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6796 * 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
6797 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6798 * 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
6799 * 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
6800 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6801 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
6802 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6803 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
6804 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6805 int rowcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6806 char *rowdata;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6807
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6808 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6809 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
6810
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6811 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6812 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6813 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6814 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6815 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6816 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
6817
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6818 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
6819 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6820 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
6821 if(rowdata == text)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6822 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6823 gfloat pos;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6824 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
6825
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6826 _dw_unselect(clist);
ab77a22a2a36 Added localization APIs as well as some miscellaneous bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 69
diff changeset
6827
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6828 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
6829
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6830 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
6831 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
6832 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6833 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6834 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6835 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6836
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6837 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6838 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6839
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6840 /*
167
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6841 * 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
6842 * Parameters:
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6843 * 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
6844 * 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
6845 */
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6846 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
6847 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6848 int _locked_by_me = FALSE;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6849 GtkWidget *clist;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6850 int rowcount, z;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6851 char *rowdata;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6852
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6853 DW_MUTEX_LOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6854 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
6855
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6856 if(!clist)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6857 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6858 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6859 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6860 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6861 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
6862
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6863 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
6864 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6865 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
6866 if(rowdata == text)
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6867 {
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6868 _dw_unselect(clist);
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6869
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6870 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
6871
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6872 rowcount--;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6873
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6874 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
6875 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6876 return;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6877 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6878 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6879
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6880 DW_MUTEX_UNLOCK;
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6881 }
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6882
0b3debaa9c6c Added new container functions, and fixed resource leaks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 165
diff changeset
6883 /*
69
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6884 * 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
6885 * Parameters:
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6886 * 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
6887 */
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6888 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
6889 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6890 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
6891 GtkWidget *clist;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6892 int colcount, z;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6893
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6894 DW_MUTEX_LOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6895 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
6896
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6897 if(!clist)
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6898 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6899 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6900 return;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6901 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
6902 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
6903 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
6904 {
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6905 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
6906 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
6907 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6908 DW_MUTEX_UNLOCK;
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6909 }
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6910
9510897c0b03 Added new container functions, and implemented some missing functionality.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 67
diff changeset
6911 /*
487
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6912 * 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
6913 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6914 * 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
6915 * 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
6916 * 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
6917 */
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6918 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
6919 {
491
fafd37119db4 Formatting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 487
diff changeset
6920 /* 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
6921 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6922
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6923 /*
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6924 * 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
6925 * Parameters:
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6926 * 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
6927 * 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
6928 */
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6929 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
6930 {
491
fafd37119db4 Formatting.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 487
diff changeset
6931 /* 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
6932 }
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6933
d6e07d292145 Implemented taskbar icons on windows, so I can keep feature for feature
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 486
diff changeset
6934 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6935 * Creates a rendering context widget (window) to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 * id: An id to be used with dw_window_from_id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6939 * A handle to the widget or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6940 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6941 HWND dw_render_new(unsigned long id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6942 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6943 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 GtkWidget *tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 tmp = gtk_drawing_area_new();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 gtk_widget_set_events(tmp, GDK_EXPOSURE_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949 | GDK_LEAVE_NOTIFY_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 | 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
6951 | GDK_KEY_PRESS_MASK
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 | GDK_POINTER_MOTION_MASK
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 | 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
6954 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
6955 GTK_WIDGET_SET_FLAGS(tmp, GTK_CAN_FOCUS);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956 gtk_widget_show(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 return tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960
193
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6961 /* 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
6962 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
6963 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6964 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
6965 {
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6966 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
6967 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
6968 }
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
6969 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
6970 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
6971 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
6972 }
efd4703450fa Build test application on Unix too... and also fixed GTK to allow
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 185
diff changeset
6973
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6974 /* Sets the current foreground drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 void dw_color_foreground_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6982 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
6983 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 DW_MUTEX_LOCK;
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
6986 gdk_color_alloc(_dw_cmap, &color);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6987 _foreground[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6988 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6989 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6990
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 /* Sets the current background drawing color.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 * red: red value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 * green: green value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 * blue: blue value.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 void dw_color_background_set(unsigned long value)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 {
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
6999 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
7000 GdkColor color = _internal_color(value);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7001
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 DW_MUTEX_LOCK;
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7003 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
7004 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
7005 _transparent[index] = 1;
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7006 else
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7007 _transparent[index] = 0;
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7008
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7009 _background[index] = color;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7010 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7011 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7012
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7013 /* Internal function to handle the color OK press */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7014 static gint _gtk_color_ok(GtkWidget *widget, DWDialog *dwwait)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7015 {
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7016 #if GTK_MAJOR_VERSION > 1
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7017 GdkColor color;
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7018 #else
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7019 gdouble colors[4];
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7020 #endif
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7021 unsigned long dw_color;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7022 GtkColorSelection *colorsel;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7023
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7024 if(!dwwait)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7025 return FALSE;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7026
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7027 colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(dwwait->data)->colorsel);
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7028 #if GTK_MAJOR_VERSION > 1
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7029 gtk_color_selection_get_current_color(colorsel, &color);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7030 #else
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7031 gtk_color_selection_get_color(colorsel, colors);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7032 #endif
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7033 gtk_widget_destroy(GTK_WIDGET(dwwait->data));
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7034 _dw_color_active = 0;
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7035 #if GTK_MAJOR_VERSION > 1
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7036 dw_color = DW_RGB( (color.red & 0xFF), (color.green & 0xFF), (color.blue & 0xFF));
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7037 #else
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7038 dw_color = DW_RGB( (int)(colors[0] * 255), (int)(colors[1] * 255), (int)(colors[2] * 255));
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7039 #endif
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7040 dw_dialog_dismiss(dwwait, (void *)dw_color);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7041 return FALSE;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7042 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7043
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7044 /* Internal function to handle the color Cancel press */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7045 static gint _gtk_color_cancel(GtkWidget *widget, DWDialog *dwwait)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7046 {
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7047 if(!dwwait)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7048 return FALSE;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7049
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7050 gtk_widget_destroy(GTK_WIDGET(dwwait->data));
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7051 _dw_color_active = 0;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7052 dw_dialog_dismiss(dwwait, (void *)-1);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7053 return FALSE;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7054 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7055
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7056 /* Allows the user to choose a color using the system's color chooser dialog.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7057 * Parameters:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7058 * value: current color
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7059 * Returns:
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7060 * The selected color or the current color if cancelled.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7061 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7062 unsigned long API dw_color_choose(unsigned long value)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7063 {
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7064 GtkWidget *colorw;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7065 int _locked_by_me = FALSE;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7066 DWDialog *dwwait;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7067 GtkColorSelection *colorsel;
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7068 #if GTK_MAJOR_VERSION > 1
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7069 GdkColor color = _internal_color(value);
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7070 #else
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7071 gdouble colors[4];
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7072 #endif
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7073 unsigned long dw_color;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7074
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7075 DW_MUTEX_LOCK;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7076
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7077 /* The DW mutex should be sufficient for
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7078 * insuring no thread changes this unknowingly.
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7079 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7080 if(_dw_color_active)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7081 {
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7082 DW_MUTEX_UNLOCK;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7083 return value;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7084 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7085
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7086 _dw_color_active = 1;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7087
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7088 colorw = gtk_color_selection_dialog_new("Select Color");
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7089
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7090 dwwait = dw_dialog_new((void *)colorw);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7091
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7092 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->ok_button), "clicked", (GtkSignalFunc) _gtk_color_ok, dwwait);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7093 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colorw)->cancel_button), "clicked", (GtkSignalFunc) _gtk_color_cancel, dwwait);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7094
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7095 colorsel = GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(colorw)->colorsel);
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7096 #if GTK_MAJOR_VERSION > 1
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7097 gtk_color_selection_set_previous_color(colorsel,&color);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7098 gtk_color_selection_set_current_color(colorsel,&color);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7099 gtk_color_selection_set_has_palette(colorsel,TRUE);
569
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7100 #else
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7101 colors[0] = ((gdouble)DW_RED_VALUE(value) / (gdouble)255);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7102 colors[1] = ((gdouble)DW_GREEN_VALUE(value) / (gdouble)255);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7103 colors[2] = ((gdouble)DW_BLUE_VALUE(value) / (gdouble)255);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7104 gtk_color_selection_set_color(colorsel, colors);
a126f4ec9570 Fixes for the color selection dialog on GTK 1.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 566
diff changeset
7105 #endif
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7106
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7107 gtk_widget_show(colorw);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7108
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7109 dw_color = (unsigned long)dw_dialog_wait(dwwait);
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7110 if ((unsigned long)dw_color == -1)
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7111 dw_color = value;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7112 DW_MUTEX_UNLOCK;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7113 return (unsigned long)dw_color;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7114 /*
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7115 dw_messagebox("Not implemented", DW_MB_OK|DW_MB_INFORMATION, "This feature not yet supported.");
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7116 return value;
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7117 */
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7118 }
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
7119
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7120 GdkGC *_set_colors(GdkWindow *window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7121 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7122 GdkGC *gc = NULL;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7123 int index = _find_thread_index(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
7124
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7125 if(!window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7126 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7127 gc = gdk_gc_new(window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7128 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7129 {
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7130 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
7131 gdk_gc_set_background(gc, &_background[index]);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7132 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7133 return gc;
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 /* Draw a point on a window (preferably a render window).
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 window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7139 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7140 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7141 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7142 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7143 void dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7144 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7145 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7146 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7147
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7148 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7149 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7150 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7151 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7152 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7153 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7154 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7155 gdk_draw_point(handle ? handle->window : pixmap->pixmap, gc, x, y);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7156 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7157 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7158 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7159 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7160
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7161 /* Draw a line on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7162 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7163 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7164 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7165 * x1: First X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7166 * y1: First Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7167 * x2: Second X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7168 * y2: Second Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7169 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7170 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
7171 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7172 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7173 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7174
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7175 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7176 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7177 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7178 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7179 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7180 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7181 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7182 gdk_draw_line(handle ? handle->window : pixmap->pixmap, gc, x1, y1, x2, y2);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7183 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7184 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7185 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7186 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7187
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7188 /* Draw a rectangle on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7189 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7190 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7191 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7192 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7193 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7194 * width: Width of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7195 * height: Height of rectangle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7196 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7197 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
7198 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7199 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7200 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7201
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7202 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7203 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7204 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7205 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7206 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7207 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7208 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7209 gdk_draw_rectangle(handle ? handle->window : pixmap->pixmap, gc, fill, x, y, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7210 gdk_gc_unref(gc);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7211 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7212 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7213 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7214
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7215 /* Draw text on a window (preferably a render window).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7216 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7217 * handle: Handle to the window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7218 * pixmap: Handle to the pixmap. (choose only one of these)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7219 * x: X coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7220 * y: Y coordinate.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7221 * text: Text to be displayed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7222 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7223 void dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7224 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7225 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7226 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
7227 #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
7228 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
7229 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7230 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
7231 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7232 char *fontname = "fixed";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7233
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
7234 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
7235 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
7236
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7237 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7238 if(handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7239 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7240 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7241 gc = _set_colors(handle->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7242 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7243 else if(pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7244 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
7245 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7246 gc = _set_colors(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7247 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7248 if(gc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7249 {
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
7250 #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
7251 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
7252 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
7253 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7254 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
7255
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7256 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
7257 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7258 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
7259
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7260 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
7261 {
372
3ef2cf70ee07 Code for drawing text with a background color on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 369
diff changeset
7262 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
7263
373
d04b0699fc28 Fixes for background color drawing on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 372
diff changeset
7264 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
7265 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
7266 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
7267
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
7268 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
7269 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
7270 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
7271 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
7272
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7273 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
7274 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7275 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
7276 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7277 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
7278 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7279 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7280 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
7281 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
7282 font = gdk_font_load("fixed");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7283 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7284 {
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
7285 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
7286 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
7287
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
7288 /* 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
7289 * 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
7290 * 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
7291 */
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
7292 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
7293 /* 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
7294 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
7295 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
7296 {
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
7297 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
7298
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
7299 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
7300 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
7301 {
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
7302 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
7303 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
7304 }
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
7305 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
7306 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
7307 }
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
7308 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
7309 gdk_font_unref(font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7310 }
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
7311 #endif
149
6028f787f7c8 Fixed a graphics context leak in dw_draw_text().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 148
diff changeset
7312 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7313 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7314 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7315 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7316
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
7317 /* 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
7318 * 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
7319 * 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
7320 * 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
7321 * 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
7322 * 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
7323 * 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
7324 */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
7325 void dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, char *text, int *width, int *height)
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
7326 {
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
7327 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
7328 #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
7329 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
7330 #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
7331 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
7332 #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
7333 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
7334
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
7335 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
7336 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
7337
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
7338 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
7339 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
7340 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
7341 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
7342 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
7343
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
7344 #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
7345 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
7346 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
7347 {
b479002e013f Upped the 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 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
7349
b479002e013f Upped the 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 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
7351 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7352 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
7353
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7354 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
7355 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7356 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
7357
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7358 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
7359 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
7360 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
7361
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7362 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
7363 *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
7364 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
7365 *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
7366
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7367 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
7368 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7369 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
7370 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7371 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
7372 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
7373 #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
7374
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
7375 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
7376 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
7377 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
7378 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
7379 {
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
7380 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
7381 *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
7382 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
7383 *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
7384 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
7385 }
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
7386 #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
7387 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
7388 }
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
7389
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7390 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7391 * Creates a pixmap with given parameters.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7392 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7393 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7394 * width: Width of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7395 * height: Height of the pixmap in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7396 * depth: Color depth of the pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7397 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7398 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7399 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7400 HPIXMAP dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7401 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7402 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7403 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7404
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7405 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7406 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7407
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7408 if (!depth)
66
664a274a46a6 Fixed color depth problem when creating a new pixmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 63
diff changeset
7409 depth = -1;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7410
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7411 pixmap->width = width; pixmap->height = height;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7412
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7413
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7414 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7415 pixmap->handle = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7416 pixmap->pixmap = gdk_pixmap_new(handle->window, width, height, depth);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7417 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7418 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7419 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7420
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7421 /*
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7422 * Creates a pixmap from a file.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7423 * Parameters:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7424 * 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
7425 * 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
7426 * DW pick the appropriate file extension.
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7427 * (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
7428 * Returns:
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7429 * 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
7430 */
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7431 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
7432 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7433 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7434 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
7435 #ifndef USE_IMLIB
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7436 GdkBitmap *bitmap = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7437 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7438 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7439 GdkPixbuf *pixbuf;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7440 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7441 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7442 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7443 char *file = alloca(strlen(filename) + 5);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7444
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7445 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7446 return NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7447
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7448 strcpy(file, filename);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7449
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7450 /* check if we can read from this file (it exists and read permission) */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7451 if(access(file, 04) != 0)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7452 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7453 /* Try with .xpm extention */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7454 strcat(file, ".xpm");
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7455 if(access(file, 04) != 0)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7456 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7457 free(pixmap);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7458 return NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7459 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7460 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7461
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7462 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7463 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7464 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7465 pixmap->width = gdk_pixbuf_get_width(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7466 pixmap->height = gdk_pixbuf_get_height(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7467 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7468 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
7469 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7470 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7471
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7472 pixmap->width = image->rgb_width;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7473 pixmap->height = image->rgb_height;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7474
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7475 gdk_imlib_render(image, pixmap->width, pixmap->height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7476 pixmap->pixmap = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7477 gdk_imlib_destroy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7478 #else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7479 pixmap->pixmap = gdk_pixmap_create_from_xpm(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7480 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7481 pixmap->handle = handle;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7482 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7483 return pixmap;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7484 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7485
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7486 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7487 * Creates a pixmap from data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7488 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7489 * handle: Window handle the pixmap is associated with.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7490 * data: Source of image data
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7491 * DW pick the appropriate file extension.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7492 * (BMP on OS/2 or Windows, XPM on Unix)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7493 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7494 * A handle to a pixmap or NULL on failure.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7495 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7496 HPIXMAP dw_pixmap_new_from_data(HWND handle, char *data, int len)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7497 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7498 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7499 char *file;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7500 FILE *fp;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7501 HPIXMAP pixmap;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7502 #ifndef USE_IMLIB
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7503 GdkBitmap *bitmap = NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7504 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7505 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7506 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
7507 #elif defined(USE_IMLIB)
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7508 GdkImlibImage *image;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7509 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7510
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7511 if (!data || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7512 return NULL;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7513
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7514 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7515 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7516 * A real hack; create a temporary file and write the contents
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7517 * of the data to the file
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7518 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7519 file = tmpnam( NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7520 fp = fopen( file, "wb" );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7521 if ( fp )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7522 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7523 fwrite( data, len, 1, fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7524 fclose( fp );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7525 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7526 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7527 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7528 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7529 return 0;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7530 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7531 #if GTK_MAJOR_VERSION > 1
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7532 pixbuf = gdk_pixbuf_new_from_file(file, NULL);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7533 pixmap->width = gdk_pixbuf_get_width(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7534 pixmap->height = gdk_pixbuf_get_height(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7535 gdk_pixbuf_render_pixmap_and_mask(pixbuf, &pixmap->pixmap, &bitmap, 1);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7536 g_object_unref(pixbuf);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7537 #elif defined(USE_IMLIB)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7538 image = gdk_imlib_load_image(file);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7539
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7540 pixmap->width = image->rgb_width;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7541 pixmap->height = image->rgb_height;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7542
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7543 gdk_imlib_render(image, pixmap->width, pixmap->height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7544 pixmap->pixmap = gdk_imlib_copy_image(image);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7545 gdk_imlib_destroy_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
7546 #else
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7547 pixmap->pixmap = gdk_pixmap_create_from_xpm_d(handle->window, &bitmap, &_colors[DW_CLR_PALEGRAY], data);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7548 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7549 /* remove our temporary file */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7550 unlink (file );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7551 pixmap->handle = handle;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7552 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
7553 return pixmap;
241
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7554 }
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7555
00d2b1bcf036 Added dw_pixmap_new_from_file().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 239
diff changeset
7556 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7557 * Creates a pixmap from internal resource graphic specified by id.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7558 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7559 * handle: Window handle the pixmap is associated with.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7560 * id: Resource ID associated with requested pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7561 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7562 * A handle to a pixmap or NULL on failure.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7563 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7564 HPIXMAP dw_pixmap_grab(HWND handle, ULONG id)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7565 {
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
7566 GdkBitmap *bitmap = NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7567 HPIXMAP pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7568 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7569
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7570 if (!(pixmap = calloc(1,sizeof(struct _hpixmap))))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7571 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7572
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7573
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7574 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
7575 pixmap->pixmap = _find_pixmap(&bitmap, id, handle, &pixmap->width, &pixmap->height);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7576 if(pixmap->pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7577 {
120
7d2108cbcd3e Porting DW 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 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7579 GdkPixmapPrivate *pvt = (GdkPixmapPrivate *)pixmap->pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7580 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
7581 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7582 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7583 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7584 return pixmap;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7585 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7586
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7587 /* Call this after drawing to the screen to make sure
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7588 * anything you have drawn is visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7589 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7590 void dw_flush(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7591 {
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
7592 #if GTK_MAJOR_VERSION < 2
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7593 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7594
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7595 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7596 gdk_flush();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7597 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
7598 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7599 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7600
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7601 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7602 * Destroys an allocated pixmap.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7603 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7604 * pixmap: Handle to a pixmap returned by
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7605 * dw_pixmap_new..
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7606 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7607 void dw_pixmap_destroy(HPIXMAP pixmap)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7608 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7609 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7610
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7611 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7612 gdk_pixmap_unref(pixmap->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7613 free(pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7614 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7615 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7616
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7617 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7618 * Copies from one item to another.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7619 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7620 * dest: Destination window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7621 * destp: Destination pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7622 * xdest: X coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7623 * ydest: Y coordinate of destination.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7624 * width: Width of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7625 * height: Height of area to copy.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7626 * src: Source window handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7627 * srcp: Source pixmap. (choose only one).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7628 * xsrc: X coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7629 * ysrc: Y coordinate of source.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7630 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7631 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
7632 {
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
7633 /* 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
7634 * 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
7635 * 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
7636 * 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
7637 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7638 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7639 GdkGC *gc = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7640
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
7641 if((!dest && (!destp || !destp->pixmap)) || (!src && (!srcp || !srcp->pixmap)))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7642 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7643
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7644 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7645 if(dest)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7646 gc = _set_colors(dest->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7647 else if(src)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7648 gc = _set_colors(src->window);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7649 else if(destp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7650 gc = gdk_gc_new(destp->pixmap);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7651 else if(srcp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7652 gc = gdk_gc_new(srcp->pixmap);
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7653
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7654 if(gc)
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7655 {
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
7656 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
7657 gdk_gc_unref(gc);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7658 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7659 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7660 }
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 * Emits a beep.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7664 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7665 * freq: Frequency.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7666 * dur: Duration.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7667 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7668 void dw_beep(int freq, int dur)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7669 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7670 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7671
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7672 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7673 gdk_beep();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7674 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7675 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7676
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7677 void _my_strlwr(char *buf)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7678 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7679 int z, len = strlen(buf);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7680
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7681 for(z=0;z<len;z++)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7682 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7683 if(buf[z] >= 'A' && buf[z] <= 'Z')
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7684 buf[z] -= 'A' - 'a';
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7685 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7686 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7687
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7688 /* Open a shared library and return a handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7689 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7690 * name: Base name of the shared library.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7691 * handle: Pointer to a module handle,
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7692 * will be filled in with the handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7693 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7694 int dw_module_load(char *name, HMOD *handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7695 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7696 int len;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7697 char *newname;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7698 char errorbuf[1024];
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7699
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7700
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7701 if(!handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7702 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7703
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7704 if((len = strlen(name)) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7705 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7706
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7707 /* Lenth + "lib" + ".so" + NULL */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7708 newname = malloc(len + 7);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7709
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7710 if(!newname)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7711 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7712
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7713 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7714 _my_strlwr(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7715
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7716 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7717 if(*handle == NULL)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7718 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7719 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
7720 printf("%s\n", errorbuf);
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7721 sprintf(newname, "lib%s.so", name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7722 *handle = dlopen(newname, RTLD_NOW);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7723 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7724
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7725 free(newname);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7726
163
0322836c5299 Return -1 on error from dw_module_load().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 162
diff changeset
7727 return (NULL == *handle) ? -1 : 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7728 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7729
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7730 /* Queries the address of a symbol within open handle.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7731 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7732 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7733 * name: Name of the symbol you want the address of.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7734 * func: A pointer to a function pointer, to obtain
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7735 * the address.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7736 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7737 int dw_module_symbol(HMOD handle, char *name, void**func)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7738 {
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7739 if(!func || !name)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7740 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7741
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7742 if(strlen(name) == 0)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7743 return -1;
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7744
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7745 *func = (void*)dlsym(handle, name);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7746 return (NULL == *func);
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7747 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7748
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7749 /* Frees the shared library previously opened.
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7750 * Parameters:
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7751 * handle: Module handle returned by dw_module_load()
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7752 */
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7753 int dw_module_close(HMOD handle)
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7754 {
162
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
7755 if(handle)
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
7756 return dlclose(handle);
df59a3fc6de6 Fixed a minor bug in dw_module_close().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 157
diff changeset
7757 return 0;
157
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7758 }
a07dd2e819f3 Added module support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 155
diff changeset
7759
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7760 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7761 * Returns the handle to an unnamed mutex semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7762 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7763 HMTX dw_mutex_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7764 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7765 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
7766
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7767 pthread_mutex_init(mutex, NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7768 return mutex;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7769 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7770
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7771 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7772 * Closes a semaphore created by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7773 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7774 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7775 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7776 void dw_mutex_close(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7777 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7778 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
7779 {
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7780 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
7781 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
7782 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7783 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7784
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7785 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7786 * Tries to gain access to the semaphore, if it can't it blocks.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7787 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7788 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7789 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7790 void dw_mutex_lock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7791 {
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
7792 /* 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
7793 * 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
7794 */
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
7795 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
7796 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
7797
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7798 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
7799
baaf4b04d284 Fixed a deadlock when locking a mutex from an event handler on FreeBSD.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 94
diff changeset
7800 /* 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
7801 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
7802 gdk_threads_enter();
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7803 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7804
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7805 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7806 * Reliquishes the access to the semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7807 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7808 * mutex: The handle to the mutex returned by dw_mutex_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7809 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7810 void dw_mutex_unlock(HMTX mutex)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7811 {
239
403b07f873e1 Use a pointer for HMTX instead of a pthread_mutex_t struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 237
diff changeset
7812 pthread_mutex_unlock(mutex);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7813 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7814
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7815 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7816 * Returns the handle to an unnamed event semaphore.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7817 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7818 HEV dw_event_new(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7819 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7820 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7821
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7822 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7823 return NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7824
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7825 /* We need to be careful here, mutexes on Linux are
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7826 * FAST by default but are error checking on other
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7827 * systems such as FreeBSD and OS/2, perhaps others.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7828 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7829 pthread_mutex_init (&(eve->mutex), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7830 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7831 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7832
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7833 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7834 eve->alive = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7835 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7836
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7837 return eve;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7838 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7839
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7840 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7841 * Resets a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7842 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7843 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7844 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7845 int dw_event_reset (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7846 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7847 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7848 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7849
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7850 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7851 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7852 pthread_cond_init (&(eve->event), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7853 eve->posted = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7854 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7855 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7856 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7857
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7858 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7859 * Posts a semaphore created by dw_event_new(). Causing all threads
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7860 * waiting on this event in dw_event_wait to continue.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7861 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7862 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7863 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7864 int dw_event_post (HEV eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7865 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7866 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7867 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7868
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7869 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7870 pthread_cond_broadcast (&(eve->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7871 eve->posted = 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7872 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7873 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7874 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7875
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7876 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7877 * Waits on a semaphore created by dw_event_new(), until the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7878 * event gets posted or until the timeout expires.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7879 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7880 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7881 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7882 int dw_event_wait(HEV eve, unsigned long timeout)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7883 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7884 int rc;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7885 struct timeval now;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7886 struct timespec timeo;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7887
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7888 if(!eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7889 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7890
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7891 if(eve->posted)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7892 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7893
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7894 pthread_mutex_lock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7895 gettimeofday(&now, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7896 timeo.tv_sec = now.tv_sec + (timeout / 1000);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7897 timeo.tv_nsec = now.tv_usec * 1000;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7898 rc = pthread_cond_timedwait (&(eve->event), &(eve->mutex), &timeo);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7899 pthread_mutex_unlock (&(eve->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7900 if(!rc)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7901 return 1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7902 if(rc == ETIMEDOUT)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7903 return -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7904 return 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7905 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7906
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7907 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7908 * Closes a semaphore created by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7909 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7910 * eve: The handle to the event returned by dw_event_new().
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7911 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7912 int dw_event_close(HEV *eve)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7913 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7914 if(!eve || !(*eve))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7915 return FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7916
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7917 pthread_mutex_lock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7918 pthread_cond_destroy (&((*eve)->event));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7919 pthread_mutex_unlock (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7920 pthread_mutex_destroy (&((*eve)->mutex));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7921 free(*eve);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7922 *eve = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7923
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7924 return TRUE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7926
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7927 struct _seminfo {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7928 int fd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7929 int waiting;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7930 };
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7931
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7932 static void _handle_sem(int *tmpsock)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7933 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7934 fd_set rd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7935 struct _seminfo *array = (struct _seminfo *)malloc(sizeof(struct _seminfo));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7936 int listenfd = tmpsock[0];
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7937 int bytesread, connectcount = 1, maxfd, z, posted = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7938 char command;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7939 sigset_t mask;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7940
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7941 sigfillset(&mask); /* Mask all allowed signals */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7942 pthread_sigmask(SIG_BLOCK, &mask, NULL);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7943
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7944 /* problems */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7945 if(tmpsock[1] == -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7946 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7947 free(array);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7948 return;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7949 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7950
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7951 array[0].fd = tmpsock[1];
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7952 array[0].waiting = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7953
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7954 /* Free the memory allocated in dw_named_event_new. */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7955 free(tmpsock);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7956
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7957 while(1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7958 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7959 FD_ZERO(&rd);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7960 FD_SET(listenfd, &rd);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7961
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7962 maxfd = listenfd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7963
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7964 /* Added any connections to the named event semaphore */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7965 for(z=0;z<connectcount;z++)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7966 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7967 if(array[z].fd > maxfd)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7968 maxfd = array[z].fd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7969
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7970 FD_SET(array[z].fd, &rd);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7971 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7972
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7973 if(select(maxfd+1, &rd, NULL, NULL, NULL) == -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7974 return;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7975
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7976 if(FD_ISSET(listenfd, &rd))
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7977 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7978 struct _seminfo *newarray;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7979 int newfd = accept(listenfd, 0, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7980
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7981 if(newfd > -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7982 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7983 /* Add new connections to the set */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7984 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount+1));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7985 memcpy(newarray, array, sizeof(struct _seminfo)*(connectcount));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7986
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7987 newarray[connectcount].fd = newfd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7988 newarray[connectcount].waiting = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7989
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7990 connectcount++;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7991
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7992 /* Replace old array with new one */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7993 free(array);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7994 array = newarray;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7995 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7996 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7997
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7998 /* Handle any events posted to the semaphore */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
7999 for(z=0;z<connectcount;z++)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8000 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8001 if(FD_ISSET(array[z].fd, &rd))
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8002 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8003 if((bytesread = read(array[z].fd, &command, 1)) < 1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8004 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8005 struct _seminfo *newarray;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8006
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8007 /* Remove this connection from the set */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8008 newarray = (struct _seminfo *)malloc(sizeof(struct _seminfo)*(connectcount-1));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8009 if(!z)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8010 memcpy(newarray, &array[1], sizeof(struct _seminfo)*(connectcount-1));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8011 else
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8012 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8013 memcpy(newarray, array, sizeof(struct _seminfo)*z);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8014 if(z!=(connectcount-1))
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8015 memcpy(&newarray[z], &array[z+1], sizeof(struct _seminfo)*(z-connectcount-1));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8016 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8017 connectcount--;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8018
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8019 /* Replace old array with new one */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8020 free(array);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8021 array = newarray;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8022 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8023 else if(bytesread == 1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8024 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8025 switch(command)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8026 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8027 case 0:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8028 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8029 /* Reset */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8030 posted = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8031 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8032 break;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8033 case 1:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8034 /* Post */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8035 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8036 int s;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8037 char tmp = (char)0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8038
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8039 posted = 1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8040
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8041 for(s=0;s<connectcount;s++)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8042 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8043 /* The semaphore has been posted so
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8044 * we tell all the waiting threads to
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8045 * continue.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8046 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8047 if(array[s].waiting)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8048 write(array[s].fd, &tmp, 1);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8049 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8050 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8051 break;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8052 case 2:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8053 /* Wait */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8054 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8055 char tmp = (char)0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8056
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8057 array[z].waiting = 1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8058
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8059 /* If we are posted exit immeditately */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8060 if(posted)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8061 write(array[z].fd, &tmp, 1);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8062 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8063 break;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8064 case 3:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8065 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8066 /* Done Waiting */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8067 array[z].waiting = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8068 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8069 break;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8070 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8071 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8072 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8073 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8074
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8075 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8076
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8077 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8078
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8079 /* Using domain sockets on unix for IPC */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8080 /* Create a named event semaphore which can be
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8081 * opened from other processes.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8082 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8083 * eve: Pointer to an event handle to receive handle.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8084 * name: Name given to semaphore which can be opened
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8085 * by other processes.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8086 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8087 HEV dw_named_event_new(char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8088 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8089 struct sockaddr_un un;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8090 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8091 DWTID dwthread;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8092
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8093 if(!tmpsock)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8094 return NULL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8095
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8096 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8097 ev = socket(AF_UNIX, SOCK_STREAM, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8098 memset(&un, 0, sizeof(un));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8099 un.sun_family=AF_UNIX;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8100 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8101 strcpy(un.sun_path, "/tmp/.dw/");
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8102 strcat(un.sun_path, name);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8103
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8104 /* just to be safe, this should be changed
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8105 * to support multiple instances.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8106 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8107 remove(un.sun_path);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8108
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8109 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8110 listen(tmpsock[0], 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8111 connect(ev, (struct sockaddr *)&un, sizeof(un));
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8112 tmpsock[1] = accept(tmpsock[0], 0, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8113
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8114 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8115 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8116 if(tmpsock[0] > -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8117 close(tmpsock[0]);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8118 if(tmpsock[1] > -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8119 close(tmpsock[1]);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8120 if(ev > -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8121 close(ev);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8122 free(tmpsock);
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8123 return NULL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8124 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8125
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8126 /* Create a thread to handle this event semaphore */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8127 pthread_create(&dwthread, NULL, (void *)_handle_sem, (void *)tmpsock);
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8128 return (HEV)ev;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8129 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8130
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8131 /* Open an already existing named event semaphore.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8132 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8133 * eve: Pointer to an event handle to receive handle.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8134 * name: Name given to semaphore which can be opened
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8135 * by other processes.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8136 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8137 HEV dw_named_event_get(char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8138 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8139 struct sockaddr_un un;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8140 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8141 if(ev < 0)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8142 return NULL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8143
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8144 un.sun_family=AF_UNIX;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8145 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8146 strcpy(un.sun_path, "/tmp/.dw/");
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8147 strcat(un.sun_path, name);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8148 connect(ev, (struct sockaddr *)&un, sizeof(un));
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8149 return (HEV)ev;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8150 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8151
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8152 /* Resets the event semaphore so threads who call wait
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8153 * on this semaphore will block.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8154 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8155 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8156 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8157 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8158 int dw_named_event_reset(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8159 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8160 /* signal reset */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8161 char tmp = (char)0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8162
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8163 if((int)eve < 0)
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8164 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8165
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8166 if(write((int)eve, &tmp, 1) == 1)
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8167 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8168 return 1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8169 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8170
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8171 /* Sets the posted state of an event semaphore, any threads
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8172 * waiting on the semaphore will no longer block.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8173 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8174 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8175 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8176 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8177 int dw_named_event_post(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8178 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8179
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8180 /* signal post */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8181 char tmp = (char)1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8182
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8183 if((int)eve < 0)
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8184 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8185
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8186 if(write((int)eve, &tmp, 1) == 1)
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8187 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8188 return 1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8189 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8190
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8191 /* Waits on the specified semaphore until it becomes
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8192 * posted, or returns immediately if it already is posted.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8193 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8194 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8195 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8196 * timeout: Number of milliseconds before timing out
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8197 * or -1 if indefinite.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8198 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8199 int dw_named_event_wait(HEV eve, unsigned long timeout)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8200 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8201 fd_set rd;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8202 struct timeval tv, *useme;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8203 int retval = 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8204 char tmp;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8205
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8206 if((int)eve < 0)
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8207 return DW_ERROR_NON_INIT;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8208
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8209 /* Set the timout or infinite */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8210 if(timeout == -1)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8211 useme = NULL;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8212 else
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8213 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8214 tv.tv_sec = timeout / 1000;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8215 tv.tv_usec = timeout % 1000;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8216
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8217 useme = &tv;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8218 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8219
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8220 FD_ZERO(&rd);
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8221 FD_SET((int)eve, &rd);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8222
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8223 /* Signal wait */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8224 tmp = (char)2;
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8225 write((int)eve, &tmp, 1);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8226
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8227 retval = select((int)eve+1, &rd, NULL, NULL, useme);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8228
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8229 /* Signal done waiting. */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8230 tmp = (char)3;
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8231 write((int)eve, &tmp, 1);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8232
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8233 if(retval == 0)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8234 return DW_ERROR_TIMEOUT;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8235 else if(retval == -1)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8236 return DW_ERROR_INTERRUPT;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8237
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8238 /* Clear the entry from the pipe so
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8239 * we don't loop endlessly. :)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8240 */
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8241 read((int)eve, &tmp, 1);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8242 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8243 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8244
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8245 /* Release this semaphore, if there are no more open
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8246 * handles on this semaphore the semaphore will be destroyed.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8247 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8248 * eve: Handle to the semaphore obtained by
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8249 * an open or create call.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8250 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8251 int dw_named_event_close(HEV eve)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8252 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8253 /* Finally close the domain socket,
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8254 * cleanup will continue in _handle_sem.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8255 */
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8256 close((int)eve);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8257 return 0;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8258 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8259
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8260 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8261 * Setup thread independent color sets.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8262 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8263 void _dwthreadstart(void *data)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8264 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8265 void (*threadfunc)(void *) = NULL;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8266 void **tmp = (void **)data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8267
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8268 threadfunc = (void (*)(void *))tmp[0];
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8269
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8270 _dw_thread_add(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8271 threadfunc(tmp[1]);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8272 _dw_thread_remove(dw_thread_id());
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8273 free(tmp);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8274 }
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8275
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8276 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8277 * Allocates a shared memory region with a name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8278 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8279 * handle: A pointer to receive a SHM identifier.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8280 * dest: A pointer to a pointer to receive the memory address.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8281 * size: Size in bytes of the shared memory region to allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8282 * name: A string pointer to a unique memory name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8283 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8284 HSHM dw_named_memory_new(void **dest, int size, char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8285 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8286 char namebuf[1024];
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8287 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8288
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8289 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8290 sprintf(namebuf, "/tmp/.dw/%s", name);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8291
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8292 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8293 {
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8294 free(handle);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8295 return NULL;
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8296 }
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8297
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8298 ftruncate(handle->fd, size);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8299
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8300 /* attach the shared memory segment to our process's address space. */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8301 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8302
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8303 if(*dest == MAP_FAILED)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8304 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8305 close(handle->fd);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8306 *dest = NULL;
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8307 free(handle);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8308 return NULL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8309 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8310
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8311 handle->size = size;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8312 handle->sid = getsid(0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8313 handle->path = strdup(namebuf);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8314
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8315 return handle;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8316 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8317
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8318 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8319 * Aquires shared memory region with a name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8320 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8321 * dest: A pointer to a pointer to receive the memory address.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8322 * size: Size in bytes of the shared memory region to requested.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8323 * name: A string pointer to a unique memory name.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8324 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8325 HSHM dw_named_memory_get(void **dest, int size, char *name)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8326 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8327 char namebuf[1024];
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8328 struct _dw_unix_shm *handle = malloc(sizeof(struct _dw_unix_shm));
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8329
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8330 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8331 sprintf(namebuf, "/tmp/.dw/%s", name);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8332
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8333 if((handle->fd = open(namebuf, O_RDWR)) < 0)
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8334 {
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8335 free(handle);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8336 return NULL;
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8337 }
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8338
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8339 /* attach the shared memory segment to our process's address space. */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8340 *dest = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8341
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8342 if(*dest == MAP_FAILED)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8343 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8344 close(handle->fd);
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8345 *dest = NULL;
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8346 free(handle);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8347 return NULL;
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8348 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8349
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8350 handle->size = size;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8351 handle->sid = -1;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8352 handle->path = NULL;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8353
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8354 return handle;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8355 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8356
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8357 /*
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8358 * Frees a shared memory region previously allocated.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8359 * Parameters:
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8360 * handle: Handle obtained from DB_named_memory_allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8361 * ptr: The memory address aquired with DB_named_memory_allocate.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8362 */
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8363 int dw_named_memory_free(HSHM handle, void *ptr)
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8364 {
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8365 struct _dw_unix_shm *h = handle;
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8366 int rc = munmap(ptr, h->size);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8367
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8368 close(h->fd);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8369 if(h->path)
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8370 {
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8371 /* Only remove the actual file if we are the
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8372 * creator of the file.
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8373 */
558
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8374 if(h->sid != -1 && h->sid == getsid(0))
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8375 remove(h->path);
05060ce4d6ae Fixes for the new shared memory and named event code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 557
diff changeset
8376 free(h->path);
557
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8377 }
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8378 return rc;
1a210e2f214b Added a bunch of support routines I now own due to the settlement
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 556
diff changeset
8379 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8380 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8381 * Creates a new thread with a starting point of func.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8382 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8383 * func: Function which will be run in the new thread.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8384 * data: Parameter(s) passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8385 * stack: Stack size of new thread (OS/2 and Windows only).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8386 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8387 DWTID dw_thread_new(void *func, void *data, int stack)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8388 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8389 DWTID gtkthread;
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8390 void **tmp = malloc(sizeof(void *) * 2);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8391
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8392 tmp[0] = func;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8393 tmp[1] = data;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8394
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8395 pthread_create(&gtkthread, NULL, (void *)_dwthreadstart, (void *)tmp);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8396 return gtkthread;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8397 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8398
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8399 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8400 * Ends execution of current thread immediately.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8401 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8402 void dw_thread_end(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8403 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8404 pthread_exit(NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8405 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8406
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8407 /*
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8408 * Returns the current thread's ID.
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8409 */
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8410 DWTID dw_thread_id(void)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8411 {
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8412 return (DWTID)pthread_self();
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8413 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8414
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8415 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8416 * Cleanly terminates a DW session, should be signal handler safe.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8417 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8418 * exitcode: Exit code reported to the operating system.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8419 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8420 void dw_exit(int exitcode)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8421 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8422 exit(exitcode);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8423 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8424
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8425 #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
8426
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8427 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8428 * Pack windows (widgets) into a box from the end (or bottom).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8429 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8430 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8431 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8432 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8433 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8434 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8435 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8436 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8437 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8438 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
8439 {
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
8440 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
8441 GtkWidget *tmp, *tmpitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8442
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8443 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8444 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8445
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
8446 /*
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
8447 * 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
8448 * 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
8449 */
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
8450 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
8451 {
526
d3ce0afa6cf5 Remove extraneous arguments to dw_messagebox()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 524
diff changeset
8452 dw_messagebox("dw_box_pack_end()", DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
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
8453 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
8454 }
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
8455
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8456 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8457
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8458 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
8459 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8460
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8461 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8462 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8463 item = gtk_label_new("");
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
8464 gtk_widget_show_all(item);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8465 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8466
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
8467 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
8468
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8469 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8470 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8471 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
8472 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
8473
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8474 /* 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
8475 * 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
8476 * 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
8477 * 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
8478 */
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
8479 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
8480 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8481 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
8482
563
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8483 /* NOTE: I left in the ability to pack boxes with a size,
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8484 * this eliminates that by forcing the size to 0.
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8485 */
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8486 height = width = 0;
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8487
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8488 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8489 {
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
8490 int boxpad = (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
8491 gtk_container_add(GTK_CONTAINER(eventbox), item);
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
8492 gtk_container_border_width(GTK_CONTAINER(eventbox), boxpad);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8493 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8494 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8495 }
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
8496 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
8497 {
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
8498 /* 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
8499 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
8500 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8501
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
8502 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
8503 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
8504 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8505 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
8506
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8507 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
8508 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8509 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8510 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8511 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8512 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
8513 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8514
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8515 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8516 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8517 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8518 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8519 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8520 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
8521 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item);
3
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 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8525 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8526 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8527
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
8528 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
8529 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8530 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
8531
563
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8532 /* NOTE: I left in the ability to pack boxes with a size,
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8533 * this eliminates that by forcing the size to 0.
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8534 */
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8535 height = width = 0;
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
8536
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8537 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8538 {
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
8539 int boxpad = (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
8540 gtk_container_add(GTK_CONTAINER(eventbox), item);
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
8541 gtk_container_border_width(GTK_CONTAINER(eventbox), boxpad);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8542 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8543 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8544 }
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
8545 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
8546 {
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
8547 /* 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
8548 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
8549 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8550
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
8551 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8552 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
8553 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8554 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8555
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8556 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8557 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8558 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8559 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
8560
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
8561 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
8562 {
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
8563 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
8564 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
8565 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
8566 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
8567 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8568 }
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 * Sets the size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8572 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8573 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8574 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8575 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8576 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8577 void dw_window_set_size(HWND handle, unsigned long width, unsigned long height)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8578 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8579 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8580 long default_width = width - _dw_border_width;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8581 long default_height = height - _dw_border_height;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8582
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8583 if(!handle)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8584 return;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8585
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8586 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8587 if(GTK_IS_WINDOW(handle))
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8588 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8589 if ( width == 0 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8590 default_width = -1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8591 if ( height == 0 )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8592 default_height = -1;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8593 _size_allocate(GTK_WINDOW(handle));
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8594 if(handle->window)
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8595 gdk_window_resize(handle->window, default_width , default_height );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8596 gtk_window_set_default_size(GTK_WINDOW(handle), default_width , default_height );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8597 if(!gtk_object_get_data(GTK_OBJECT(handle), "_dw_size"))
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8598 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8599 gtk_object_set_data(GTK_OBJECT(handle), "_dw_width", (gpointer)default_width );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8600 gtk_object_set_data(GTK_OBJECT(handle), "_dw_height", (gpointer)default_height );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8601 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8602 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8603 else
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8604 gtk_widget_set_usize(handle, width, height);
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8605 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8606 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8607
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8608 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8609 * Returns the width of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8610 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8611 int dw_screen_width(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8612 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8613 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8614 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8615
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8616 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8617 retval = gdk_screen_width();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8618 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8619 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8620 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8621
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8622 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8623 * Returns the height of the screen.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8624 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8625 int dw_screen_height(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8626 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8627 int retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8628 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8629
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8630 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8631 retval = gdk_screen_height();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8632 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8633 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8634 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8635
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8636 /* This should return the current color depth */
514
08d770271709 More function name changes for Rexx/DW compatibility.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 513
diff changeset
8637 unsigned long dw_color_depth_get(void)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8638 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8639 int retval;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8640 GdkVisual *vis;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8641 int _locked_by_me = FALSE;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8642
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8643 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8644 vis = gdk_visual_get_system();
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8645 retval = vis->depth;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8646 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8647 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8648 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8649
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8650 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8651 * Sets the position of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8652 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8653 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8654 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8655 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8656 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8657 void dw_window_set_pos(HWND handle, unsigned long x, unsigned long y)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8658 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8659 int _locked_by_me = FALSE;
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8660 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8661 GtkWidget *mdi;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8662 #endif
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8663
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8664 DW_MUTEX_LOCK;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8665 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8666 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8667 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8668 gtk_mdi_move(GTK_MDI(mdi), handle, x, y);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8669 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8670 else
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8671 #endif
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8672 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8673 if(handle && handle->window)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8674 gdk_window_move(handle->window, x, y);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8675 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8676 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8677 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8678
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8679 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8680 * Sets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8681 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8682 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8683 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8684 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8685 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8686 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8687 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8688 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
8689 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8690 int _locked_by_me = FALSE;
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8691 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8692 GtkWidget *mdi;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8693 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8694
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
8695 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
8696 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
8697
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
8698 DW_MUTEX_LOCK;
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8699 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8700 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8701 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8702 gtk_mdi_move(GTK_MDI(mdi), handle, x, y);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8703 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8704 else
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8705 #endif
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8706 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8707 if(GTK_IS_WINDOW(handle))
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8708 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8709 dw_window_set_size(handle, width, height);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8710 gtk_widget_set_uposition(handle, x, y);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8711 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8712 else if(handle->window)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8713 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8714 gdk_window_resize(handle->window, width, height);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8715 gdk_window_move(handle->window, x, y);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8716 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8717 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8718 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8719 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8720
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8721 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8722 * Gets the position and size of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8723 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8724 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8725 * x: X location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8726 * y: Y location from the bottom left.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8727 * width: Width of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8728 * height: Height of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8729 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8730 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
8731 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8732 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8733 gint gx, gy, gwidth, gheight, gdepth;
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8734 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8735 GtkWidget *mdi;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8736 #endif
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8737
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8738 DW_MUTEX_LOCK;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8739 #if GTK_MAJOR_VERSION > 1
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8740 if((mdi = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_mdi")) && GTK_IS_MDI(mdi))
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8741 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
8742 gint myx=0, myy=0;
521
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8743
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8744 gtk_mdi_get_pos(GTK_MDI(mdi), handle, &myx, &myy);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8745 *x = myx;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8746 *y = myy;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8747 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8748 else
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8749 #endif
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8750 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8751 if(handle && handle->window)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8752 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8753
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8754 gdk_window_get_geometry(handle->window, &gx, &gy, &gwidth, &gheight, &gdepth);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8755 gdk_window_get_root_origin(handle->window, &gx, &gy);
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8756 if(x)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8757 *x = gx;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8758 if(y)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8759 *y = gy;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8760 if(GTK_IS_WINDOW(handle))
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8761 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8762 if(width)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8763 *width = gwidth + _dw_border_width;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8764 if(height)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8765 *height = gheight + _dw_border_height;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8766 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8767 else
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8768 {
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8769 if(width)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8770 *width = gwidth;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8771 if(height)
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8772 *height = gheight;
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8773 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8774 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8775 }
e3d6f2aac90c Implemented dw_window_set_pos/get_pos/etc.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 520
diff changeset
8776 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8777 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8778
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8779 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8780 * Sets the style of a given window (widget).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8781 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8782 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8783 * width: New width in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8784 * height: New height in pixels.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8785 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8786 void dw_window_set_style(HWND handle, unsigned long style, unsigned long mask)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8787 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8788 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8789 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8790
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8791 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8792 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8793 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8794 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8795 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8796 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8797 }
426
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
8798 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
8799 {
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
8800 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
8801 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
8802 handle2 = tmp;
1f92eadea7d3 Allow dw_window_set_style() on status_text widgets.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 424
diff changeset
8803 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
8804 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
8805 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8806 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
8807 {
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8808 gfloat x, y;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8809
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8810 x = y = DW_LEFT;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8811
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8812 if(style & DW_DT_CENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8813 x = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8814
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8815 if(style & DW_DT_VCENTER)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8816 y = DW_CENTER;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8817
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8818 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
8819 }
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8820 if(style & DW_DT_WORDBREAK)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
8821 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
8822 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8823 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8824 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8825
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8826 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8827 * Adds a new page to specified notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8828 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8829 * handle: Window (widget) handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8830 * flags: Any additional page creation flags.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8831 * front: If TRUE page is added at the beginning.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8832 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8833 unsigned long dw_notebook_page_new(HWND handle, unsigned long flags, int front)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8834 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8835 int z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8836 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
8837 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8838
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8839 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
8840 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
8841
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8842 if(pagearray)
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8843 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8844 for(z=0;z<256;z++)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8845 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8846 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
8847 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8848 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
8849 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
8850
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8851 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
8852 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
8853
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8854 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
8855 /* 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
8856 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
8857 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
8858 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
8859 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8860 }
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
8861 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8862 DW_MUTEX_UNLOCK;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8863
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8864 /* Hopefully this won't happen. */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8865 return 256;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8866 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8867
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8868 /* 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
8869 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
8870 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8871 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
8872 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
8873
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8874 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
8875 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8876 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
8877 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8878 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
8879 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8880 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
8881 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
8882 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8883 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8884 }
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8885 return 256;
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8886 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8887
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8888 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8889 * Remove a page from a notebook.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8890 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8891 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8892 * pageid: ID of the page to be destroyed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8893 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8894 void dw_notebook_page_destroy(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8895 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8896 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
8897 GtkWidget **pagearray;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8898
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8899 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
8900 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
8901 if(realpage > -1 && realpage < 256)
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8902 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8903 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
8904 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
8905 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
8906 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8907 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8908 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8909
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8910 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8911 * Queries the currently visible page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8912 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8913 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8914 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
8915 unsigned long dw_notebook_page_get(HWND handle)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8916 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8917 int retval, phys;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8918 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8919
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8920 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
8921 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
8922 retval = _get_logical_page(handle, phys);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8923 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8924 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8925 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8926
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8927 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8928 * Sets the currently visibale page ID.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8929 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8930 * handle: Handle to the notebook widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8931 * pageid: ID of the page to be made visible.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8932 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8933 void dw_notebook_page_set(HWND handle, unsigned int pageid)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8934 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8935 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8936
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8937 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
8938 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
8939 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
8940 gtk_notebook_set_page(GTK_NOTEBOOK(handle), pageid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8941 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8942 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8943
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8944
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8945 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8946 * Sets the text on the specified notebook tab.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8947 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8948 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8949 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8950 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8951 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8952 void dw_notebook_page_set_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8953 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8954 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
8955 int realpage, _locked_by_me = FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8956
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8957 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
8958 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
8959 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
8960 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8961 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
8962 int num;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8963
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
8964 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
8965 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
8966 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
8967 }
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8968
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8969 if(realpage > -1 && realpage < 256)
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
8970 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8971 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
8972 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
8973 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
8974 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8975 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8976 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8977
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8978 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8979 * Sets the text on the specified notebook tab status area.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8980 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8981 * handle: Notebook handle.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8982 * pageid: Page ID of the tab to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8983 * text: Pointer to the text to set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8984 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8985 void dw_notebook_page_set_status_text(HWND handle, unsigned long pageid, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8986 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8987 /* TODO (if possible) */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8988 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8989
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8990 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8991 * Packs the specified box into the notebook page.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8992 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8993 * handle: Handle to the notebook to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8994 * pageid: Page ID in the notebook which is being packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8995 * page: Box handle to be packed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8996 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8997 void dw_notebook_pack(HWND handle, unsigned long pageid, HWND page)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
8998 {
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
8999 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
9000 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
9001 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
9002 char ptext[100];
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9003
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9004 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
9005 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
9006 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
9007 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
9008 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
9009
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9010 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
9011 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9012 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
9013 return;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9014 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9015
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9016 /* 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
9017 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
9018 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9019 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
9020 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9021 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
9022 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
9023 {
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9024 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
9025 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
9026 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
9027 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
9028 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
9029 break;
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9030 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9031 }
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9032 }
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
9033
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9034 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
9035
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
9036 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
9037
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9038 if(GTK_IS_TABLE(page))
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9039 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9040 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
9041 gtk_container_border_width(GTK_CONTAINER(page), pad);
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9042 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9043
114
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9044 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
9045 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
9046 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
9047 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
9048 else
39932767ef46 Fixes to the notebook code to better handle removing of pages. Also,
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 112
diff changeset
9049 gtk_notebook_insert_page(GTK_NOTEBOOK(handle), page, label, 256);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9050 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9051 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9052
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9053 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9054 * Appends the specified text to the listbox's (or combobox) entry list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9055 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9056 * handle: Handle to the listbox to be appended to.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9057 * text: Text to append into listbox.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9058 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9059 void dw_listbox_append(HWND handle, char *text)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9060 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9061 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9062 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9063
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9064 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9065 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9066 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9067 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9068 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9069 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9070 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9071 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9072 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9073 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9074 GtkWidget *list_item;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9075 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
9076 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
9077 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
9078 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9079
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9080 list_item=gtk_list_item_new_with_label(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9081
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9082 if(font)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9083 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9084 if(fore && back)
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
9085 _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
9086 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
9087 DW_RGB(back->red, back->green, back->blue));
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9088
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9089 tmp = g_list_append(NULL, list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9090 gtk_widget_show(list_item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9091 gtk_list_append_items(GTK_LIST(handle2),tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9092 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9093 else if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9094 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9095 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9096 char *addtext = strdup(text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9097
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9098 if(addtext)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9099 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9100 tmp = g_list_append(tmp, addtext);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9101 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9102 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9103 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9104 }
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9105 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9106 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9107 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9108
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9109 /*
571
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9110 * Appends the specified text items to the listbox's (or combobox) entry list.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9111 * Parameters:
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9112 * handle: Handle to the listbox to be appended to.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9113 * text: Text strings to append into listbox.
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9114 * count: Number of text strings to append
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9115 */
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9116 void dw_listbox_list_append(HWND handle, char **text, int count)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9117 {
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9118 GtkWidget *handle2 = handle;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9119 int _locked_by_me = FALSE;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9120
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9121 DW_MUTEX_LOCK;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9122 if(GTK_IS_SCROLLED_WINDOW(handle))
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9123 {
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9124 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9125 if(tmp)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9126 handle2 = tmp;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9127 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9128 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", (gpointer)1);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9129 if(GTK_IS_LIST(handle2))
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9130 {
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9131 GtkWidget *list_item;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9132 GList *tmp;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9133 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_font");
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9134 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_foregdk");
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9135 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk");
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9136
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9137 list_item=gtk_list_item_new_with_label(*text);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9138
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9139 if(font)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9140 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9141 if(fore && back)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9142 _set_color(GTK_LIST_ITEM(list_item)->item.bin.child,
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9143 DW_RGB(fore->red, fore->green, fore->blue),
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9144 DW_RGB(back->red, back->green, back->blue));
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9145
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9146 tmp = g_list_append(NULL, list_item);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9147 gtk_widget_show(list_item);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9148 gtk_list_append_items(GTK_LIST(handle2),tmp);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9149 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9150 else if(GTK_IS_COMBO(handle2))
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9151 {
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9152 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9153 char *addtext;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9154 int i;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9155
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9156 for (i=0;i<count;i++)
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9157 {
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9158 addtext = strdup(text[i]);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9159 tmp = g_list_append(tmp, addtext);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9160 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9161 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9162 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9163 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9164 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL);
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9165 DW_MUTEX_UNLOCK;
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9166 }
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9167
828e6a66c5c5 Add dw_listbox_list_append()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 569
diff changeset
9168 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9169 * Clears the listbox's (or combobox) list of all entries.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9170 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9171 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9172 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9173 void dw_listbox_clear(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9174 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9175 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9176 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9177
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9178 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9179 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9180 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9181 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9182 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9183 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9184 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9185 if(GTK_IS_COMBO(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9186 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9187 GList *list, *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9188
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9189 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9190 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9191 list = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9192 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9193 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9194 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9195 free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9196 list=list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9197 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9198 g_list_free(tmp);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9199 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9200 gtk_object_set_user_data(GTK_OBJECT(handle2), NULL);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9201 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9202 else if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9203 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9204 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9205
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9206 gtk_list_clear_items(GTK_LIST(handle2), 0, count - 1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9207 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9208 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9209 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9210
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9211 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9212 * Returns the listbox's item count.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9213 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9214 * handle: Handle to the listbox to be counted
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9215 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9216 int dw_listbox_count(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9217 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9218 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9219 int retval = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9220 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9221
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9222 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9223 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9224 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9225 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9226 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9227 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9228 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9229 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9230 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9231 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9232 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9233 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9234 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9235 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9236 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9237 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9238 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9239 retval++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9240 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9241 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9242 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9243 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9244 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9245
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9246 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9247 * Sets the topmost item in the viewport.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9248 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9249 * handle: Handle to the listbox to be cleared.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9250 * top: Index to the top item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9251 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9252 void dw_listbox_set_top(HWND handle, int top)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9253 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9254 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9255 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9256
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9257 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9258 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9259 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9260 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9261 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9262 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9263 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9264 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9265 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9266 int count = dw_listbox_count(handle);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9267 GtkAdjustment *adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9268 float pos, ratio;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9269
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9270 if(count)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9271 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9272 ratio = (float)top/(float)count;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9273
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9274 pos = (ratio * (float)(adj->upper - adj->lower)) + adj->lower;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9275
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9276 gtk_adjustment_set_value(adj, pos);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9277 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9278 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9279 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9280 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9281
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9282 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9283 * Copies the given index item's text into buffer.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9284 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9285 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9286 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9287 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9288 * length: Length of the buffer (including NULL).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9289 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
9290 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
9291 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9292 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9293 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9294
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9295 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9296 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9297 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9298 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9299 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9300 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9301 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9302 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9303 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9304 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9305 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9306 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9307 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9308 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9309 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9310
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9311 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9312 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9313 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9314 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9315 gchar *text = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9316
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9317 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9318 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9319 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9320
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9321 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9322 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9323 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9324
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9325 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9326 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9327 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9328
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9329 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9330 gtk_label_get(GTK_LABEL(b->child), &text);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9332 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9333 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9334 else if(GTK_IS_COMBO(handle) && list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9335 text = (gchar *)list->data;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9336
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9337 strncpy(buffer, (char *)text, length);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9338 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9339 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9340 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9341 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9343 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9344 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9346
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9347 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9348 * Sets the text of a given listbox entry.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9349 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9350 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9351 * index: Index into the list to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9352 * buffer: Buffer where text will be copied.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9353 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9354 void dw_listbox_set_text(HWND handle, unsigned int index, char *buffer)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9355 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9356 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9357 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9358
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9359 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9360 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9361 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9362 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9363 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9364 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9365 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9366 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9367 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9368 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9370 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9371 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9372 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9373 GList *list = GTK_LIST(handle2)->children;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9374
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9375 while(list)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9376 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9377 if(counter == index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9378 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9379
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9380 if(GTK_IS_LIST_ITEM(list->data))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9381 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9382 GtkListItem *li = GTK_LIST_ITEM(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9383
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9384 if(GTK_IS_ITEM(&(li->item)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9385 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9386 GtkItem *i = &(li->item);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9387
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9388 if(GTK_IS_BIN(&(i->bin)))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9389 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9390 GtkBin *b = &(i->bin);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9391
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9392 if(GTK_IS_LABEL(b->child))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9393 gtk_label_set_text(GTK_LABEL(b->child), buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9394 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9395 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9396 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9397 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9398 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9399 if(list->data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9400 g_free(list->data);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9401 list->data = g_strdup(buffer);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9402 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9403 break;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9404 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9405 list = list->next;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9406 counter++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9407 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9408 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9409 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9410 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9411
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
9412 #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
9413 /* 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
9414 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
9415 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9416 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
9417 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9418 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
9419 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
9420
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9421 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
9422 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9423 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
9424 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9425 #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
9426
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9427 /*
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9428 * 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
9429 * Parameters:
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9430 * 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
9431 * 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
9432 */
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9433 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
9434 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9435 GtkWidget *handle2 = handle;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9436 int retval = DW_LIT_NONE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9437 int _locked_by_me = FALSE;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9438
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9439 DW_MUTEX_LOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9440 if(GTK_IS_SCROLLED_WINDOW(handle))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9441 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9442 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
9443 if(tmp)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9444 handle2 = tmp;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9445 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9446 if(GTK_IS_LIST(handle2))
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9447 {
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
9448 #if GTK_MAJOR_VERSION > 1
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9449 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
9450 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
9451
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9452 while(list)
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9453 {
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
9454 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
9455
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9456 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
9457 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
9458 && 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
9459 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9460 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
9461 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
9462 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9463
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9464
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9465 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
9466 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
9467 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9468 #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
9469 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
9470 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
9471
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9472 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
9473 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9474 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
9475 {
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9476 retval = counter;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9477 break;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9478 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9479
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9480 list = list->next;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9481 counter++;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9482 }
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
9483 #endif
60
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9484 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9485 DW_MUTEX_UNLOCK;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9486 return retval;
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9487 }
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9488
61869769c050 Sync with the latest DW code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 57
diff changeset
9489 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9490 * Returns the index to the item in the list currently selected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9491 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9492 * handle: Handle to the listbox to be queried.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9493 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9494 unsigned int dw_listbox_selected(HWND handle)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9495 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9496 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9497 int retval = DW_LIT_NONE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9498 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9499
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9500 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9501 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9502 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9503 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9504 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9505 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9506 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9507 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9508 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9509 retval = (unsigned int)gtk_object_get_data(GTK_OBJECT(handle), "_dw_item");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9510 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9511 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9512 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9513 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9514 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9515 int counter = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9516 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
9517 #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
9518
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9519 while(list)
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9520 {
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9521 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
9522
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9523 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
9524 {
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9525 retval = counter;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9526 break;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9527 }
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9528
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9529 list = list->next;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9530 counter++;
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9531 }
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
9532 #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
9533 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
9534
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
9535 if(selection)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9536 {
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
9537 while(list)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9538 {
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
9539 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
9540 {
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9541 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
9542 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
9543 }
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9544
b479002e013f Upped the DW revision to 1.0, and merged with the latest code in the FX
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 145
diff changeset
9545 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
9546 counter++;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9547 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9548 }
423
c1c75e363a91 Hopefully fixed dw_listbox_selected() on GTK 2.x.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 422
diff changeset
9549 #endif
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9550 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9551 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9552 return retval;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9553 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9554
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9555 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9556 * Sets the selection state of a given index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9557 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9558 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9559 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9560 * state: TRUE if selected FALSE if unselected.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9561 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9562 void dw_listbox_select(HWND handle, int index, int state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9563 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9564 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9565 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9566
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9567 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9568 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9569 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9570 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9571 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9572 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9573 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9574 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9575 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9576 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9577 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9578 if(GTK_IS_LIST(handle2))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9579 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9580 if(state)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9581 gtk_list_select_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9582 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9583 gtk_list_unselect_item(GTK_LIST(handle2), index);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9584 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9585 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9586 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9587
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9588 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9589 * Deletes the item with given index from the list.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9590 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9591 * handle: Handle to the listbox to be set.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9592 * index: Item index.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9593 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9594 void dw_listbox_delete(HWND handle, int index)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9595 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9596 GtkWidget *handle2 = handle;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9597 int _locked_by_me = FALSE;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9598
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9599 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9600 if(GTK_IS_SCROLLED_WINDOW(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9601 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9602 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9603 if(tmp)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9604 handle2 = tmp;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9605 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9606 else if(GTK_IS_COMBO(handle))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9607 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9608 handle2 = GTK_COMBO(handle)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9609 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9610 if(GTK_IS_LIST(handle2))
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
9611 {
464
3251fbca6fb3 dw_listbox_delete() needs index+1 for end arg
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 463
diff changeset
9612 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
9613 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9614 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9615 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9616
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9617 /* 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
9618 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
9619 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9620 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
9621 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
9622 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
9623
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
9624 /* 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
9625 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
9626 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
9627
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9628 lastwidth = event->width; lastheight = event->height;
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
9629
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9630 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
9631 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
9632
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9633 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
9634 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
9635 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
9636 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
9637 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
9638 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
9639 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9640
122
a05b6fb9c545 Minor bug fixes and code cleanups.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 121
diff changeset
9641 #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
9642 /* 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
9643 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
9644 {
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9645 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
9646 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
9647 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
9648
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9649 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
9650 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
9651
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9652 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
9653 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
9654 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
9655 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
9656
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9657 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
9658 *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
9659 }
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9660 #endif
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9661
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9662 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9663 * 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
9664 * 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
9665 * 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
9666 * 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
9667 * 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
9668 * Returns:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9669 * 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
9670 */
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9671 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
9672 {
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9673 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
9674 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
9675 float *percent = malloc(sizeof(float));
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
9676
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9677 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
9678 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
9679 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
9680 else
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9681 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
9682 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
9683 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
9684 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
9685 *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
9686 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
9687 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
9688 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
9689 #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
9690 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
9691 #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
9692 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
9693 #endif
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9694 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
9695 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
9696 return tmp;
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9697 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9698
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9699 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9700 * 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
9701 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9702 * 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
9703 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9704 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
9705 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9706 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
9707 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
9708
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9709 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
9710 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
9711 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
9712 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
9713
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9714 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
9715 *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
9716
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9717 if(size > 10)
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
9718 {
145
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9719 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
9720
659c1a2bccad Fixed the calculations in the splitbar widget. Finished all the splitbar
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 144
diff changeset
9721 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
9722 }
119
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9723 }
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9724
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9725 /*
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9726 * 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
9727 * Parameters:
1cad81b7cc4c Implemented initial splitbar code on Unix. And made some fixes for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 115
diff changeset
9728 * 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
9729 */
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9730 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
9731 {
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9732 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
9733
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
9734 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
9735 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
9736 return 0.0;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9737 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9738
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9739 /*
592
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
9740 * Creates a calendar window (widget) with given parameters.
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
9741 * Parameters:
840b43f3976b Attempt to make spinbutton emit VALUE_CHANGED signal; not working
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 591
diff changeset
9742 * id: Unique identifier for calendar widget
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9743 * Returns:
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9744 * A handle to a calendar window or NULL on failure.
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9745 */
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9746 HWND dw_calendar_new(unsigned long id)
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9747 {
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9748 GtkWidget *tmp;
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9749 int _locked_by_me = FALSE;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9750 GtkCalendarDisplayOptions flags;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9751 time_t now;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9752 struct tm *tmdata;
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9753
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9754 DW_MUTEX_LOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9755 tmp = gtk_calendar_new();
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9756 gtk_widget_show(tmp);
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9757 gtk_object_set_data(GTK_OBJECT(tmp), "_dw_id", (gpointer)id);
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9758 /* select today */
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9759 flags = GTK_CALENDAR_WEEK_START_MONDAY|GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9760 gtk_calendar_display_options( GTK_CALENDAR(tmp), flags );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9761 now = time( NULL );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9762 tmdata = localtime( & now );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9763 gtk_calendar_select_month( GTK_CALENDAR(tmp), tmdata->tm_mon, 1900+tmdata->tm_year );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9764 gtk_calendar_select_day( GTK_CALENDAR(tmp), tmdata->tm_mday );
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9765
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9766 DW_MUTEX_UNLOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9767 return tmp;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9768 }
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9769
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9770 /*
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9771 * Sets the current date of a calendar
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9772 * Parameters:
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9773 * handle: The handle to the calendar returned by dw_calendar_new().
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9774 * year...
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9775 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9776 void dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9777 {
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9778 int _locked_by_me = FALSE;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9779
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9780 DW_MUTEX_LOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9781 if(GTK_IS_CALENDAR(handle))
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9782 {
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9783 gtk_calendar_select_month(GTK_CALENDAR(handle),month-1,year);
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9784 gtk_calendar_select_day(GTK_CALENDAR(handle), day);
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9785 }
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9786 DW_MUTEX_UNLOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9787 return;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9788 }
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9789
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9790 /*
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9791 * Gets the position of a splitbar (pecentage).
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9792 * Parameters:
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9793 * handle: The handle to the splitbar returned by dw_splitbar_new().
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9794 */
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9795 void dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9796 {
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9797 int _locked_by_me = FALSE;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9798
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9799 DW_MUTEX_LOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9800 if(GTK_IS_CALENDAR(handle))
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9801 {
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9802 gtk_calendar_get_date(GTK_CALENDAR(handle),year,month,day);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
9803 *month = *month + 1;
591
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9804 }
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9805 DW_MUTEX_UNLOCK;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9806 return;
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9807 }
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9808
98a667881e44 Add dw_calendar_new()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 590
diff changeset
9809 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9810 * Pack windows (widgets) into a box from the start (or top).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9811 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9812 * box: Window handle of the box to be packed into.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9813 * item: Window handle of the item to be back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9814 * width: Width in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9815 * height: Height in pixels of the item or -1 to be self determined.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9816 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9817 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9818 * pad: Number of pixels of padding around the item.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9819 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9820 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
9821 {
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
9822 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
9823 GtkWidget *tmp, *tmpitem;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9824
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9825 if(!box)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9826 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9827
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
9828 /*
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
9829 * 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
9830 * 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
9831 */
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
9832 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
9833 {
526
d3ce0afa6cf5 Remove extraneous arguments to dw_messagebox()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 524
diff changeset
9834 dw_messagebox("dw_box_pack_start()", DW_MB_OK|DW_MB_ERROR, "Danger! Danger! Will Robinson; box and item are the same!");
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
9835 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
9836 }
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
9837
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9838 DW_MUTEX_LOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9839
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9840 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
9841 box = tmp;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
9842
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9843 if(!item)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9844 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9845 item = gtk_label_new("");
590
2111cdb6c451 Updates to the GtkMozEmbed code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 588
diff changeset
9846 gtk_widget_show_all(item);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9847 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9848
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
9849 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
9850
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9851 if(GTK_IS_TABLE(box))
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9852 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9853 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
9854 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
9855 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
9856
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9857 /* 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
9858 * 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
9859 * 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
9860 * 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
9861 */
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
9862 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
9863 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9864 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
9865
563
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9866 /* NOTE: I left in the ability to pack boxes with a size,
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9867 * this eliminates that by forcing the size to 0.
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9868 */
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9869 height = width = 0;
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9870
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9871 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9872 {
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
9873 int boxpad = (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
9874 gtk_container_add(GTK_CONTAINER(eventbox), item);
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
9875 gtk_container_border_width(GTK_CONTAINER(eventbox), boxpad);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9876 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9877 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9878 }
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
9879 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
9880 {
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
9881 /* 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
9882 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
9883 }
36
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9884
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
9885 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
9886 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9887 x = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9888 y = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9889 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
9890 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9891 else
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9892 {
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9893 x = boxcount;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9894 y = 0;
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9895 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
9896 }
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9897
cddb02f847e1 Added unix versions of functions in compat, and added getfsname, plus
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 34
diff changeset
9898 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
9899 gtk_object_set_data(GTK_OBJECT(box), "_dw_boxcount", (gpointer)boxcount + 1);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9900 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9901 if(GTK_IS_RADIO_BUTTON(item))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9902 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9903 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
9904 GtkWidget *groupstart = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(box), "_dw_group");
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9905
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9906 if(groupstart)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9907 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9908 group = gtk_radio_button_group(GTK_RADIO_BUTTON(groupstart));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9909 gtk_radio_button_set_group(GTK_RADIO_BUTTON(item), group);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9910 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9911 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
9912 gtk_object_set_data(GTK_OBJECT(box), "_dw_group", (gpointer)item);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9913 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9914 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9915 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9916 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9917 GtkWidget *vbox = gtk_vbox_new(FALSE, 0);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9918
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
9919 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
9920 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
9921 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
9922
563
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9923 /* NOTE: I left in the ability to pack boxes with a size,
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9924 * this eliminates that by forcing the size to 0.
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9925 */
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9926 height = width = 0;
d7c61755a57b Force boxes to size 0 on Unix to eliminate box packing confusion, I
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 561
diff changeset
9927
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9928 if(eventbox)
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9929 {
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
9930 int boxpad = (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
9931 gtk_container_add(GTK_CONTAINER(eventbox), item);
550
ebb26cb6bfb2 Fixes to the box packing padding code on Unix. An old workaround was
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 533
diff changeset
9932 gtk_container_border_width(GTK_CONTAINER(eventbox), boxpad);
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9933 item = eventbox;
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9934 }
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9935 }
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
9936 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
9937 {
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
9938 /* 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
9939 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
9940 }
48
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9941
16eac0f8b45f Latest fixes, mainly for GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 47
diff changeset
9942 gtk_container_border_width(GTK_CONTAINER(box), pad);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9943 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
9944 gtk_box_pack_end(GTK_BOX(vbox), item, TRUE, TRUE, 0);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9945 gtk_widget_show(vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9946
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9947 gtk_widget_set_usize(item, width, height);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9948 gtk_object_set_user_data(GTK_OBJECT(box), vbox);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9949 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9950 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
9951
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
9952 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
9953 {
7c8bd3bc6c27 Throw the warning after the mutex has been released in dw_box_pack_*
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 438
diff changeset
9954 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
9955 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
9956 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
9957 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
9958 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9959 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9960
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9961 /*
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
9962 * 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
9963 * 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
9964 * 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
9965 * 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
9966 */
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9967 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
9968 {
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9969 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
9970
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9971 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
9972 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
9973
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9974 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
9975 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
9976 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
9977 }
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9978
b03b24bb95f8 Added dw_window_default() to set the default focus widget in a dialog.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 33
diff changeset
9979 /*
40
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9980 * 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
9981 * Parameters:
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9982 * 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
9983 * 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
9984 */
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9985 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
9986 {
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9987 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
9988
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9989 if(!window)
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9990 return;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9991
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9992 DW_MUTEX_LOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9993 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
9994 DW_MUTEX_UNLOCK;
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9995 }
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9996
88c9c7410c22 Lots of fixes and new functions on all platforms.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 39
diff changeset
9997 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9998 * Returns some information about the current operating environment.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
9999 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10000 * env: Pointer to a DWEnv struct.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10001 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10002 void dw_environment_query(DWEnv *env)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10003 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10004 struct utsname name;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10005 char tempbuf[100];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10006 int len, z;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10007
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10008 uname(&name);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10009 strcpy(env->osName, name.sysname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10010 strcpy(tempbuf, name.release);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10011
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10012 env->MajorBuild = env->MinorBuild = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10013
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10014 len = strlen(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10015
15
81833f25b1aa Added new Dynamic Windows build information to the DWEnv struct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 14
diff changeset
10016 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
10017 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
10018 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
10019 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
10020 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
10021
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10022 for(z=1;z<len;z++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10023 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10024 if(tempbuf[z] == '.')
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10025 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10026 tempbuf[z] = '\0';
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10027 env->MajorVersion = atoi(&tempbuf[z-1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10028 env->MinorVersion = atoi(&tempbuf[z+1]);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10029 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10030 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10031 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10032 env->MajorVersion = atoi(tempbuf);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10033 env->MinorVersion = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10034 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10035
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10036 /* 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
10037 static gint _gtk_file_ok(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10038 {
120
7d2108cbcd3e Porting DW to GTK 2.0... and changed the percent value from into to a float
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 119
diff changeset
10039 #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
10040 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
10041 #else
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10042 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
10043 #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
10044 char *tmpdup=NULL;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10045
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
10046 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
10047 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
10048
214
0e98514a3905 Applied patch from Mark Hessling to prevent the return buffer from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 208
diff changeset
10049 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
10050 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
10051 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
10052 _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
10053 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
10054 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10055 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10056
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10057 /* 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
10058 static gint _gtk_file_cancel(GtkWidget *widget, DWDialog *dwwait)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10059 {
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
10060 if(!dwwait)
134
caeb52bb5ef4 Pass pointers to argc and argv on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 133
diff changeset
10061 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
10062
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
10063 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
10064 _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
10065 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
10066 return FALSE;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10067 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10068
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
10069 /* 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
10070 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
10071 {
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
10072 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
10073 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
10074 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
10075
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
10076 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
10077 {
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
10078 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
10079 {
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
10080 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
10081 {
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
10082 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
10083 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
10084 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
10085 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
10086
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
10087 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
10088 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
10089
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
10090 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
10091
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
10092 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
10093 {
f18c70cb3e38 Fixes for GTK 2.x, and correctly check for the directory bit. NOTE:
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 483
diff changeset
10094 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
10095 tempitem = dw_tree_insert(tree, "", 0, item, 0);
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
10096 dw_tree_item_set_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
10097 }
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
10098
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
10099 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
10100 }
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
10101 }
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
10102 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
10103 }
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
10104 }
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
10105
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
10106 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
10107 {
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
10108 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
10109 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
10110
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
10111 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
10112 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
10113
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
10114 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
10115 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
10116 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
10117 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
10118 }
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
10119
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
10120 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
10121 {
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
10122 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
10123
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
10124 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
10125 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
10126
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
10127 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
10128 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
10129 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
10130 }
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
10131
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
10132 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
10133 {
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
10134 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
10135 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
10136
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
10137 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
10138 {
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
10139 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
10140
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
10141 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
10142 {
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
10143 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
10144 strcpy(temp, text);
493
84e471a4ec7e Don't warn in dw_box_pack_*() for groupboxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 491
diff changeset
10145 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
10146 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
10147 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
10148 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
10149 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
10150 }
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
10151 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
10152 }
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
10153 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
10154 }
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
10155
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
10156 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
10157 {
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
10158 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
10159 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
10160
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
10161 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
10162 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
10163 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
10164
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
10165 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
10166 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
10167
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
10168 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
10169 }
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
10170
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
10171 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
10172 {
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
10173 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
10174 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
10175 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
10176
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
10177 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
10178 {
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
10179 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
10180
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
10181 dw_tree_item_set_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
10182
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
10183 if(*folder)
3bc712d2c362 Delete the temporary item _after_ populating the subtree. This prevents
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 484
diff changeset
10184 _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
10185
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
10186 #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
10187 /* 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
10188 * 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
10189 * 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
10190 * 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
10191 */
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
10192 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
10193 #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
10194 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
10195 }
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
10196
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
10197 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
10198 }
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
10199
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10200 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10201 * Opens a file dialog and queries user selection.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10202 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10203 * title: Title bar text for dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10204 * defpath: The default path of the open dialog.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10205 * 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
10206 * flags: DW_FILE_OPEN or DW_FILE_SAVE or DW_DIRECTORY_OPEN
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10207 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10208 * NULL on error. A malloced buffer containing
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10209 * the file path on success.
566
f6de197ecbe9 Add dw_color_choose()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 563
diff changeset
10210 *
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10211 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10212 char *dw_file_browse(char *title, char *defpath, char *ext, int flags)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10213 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10214 GtkWidget *filew;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10215 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
10216 DWDialog *dwwait;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10217
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
10218 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
10219 {
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
10220 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
10221 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
10222
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
10223 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
10224
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
10225 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
10226
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
10227 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
10228
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
10229 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
10230
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
10231 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
10232 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
10233
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
10234 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
10235
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
10236 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
10237
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
10238 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
10239
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
10240 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
10241 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
10242
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
10243 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
10244 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
10245 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
10246
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
10247 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
10248 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
10249 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
10250
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
10251 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
10252 tempitem = dw_tree_insert(tree, "", 0, item, 0);
513
7755599311d4 Fixes search and replace errors.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 511
diff changeset
10253 dw_tree_item_set_data(tree, item, (void *)tempitem);
510
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
10254
710f82598210 Change function names to be inline with Mark Hessling's Rexx/DW.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 508
diff changeset
10255 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
10256 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
10257 }
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
10258 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
10259 {
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
10260 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
10261
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
10262 /* 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
10263 * 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
10264 */
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
10265 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
10266 {
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
10267 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
10268 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
10269 }
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
10270
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
10271 _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
10272
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
10273 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
10274
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
10275 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
10276
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
10277 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
10278 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
10279
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
10280 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
10281 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
10282
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
10283 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
10284
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10285 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
10286 }
22
6a246b3bb14f Added tree widgets, fixed some delete event processing, fixed a layout bug
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 19
diff changeset
10287 return (char *)dw_dialog_wait(dwwait);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10288 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10289
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10290
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10291 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10292 * Execute and external program in a seperate session.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10293 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10294 * program: Program name with optional path.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10295 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10296 * params: An array of pointers to string arguements.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10297 * Returns:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10298 * -1 on error.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10299 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10300 int dw_exec(char *program, int type, char **params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10301 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10302 int ret = -1;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10303
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10304 if((ret = fork()) == 0)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10305 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10306 int i;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10307
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10308 for (i = 3; i < 256; i++)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10309 close(i);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10310 setsid();
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10311 if(type == DW_EXEC_GUI)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10312 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10313 execvp(program, params);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10314 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10315 else if(type == DW_EXEC_CON)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10316 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10317 char **tmpargs;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10318
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10319 if(!params)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10320 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10321 tmpargs = malloc(sizeof(char *));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10322 tmpargs[0] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10323 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10324 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10325 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10326 int z = 0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10327
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10328 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10329 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10330 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10331 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10332 tmpargs = malloc(sizeof(char *)*(z+3));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10333 z=0;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10334 tmpargs[0] = "xterm";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10335 tmpargs[1] = "-e";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10336 while(params[z])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10337 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10338 tmpargs[z+2] = params[z];
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10339 z++;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10340 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10341 tmpargs[z+2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10342 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10343 execvp("xterm", tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10344 free(tmpargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10345 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10346 /* If we got here exec failed */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10347 _exit(-1);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10348 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10349 return ret;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10350 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10351
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10352 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10353 * Loads a web browser pointed at the given URL.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10354 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10355 * url: Uniform resource locator.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10356 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10357 int dw_browse(char *url)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10358 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10359 /* 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
10360 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
10361
2d7b27204cd4 Add support for DW_BROWSER to specify browser executable fir dw_browse()
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 460
diff changeset
10362 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
10363 if(tmp) browser = tmp;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10364 execargs[0] = browser;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10365 execargs[1] = url;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10366 execargs[2] = NULL;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10367
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10368 return dw_exec(browser, DW_EXEC_GUI, execargs);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10369 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10370
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10371 /*
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10372 * Causes the embedded HTML widget to take action.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10373 * Parameters:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10374 * handle: Handle to the window.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10375 * action: One of the DW_HTML_* constants.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10376 */
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10377 void dw_html_action(HWND handle, int action)
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10378 {
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10379 #ifdef USE_GTKMOZEMBED
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10380 int _locked_by_me = FALSE;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10381
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10382 if(!_gtk_moz_embed_new)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10383 return;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10384
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10385 DW_MUTEX_LOCK;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10386 switch(action)
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10387 {
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10388 case DW_HTML_GOBACK:
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10389 _gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle));
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10390 break;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10391 case DW_HTML_GOFORWARD:
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10392 _gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle));
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10393 break;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10394 case DW_HTML_GOHOME:
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10395 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org");
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10396 break;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10397 case DW_HTML_RELOAD:
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10398 _gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0);
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10399 break;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10400 case DW_HTML_STOP:
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10401 _gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle));
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10402 break;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10403 }
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10404 DW_MUTEX_UNLOCK;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10405 #endif
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10406 }
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10407
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10408 /*
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10409 * Render raw HTML code in the embedded HTML widget..
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10410 * Parameters:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10411 * handle: Handle to the window.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10412 * string: String buffer containt HTML code to
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10413 * be rendered.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10414 * Returns:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10415 * 0 on success.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10416 */
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10417 int dw_html_raw(HWND handle, char *string)
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10418 {
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10419 #ifdef USE_GTKMOZEMBED
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10420 int _locked_by_me = FALSE;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10421
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10422 if(!_gtk_moz_embed_new)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10423 return -1;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10424
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10425 DW_MUTEX_LOCK;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10426 _gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "", "");
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10427 DW_MUTEX_UNLOCK;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10428 return 0;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10429 #endif
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10430 return -1;
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10431 }
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10432
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10433 /*
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10434 * Render file or web page in the embedded HTML widget..
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10435 * Parameters:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10436 * handle: Handle to the window.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10437 * url: Universal Resource Locator of the web or
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10438 * file object to be rendered.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10439 * Returns:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10440 * 0 on success.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10441 */
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10442 int dw_html_url(HWND handle, char *url)
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10443 {
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10444 #ifdef USE_GTKMOZEMBED
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10445 int _locked_by_me = FALSE;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10446
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10447 if(!_gtk_moz_embed_new)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10448 return -1;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10449
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10450 DW_MUTEX_LOCK;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10451 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), url);
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10452 DW_MUTEX_UNLOCK;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10453 return 0;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10454 #endif
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10455 return -1;
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10456 }
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10457
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10458 /*
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10459 * Create a new Entryfield window (widget) to be packed.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10460 * Parameters:
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10461 * text: The default text to be in the entryfield widget.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10462 * id: An ID to be used with dw_window_from_id() or 0L.
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10463 */
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10464 HWND dw_html_new(unsigned long id)
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10465 {
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10466 #ifdef USE_GTKMOZEMBED
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10467 GtkWidget *widget;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10468 int _locked_by_me = FALSE;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10469
588
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10470 if(!_gtk_moz_embed_new)
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10471 return NULL;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10472
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10473 DW_MUTEX_LOCK;
1b398af1ec38 Implemented dynamic loading of the Mozilla renderer.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 587
diff changeset
10474 widget = _gtk_moz_embed_new();
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10475 DW_MUTEX_UNLOCK;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10476 return widget;
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10477 #else
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10478 return dw_box_new(DW_HORZ, 0);
587
9e81f23b57ae If available try to use GtkMozEmbed from Mozilla.or.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 586
diff changeset
10479 #endif
586
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10480 }
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10481
b9d903cde2f4 Added stubs for HTML renderer on Unix.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 577
diff changeset
10482 /*
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10483 * Gets the contents of the default clipboard as text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10484 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10485 * None.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10486 * Returns:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10487 * Pointer to an allocated string of text or NULL if clipboard empty or contents could not
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10488 * be converted to text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10489 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10490 char *dw_clipboard_get_text()
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10491 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10492 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10493
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10494 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10495 if ( _clipboard_object[index] == NULL )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10496 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10497 _clipboard_object[index] = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10498 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10499 if ( _clipboard_contents[index] != NULL )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10500 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10501 g_free( _clipboard_contents[index] );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10502 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10503 _clipboard_contents[index] = gtk_clipboard_wait_for_text( _clipboard_object[index] );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10504 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10505 return (char *)_clipboard_contents[index];
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10506 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10507
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10508 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10509 * Sets the contents of the default clipboard to the supplied text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10510 * Parameters:
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10511 * Text.
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10512 */
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10513 void dw_clipboard_set_text( char *str, int len )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10514 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10515 int _locked_by_me = FALSE, index = _find_thread_index(dw_thread_id());
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10516
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10517 DW_MUTEX_LOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10518 if ( _clipboard_object[index] == NULL )
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10519 {
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10520 _clipboard_object[index] = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10521 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10522 gtk_clipboard_set_text( _clipboard_object[index], str, len );
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10523 DW_MUTEX_UNLOCK;
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10524 }
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10525
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10526 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10527 * Returns a pointer to a static buffer which containes the
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10528 * current user directory. Or the root directory (C:\ on
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10529 * OS/2 and Windows).
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10530 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10531 char *dw_user_dir(void)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10532 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10533 static char _user_dir[1024] = "";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10534
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10535 if(!_user_dir[0])
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10536 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10537 char *home = getenv("HOME");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10538
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10539 if(home)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10540 strcpy(_user_dir, home);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10541 else
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10542 strcpy(_user_dir, "/");
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10543 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10544 return _user_dir;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10545 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10546
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10547 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10548 * Call a function from the window (widget)'s context.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10549 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10550 * handle: Window handle of the widget.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10551 * function: Function pointer to be called.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10552 * data: Pointer to the data to be passed to the function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10553 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10554 void dw_window_function(HWND handle, void *function, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10555 {
37
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10556 void (* windowfunc)(void *);
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10557
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10558 windowfunc = function;
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10559
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10560 if(windowfunc)
360bc6a5f1c9 Sync with latest Dynamic Windows code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 36
diff changeset
10561 windowfunc(data);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10562 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10563
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10564 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10565 * 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
10566 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10567 * 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
10568 * 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
10569 * 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
10570 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10571 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
10572 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10573 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
10574
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10575 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
10576 return;
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10577
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10578 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
10579 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
10580 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
10581 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
10582 {
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
10583 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
10584
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
10585 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
10586 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
10587 }
cf0115e38ef0 On multi-widget windows, set the data on all components.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 107
diff changeset
10588 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
10589 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
10590 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
10591 }
90
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10592 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
10593 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10594
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10595 /*
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10596 * 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
10597 * Parameters:
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10598 * 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
10599 * 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
10600 * 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
10601 */
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10602 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
10603 {
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10604 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
10605 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
10606
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10607 if(!window)
92
0a085f295e81 A couple more minor changes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 91
diff changeset
10608 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
10609
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10610 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
10611 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
10612 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
10613 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
10614 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
10615 }
eeb98f881663 Committed the dw_window_set/get_data() changes from the FX tree.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 87
diff changeset
10616
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10617 /*
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10618 * 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
10619 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10620 * 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
10621 * 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
10622 * 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
10623 * Returns:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10624 * 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
10625 */
199
b955228477b3 Removed the window parameter to dw_timer_connect() it was no needed.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 198
diff changeset
10626 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
10627 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10628 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
10629
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10630 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10631 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
10632 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10633 return tag;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10634 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10635
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10636 /*
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10637 * Removes timer callback.
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10638 * Parameters:
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10639 * 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
10640 */
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10641 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
10642 {
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10643 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
10644
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10645 DW_MUTEX_LOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10646 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
10647 DW_MUTEX_UNLOCK;
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10648 }
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10649
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10650 /* 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
10651 * 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
10652 */
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10653 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
10654 {
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10655 HWND thiswindow = window;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10656
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10657 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
10658 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
10659 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
10660 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
10661 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
10662 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
10663 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
10664 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
10665 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
10666 #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
10667 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
10668 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
10669 #endif
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10670 return thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10671 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10672
195
b023d363fc09 Added scrollbar and timer support on OS/2 and GTK.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 193
diff changeset
10673 /*
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10674 * Add a callback to a window event.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10675 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10676 * window: Window handle of signal to be called back.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10677 * signame: A string pointer identifying which signal to be hooked.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10678 * sigfunc: The pointer to the function to be used as the callback.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10679 * data: User data to be passed to the handler function.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10680 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10681 void dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10682 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10683 void *thisfunc = _findsigfunc(signame);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10684 char *thisname = signame;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10685 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
10686 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
10687 gint cid;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10688
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10689 DW_MUTEX_LOCK;
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10690 /*
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10691 * If the window we are setting the signal on is a scrolled window we need to get
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10692 * the "real" widget type. thiswindow is the "real" widget type
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10693 */
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10694 if(GTK_IS_SCROLLED_WINDOW(thiswindow))
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10695 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10696 thiswindow = (HWND)gtk_object_get_user_data(GTK_OBJECT(window));
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10697 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10698
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10699 if(GTK_IS_MENU_ITEM(thiswindow) && strcmp(signame, DW_SIGNAL_CLICKED) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10700 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10701 thisname = "activate";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10702 thisfunc = _findsigfunc(thisname);
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10703 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10704 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_CONTEXT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10705 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10706 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
10707 thisfunc = _findsigfunc(DW_SIGNAL_ITEM_CONTEXT);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10708 }
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
10709 #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
10710 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
10711 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
10712 thisfunc = _findsigfunc("tree-context");
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10713
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10714 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
10715 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
10716 _set_signal_handler_id(thiswindow, sigid, cid);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10717
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10718 #if 0
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10719 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
10720 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
10721 _set_signal_handler_id(window, sigid, cid);
612
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10722 #endif
c5e5671dec8f Modify Calendar widget
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 610
diff changeset
10723
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
10724 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
10725 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
10726 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10727 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
10728 {
362
eb61b854fd58 Fixes for new signal handler code, for GTK 2.x tree control.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 361
diff changeset
10729 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
10730
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
10731 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
10732 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
10733
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10734 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
10735 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
10736 _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
10737 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
10738 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
10739 }
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
10740 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
10741 {
ea099ba917c6 Added two new tree functions, get_title and get_parent and finished the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 472
diff changeset
10742 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
10743 }
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
10744 #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
10745 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
10746 {
c4e1139d9872 Added new tree functions, and fixed a memory leak as well as use of
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 52
diff changeset
10747 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
10748 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
10749
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
10750 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
10751 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
10752 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
10753 _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
10754 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
10755 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
10756 _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
10757 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
10758 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
10759 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10760 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
10761 {
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
10762 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
10763 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10764 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
10765 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
10766 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
10767 }
e0e73b4372a6 GTK 2.0 tree control is now fully functional. I just need to check for
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 139
diff changeset
10768 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
10769 }
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
10770 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
10771 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
10772 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
10773 {
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
10774 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
10775 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
10776 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
10777 }
1cb1b87bbd30 Fixes for the Unix file browser... seems to have revealed a problem in
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 482
diff changeset
10778 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
10779 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
10780 }
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
10781 #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
10782 else if(GTK_IS_CLIST(thiswindow) && strcmp(signame, DW_SIGNAL_ITEM_ENTER) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10783 {
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10784 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
10785 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
10786 _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
10787
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10788 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
10789 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
10790 }
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10791 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
10792 {
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
10793 thisname = "select_row";
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
10794 thisfunc = (void *)_container_select_row;
d35771f70bdd Allow tree-select to work on container controls.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 163
diff changeset
10795 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10796 else if(GTK_IS_COMBO(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10797 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10798 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10799 thiswindow = GTK_COMBO(thiswindow)->list;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10800 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10801 else if(GTK_IS_LIST(thiswindow) && strcmp(signame, DW_SIGNAL_LIST_SELECT) == 0)
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10802 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10803 thisname = "select_child";
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10804 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10805 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
10806 {
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
10807 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
10808 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
10809 thiswindow = GTK_COMBO(thiswindow)->entry;
14
176cee043f1b Lots of Windows and Unix bug fixes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 12
diff changeset
10810 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10811 #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
10812 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
10813 {
b6948eac375a Sync with the latest dynamic windows, tree fixes, and other miscellaneous
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 54
diff changeset
10814 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
10815 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
10816 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
10817 }
307
324587c06cea Use the signal #defines internally so all that is required to change
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 296
diff changeset
10818 #endif
205
b9283fd56d69 Updated scrollbar code on Unix and added dw_main_iteration()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 202
diff changeset
10819 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
10820 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
10821 {
358
526642f70ddd Prefix all internally used data with _dw_ to avoid conflicts with user
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 357
diff changeset
10822 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
10823 }
331
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
10824 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
10825 {
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
10826 thisname = "switch-page";
20def3eaae8d Implement handling of switch-page signal for notebooks.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 329
diff changeset
10827 }
472
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
10828 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
10829 {
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
10830 thisname = "click-column";
d11be1f40f8c Add support for column-click signal.
mhessling@81767d24-ef19-dc11-ae90-00e081727c95
parents: 464
diff changeset
10831 }
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10832
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10833 if(!thisfunc || !thiswindow)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10834 {
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10835 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10836 return;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10837 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10838
409
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10839 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
10840 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
10841 _set_signal_handler_id(thiswindow, sigid, cid);
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10842 DW_MUTEX_UNLOCK;
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10843 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10844
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10845 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10846 * Removes callbacks for a given window with given name.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10847 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10848 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10849 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10850 void dw_signal_disconnect_by_name(HWND window, char *signame)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10851 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10852 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10853 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10854 void *thisfunc;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10855 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
10856
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10857 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10858 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
10859 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
10860 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
10861
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10862 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
10863 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10864 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
10865
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10866 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
10867 _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
10868 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10869 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10870 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10871
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10872 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10873 * Removes all callbacks for a given window.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10874 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10875 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10876 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10877 void dw_signal_disconnect_by_window(HWND window)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10878 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10879 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10880 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10881 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
10882
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10883 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10884 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
10885 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
10886
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10887 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
10888 _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
10889 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
10890 DW_MUTEX_UNLOCK;
3
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10891 }
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10892
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10893 /*
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10894 * Removes all callbacks for a given window with specified data.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10895 * Parameters:
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10896 * window: Window handle of callback to be removed.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10897 * data: Pointer to the data to be compared against.
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10898 */
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10899 void dw_signal_disconnect_by_data(HWND window, void *data)
ktk@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10900 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10901 HWND thiswindow;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10902 int z, count;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10903 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
10904
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10905 DW_MUTEX_LOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10906 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
10907 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
10908
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10909 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
10910 {
410
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10911 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
10912
1d7be77cbfb5 Implemented signal removal system so it works like OS/2 and Windows.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 407
diff changeset
10913 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
10914 _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
10915 }
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10916 DW_MUTEX_UNLOCK;
47273b6a8500 Fixes for signal removal. Some limitations still exist... like some
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 409
diff changeset
10917 }