63 lines
2.0 KiB
Elixir
63 lines
2.0 KiB
Elixir
|
|
--------------------------------------------------------------------------------
|
|
--# GtkGrid - simple demo
|
|
--
|
|
-- Note: the grid has strange syntax for the 'attach next to' function,
|
|
-- it seems to be some sort of reverse notation. Pay attention to
|
|
-- the GTK docs when you use this otherwise useful feature.
|
|
-- I could, of course, fix this in EuGTK, but have left it as documented
|
|
-- in the GTK docs. Programmers will discover their error soon enough,
|
|
-- and swap the parameters if they use the correct order, which is the
|
|
-- wrong order :P
|
|
--------------------------------------------------------------------------------
|
|
|
|
include GtkEngine.e
|
|
|
|
constant docs = `<u><b>GtkGrid</b></u>
|
|
The GtkGrid allows you to layout items neatly.
|
|
Note the odd, reversed notation.
|
|
`
|
|
constant
|
|
cow = create(GtkImage,"thumbnails/cowbell.png"),
|
|
fox = create(GtkImage,"thumbnails/fox.png"),
|
|
fish = create(GtkImage,"thumbnails/fish.png"),
|
|
mouse = create(GtkImage,"thumbnails/mouse.png")
|
|
|
|
constant win = create(GtkWindow,
|
|
"size=300x300,border_width=10,position=1,$destroy=Quit")
|
|
|
|
constant panel = create(GtkBox,"orientation=VERTICAL")
|
|
add(win,panel)
|
|
|
|
constant lbl = pack(panel,create(GtkLabel))
|
|
set(lbl,"markup",docs)
|
|
|
|
constant grid = create(GtkGrid)
|
|
add(panel,grid)
|
|
add(grid,cow)
|
|
set(grid,{
|
|
{"attach next to",fox,cow,TOP,1,1},
|
|
{"attach next to",fish,cow,LEFT,1,1},
|
|
{"attach next to",mouse,cow,RIGHT,1,1}})
|
|
|
|
constant thislabel = create(GtkLabel)
|
|
|
|
set(grid,"attach next to",thislabel,fish,BOTTOM,3,1)
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- below is the formatted source code to display on window;
|
|
--------------------------------------------------------------------------------
|
|
set(thislabel,"font","8")
|
|
set(thislabel,"markup",`<b><u>Source:</u></b>
|
|
|
|
<b>add</b>(grid,cow)
|
|
<b>set</b>(grid,{
|
|
{"attach next to",fox,cow,TOP,1,1},
|
|
{"attach next to",fish,cow,LEFT,1,1},
|
|
{"attach next to",mouse,cow,RIGHT,1,1},
|
|
{"attach next to",thislabel,fish,BOTTOM,3,1)`)
|
|
-- end of markup source code;
|
|
|
|
show_all(win)
|
|
main()
|