gwenhywfar 5.12.0
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
11
12
13static 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
63static 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
102static 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
131static 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
170
171
172
173static void CocoaGui_WTextEdit_Changed_text_handler(NSTextField *textField, void* data) {
174 GWEN_WIDGET *w;
175 int rv;
176
177 w=data;
178 assert(w);
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
217
222
223
225 [textField setC_ActionPtr:ptr Data:w];
226
228 [textField setC_TextChanged_ActionPtr:changed_ptr Data:w];
229
230 if (wParent)
232
233 return 0;
234}
235
236
void(* gwenTextFieldActionPtr)(NSTextField *textField, void *data)
#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,...)
Definition debug.h:125
int GWEN_Dialog_EmitSignal(GWEN_DIALOG *dlg, GWEN_DIALOG_EVENTTYPE t, const char *sender)
Definition dialog.c:321
#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_Title
Definition dialog.h:263
@ 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
@ GWEN_DialogEvent_TypeActivated
Definition dialog.h:102
@ GWEN_DialogEvent_ResultAccept
Definition dialog.h:122
@ GWEN_DialogEvent_ResultReject
Definition dialog.h:123
#define GWEN_ERROR_INVALID
Definition error.h:67
#define GWENHYWFAR_CB
#define GWEN_LOGDOMAIN
Definition logger.h:35
static GWENHYWFAR_CB int CocoaGui_WTextEdit_SetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *value, int doSignal)
static GWENHYWFAR_CB int CocoaGui_WTextEdit_GetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int defaultValue)
Definition w_textedit.mm:64
static GWENHYWFAR_CB int CocoaGui_WTextEdit_SetIntProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, int value, int doSignal)
Definition w_textedit.mm:14
static GWENHYWFAR_CB const char * CocoaGui_WTextEdit_GetCharProperty(GWEN_WIDGET *w, GWEN_DIALOG_PROPERTY prop, int index, const char *defaultValue)
static void CocoaGui_WTextEdit_Changed_text_handler(NSTextField *textField, void *data)
static void CocoaGui_WTextEdit_End_Editing_text_handler(NSTextField *textField, void *data)
int CocoaGui_WTextEdit_Setup(GWEN_WIDGET *w)
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