]> git.street.me.uk Git - andy/viking.git/blame - src/uibuilder.h
Prevent the program grinding to a halt if trying to deal with thousands of tiles
[andy/viking.git] / src / uibuilder.h
CommitLineData
f33aa4e0
EB
1/*
2 * viking -- GPS Data and Topo Analyzer, Explorer, and Manager
3 *
4 * Copyright (C) 2003-2007, Evan Battaglia <gtoevan@gmx.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 */
21#ifndef _VIKING_UIBUILDER_H
22#define _VIKING_UIBUILDER_H
23
24#include <gtk/gtk.h>
25
722b5481
RN
26G_BEGIN_DECLS
27
f33aa4e0
EB
28/* Parameters (for I/O and Properties) */
29
30typedef union {
31 gdouble d;
32 guint32 u;
33 gint32 i;
34 gboolean b;
35 const gchar *s;
36 GdkColor c;
37 GList *sl;
38} VikLayerParamData;
39
72a335a4
RN
40typedef enum {
41 VIK_LAYER_WIDGET_CHECKBUTTON=0,
42 VIK_LAYER_WIDGET_RADIOGROUP,
43 VIK_LAYER_WIDGET_RADIOGROUP_STATIC,
44 VIK_LAYER_WIDGET_SPINBUTTON,
45 VIK_LAYER_WIDGET_ENTRY,
46 VIK_LAYER_WIDGET_PASSWORD,
47 VIK_LAYER_WIDGET_FILEENTRY,
48 VIK_LAYER_WIDGET_FOLDERENTRY,
49 VIK_LAYER_WIDGET_HSCALE,
50 VIK_LAYER_WIDGET_COLOR,
51 VIK_LAYER_WIDGET_COMBOBOX,
52 VIK_LAYER_WIDGET_FILELIST,
53} VikLayerWidgetType;
54
3671126d
RN
55/* id is index */
56typedef enum {
57VIK_LAYER_PARAM_DOUBLE=1,
58VIK_LAYER_PARAM_UINT,
59VIK_LAYER_PARAM_INT,
60
61/* in my_layer_set_param, if you want to use the string, you should dup it
62 * in my_layer_get_param, the string returned will NOT be free'd, you are responsible for managing it (I think) */
63VIK_LAYER_PARAM_STRING,
64VIK_LAYER_PARAM_BOOLEAN,
65VIK_LAYER_PARAM_COLOR,
66
67/* NOTE: string list works uniquely: data.sl should NOT be free'd when
68 * the internals call get_param -- i.e. it should be managed w/in the layer.
69 * The value passed by the internals into set_param should also be managed
70 * by the layer -- i.e. free'd by the layer.
71 */
72
73VIK_LAYER_PARAM_STRING_LIST,
74} VikLayerParamType;
75
a7023a1b
RN
76typedef enum {
77 VIK_LAYER_AGGREGATE = 0,
78 VIK_LAYER_TRW,
79 VIK_LAYER_COORD,
80 VIK_LAYER_GEOREF,
81 VIK_LAYER_GPS,
82 VIK_LAYER_MAPS,
83 VIK_LAYER_DEM,
84 VIK_LAYER_NUM_TYPES // Also use this value to indicate no layer association
85} VikLayerTypeEnum;
86
87// Default value has to be returned via a function
88// because certain types value are can not be statically allocated
89// (i.e. a string value that is dependent on other functions)
90// Also easier for colours to be set via a function call rather than a static assignment
91typedef VikLayerParamData (*VikLayerDefaultFunc) ( void );
92
f33aa4e0 93typedef struct {
a7023a1b 94 VikLayerTypeEnum layer;
f33aa4e0 95 const gchar *name;
3671126d 96 VikLayerParamType type;
f33aa4e0
EB
97 gint16 group;
98 const gchar *title;
72a335a4 99 VikLayerWidgetType widget_type;
f33aa4e0
EB
100 gpointer widget_data;
101 gpointer extra_widget_data;
e6994d8d 102 const gchar *tooltip;
a7023a1b 103 VikLayerDefaultFunc default_value;
f33aa4e0
EB
104} VikLayerParam;
105
106enum {
107VIK_LAYER_NOT_IN_PROPERTIES=-2,
108VIK_LAYER_GROUP_NONE=-1
109};
110
f33aa4e0
EB
111typedef struct {
112 gdouble min;
113 gdouble max;
114 gdouble step;
115 guint8 digits;
116} VikLayerParamScale;
117
17a1f8f9 118
a7023a1b
RN
119 /* Annoyingly 'C' cannot initialize unions properly */
120 /* It's dependent on the standard used or the compiler support... */
121#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L || __GNUC__
122#define VIK_LPD_BOOLEAN(X) (VikLayerParamData) { .b = (X) }
123#define VIK_LPD_INT(X) (VikLayerParamData) { .u = (X) }
124#define VIK_LPD_UINT(X) (VikLayerParamData) { .i = (X) }
125#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { .c = (GdkColor){ (X), (Y), (Z), (A) } }
126#define VIK_LPD_DOUBLE(X) (VikLayerParamData) { .d = (X) }
127#else
128#define VIK_LPD_BOOLEAN(X) (VikLayerParamData) { (X) }
129#define VIK_LPD_INT(X) (VikLayerParamData) { (X) }
130#define VIK_LPD_UINT(X) (VikLayerParamData) { (X) }
131#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { (X), (Y), (Z), (A) }
132#define VIK_LPD_DOUBLE(X) (VikLayerParamData) { (X) }
133#endif
134
135VikLayerParamData vik_lpd_true_default ( void );
136VikLayerParamData vik_lpd_false_default ( void );
f33aa4e0
EB
137
138GtkWidget *a_uibuilder_new_widget ( VikLayerParam *param, VikLayerParamData data );
139VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param );
3671126d
RN
140gint a_uibuilder_properties_factory ( const gchar *dialog_name,
141 GtkWindow *parent,
142 VikLayerParam *params,
143 guint16 params_count,
144 gchar **groups,
145 guint8 groups_count,
146 gboolean (*setparam) (gpointer,guint16,VikLayerParamData,gpointer,gboolean),
147 gpointer pass_along1,
148 gpointer pass_along2,
149 VikLayerParamData (*getparam) (gpointer,guint16,gboolean),
150 gpointer pass_along_getparam );
158b3642 151 /* pass_along1 and pass_along2 are for set_param first and last params */
f33aa4e0 152
13fde155 153VikLayerParamData *a_uibuilder_run_dialog ( const gchar *dialog_name, GtkWindow *parent, VikLayerParam *params,
f33aa4e0
EB
154 guint16 params_count, gchar **groups, guint8 groups_count,
155 VikLayerParamData *params_defaults );
156
157/* frees data from last (if ness) */
158void a_uibuilder_free_paramdatas ( VikLayerParamData *paramdatas, VikLayerParam *params, guint16 params_count );
159
722b5481
RN
160G_END_DECLS
161
f33aa4e0 162#endif