gs:set-border-layout not working as expected...

Started by oofoe, January 12, 2013, 08:36:40 PM

Previous topic - Next topic

oofoe

Hi!



This may just be that I'm not reading the documentation closely enough, however if I understand correctly, the "border" layout style allows five sections -- north, south, east, west and center -- and they should work together.



So, this piece of code should show a red box on top, with the bottom divided evenly between a green box on the left and a blue box on the right.



Instead I get a single blue box that fills the entire frame. Any ideas? Thanks!


(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

(gs:init)
(gs:set-trace true)
(gs:set-look-and-feel "javax.swing.plaf.metal.MetalLookAndFeel")

(gs:frame 'main 100 100 512 512 "Layout Test")

(gs:set-border-layout 'main)

(gs:panel 'i1 100 100)  (gs:set-color 'i1 1 0 0)
(gs:panel 'i2 100 100)  (gs:set-color 'i2 0 1 0)
(gs:panel 'i3 100 100)  (gs:set-color 'i3 0 0 1)

(gs:add-to 'main 'i1 'north  'i2 'west  'i3 'east)

(gs:set-visible 'main true)
(gs:listen)


I've tried using separate (gs:add-to) calls and putting the panels inside an inset panel with the border layout, but nothing seems to work. By the way: newLisp v10.4.4, newLISP-GS v.1.47 on Windows 7
Testing can show the presence of bugs, but not their absence.

oofoe

#1
OK, figured it out almost as soon as I posted. The problem is that the canonical directions (north, south, etc.) must be strings. Can't be symbols that I expect to be converted to strings, must absolutely, positively only be strings.



For what it's worth, I think this is a bug in light of the "String constants for type and orientation constants can be given as symbols" shortcut method mentioned in the documentation.



However! In the meantime, this is all I had to change to get it to work:


(gs:add-to 'main 'i1 "north"  'i2 "west"  'i3 "east")
Testing can show the presence of bugs, but not their absence.

Lutz

#2
Thanks for catching this. The online documentation has been corrected.



The text regarding orientation labels referred to an older version of software. Now, only ids may be expressed as either symbols or strings.

oofoe

#3
Thanks for the update!



For what it's worth, the GUI documentation would really benefit from more code examples like the main NewLisp manual. If you feel it's sufficiently clear, please feel free to use my test program for gs:set-border-layout!



If you're interested in having more runnable examples for other GUI server functions, I would be happy to supply you with more -- I'm currently hacking a new program up and have been studying the GUI stuff intensively lately.
Testing can show the presence of bugs, but not their absence.

Lutz

#4
At the moment the GUI documentation is part of the guiserver.lsp module and this module file would get too heavy, if the documentation gets too big. Perhaps it is time to make a separate HTML manual and leave the guiserver.lsp module as light as possible for fast loading?



The best way to study the GUI server, is to run read the demo programs accessible from the Help menu of the IDE application and from the following directories:


; on OSX and UNIX
/usr/share/newlisp/guiserver/

; on Windows
c:/Program Files/newlisp/guiserver/


Cormullion has some additional example code in his Introduction to newLISP here:



http://en.wikibooks.org/wiki/Introduction_to_newLISP/Graphical_interface">http://en.wikibooks.org/wiki/Introducti ... _interface">http://en.wikibooks.org/wiki/Introduction_to_newLISP/Graphical_interface