gwenhywfar  4.6.0beta
w_progressbar.mm
Go to the documentation of this file.
1 /***************************************************************************
2  begin : August 10 2010
3  copyright : (C) 2010 by Samuel Strupp
4 
5  ***************************************************************************
6  * Please see toplevel file COPYING for license details *
7  ***************************************************************************/
8 
9 
10 #import "CocoaProgressbar.h"
11 
12 
14 struct W_PROGRESSBAR {
15  int minValue;
16  int maxValue;
18 };
19 
20 
22 
23 
24 
25 static GWENHYWFAR_CB
28  int index,
29  int value,
30  int doSignal) {
31  CocoaProgressbar *progressbar;
32  W_PROGRESSBAR *xw;
33 
34  assert(w);
36  assert(xw);
37 
39  assert(progressbar);
40 
41  switch(prop) {
43  return 0;
44 
46  return 0;
47 
49  NSRect frame = [progressbar frame];
50  frame.size.width = value;
51  [progressbar setFrame:frame];
52  }
53  return 0;
54 
56  NSRect frame = [progressbar frame];
57  frame.size.height = value;
58  [progressbar setFrame:frame];
59  }
60 
61  return 0;
62 
64  double d;
65 
66  xw->currentValue=value;
67  d=(double)value;
68  [progressbar setDoubleValue:d];
69  //NSLog(@"progressbar value = %f",d);
70  return 0;
71  }
72 
74  double d;
75 
76  xw->minValue=value;
77  d=(double)value;
78  [progressbar setMinValue:d];
79  //NSLog(@"progressbar min value = %f",d);
80  return 0;
81  }
82 
84  double d;
85 
86  xw->maxValue=value;
87  d=(double)value;
88  [progressbar setMaxValue:d];
89  //NSLog(@"progressbar max value = %f",d);
90  return 0;
91  }
92 
93  default:
94  break;
95  }
96 
98  "Function is not appropriate for this type of widget (%s)",
100  return GWEN_ERROR_INVALID;
101 }
102 
103 
104 
105 
106 static GWENHYWFAR_CB
109  int index,
110  int defaultValue) {
111  CocoaProgressbar *progressbar;
112  W_PROGRESSBAR *xw;
113 
114  assert(w);
116  assert(xw);
117 
119  assert(progressbar);
120 
121  switch(prop) {
123  return 1;
124 
126  return 0;
127 
129  return [progressbar frame].size.width;
131  return [progressbar frame].size.height;
132 
134  return xw->currentValue;
135 
137  return xw->minValue;
138 
140  return xw->maxValue;
141 
142  default:
143  break;
144  }
145 
147  "Function is not appropriate for this type of widget (%s)",
149  return defaultValue;
150 }
151 
152 
153 
154 static GWENHYWFAR_CB
157  int index,
158  const char *value,
159  int doSignal) {
161  "Function is not appropriate for this type of widget (%s)",
163  return GWEN_ERROR_INVALID;
164 }
165 
166 
167 
168 static GWENHYWFAR_CB
171  int index,
172  const char *defaultValue) {
174  "Function is not appropriate for this type of widget (%s)",
176  return defaultValue;
177 }
178 
179 
180 
181 static void GWENHYWFAR_CB CocoaGui_WProgressBar_FreeData(void *bp, void *p) {
182  W_PROGRESSBAR *xw;
183 
184  xw=(W_PROGRESSBAR*) p;
185  GWEN_FREE_OBJECT(xw);
186 }
187 
188 
189 
191  CocoaProgressbar *progressbar;
192  //const char *s;
193  uint32_t flags;
194  GWEN_WIDGET *wParent;
195  W_PROGRESSBAR *xw;
196 
199 
200  flags=GWEN_Widget_GetFlags(w);
201  wParent=GWEN_Widget_Tree_GetParent(w);
202  //s=GWEN_Widget_GetText(w, 0);
203 
204  //g=gtk_progress_bar_new();
205  progressbar = [[[CocoaProgressbar alloc] initWithFrame:NSMakeRect(0.0, 0.0, 100.0, 20.0)] autorelease];
206  if (flags & GWEN_WIDGET_FLAGS_FILLX) progressbar.fillX = YES;
207  if (flags & GWEN_WIDGET_FLAGS_FILLY) progressbar.fillY = YES;
208  [progressbar setIndeterminate:NO];
209  [progressbar setUsesThreadedAnimation:YES];
210  [progressbar startAnimation:nil];
211  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) progressbar);
212  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) progressbar);
213 
218 
219  if (wParent)
220  GWEN_Widget_AddChildGuiWidget(wParent, w);
221 
222  return 0;
223 }
224 
225