]> git.street.me.uk Git - andy/viking.git/blame - src/uibuilder.h
Fix stdout/stderr variable usage.
[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;
fc23d18f 38 gpointer ptr; // For internal usage - don't save this value in a file!
f33aa4e0
EB
39} VikLayerParamData;
40
72a335a4
RN
41typedef enum {
42 VIK_LAYER_WIDGET_CHECKBUTTON=0,
43 VIK_LAYER_WIDGET_RADIOGROUP,
44 VIK_LAYER_WIDGET_RADIOGROUP_STATIC,
45 VIK_LAYER_WIDGET_SPINBUTTON,
46 VIK_LAYER_WIDGET_ENTRY,
47 VIK_LAYER_WIDGET_PASSWORD,
48 VIK_LAYER_WIDGET_FILEENTRY,
49 VIK_LAYER_WIDGET_FOLDERENTRY,
50 VIK_LAYER_WIDGET_HSCALE,
51 VIK_LAYER_WIDGET_COLOR,
52 VIK_LAYER_WIDGET_COMBOBOX,
53 VIK_LAYER_WIDGET_FILELIST,
fc23d18f 54 VIK_LAYER_WIDGET_BUTTON,
72a335a4
RN
55} VikLayerWidgetType;
56
3671126d
RN
57/* id is index */
58typedef enum {
59VIK_LAYER_PARAM_DOUBLE=1,
60VIK_LAYER_PARAM_UINT,
61VIK_LAYER_PARAM_INT,
62
63/* in my_layer_set_param, if you want to use the string, you should dup it
64 * in my_layer_get_param, the string returned will NOT be free'd, you are responsible for managing it (I think) */
65VIK_LAYER_PARAM_STRING,
66VIK_LAYER_PARAM_BOOLEAN,
67VIK_LAYER_PARAM_COLOR,
68
69/* NOTE: string list works uniquely: data.sl should NOT be free'd when
70 * the internals call get_param -- i.e. it should be managed w/in the layer.
71 * The value passed by the internals into set_param should also be managed
72 * by the layer -- i.e. free'd by the layer.
73 */
74
75VIK_LAYER_PARAM_STRING_LIST,
fc23d18f 76VIK_LAYER_PARAM_PTR, // Not really a 'parameter' but useful to route to extended configuration (e.g. toolbar order)
3671126d
RN
77} VikLayerParamType;
78
a7023a1b
RN
79typedef enum {
80 VIK_LAYER_AGGREGATE = 0,
81 VIK_LAYER_TRW,
82 VIK_LAYER_COORD,
83 VIK_LAYER_GEOREF,
84 VIK_LAYER_GPS,
85 VIK_LAYER_MAPS,
86 VIK_LAYER_DEM,
87 VIK_LAYER_NUM_TYPES // Also use this value to indicate no layer association
88} VikLayerTypeEnum;
89
90// Default value has to be returned via a function
91// because certain types value are can not be statically allocated
92// (i.e. a string value that is dependent on other functions)
93// Also easier for colours to be set via a function call rather than a static assignment
94typedef VikLayerParamData (*VikLayerDefaultFunc) ( void );
95
a87f8fa1
RN
96// Convert between the value held internally and the value used for display
97// e.g. keep the internal value in seconds yet use days in the display
98typedef VikLayerParamData (*VikLayerConvertFunc) ( VikLayerParamData );
99
f33aa4e0 100typedef struct {
a7023a1b 101 VikLayerTypeEnum layer;
f33aa4e0 102 const gchar *name;
3671126d 103 VikLayerParamType type;
f33aa4e0
EB
104 gint16 group;
105 const gchar *title;
72a335a4 106 VikLayerWidgetType widget_type;
f33aa4e0
EB
107 gpointer widget_data;
108 gpointer extra_widget_data;
e6994d8d 109 const gchar *tooltip;
a7023a1b 110 VikLayerDefaultFunc default_value;
a87f8fa1
RN
111 VikLayerConvertFunc convert_to_display;
112 VikLayerConvertFunc convert_to_internal;
f33aa4e0
EB
113} VikLayerParam;
114
115enum {
116VIK_LAYER_NOT_IN_PROPERTIES=-2,
117VIK_LAYER_GROUP_NONE=-1
118};
119
f33aa4e0
EB
120typedef struct {
121 gdouble min;
122 gdouble max;
123 gdouble step;
124 guint8 digits;
125} VikLayerParamScale;
126
17a1f8f9 127
a7023a1b
RN
128 /* Annoyingly 'C' cannot initialize unions properly */
129 /* It's dependent on the standard used or the compiler support... */
130#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L || __GNUC__
131#define VIK_LPD_BOOLEAN(X) (VikLayerParamData) { .b = (X) }
132#define VIK_LPD_INT(X) (VikLayerParamData) { .u = (X) }
133#define VIK_LPD_UINT(X) (VikLayerParamData) { .i = (X) }
134#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { .c = (GdkColor){ (X), (Y), (Z), (A) } }
135#define VIK_LPD_DOUBLE(X) (VikLayerParamData) { .d = (X) }
136#else
137#define VIK_LPD_BOOLEAN(X) (VikLayerParamData) { (X) }
138#define VIK_LPD_INT(X) (VikLayerParamData) { (X) }
139#define VIK_LPD_UINT(X) (VikLayerParamData) { (X) }
140#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { (X), (Y), (Z), (A) }
141#define VIK_LPD_DOUBLE(X) (VikLayerParamData) { (X) }
142#endif
143
144VikLayerParamData vik_lpd_true_default ( void );
145VikLayerParamData vik_lpd_false_default ( void );
f33aa4e0 146
db43cfa4
RN
147typedef enum {
148 UI_CHG_LAYER = 0,
149 UI_CHG_PARAM,
150 UI_CHG_PARAM_ID,
151 UI_CHG_WIDGETS,
152 UI_CHG_LABELS,
153 UI_CHG_LAST
154} ui_change_index;
155
156typedef gpointer ui_change_values[UI_CHG_LAST];
157
f33aa4e0
EB
158GtkWidget *a_uibuilder_new_widget ( VikLayerParam *param, VikLayerParamData data );
159VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param );
3671126d
RN
160gint a_uibuilder_properties_factory ( const gchar *dialog_name,
161 GtkWindow *parent,
162 VikLayerParam *params,
163 guint16 params_count,
164 gchar **groups,
165 guint8 groups_count,
db43cfa4 166 gboolean (*setparam) (gpointer,guint16,VikLayerParamData,gpointer,gboolean), // AKA VikLayerFuncSetParam in viklayer.h
3671126d
RN
167 gpointer pass_along1,
168 gpointer pass_along2,
db43cfa4
RN
169 VikLayerParamData (*getparam) (gpointer,guint16,gboolean), // AKA VikLayerFuncGetParam in viklayer.h
170 gpointer pass_along_getparam,
171 void (*changeparam) (GtkWidget*, ui_change_values) ); // AKA VikLayerFuncChangeParam in viklayer.h
158b3642 172 /* pass_along1 and pass_along2 are for set_param first and last params */
f33aa4e0 173
13fde155 174VikLayerParamData *a_uibuilder_run_dialog ( const gchar *dialog_name, GtkWindow *parent, VikLayerParam *params,
f33aa4e0
EB
175 guint16 params_count, gchar **groups, guint8 groups_count,
176 VikLayerParamData *params_defaults );
177
178/* frees data from last (if ness) */
179void a_uibuilder_free_paramdatas ( VikLayerParamData *paramdatas, VikLayerParam *params, guint16 params_count );
180
1bc1c05b
RN
181/*
182 * Since combo boxes are used in various places
183 * keep the code reasonably tidy and only have one ifdef to cater for the naming variances
184 */
185#if GTK_CHECK_VERSION (2, 24, 0)
186#define vik_combo_box_text_new gtk_combo_box_text_new
187#define vik_combo_box_text_append(X,Y) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(X),Y)
188#else
189#define vik_combo_box_text_new gtk_combo_box_new_text
190#define vik_combo_box_text_append(X,Y) gtk_combo_box_append_text(GTK_COMBO_BOX(X),Y)
191#endif
192
0a150ac4
RN
193// Consider adding sort options such as by time
194// However use within the treeview then is more complicated as one would need to store that data in the treeview...
195typedef enum {
196 VL_SO_NONE = 0,
197 VL_SO_ALPHABETICAL_ASCENDING,
198 VL_SO_ALPHABETICAL_DESCENDING,
199 VL_SO_LAST
200} vik_layer_sort_order_t;
201
722b5481
RN
202G_END_DECLS
203
f33aa4e0 204#endif