Ecere SDK/eC Forums • View topic - GUI Menu




Ecere SDK/eC Forums

Ecere Developers Community

GUI Menu

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.

GUI Menu

Postby lavictom » Thu Apr 24, 2014 1:44 am

HI, I am new in ecere and I tried to understand code for simple GUI. Next code is excerpt from eNotepad.ec:
Code: Select all
   MenuItem saveItem { fileMenu, "Save", s, ctrlS, NotifySelect = MenuFileSave };
   FileDialog fileSaveDialog
   {
      ...
   };
   saveDialog = fileSaveDialog;

   bool OnSaveFile(char * fileName)
   {
      ...
   }

There is no visible connection between saveItem, MenuFileSave, fileSaveDialog, saveDialog and OnSaveFile.
If I got it right:
saveItem is just pointer to menu item, if I need to access it for some reason (like change text).
MenuFileSave is some kind of predefined method for executing, when this menu is selected.
fileSaveDialog is method, which is called from MenuFileSave and MUST be defined, if I am using MenuFileSave method.
saveDialog is totally confusing me. I am assigning method name to some variable, which is not used at all.
OnSaveFile is some method, which should be defined, if MenuFileSave method is used (same like fileSaveDialog).

If I got it right, where can I find methods, which can be assigned to NotifySelect, where can I find what I should define for these kind of methods and so on ...
I tried to open API Reference - there is almost no info, I tried Tao of Programming - just 5 (FIVE!) pages about GUI. I know that the book is still in progress, but I think API reference should be almost complete. If not, can you tell me please, where I can find relevant informations?

Thx for you help.

BTW: Sorry for my bad english, I am from Czech Republic and english is not my native language.
echo 16i[APq]sa[ln0=aln4A%2D+Pln4A/snlbx]sbBF758B646170544A49E44D6D826Bsnlbx|dc
lavictom
 
Posts: 1
Joined: Tue Apr 22, 2014 7:52 am
Location: Ostrava, Czech Republic

Re: GUI Menu

Postby jerome » Thu Apr 24, 2014 3:48 am

Hi there Josh, welcome to the forums!

'saveDialog' is a property of the 'Window' class, which is used when you call MenuFileSave().
Setting 'isDocument = true' basically causes the Window to also be treated as a document model object.
'saveDialog' lets you assign your own FileDialog instance, e.g. to customize the caption or the filters etc.
If you don't set one, it will use a default dialog.

'MenuFileSave' is also a method of the 'Window' class related to the document model system.
It is a method you can conveniently assign to a menu item that will cause the document to save.

You can locate both of these in the API Reference under ecere module, ecere::gui namespace, Classes, Window, under Properties and Methods respectively.
There is indeed almost no info in the API reference, I hope to address that this summer, as well as expand on the GUI section of the Tao. It should however be quite useful to show you all the classes/properties/methods available. As of today, the best reference is the samples/ folder as well as the many posts on these forums. Don't hesitate however to post a new question or hang around on IRC or message/e-mail me to guide you quickly in the right direction.

'fileSaveDialog' in the eNotepad sample is an instance of the FileDialog class.
All class instance members are defined as: 'Class object { };'

OnSaveFile() is indeed a virtual method of the Window class (again, part of the document model embedded in the Window class) which is called back by MenuFileSave.

The methods in the GUI classes are all named in a systematic manner.
Methods starting with "On....." are virtual methods called back for the window itself.
Methods starting with "Notify..." are 'events', virtual methods for common controls called back with their owner (master) as the 'this' object, e.g. NotifyClicked, NotifySelect for menu items.

Methods starting with "Menu..." or the method ButtonCloseDialog, are predefined methods meant to be assigned to common controls virtual methods (e.g. "Menu..." to NotifySelect of PopupMenus, ButtonCloseDialog to the NotifyClicked of a Button).

In the API Reference, you will see non-virutal/virtual methods (callbacks) are grouped separately, and you will notice a special yellow icon for events (within the virtual methods).

You can also of course assign any method with a matching prototype to NotifySelect, which you can write yourself, or you can define it in place (The IDE will help you do so by auto completing the prototype after you type 'bool NotifySelect('. See the NotifySelect defined within the 'openItem' in eNotepad.ec.

The Ecere Tao of Programming goes to some extent to explain virtual methods/events.
There is also some more GUI explanations in this tutorial you can find at https://github.com/ecere/ecere-sdk/blob ... f?raw=true .

Again don't hesitate to ask for help, that's what these forums and myself are here for :)
I realize the docs are lacking and I really hope to improve on this as soon as possible.

Hoping to hear back from you with more good questions soon :)

Good luck and best regards,

-Jerome
jerome
Site Admin
 
Posts: 622
Joined: Sat Jan 16, 2010 11:16 pm


Return to GUI Toolkit & 2D Graphics

Who is online

Users browsing this forum: No registered users and 1 guest

cron