| 42 scrollview.documentView = textview; |
42 scrollview.documentView = textview; |
| 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 |
| |
48 UiVar* var = uic_widget_var(obj->ctx, obj->ctx, args.value, args.varname, UI_VAR_TEXT); |
| |
49 if(var) { |
| |
50 UiText *text = var->value; |
| |
51 text->obj = (__bridge void*)textview; |
| |
52 ui_textarea_restore(text); |
| |
53 |
| |
54 text->save = ui_textarea_save; |
| |
55 text->destroy = ui_textarea_destroy; |
| |
56 text->restore = ui_textarea_restore; |
| |
57 text->set = ui_textarea_set; |
| |
58 text->get = ui_textarea_get; |
| |
59 text->getsubstr = ui_textarea_getsubstr; |
| |
60 text->insert = ui_textarea_insert; |
| |
61 text->setposition = ui_textarea_setposition; |
| |
62 text->position = ui_textarea_position; |
| |
63 text->setselection = ui_textarea_setselection; |
| |
64 text->selection = ui_textarea_selection; |
| |
65 text->length = ui_textarea_length; |
| |
66 text->remove = ui_textarea_remove; |
| |
67 } |
| |
68 |
| 47 return (__bridge void*)scrollview; |
69 return (__bridge void*)scrollview; |
| 48 } |
70 } |
| |
71 |
| |
72 |
| |
73 |
| |
74 |
| |
75 void ui_textarea_save(UiText *text) { |
| |
76 |
| |
77 } |
| |
78 |
| |
79 void ui_textarea_destroy(UiText *text) { |
| |
80 (void)(__bridge_transfer NSTextStorage*)text->data1; |
| |
81 } |
| |
82 |
| |
83 void ui_textarea_restore(UiText *text) { |
| |
84 NSTextView *textview = (__bridge NSTextView*)text->obj; |
| |
85 NSTextStorage *textStorage; |
| |
86 if(text->data1) { |
| |
87 textStorage = (__bridge NSTextStorage*)text->data1; |
| |
88 |
| |
89 } else { |
| |
90 textStorage = [[NSTextStorage alloc] init]; |
| |
91 } |
| |
92 [textview.layoutManager replaceTextStorage:textStorage]; |
| |
93 text->data1 = (__bridge_retained void*)textStorage; |
| |
94 } |
| |
95 |
| |
96 void ui_textarea_set(UiText *text, const char *str) { |
| |
97 |
| |
98 } |
| |
99 |
| |
100 char* ui_textarea_get(UiText *text) { |
| |
101 return NULL; |
| |
102 } |
| |
103 |
| |
104 char* ui_textarea_getsubstr(UiText *text, int begin, int end) { |
| |
105 return NULL; |
| |
106 } |
| |
107 |
| |
108 void ui_textarea_insert(UiText *text, int pos, char *str) { |
| |
109 |
| |
110 } |
| |
111 |
| |
112 void ui_textarea_setposition(UiText *text, int pos) { |
| |
113 |
| |
114 } |
| |
115 |
| |
116 int ui_textarea_position(UiText *text) { |
| |
117 return 0; |
| |
118 } |
| |
119 |
| |
120 void ui_textarea_setselection(UiText *text, int begin, int end) { |
| |
121 |
| |
122 } |
| |
123 |
| |
124 void ui_textarea_selection(UiText *text, int *begin, int *end) { |
| |
125 |
| |
126 } |
| |
127 |
| |
128 int ui_textarea_length(UiText *text) { |
| |
129 return 0; |
| |
130 } |
| |
131 |
| |
132 void ui_textarea_remove(UiText *text, int begin, int end) { |
| |
133 |
| |
134 } |