summaryrefslogtreecommitdiff
path: root/pages/develop/tutorials
diff options
context:
space:
mode:
authorXavi Artigas <xavierartigas@yahoo.es>2019-01-23 09:33:37 -0800
committerapache <apache@e5-web1.enlightenment.org>2019-01-23 09:33:37 -0800
commit04a4bebe7b1e5e68a9fe3cd0e69582c59759a956 (patch)
tree58bf04e3178903a9a6cfbf7f197cf96c9aaae3be /pages/develop/tutorials
parenteb28f017907bc7c41ef431041af040112e58db7a (diff)
Wiki page hello-world-gui-cs.md changed with summary [Adapt to latest EFL# syntax] by Xavi Artigas
Diffstat (limited to 'pages/develop/tutorials')
-rw-r--r--pages/develop/tutorials/csharp/hello-world-gui-cs.md.txt150
1 files changed, 73 insertions, 77 deletions
diff --git a/pages/develop/tutorials/csharp/hello-world-gui-cs.md.txt b/pages/develop/tutorials/csharp/hello-world-gui-cs.md.txt
index 6fe9e837a..2ecdb9fc9 100644
--- a/pages/develop/tutorials/csharp/hello-world-gui-cs.md.txt
+++ b/pages/develop/tutorials/csharp/hello-world-gui-cs.md.txt
@@ -29,7 +29,7 @@ public class Example
29 public static void QuitCb(object sender, EventArgs e) 29 public static void QuitCb(object sender, EventArgs e)
30 { 30 {
31 // Exit the EFL main loop 31 // Exit the EFL main loop
32 efl.ui.Config.Exit(); 32 Efl.Ui.Config.Exit();
33 } 33 }
34 34
35#if WIN32 35#if WIN32
@@ -38,55 +38,51 @@ public class Example
38 public static void Main() 38 public static void Main()
39 { 39 {
40 // Initialize EFL and all UI components 40 // Initialize EFL and all UI components
41 efl.All.Init(efl.Components.Ui); 41 Efl.All.Init(Efl.Components.Ui);
42 42
43 // Create a window and initialize it 43 // Create a window and initialize it
44 efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => { 44 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
45 // Set the window's title 45 // Set the window's title
46 ewin.SetText("Hello World"); 46 win.SetText("Hello World");
47 // Request that the window is automatically hidden when the "close" 47 // Request that the window is automatically hidden when the "close"
48 // button is pressed 48 // button is pressed
49 ewin.SetAutohide(true); 49 win.SetAutohide(true);
50 // Hook to the Hide event 50 // Hook to the Hide event
51 ewin.HideEvt += QuitCb; 51 win.HideEvt += QuitCb;
52 });
53 52
54 // Create a box container 53 // Create a box container
55 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => { 54 var box = new Efl.Ui.Box(win);
56 // Set its minimum size 55 // Set its minimum size
57 ebox.SetHintMin(new eina.Size2D(360, 240)); 56 box.SetHintMin(new Eina.Size2D(360, 240));
58 // Set the box as the content for the window 57 // Set the box as the content for the window
59 // The window size will adapt to the box size 58 // The window size will adapt to the box size
60 win.SetContent(ebox); 59 win.SetContent(box);
61 });
62 60
63 // Create a text label widget 61 // Create a text label widget
64 new efl.ui.Text(box, (efl.ui.IText etext) => { 62 var label = new Efl.Ui.Text(box);
65 // Set its content and customize it 63 // Set its content and customize it
66 etext.SetText("Hello World. This is an Efl.Ui application!"); 64 label.SetText("Hello World. This is an Efl.Ui application!");
67 etext.SetSelectionAllowed(false); 65 label.SetSelectionAllowed(false);
68 etext.SetHintWeight(1.0, 0.9); 66 label.SetHintWeight(1.0, 0.9);
69 etext.SetHintAlign(0.5, 0.5); 67 label.SetHintAlign(0.5, 0.5);
70 // Add the text to the box container 68 // Add the text to the box container
71 box.DoPack(etext); 69 box.DoPack(label);
72 });
73 70
74 // Create a button widget 71 // Create a button widget
75 new efl.ui.Button(box, (efl.ui.IButton ebutton) => { 72 var button = new Efl.Ui.Button(box);
76 // Customize it 73 // Customize it
77 ebutton.SetText("Quit"); 74 button.SetText("Quit");
78 ebutton.SetHintWeight(1.0, 0.1); 75 button.SetHintWeight(1.0, 0.1);
79 // Set the method to be called when the button is pressed 76 // Set the method to be called when the button is pressed
80 ebutton.ClickedEvt += QuitCb; 77 button.ClickedEvt += QuitCb;
81 // Add the button to the box container 78 // Add the button to the box container
82 box.DoPack(ebutton); 79 box.DoPack(button);
83 });
84 80
85 // Start the EFL main loop 81 // Start the EFL main loop
86 efl.ui.Config.Run(); 82 Efl.Ui.Config.Run();
87 83
88 // Shutdown EFL 84 // Shutdown EFL
89 efl.All.Shutdown(); 85 Efl.All.Shutdown();
90 } 86 }
91} 87}
92``` 88```
@@ -105,18 +101,17 @@ Take a look at the window instantiation:
105 101
106```csharp 102```csharp
107 // Create a window and initialize it 103 // Create a window and initialize it
108 efl.ui.IWin win = new efl.ui.Win(efl.App.GetLoopMain(), (efl.ui.IWin ewin) => { 104 Efl.Ui.Win win = new Efl.Ui.Win(Efl.App.AppMain);
109 // Set the window's title 105 // Set the window's title
110 ewin.SetText("Hello World"); 106 win.SetText("Hello World");
111 // Request that the window is automatically hidden when the "close" 107 // Request that the window is automatically hidden when the "close"
112 // button is pressed 108 // button is pressed
113 ewin.SetAutohide(true); 109 win.SetAutohide(true);
114 // Hook to the Hide event 110 // Hook to the Hide event
115 ewin.HideEvt += QuitCb; 111 win.HideEvt += QuitCb;
116 });
117``` 112```
118 113
119This creates a new window, making it a child of the application's Main Loop, and customizing it with an initialization method. In this case, the initialization method is a lambda function which: 114This creates a new window, making it a child of the application's Main Loop, and customizes it:
120 115
121* Sets the window title to `Hello World`. 116* Sets the window title to `Hello World`.
122* Sets the `autohide` flag to `true` (see the [previous tutorial](hello-world-cs.md)). 117* Sets the `autohide` flag to `true` (see the [previous tutorial](hello-world-cs.md)).
@@ -131,7 +126,11 @@ All event handlers in EFL have the same signature:
131Where `sender` is the object that emitted the event, and `e` contains any additional information, which depends on the type of the event. 126Where `sender` is the object that emitted the event, and `e` contains any additional information, which depends on the type of the event.
132 127
133> **NOTE:** 128> **NOTE:**
134> `e` must be cast to the correct type to be able to extract this information. For example, when connecting to the `efl.input.Interface.KeyDownEvt` to be informed of key presses, you must cast `e` to `efl.input.Interface.KeyDownEvt_Args` to retrieve the actual key. 129> `e` must be typed correctly to be able to extract this information. For example, when connecting to the `Efl.Input.Interface.KeyDownEvt` to be informed of key presses, the event handler signature is:
130> ```csharp
131> public static void Handler(object sender, Efl.Input.InterfaceKeyDownEvt_Args e);
132> ```
133> And you can retrieve the pressed key using `e.arg.GetKey()`.
135 134
136This tutorial simply quits the application whenever the window is closed: 135This tutorial simply quits the application whenever the window is closed:
137 136
@@ -140,7 +139,7 @@ This tutorial simply quits the application whenever the window is closed:
140 public static void QuitCb(object sender, EventArgs e) 139 public static void QuitCb(object sender, EventArgs e)
141 { 140 {
142 // Exit the EFL main loop 141 // Exit the EFL main loop
143 efl.ui.Config.Exit(); 142 Efl.Ui.Config.Exit();
144 } 143 }
145``` 144```
146 145
@@ -158,13 +157,12 @@ This tutorial uses a *box* container:
158 157
159```csharp 158```csharp
160 // Create a box container 159 // Create a box container
161 efl.ui.IBox box = new efl.ui.Box(win, (efl.ui.IBox ebox) => { 160 var box = new Efl.Ui.Box(win);
162 // Set its minimum size 161 // Set its minimum size
163 ebox.SetHintMin(new eina.Size2D(360, 240)); 162 box.SetHintMin(new Eina.Size2D(360, 240));
164 // Set the box as the content for the window 163 // Set the box as the content for the window
165 // The window size will adapt to the box size 164 // The window size will adapt to the box size
166 win.SetContent(ebox); 165 win.SetContent(box);
167 });
168``` 166```
169 167
170A box container can be vertical or horizontal, and by default it is vertical. All widgets inside a vertical box container will have the same width as the container, and their heights will be automatically chosen so that they cover the whole surface of the container from top to bottom (Imagine a stack of pizza boxes neatly fitting inside your oven). By default, all widgets will have the same height, but that can be customized as you will see in a moment. 168A box container can be vertical or horizontal, and by default it is vertical. All widgets inside a vertical box container will have the same width as the container, and their heights will be automatically chosen so that they cover the whole surface of the container from top to bottom (Imagine a stack of pizza boxes neatly fitting inside your oven). By default, all widgets will have the same height, but that can be customized as you will see in a moment.
@@ -181,18 +179,17 @@ So far the tutorial has created a window and an invisible container, it is about
181 179
182```csharp 180```csharp
183 // Create a text label widget 181 // Create a text label widget
184 new efl.ui.Text(box, (efl.ui.IText etext) => { 182 var label = new Efl.Ui.Text(box);
185 // Set its content and customize it 183 // Set its content and customize it
186 etext.SetText("Hello World. This is an Efl.Ui application!"); 184 label.SetText("Hello World. This is an Efl.Ui application!");
187 etext.SetSelectionAllowed(false); 185 label.SetSelectionAllowed(false);
188 etext.SetHintWeight(1.0, 0.9); 186 label.SetHintWeight(1.0, 0.9);
189 etext.SetHintAlign(0.5, 0.5); 187 label.SetHintAlign(0.5, 0.5);
190 // Add the text to the box container 188 // Add the text to the box container
191 box.DoPack(etext); 189 box.DoPack(label);
192 });
193``` 190```
194 191
195This instantiates an `efl.ui.Text` object, as a child of the box container. Quite sensibly, this is the widget used to display text on screen. The initialization above is worth a careful look: 192This instantiates an `Efl.Ui.Text` object, as a child of the box container. Quite sensibly, this is the widget used to display text on screen. The initialization above is worth a careful look:
196 193
197* `SetText()`: Specifies the text string to display in the widget. 194* `SetText()`: Specifies the text string to display in the widget.
198* `SetSelectionAllowed()`: This disables selecting the text (by dragging over it with the mouse, for example). Just to showcase a bit the EFL's capabilities. 195* `SetSelectionAllowed()`: This disables selecting the text (by dragging over it with the mouse, for example). Just to showcase a bit the EFL's capabilities.
@@ -206,7 +203,7 @@ This instantiates an `efl.ui.Text` object, as a child of the box container. Quit
206 > 203 >
207 > If you want to vertically align the text inside a vertical box, you have to align the text **inside** the text widget using `SetValign(0.5)` (or `SetHalign(0.5)`). This is a complex topic explained in it own tutorial (*coming soon*). 204 > If you want to vertically align the text inside a vertical box, you have to align the text **inside** the text widget using `SetValign(0.5)` (or `SetHalign(0.5)`). This is a complex topic explained in it own tutorial (*coming soon*).
208 205
209* `Efl.ui.Box.DoPack()`: This adds the text widget to the box container. The order in which widgets are added to a container dictates the order in which they are placed on the screen. 206* `Efl.Ui.Box.DoPack()`: This adds the text widget to the box container. The order in which widgets are added to a container dictates the order in which they are placed on the screen.
210 207
211 Besides being a child of the box object, the text widget also needs to be *packed* into the box with `DoPack()`. 208 Besides being a child of the box object, the text widget also needs to be *packed* into the box with `DoPack()`.
212 209
@@ -218,15 +215,14 @@ Let's now add a button below the text label:
218 215
219```csharp 216```csharp
220 // Create a button widget 217 // Create a button widget
221 new efl.ui.Button(box, (efl.ui.IButton ebutton) => { 218 var button = new Efl.Ui.Button(box);
222 // Customize it 219 // Customize it
223 ebutton.SetText("Quit"); 220 button.SetText("Quit");
224 ebutton.SetHintWeight(1.0, 0.1); 221 button.SetHintWeight(1.0, 0.1);
225 // Set the method to be called when the button is pressed 222 // Set the method to be called when the button is pressed
226 ebutton.ClickedEvt += QuitCb; 223 button.ClickedEvt += QuitCb;
227 // Add the button to the box container 224 // Add the button to the box container
228 box.DoPack(ebutton); 225 box.DoPack(button);
229 });
230``` 226```
231 227
232This instantiates a button as a child of the box and initializes it so: 228This instantiates a button as a child of the box and initializes it so: