-
Notifications
You must be signed in to change notification settings - Fork 2
/
pref.h
195 lines (141 loc) · 4.61 KB
/
pref.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
/*
Copyright (C) 2021 BrerDawg
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
//pref.h
//v1.13
#ifndef pref_h
#define pref_h
#include <stdio.h>
#include <string>
#include <FL/Fl_Window.H>
//#include <FL/Fl_Box.H>
#include <FL/Fl_Scroll.H>
#include <FL/Fl_Value_Slider.H>
#include <FL/Fl_Pack.H>
#include <FL/Enumerations.H>
#include <FL/fl_draw.H>
#include "GCProfile.h"
#include "GCCol.h"
#include "GCLed.h"
#define cnControlHeight 20
using namespace std;
enum //type of control
{
cnNone,
cnStaticTextPref,
cnInputPref, //edit text box for strings
cnInputIntPref, //edit text box for integers
cnInputHexPref, //edit text box for hex nums
cnInputDoublePref, //edit text box for floats/doubles
cnEditHistPref, //edit text ?????
cnButtonPref,
cnLightButtonPref,
cnRoundButtonPref,
cnRadioButtonPref,
cnToggleButtonPref,
cnCheckPref,
cnMenuChoicePref,
cnGCColColour,
cnGCLed,
cnEndMarkerPref //make sure this is last enum
};
#define cnMaxCtrl 30 //max controls in an row
#define cnMaxRow 200 //max row entries
#define cn_empty_control_uniq_id 0xffffffff //value used to clear scontrol[][].uniq_id, it shows no control is set at a particular row and column
//don't use this value as find_control_from_its_id() won't find control
//see also cn_dontcare_control_uniq_id
#define cn_dontcare_control_uniq_id 0xfffffffe //highest allowable value, used to show uniq_id is set to don't care
//void PrefWnd; //need this for struct below, see further down for real PrefWnd class def
struct sControl //a control's params
{
string label;
string tooltip;
string section;
string key;
int keypostfix;
int label_type;
int label_align;
string options;
int ctrl_style; //e.g: for GCLed could be: cn_gcled_style_square, cn_gcled_style_round
int type;
int x,y,w,h;
int labelfont;
int labelsize;
int textfont;
int textsize;
bool dynamic;
string def;
string radio_group_name; //if a name assigned, any other radio button with matching name is toggled off when
// - pressed, allows radio button 'groups' to span across many rows
int *iretval;
double *dretval;
string *sretval;
unsigned int uniq_id; //this is a user value that may be used to identify which control was pressed, apart from row and column values callback receives
//don't use 0xffffffff (cn_empty_control_uniq_id) as this is the value to show no control exists, find_control_from_its_id() won't find control if you use it
void (*cb)(void*,int,int);
};
class fl_input_change : public Fl_Input
{
private:
bool ctrl_key;
bool left_button;
string dropped_str;
public:
int row; //v1.09
int clmn;
public:
fl_input_change( int xx, int yy, int ww, int hh, const char *label );
private:
int handle( int e );
};
class PrefWnd : public Fl_Double_Window
{
private:
int label_w;
int control_h;
int control_cnt;
int xpos,ypos;
//int typelist[cnMaxRow][cnMaxCtrl+1]; //first number is num of controls in this entry
Fl_Group *entry_wnd[cnMaxRow];
int entry_count;
public:
Fl_Pack* pck;
sControl sc;
sControl ctrl_list[cnMaxRow][cnMaxCtrl];
void* ctrl_ptrs[cnMaxRow][cnMaxCtrl];
int ctrl_count;
int row_count;
sControl ctrl;
string sSectionPos; //set if you need pos of pref wnd to be saved/recalled
string sKeyPos;
public:
Fl_Scroll* scroll;
void (*p_cb_on_ok)( void * ); //for final OK button press 'cb_btPrefOK()', allows user set callback function
public:
void ClearToDefCtrl();
void End();
void CreateRow(int height=cnControlHeight);
bool AddControl();
void Show(bool modal);
void Save(GCProfile &p);
void Load(GCProfile &p);
bool find_control_from_its_id( unsigned int id, int &row, int &column );
void set_callback_on_ok( void (*p_cb)( void* ) );
void refresh_controls_from_user_vars();
//void AddVar(string s);
PrefWnd(int x,int y,int w, int h,const char *label,string sSectionPosIn,string sKeyPosIn);
private:
int handle(int e);
};
#endif