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