summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/c/calculator/src/calculator.c27
-rw-r--r--apps/c/texteditor/src/texteditor_main.c5
-rw-r--r--apps/csharp/texteditor/src/texteditor_main.cs3
3 files changed, 23 insertions, 12 deletions
diff --git a/apps/c/calculator/src/calculator.c b/apps/c/calculator/src/calculator.c
index b42c4ba5..6bc55944 100644
--- a/apps/c/calculator/src/calculator.c
+++ b/apps/c/calculator/src/calculator.c
@@ -57,12 +57,14 @@ _button_pressed_cb(void *data, const Efl_Event *event EINA_UNUSED)
57 efl_text_set(_screen, ""); 57 efl_text_set(_screen, "");
58 _must_overwrite = EINA_FALSE; 58 _must_overwrite = EINA_FALSE;
59 } 59 }
60 Efl_Text_Cursor_Cursor *cursor = efl_text_cursor_get(_screen, EFL_TEXT_CURSOR_GET_TYPE_MAIN); 60 Efl_Text_Cursor *cursor = efl_text_interactive_main_cursor_get(_screen);
61 efl_text_cursor_text_insert(_screen, cursor, str); 61 efl_text_cursor_text_insert(cursor, str);
62 } 62 }
63 else 63 else
64 { 64 {
65 char str[32] = ""; 65 char str[32] = "";
66 // No need to sanitize these values, so do not emit "text changed" events
67 efl_event_freeze(_screen);
66 switch (button) 68 switch (button)
67 { 69 {
68 case 'C': 70 case 'C':
@@ -89,11 +91,12 @@ _button_pressed_cb(void *data, const Efl_Event *event EINA_UNUSED)
89 default: 91 default:
90 break; 92 break;
91 } 93 }
94 efl_event_thaw(_screen);
92 } 95 }
93} 96}
94 97
95// Called every time the content of the screen changes 98// Called every time the content of the screen changes
96// We use it to sanitize input (remove heading zeros, for example) 99// We use it to sanitize input (remove leading zeros, for example)
97// This makes more sense when the Text widget is editable, since the user 100// This makes more sense when the Text widget is editable, since the user
98// is free to type anything. 101// is free to type anything.
99static void 102static void
@@ -113,7 +116,11 @@ _screen_changed_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
113 } 116 }
114 if (strncmp(_text, str, sizeof(_text))) 117 if (strncmp(_text, str, sizeof(_text)))
115 { 118 {
119 // Avoid infinite recursion when setting the text from the
120 // "text changed" callback
121 efl_event_freeze(_screen);
116 efl_text_set(_screen, _text); 122 efl_text_set(_screen, _text);
123 efl_event_thaw(_screen);
117 } 124 }
118} 125}
119 126
@@ -134,11 +141,12 @@ _button_add(Efl_Ui_Table *table, const char *text, const char *command, int posx
134 Efl_Ui_Text *label = 141 Efl_Ui_Text *label =
135 efl_add(EFL_UI_TEXT_CLASS, button, 142 efl_add(EFL_UI_TEXT_CLASS, button,
136 efl_text_interactive_editable_set(efl_added, EINA_FALSE), 143 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
137 efl_text_halign_set(efl_added, 0.5), 144 efl_text_horizontal_align_set(efl_added, 0.5),
138 efl_text_valign_set(efl_added, 0.5), 145 efl_text_vertical_align_set(efl_added, 0.5),
139 efl_gfx_color_set(efl_added, r, g, b, 255), 146 efl_gfx_color_set(efl_added, r, g, b, 255),
140 efl_text_set(efl_added, text)); 147 efl_text_set(efl_added, text));
141 efl_text_font_set(label, "Sans", 36); 148 efl_text_font_family_set(label, "Sans");
149 efl_text_font_size_set(label, 36);
142 efl_content_set(button, label); 150 efl_content_set(button, label);
143} 151}
144 152
@@ -188,13 +196,14 @@ _gui_setup()
188 efl_text_interactive_editable_set(efl_added, EINA_FALSE), 196 efl_text_interactive_editable_set(efl_added, EINA_FALSE),
189 efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE), 197 efl_text_interactive_selection_allowed_set(efl_added, EINA_FALSE),
190 efl_pack_table(table, efl_added, 0, 0, 4, 1), 198 efl_pack_table(table, efl_added, 0, 0, 4, 1),
191 efl_text_halign_set(efl_added, 0.9), 199 efl_text_horizontal_align_set(efl_added, 0.9),
192 efl_text_valign_set(efl_added, 0.5), 200 efl_text_vertical_align_set(efl_added, 0.5),
193 efl_text_effect_type_set(efl_added, EFL_TEXT_STYLE_EFFECT_TYPE_GLOW), 201 efl_text_effect_type_set(efl_added, EFL_TEXT_STYLE_EFFECT_TYPE_GLOW),
194 efl_text_glow_color_set(efl_added, 128, 128, 128, 128), 202 efl_text_glow_color_set(efl_added, 128, 128, 128, 128),
195 efl_event_callback_add(efl_added, EFL_UI_TEXT_EVENT_CHANGED, 203 efl_event_callback_add(efl_added, EFL_UI_TEXT_EVENT_CHANGED,
196 _screen_changed_cb, NULL)); 204 _screen_changed_cb, NULL));
197 efl_text_font_set(_screen, "Sans", 48); 205 efl_text_font_family_set(_screen, "Sans");
206 efl_text_font_size_set(_screen, 48);
198} 207}
199 208
200EAPI_MAIN void 209EAPI_MAIN void
diff --git a/apps/c/texteditor/src/texteditor_main.c b/apps/c/texteditor/src/texteditor_main.c
index bc70b618..2ee15ef5 100644
--- a/apps/c/texteditor/src/texteditor_main.c
+++ b/apps/c/texteditor/src/texteditor_main.c
@@ -82,7 +82,7 @@ _gui_toolbar_refresh(void)
82 82
83EFL_CALLBACKS_ARRAY_DEFINE(_editor_callbacks, 83EFL_CALLBACKS_ARRAY_DEFINE(_editor_callbacks,
84 { EFL_UI_TEXT_EVENT_CHANGED, _editor_changed_cb }, 84 { EFL_UI_TEXT_EVENT_CHANGED, _editor_changed_cb },
85 { EFL_UI_TEXT_EVENT_CHANGED_USER, _editor_changed_cb }); 85 { EFL_TEXT_INTERACTIVE_EVENT_CHANGED_USER, _editor_changed_cb });
86 86
87static void 87static void
88_gui_setup() 88_gui_setup()
@@ -104,12 +104,13 @@ _gui_setup()
104 _gui_toolbar_setup(box); 104 _gui_toolbar_setup(box);
105 105
106 _editor = efl_add(EFL_UI_TEXT_CLASS, box, 106 _editor = efl_add(EFL_UI_TEXT_CLASS, box,
107 efl_text_font_set(efl_added, "Mono", 14),
108 efl_text_multiline_set(efl_added, EINA_TRUE), 107 efl_text_multiline_set(efl_added, EINA_TRUE),
109 efl_text_interactive_editable_set(efl_added, EINA_TRUE), 108 efl_text_interactive_editable_set(efl_added, EINA_TRUE),
110 efl_event_callback_array_add(efl_added, _editor_callbacks(), NULL), 109 efl_event_callback_array_add(efl_added, _editor_callbacks(), NULL),
111 efl_pack(box, efl_added)); 110 efl_pack(box, efl_added));
112 efl_ui_text_scrollable_set(_editor, EINA_TRUE); 111 efl_ui_text_scrollable_set(_editor, EINA_TRUE);
112 efl_text_font_family_set(_editor, "Mono");
113 efl_text_font_size_set(_editor, 14);
113} 114}
114 115
115EAPI_MAIN void 116EAPI_MAIN void
diff --git a/apps/csharp/texteditor/src/texteditor_main.cs b/apps/csharp/texteditor/src/texteditor_main.cs
index c3b144cd..0de15e22 100644
--- a/apps/csharp/texteditor/src/texteditor_main.cs
+++ b/apps/csharp/texteditor/src/texteditor_main.cs
@@ -168,7 +168,8 @@ public class TextEditor : Efl.Csharp.Application
168 168
169 // Create the main text entry 169 // Create the main text entry
170 editorTextBox = new Efl.Ui.Text(box); 170 editorTextBox = new Efl.Ui.Text(box);
171 editorTextBox.SetFont("Mono", 14); 171 editorTextBox.FontFamily = "Mono";
172 editorTextBox.FontSize = 14;
172 editorTextBox.Multiline = true; 173 editorTextBox.Multiline = true;
173 editorTextBox.Editable = true; 174 editorTextBox.Editable = true;
174 editorTextBox.Scrollable = true; 175 editorTextBox.Scrollable = true;