2018-02-09 13:06:13 -08:00
|
|
|
using System;
|
|
|
|
|
|
|
|
public class Example
|
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Callback to quit the application
|
2018-02-09 13:06:13 -08:00
|
|
|
public static void QuitCb(object sender, EventArgs e)
|
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Exit the EFL main loop
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.ui.Config.Exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Main()
|
|
|
|
{
|
2018-08-22 06:22:29 -07:00
|
|
|
// Initialize EFL and all UI components
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.All.Init(efl.Components.Ui);
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a window and initialize it
|
2018-07-04 08:48:09 -07:00
|
|
|
efl.ui.IWin win = new efl.ui.Win(null, (efl.ui.IWin ewin) => {
|
2018-08-22 06:22:29 -07:00
|
|
|
// Request a simple window
|
2018-07-04 08:48:09 -07:00
|
|
|
ewin.SetWinType(efl.ui.Win_Type.Basic);
|
2018-08-22 06:22:29 -07:00
|
|
|
// Set the window's title
|
2018-02-09 13:06:13 -08:00
|
|
|
ewin.SetText("Hello World");
|
2018-08-22 06:22:29 -07:00
|
|
|
// Request that the window is automatically hidden when the "close"
|
|
|
|
// button is pressed
|
2018-02-09 13:06:13 -08:00
|
|
|
ewin.SetAutohide(true);
|
|
|
|
});
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Hook to the Hide event
|
2018-07-04 08:48:09 -07:00
|
|
|
win.HideEvt += QuitCb;
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a box container
|
2018-07-04 08:48:09 -07:00
|
|
|
efl.ui.IBox box = new efl.ui.Box(win);
|
2018-08-22 06:22:29 -07:00
|
|
|
// Set its minimum size
|
2018-02-09 13:06:13 -08:00
|
|
|
eina.Size2D sz;
|
|
|
|
sz.W = 360;
|
|
|
|
sz.H = 240;
|
|
|
|
box.SetHintMin(sz);
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Set the box as the content for the window
|
|
|
|
// The window size will adapt to the box size
|
2018-02-09 13:06:13 -08:00
|
|
|
win.SetContent(box);
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a text label widget
|
2018-07-04 08:48:09 -07:00
|
|
|
efl.ui.IText text = new efl.ui.Text(box);
|
2018-08-22 06:22:29 -07:00
|
|
|
// Set its content and customize it
|
2018-02-09 13:06:13 -08:00
|
|
|
text.SetText("Hello World. This is an Efl.Ui application!");
|
|
|
|
text.SetSelectionAllowed(false);
|
|
|
|
text.SetHintWeight(1.0, 0.9);
|
|
|
|
text.SetHintAlign(0.5, 0.5);
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Add the text to the box container
|
2018-07-04 08:48:09 -07:00
|
|
|
box.DoPack(text);
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Create a button widget
|
2018-07-04 08:48:09 -07:00
|
|
|
efl.ui.IButton button = new efl.ui.Button(box);
|
2018-08-22 06:22:29 -07:00
|
|
|
// Customize it
|
2018-02-09 13:06:13 -08:00
|
|
|
button.SetText("Quit");
|
|
|
|
button.SetHintWeight(1.0, 0.1);
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Set the method to be called when the button is pressed
|
2018-07-04 08:48:09 -07:00
|
|
|
button.ClickedEvt += QuitCb;
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Add the button to the box container
|
2018-07-04 08:48:09 -07:00
|
|
|
box.DoPack(button);
|
2018-02-09 13:06:13 -08:00
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Start the EFL main loop
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.ui.Config.Run();
|
|
|
|
|
2018-08-22 06:22:29 -07:00
|
|
|
// Shutdown EFL
|
2018-02-09 13:06:13 -08:00
|
|
|
efl.All.Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|