gwenhywfar  4.6.0beta
w_label.mm
Go to the documentation of this file.
1 /***************************************************************************
2  begin : August 09 2010
3  copyright : (C) 2010 by Samuel Strupp
4 
5  ***************************************************************************
6  * Please see toplevel file COPYING for license details *
7  ***************************************************************************/
8 
9 
10 #import "CocoaLabel.h"
11 
12 
13 static GWENHYWFAR_CB
16  int index,
17  int value,
18  int doSignal) {
19  CocoaLabel *labelTextField;
20 
22  assert(labelTextField);
23 
24  switch(prop) {
26  [labelTextField setEnabled:(value==0)?NO:YES];
27  return 0;
28 
30  if ([labelTextField window]) {
31  [[labelTextField window] makeFirstResponder:labelTextField];
32  }
33  return 0;
34 
36  NSRect frame = [labelTextField frame];
37  frame.size.width = value;
38  [labelTextField setFrame:frame];
39  }
40  return 0;
41 
43  NSRect frame = [labelTextField frame];
44  frame.size.height = value;
45  [labelTextField setFrame:frame];
46  }
47  return 0;
48 
49  default:
50  break;
51  }
52 
54  "Function is not appropriate for this type of widget (%s)",
56  return GWEN_ERROR_INVALID;
57 }
58 
59 
60 
61 
62 static GWENHYWFAR_CB
65  int index,
66  int defaultValue) {
67  CocoaLabel *labelTextField;
68 
70  assert(labelTextField);
71 
72  switch(prop) {
74  return ([labelTextField isEnabled])?1:0;
75 
77  if ([labelTextField window]) {
78  if ([[labelTextField window] firstResponder] == labelTextField) {
79  return 1;
80  }
81  }
82  return 0;
83 
85  return [labelTextField frame].size.width;
86 
88  return [labelTextField frame].size.height;
89 
90  default:
91  break;
92  }
93 
95  "Function is not appropriate for this type of widget (%s)",
97  return defaultValue;
98 }
99 
100 
101 
102 static GWENHYWFAR_CB
105  int index,
106  const char *value,
107  int doSignal) {
108  CocoaLabel *labelTextField;
109 
111  assert(labelTextField);
112 
113  switch(prop) {
115  NSString *stringValue = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
116  [labelTextField setStringValue:stringValue];
117  NSLog(@"%@", stringValue);
118  [stringValue release];
119  }
120  return 0;
121  default:
122  break;
123  }
124 
126  "Function is not appropriate for this type of widget (%s)",
128  return GWEN_ERROR_INVALID;
129 }
130 
131 
132 
133 static GWENHYWFAR_CB
136  int index,
137  const char *defaultValue) {
138  CocoaLabel *labelTextField;
139 
141  assert(labelTextField);
142 
143  switch(prop) {
145  return [[labelTextField stringValue] cStringUsingEncoding:NSUTF8StringEncoding];
146  default:
147  break;
148  }
149 
151  "Function is not appropriate for this type of widget (%s)",
153  return defaultValue;
154 }
155 
156 
157 
159 
160  CocoaLabel *labelTextField;
161  const char *s;
162  uint32_t flags;
163  GWEN_WIDGET *wParent;
164 
165  flags=GWEN_Widget_GetFlags(w);
166  wParent=GWEN_Widget_Tree_GetParent(w);
167  s=GWEN_Widget_GetText(w, 0);
168 
169  labelTextField = [[[CocoaLabel alloc] initWithFrame:NSMakeRect(10.0, 10.0, 100.0, 24.0)] autorelease];
170  if (flags & GWEN_WIDGET_FLAGS_FILLX) labelTextField.fillX = YES;
171  if (flags & GWEN_WIDGET_FLAGS_FILLY) labelTextField.fillY = YES;
172  [labelTextField setDrawsBackground:NO];
173  [labelTextField setBordered:NO];
174  [labelTextField setEditable:NO];
175  if (s && *s) {
176  NSString *stringValue = [[NSString alloc] initWithCString:s encoding:NSUTF8StringEncoding];
177  [labelTextField setStringValue:stringValue];
178  //NSLog(@"%@", stringValue);
179  [stringValue release];
180  }
181 
182 
183  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) labelTextField);
184  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_CONTENT, (void*) labelTextField);
185 
190 
191  if (wParent)
192  GWEN_Widget_AddChildGuiWidget(wParent, w);
193 
194 
195 
196  return 0;
197 }
198 
199