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