Why does the automatically generated code create the toolbars in differently?

Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 216
Joined: 24 Apr 2007 12:26

Why does the automatically generated code create the toolbars in differently?

Unread post by Ferenc Nagy » 20 Nov 2013 11:36

Hi,
The status line toolbar is generated simply.
The project toolbar is create in the brackets of a whenCreated call.
Place: generatedOnShow

Code: Select all

statusLine::create(getVPIWindow()),
Place: generatedInitialize

Code: Select all

whenCreated({ :- projectToolbar::create(getVPIWindow()) }),
Why?
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1172
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 22 Nov 2013 20:32

getVPIWindow will raise an exception if the window is not actually created/shown.

whenCreated postpones the call until the window is created. If is is already created it just run the code.

In a show-handler the window is created, in the constructor/generatedInitialize the window is not yet created.

So in a show handler whenCreated is not necessary, but in the constructor/generatedInitialize it is necessary.

In a new project (created today) the toolbars are created in generatedInitialize like this:

Code: Select all

predicates     generatedInitialize : (). clauses     generatedInitialize():-         setText("testGUI"),         setDecoration(titlebar([closebutton(),maximizebutton(),minimizebutton()])),         setBorder(sizeBorder()),         setState([wsf_ClipSiblings]),         whenCreated({ :- projectToolbar::create(getVpiWindow()), statusLine::create(getVpiWindow()) }),         addSizeListener({ :- vpiToolbar::resize(getVpiWindow()) }),         setMdiProperty(mdiProperty),         menuSet(resMenu(resourceIdentifiers::id_TaskMenu)),         addShowListener(onShow),         addSizeListener(onSizeChanged),         addDestroyListener(onDestroy),         addMenuItemListener(resourceIdentifiers::id_help_about, onHelpAbout),         addMenuItemListener(resourceIdentifiers::id_file_exit, onFileExit).
Regards Thomas Linder Puls
PDC

User avatar
Ferenc Nagy
VIP Member
Posts: 216
Joined: 24 Apr 2007 12:26

WhenCreated vs. e_Create

Unread post by Ferenc Nagy » 23 Nov 2013 14:32

Thomas, I uderstand your answer.
Is this code equivalent

Code: Select all

whenCreated({ :- projectToolbar::create(getVpiWindow()), statusLine::create(getVpiWindow()) }
with the same predicate calls within the handling of the Create event?


Code: Select all

task_win_eh(_Win,e_Create(_),0):-!, projectToolbar::create(getVpiWindow()), statusLine::create(getVpiWindow(),         !.
Is the Show event sent to a window exactly once?
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1172
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 23 Nov 2013 23:24

Yes, the show event is sent (exactly once) in the e_create handler.
Regards Thomas Linder Puls
PDC

User avatar
Ferenc Nagy
VIP Member
Posts: 216
Joined: 24 Apr 2007 12:26

What do you recommend to put in whenCreated(), onCreate() and onShow()?

Unread post by Ferenc Nagy » 24 Nov 2013 10:23

As I see the VIP team has changed the strategy of automatically created code since version 5.2,
and you have invented the whenCreated procedure which gathers the todolist for onCreate event handler.

Please give me some examples of actions for which the best / only place is
a) the actual parameters of whenCreated(....),
b) the clauses of the classic onCreate(...) event handler,
c) the clauses of the classic onShow(...) event handler,
respectively.
TIA, Regards,
Frank Nagy

User avatar
Thomas Linder Puls
VIP Member
Posts: 1172
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 24 Nov 2013 16:41

There are only whenCreated and show listeners, create belongs to the vpi world.

It is not possible to give best/only advices.

but in some cases you may consider the execution order: whenCreated actions are performed before the show listeners are invoked. (If you want something to take place after all show listeners you can use a postAction).
Regards Thomas Linder Puls
PDC

Post Reply