gwenhywfar  4.3.3
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 
22 static 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 
82 static 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 
125 static 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 
158 static 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 
183 static 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);
195  else if (rv==GWEN_DialogEvent_ResultReject)
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)
241  GWEN_Widget_AddChildGuiWidget(wParent, w);
242 
243  return 0;
244 }
245 
246