gwenhywfar  4.6.0beta
w_textedit.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 "CocoaLineTextField.h"
11 
12 
13 static GWENHYWFAR_CB
16  int index,
17  int value,
18  int doSignal) {
19  CocoaLineTextField *textField;
20 
22  assert(textField);
23 
24  switch(prop) {
26  [textField setEnabled:(value==0)?NO:YES];
27  return 0;
28 
30  if ([textField window]) {
31  [[textField window] makeFirstResponder:textField];
32  }
33  return 0;
34 
36  NSRect frame = [textField frame];
37  frame.size.width = value;
38  [textField setFrame:frame];
39  }
40  return 0;
41 
43  NSRect frame = [textField frame];
44  frame.size.height = value;
45  [textField setFrame:frame];
46  }
47  return 0;
48 
49  default:
50  break;
51  }
52 
53 
55  "Function is not appropriate for this type of widget (%s)",
57  return GWEN_ERROR_INVALID;
58 }
59 
60 
61 
62 
63 static GWENHYWFAR_CB
66  int index,
67  int defaultValue) {
68  CocoaLineTextField *textField;
69 
71  assert(textField);
72 
73  switch(prop) {
75  return ([textField isEnabled])?1:0;
76 
77 
79  if ([textField window]) {
80  if ([[textField window] firstResponder] == textField) return 1;
81  }
82  return 0;
83 
85  return [textField frame].size.width;
86 
88  return [textField 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  CocoaLineTextField *textField;
109 
111  assert(textField);
112 
113  switch(prop) {
115  NSString *stringValue = [[NSString alloc] initWithCString:value encoding:NSUTF8StringEncoding];
116  [textField setStringValue:stringValue];
117  [stringValue release];
118  }
119  default:
120  break;
121  }
122 
124  "Function is not appropriate for this type of widget (%s)",
126  return GWEN_ERROR_INVALID;
127 }
128 
129 
130 
131 static GWENHYWFAR_CB
134  int index,
135  const char *defaultValue) {
136  CocoaLineTextField *textField;
137 
139  assert(textField);
140 
141  switch(prop) {
143  return [[textField stringValue] cStringUsingEncoding:NSUTF8StringEncoding];
144  default:
145  break;
146  }
147 
149  "Function is not appropriate for this type of widget (%s)",
151  return defaultValue;
152 }
153 
154 
155 
156 static void CocoaGui_WTextEdit_End_Editing_text_handler(NSTextField *textField, void* data) {
157  GWEN_WIDGET *w;
158  int rv;
159 
160  w=data;
161  assert(w);
167  else if (rv==GWEN_DialogEvent_ResultReject)
169 }
170 
171 
172 
173 static void CocoaGui_WTextEdit_Changed_text_handler(NSTextField *textField, void* data) {
174  GWEN_WIDGET *w;
175  int rv;
176 
177  w=data;
178  assert(w);
184  else if (rv==GWEN_DialogEvent_ResultReject)
186 }
187 
188 
189 
191  CocoaLineTextField *textField;
192  const char *s;
193  uint32_t flags;
194  GWEN_WIDGET *wParent;
195 
196  //gulong changed_handler_id;
197 
198  flags=GWEN_Widget_GetFlags(w);
199  wParent=GWEN_Widget_Tree_GetParent(w);
200  s=GWEN_Widget_GetText(w, 0);
201 
202  /* create widget */
203  textField = [[[CocoaLineTextField alloc] initWithFrame:NSMakeRect(10.0, 10.0, 100.0, 22.0)] autorelease];
204  if (flags & GWEN_WIDGET_FLAGS_FILLX) textField.fillX = YES;
205  if (flags & GWEN_WIDGET_FLAGS_FILLY) textField.fillY = YES;
206  //[textField setBordered:YES];
207  [textField setEditable:YES];
208 
209  if (s && *s) {
210  NSString *stringValue = [[NSString alloc] initWithCString:s encoding:NSUTF8StringEncoding];
211  [textField setStringValue:stringValue];
212  [stringValue release];
213  }
214 
215  GWEN_Widget_SetImplData(w, COCOA_DIALOG_WIDGET_REAL, (void*) textField);
217 
222 
223 
225  [textField setC_ActionPtr:ptr Data:w];
226 
228  [textField setC_TextChanged_ActionPtr:changed_ptr Data:w];
229 
230  if (wParent)
231  GWEN_Widget_AddChildGuiWidget(wParent, w);
232 
233  return 0;
234 }
235 
236