gwenhywfar 5.10.1
w_spinbox.mm
Go to the documentation of this file.
1/***************************************************************************
2 begin : August 19 2010
3 copyright : (C) 2010 by Samuel Strupp
4
5 ***************************************************************************
6 * Please see toplevel file COPYING for license details *
7 ***************************************************************************/
8
9#import "CocoaSpinbox.h"
10
11
12/*typedef struct W_SPINBOX W_SPINBOX;
13 struct W_SPINBOX {
14 GtkAdjustment *adjustment;
15 };*/
16
17
19
20
21
22static GWENHYWFAR_CB
25 int index,
26 int value,
27 int doSignal) {
28
29 CocoaSpinbox *spinbox;
30
32 assert(spinbox);
33
34 switch(prop) {
36 [spinbox setEnabled:(value==0)?NO:YES];
37 return 0;
38
40 [spinbox makeFirstResponder];
41 return 0;
42
44 NSRect frame = [spinbox frame];
45 frame.size.width = value;
46 [spinbox setFrame:frame];
47 }
48 return 0;
49
51 NSRect frame = [spinbox frame];
52 frame.size.height = value;
53 [spinbox setFrame:frame];
54 }
55 return 0;
56
58 [spinbox setIntegerValue:value];
59 return 0;
60
62 [spinbox setMinValue:value];
63 return 0;
64
66 [spinbox setMaxValue:value];
67 return 0;
68
69 default:
70 break;
71 }
72
74 "Function is not appropriate for this type of widget (%s)",
76 return GWEN_ERROR_INVALID;
77}
78
79
80
81
82static GWENHYWFAR_CB
85 int index,
86 int defaultValue) {
87 CocoaSpinbox *spinbox;
88
90 assert(spinbox);
91
92 switch(prop) {
94 return ([spinbox isEnabled])?1:0;
95
97 return ([spinbox isFirstResponder])?1:0;
98
100 return [spinbox frame].size.width;
101
103 return [spinbox frame].size.height;
104
106 return [spinbox integerValue];
107
109 return [spinbox minValue];
110
112 return [spinbox maxValue];
113
114 default:
115 break;
116 }
118 "Function is not appropriate for this type of widget (%s)",
120 return defaultValue;
121}
122
123
124
125static GWENHYWFAR_CB
128 int index,
129 const char *value,
130 int doSignal) {
131
132 CocoaSpinbox *spinbox;
133
135 assert(spinbox);
136
137
138 switch(prop) {
140 if (value && *value) {
141 NSString *stringValue = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
142 [spinbox setStringValue:stringValue];
143 [stringValue release];
144 }
145 }
146 default:
147 break;
148 }
149
151 "Function is not appropriate for this type of widget (%s)",
153 return GWEN_ERROR_INVALID;
154}
155
156
157
158static GWENHYWFAR_CB
161 int index,
162 const char *defaultValue) {
163 CocoaSpinbox *spinbox;
164
166 assert(spinbox);
167
168
169 switch(prop) {
171 return [[spinbox stringValue] cStringUsingEncoding:NSUTF8StringEncoding];
172 default:
173 break;
174 }
175
177 "Function is not appropriate for this type of widget (%s)",
179 return defaultValue;
180}
181
182
183static void CocoaGui_WSpinBox_Changed_handler(NSView *spinbox, void* data) {
184 GWEN_WIDGET *w;
185 int rv;
186
187 DBG_ERROR(0, "ValueChanged");
188 w=data;
189 assert(w);
197}
198
199
200
202 CocoaSpinbox *spinbox;
203 const char *s;
204 uint32_t flags;
205 GWEN_WIDGET *wParent;
206
207 flags=GWEN_Widget_GetFlags(w);
208 wParent=GWEN_Widget_Tree_GetParent(w);
209 s=GWEN_Widget_GetText(w, 0);
210
211
212
213
214
215 spinbox = [[[CocoaSpinbox alloc] initWithFrame:NSMakeRect(0.0, 0.0, 100.0, 22.0)] autorelease];
216 if (flags & GWEN_WIDGET_FLAGS_FILLX) spinbox.fillX = YES;
217 if (flags & GWEN_WIDGET_FLAGS_FILLY) spinbox.fillY = YES;
218
219 if (s && *s) {
220 NSString *stringValue = [[NSString alloc] initWithCString:s encoding:NSUTF8StringEncoding];
221 [spinbox setStringValue:stringValue];
222 [stringValue release];
223 }
224 else {
225 [spinbox setStringValue:nil];
226 }
227
230
235
236
238 [spinbox setC_ActionPtr:ptr Data:w];
239
240 if (wParent)
242
243 return 0;
244}
245
246
void(* gwenSpinBoxActionPtr)(NSView *spinbox, void *data)
Definition: CocoaSpinbox.h:16
#define COCOA_DIALOG_WIDGET_REAL
void CocoaGui_Dialog_Leave(GWEN_DIALOG *dlg, int result)
#define COCOA_DIALOG_WIDGET_CONTENT
#define DBG_WARN(dbg_logger, format, args...)
Definition: debug.h:125
#define DBG_ERROR(dbg_logger, format, args...)
Definition: debug.h:97
int GWEN_Dialog_EmitSignal(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
Definition: dialog.c:321
@ GWEN_DialogEvent_ResultAccept
Definition: dialog.h:122
@ GWEN_DialogEvent_ResultReject
Definition: dialog.h:123
#define GWEN_WIDGET_FLAGS_FILLY
Definition: dialog.h:62
#define GWEN_WIDGET_FLAGS_FILLX
Definition: dialog.h:61
GWEN_DIALOG_PROPERTY
Definition: dialog.h:260
@ GWEN_DialogProperty_MinValue
Definition: dialog.h:265
@ GWEN_DialogProperty_MaxValue
Definition: dialog.h:266
@ GWEN_DialogProperty_Height
Definition: dialog.h:273
@ GWEN_DialogProperty_Enabled
Definition: dialog.h:267
@ GWEN_DialogProperty_Value
Definition: dialog.h:264
@ GWEN_DialogProperty_Focus
Definition: dialog.h:276
@ GWEN_DialogProperty_Width
Definition: dialog.h:272
@ GWEN_DialogEvent_TypeValueChanged
Definition: dialog.h:101
#define GWEN_ERROR_INVALID
Definition: error.h:67
#define GWENHYWFAR_CB
Definition: gwenhywfarapi.h:89
#define GWEN_INHERIT(bt, t)
Definition: inherit.h:264
#define GWEN_LOGDOMAIN
Definition: logger.h:35
static GWENHYWFAR_CB int CocoaGui_WSpinBox_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition: w_spinbox.mm:23
int CocoaGui_WSpinBox_Setup(GWEN_WIDGET *w)
Definition: w_spinbox.mm:201
static GWENHYWFAR_CB int CocoaGui_WSpinBox_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
Definition: w_spinbox.mm:126
static GWENHYWFAR_CB const char * CocoaGui_WSpinBox_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
Definition: w_spinbox.mm:159
static GWENHYWFAR_CB int CocoaGui_WSpinBox_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
Definition: w_spinbox.mm:83
static void CocoaGui_WSpinBox_Changed_handler(NSView *spinbox, void *data)
Definition: w_spinbox.mm:183
GWEN_WIDGET_GETCHARPROPERTY_FN GWEN_Widget_SetGetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETCHARPROPERTY_FN fn)
Definition: widget.c:732
GWEN_DIALOG * GWEN_Widget_GetTopDialog(const GWEN_WIDGET *w)
Definition: widget.c:102
const char * GWEN_Widget_GetName(const GWEN_WIDGET *w)
Definition: widget.c:320
GWEN_WIDGET_GETINTPROPERTY_FN GWEN_Widget_SetGetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_GETINTPROPERTY_FN fn)
Definition: widget.c:702
int GWEN_Widget_AddChildGuiWidget(GWEN_WIDGET *w, GWEN_WIDGET *wChild)
Definition: widget.c:828
void GWEN_Widget_SetImplData(GWEN_WIDGET *w, int index, void *ptr)
Store a pointer with the widget.
Definition: widget.c:136
void * GWEN_Widget_GetImplData(const GWEN_WIDGET *w, int index)
Definition: widget.c:122
GWEN_WIDGET_SETINTPROPERTY_FN GWEN_Widget_SetSetIntPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETINTPROPERTY_FN fn)
Definition: widget.c:687
const char * GWEN_Widget_GetText(const GWEN_WIDGET *w, int idx)
Definition: widget.c:293
uint32_t GWEN_Widget_GetFlags(const GWEN_WIDGET *w)
Definition: widget.c:149
const char * GWEN_Widget_Type_toString(GWEN_WIDGET_TYPE t)
Definition: widget.c:452
GWEN_DIALOG * GWEN_Widget_GetDialog(const GWEN_WIDGET *w)
Definition: widget.c:92
GWEN_WIDGET_TYPE GWEN_Widget_GetType(const GWEN_WIDGET *w)
Definition: widget.c:185
GWEN_WIDGET_SETCHARPROPERTY_FN GWEN_Widget_SetSetCharPropertyFn(GWEN_WIDGET *w, GWEN_WIDGET_SETCHARPROPERTY_FN fn)
Definition: widget.c:717
struct GWEN_WIDGET GWEN_WIDGET
Definition: widget_be.h:34