ui/cocoa/text.m

changeset 603
8d2b7b934230
parent 590
07ecff1fa805
child 685
36e08a9aff8e
equal deleted inserted replaced
602:9f3ff50da302 603:8d2b7b934230
29 #import "text.h" 29 #import "text.h"
30 #import "EventData.h" 30 #import "EventData.h"
31 #import "Container.h" 31 #import "Container.h"
32 #import <objc/runtime.h> 32 #import <objc/runtime.h>
33 33
34 UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs args) { 34 UIWIDGET ui_textarea_create(UiObject *obj, UiTextAreaArgs *args) {
35 NSTextView *textview = [[NSTextView alloc] init]; 35 NSTextView *textview = [[NSTextView alloc] init];
36 textview.autoresizingMask = NSViewWidthSizable; 36 textview.autoresizingMask = NSViewWidthSizable;
37 textview.minSize = NSMakeSize(0, 0); 37 textview.minSize = NSMakeSize(0, 0);
38 textview.maxSize = NSMakeSize(FLT_MAX, FLT_MAX); 38 textview.maxSize = NSMakeSize(FLT_MAX, FLT_MAX);
39 39
43 43
44 UiLayout layout = UI_INIT_LAYOUT(args); 44 UiLayout layout = UI_INIT_LAYOUT(args);
45 ui_container_add(obj, scrollview, &layout, TRUE); 45 ui_container_add(obj, scrollview, &layout, TRUE);
46 46
47 47
48 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_TEXT); 48 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_TEXT);
49 if(var) { 49 if(var) {
50 UiText *text = var->value; 50 UiText *text = var->value;
51 text->obj = (__bridge void*)textview; 51 text->obj = (__bridge void*)textview;
52 ui_textarea_restore(text); 52 ui_textarea_restore(text);
53 53
135 135
136 136
137 137
138 /* -------------------------- TextField -------------------------- */ 138 /* -------------------------- TextField -------------------------- */
139 139
140 static UIWIDGET textfield_create(UiObject *obj, UiTextFieldArgs args, BOOL password, BOOL frameless) { 140 static UIWIDGET textfield_create(UiObject *obj, UiTextFieldArgs *args, BOOL password, BOOL frameless) {
141 NSTextField *textfield; 141 NSTextField *textfield;
142 if(password) { 142 if(password) {
143 textfield = [[NSSecureTextField alloc] init]; 143 textfield = [[NSSecureTextField alloc] init];
144 } else { 144 } else {
145 textfield = [[NSTextField alloc] init]; 145 textfield = [[NSTextField alloc] init];
150 } 150 }
151 151
152 UiLayout layout = UI_INIT_LAYOUT(args); 152 UiLayout layout = UI_INIT_LAYOUT(args);
153 ui_container_add(obj, textfield, &layout, FALSE); 153 ui_container_add(obj, textfield, &layout, FALSE);
154 154
155 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_STRING); 155 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args->value, args->varname, UI_VAR_STRING);
156 if(var) { 156 if(var) {
157 UiString *s = var->value; 157 UiString *s = var->value;
158 if(s->value.ptr) { 158 if(s->value.ptr) {
159 textfield.stringValue = [[NSString alloc] initWithUTF8String:s->value.ptr]; 159 textfield.stringValue = [[NSString alloc] initWithUTF8String:s->value.ptr];
160 if(s->value.free) { 160 if(s->value.free) {
167 } 167 }
168 168
169 return (__bridge void*)textfield; 169 return (__bridge void*)textfield;
170 } 170 }
171 171
172 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs args) { 172 UIWIDGET ui_textfield_create(UiObject *obj, UiTextFieldArgs *args) {
173 return textfield_create(obj, args, FALSE, FALSE); 173 return textfield_create(obj, args, FALSE, FALSE);
174 } 174 }
175 175
176 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs args) { 176 UIWIDGET ui_frameless_textfield_create(UiObject* obj, UiTextFieldArgs *args) {
177 return textfield_create(obj, args, FALSE, TRUE); 177 return textfield_create(obj, args, FALSE, TRUE);
178 } 178 }
179 179
180 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs args) { 180 UIWIDGET ui_passwordfield_create(UiObject* obj, UiTextFieldArgs *args) {
181 return textfield_create(obj, args, TRUE, FALSE); 181 return textfield_create(obj, args, TRUE, FALSE);
182 } 182 }
183 183
184 char* ui_textfield_get(UiString *s) { 184 char* ui_textfield_get(UiString *s) {
185 NSTextField *textfield = (__bridge NSTextField*)s->obj; 185 NSTextField *textfield = (__bridge NSTextField*)s->obj;

mercurial