summaryrefslogtreecommitdiff
path: root/apps/csharp/texteditor/src/texteditor_main.cs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/csharp/texteditor/src/texteditor_main.cs')
-rw-r--r--apps/csharp/texteditor/src/texteditor_main.cs88
1 files changed, 41 insertions, 47 deletions
diff --git a/apps/csharp/texteditor/src/texteditor_main.cs b/apps/csharp/texteditor/src/texteditor_main.cs
index 69e95bf..6f52e6b 100644
--- a/apps/csharp/texteditor/src/texteditor_main.cs
+++ b/apps/csharp/texteditor/src/texteditor_main.cs
@@ -58,50 +58,46 @@ public class TextEditor
58 // Shows a modal message popup with an "OK" button 58 // Shows a modal message popup with an "OK" button
59 private void ShowMessage(string message) 59 private void ShowMessage(string message)
60 { 60 {
61 new Efl.Ui.TextAlertPopup (win, (Efl.Ui.TextAlertPopup epopup) => { 61 var popup = new Efl.Ui.TextAlertPopup (win);
62 epopup.SetText(message); 62 popup.SetText(message);
63 epopup.SetExpandable(new Eina.Size2D(200,200)); 63 popup.SetExpandable(new Eina.Size2D(200, 200));
64 epopup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null); 64 popup.SetButton(Efl.Ui.AlertPopupButton.Positive, "OK", null);
65 epopup.ButtonClickedEvt += 65 popup.ButtonClickedEvt +=
66 (object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args ea) => { 66 (object sender, Efl.Ui.AlertPopupButtonClickedEvt_Args ea) => {
67 // Dismiss popup when the button is clicked 67 // Dismiss popup when the button is clicked
68 ((Efl.Ui.TextAlertPopup)sender).SetParent(null); 68 ((Efl.Ui.TextAlertPopup)sender).SetParent(null);
69 }; 69 };
70 });
71 } 70 }
72 71
73 // Adds a button to the toolbar, with the given text, icon and click event handler 72 // Adds a button to the toolbar, with the given text, icon and click event handler
74 private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name, 73 private Efl.Ui.Button GUIToolbarButtonAdd(Efl.Ui.Box toolbar, string name,
75 string iconName, EventHandler func) 74 string iconName, EventHandler func)
76 { 75 {
77 return new Efl.Ui.Button(toolbar, (Efl.Ui.Button ebutton) => { 76 var button = new Efl.Ui.Button(toolbar);
78 ebutton.SetText(name); 77 button.SetText(name);
79 ebutton.ClickedEvt += func; 78 button.ClickedEvt += func;
80 ebutton.SetHintWeight(0, 1); 79 button.SetHintWeight(0, 1);
81 toolbar.DoPack(ebutton); 80
82 81 // Set the content of the button, which is an image
83 // Set the content of the button 82 var image = new Efl.Ui.Image(toolbar);
84 ebutton.SetContent( 83 image.SetIcon(iconName);
85 // Which is an image 84 button.SetContent(image);
86 new Efl.Ui.Image(toolbar, (Efl.Ui.Image eimage) => { 85
87 eimage.SetIcon(iconName); 86 toolbar.DoPack(button);
88 }) 87 return button;
89 );
90 });
91 } 88 }
92 89
93 // Creates a new toolbar, with all its buttons 90 // Creates a new toolbar, with all its buttons
94 private void GUIToolbarSetup(Efl.Ui.Box parent) 91 private void GUIToolbarSetup(Efl.Ui.Box parent)
95 { 92 {
96 // Create a horizontal box container for the buttons 93 // Create a horizontal box container for the buttons
97 Efl.Ui.Box bar = new Efl.Ui.Box(parent, (Efl.Ui.Box ebox) => { 94 var bar = new Efl.Ui.Box(parent);
98 // 0 vertical weight means that the toolbar will have the minimum height 95 // 0 vertical weight means that the toolbar will have the minimum height
99 // to accommodate all its buttons and not a pixel more. The rest of the 96 // to accommodate all its buttons and not a pixel more. The rest of the
100 // space will be given to the other object in the parent container. 97 // space will be given to the other object in the parent container.
101 ebox.SetHintWeight(1, 0); 98 bar.SetHintWeight(1, 0);
102 ebox.SetDirection(Efl.Ui.Dir.Horizontal); 99 bar.SetDirection(Efl.Ui.Dir.Horizontal);
103 parent.DoPack(ebox); 100 parent.DoPack(bar);
104 });
105 101
106 // "New" button 102 // "New" button
107 toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new", 103 toolbarButtonNew = GUIToolbarButtonAdd(bar, "New", "document-new",
@@ -157,11 +153,10 @@ public class TextEditor
157 public TextEditor() 153 public TextEditor()
158 { 154 {
159 // Create a window and initialize it 155 // Create a window and initialize it
160 win = new Efl.Ui.Win(Efl.App.AppMain, (Efl.Ui.Win ewin) => { 156 win = new Efl.Ui.Win(Efl.App.AppMain);
161 ewin.SetText("Text Editor"); 157 win.SetText("Text Editor");
162 ewin.SetAutohide(true); 158 win.SetAutohide(true);
163 ewin.HideEvt += GUIQuitCb; 159 win.HideEvt += GUIQuitCb;
164 });
165 160
166 // Create a vertical box container 161 // Create a vertical box container
167 Efl.Ui.Box box = new Efl.Ui.Box(win); 162 Efl.Ui.Box box = new Efl.Ui.Box(win);
@@ -171,16 +166,15 @@ public class TextEditor
171 GUIToolbarSetup(box); 166 GUIToolbarSetup(box);
172 167
173 // Create the main text entry 168 // Create the main text entry
174 editorTextBox = new Efl.Ui.Text(box, (Efl.Ui.Text etext) => { 169 editorTextBox = new Efl.Ui.Text(box);
175 etext.SetFont("Mono", 14); 170 editorTextBox.SetFont("Mono", 14);
176 etext.SetMultiline(true); 171 editorTextBox.SetMultiline(true);
177 etext.SetEditable(true); 172 editorTextBox.SetEditable(true);
178 etext.SetScrollable(true); 173 editorTextBox.SetScrollable(true);
179 etext.SetHintMin(new Eina.Size2D(360, 240)); 174 editorTextBox.SetHintMin(new Eina.Size2D(360, 240));
180 etext.ChangedEvt += EditorChangedCb; 175 editorTextBox.ChangedEvt += EditorChangedCb;
181 etext.ChangedUserEvt += EditorChangedCb; 176 editorTextBox.ChangedUserEvt += EditorChangedCb;
182 box.DoPack(etext); 177 box.DoPack(editorTextBox);
183 });
184 178
185 // Initial refresh of the toolbar buttons 179 // Initial refresh of the toolbar buttons
186 GUIToolbarRefresh(); 180 GUIToolbarRefresh();