Created
October 16, 2011 23:20
-
-
Save glurp/1291582 to your computer and use it in GitHub Desktop.
gtkh exemple
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def component() | |
| stack do | |
| slot(htoolbar({"open/ourir fichier"=>nil,"close/fermer le fichier"=>nil, | |
| "undo/defaire"=>nil,"redo/refaire"=>proc { alert("e") },"ee"=>nil })) | |
| slot(label( <<-EEND | |
| This window is done with 55 LOC... | |
| 50 lines for create widgets, but don't do any traitment ! | |
| I will use that for Inscape extensions (SCADA Synoptics in SVG) | |
| EEND | |
| )) | |
| separator | |
| flow { | |
| @left=stack { | |
| frame("") { table(2,10,{set_column_spacings: 3}) do | |
| row { cell label "mode de fontionnement" ; cell(button("set") { alert("?") }) } | |
| row { cell label "vitesse" ; cell entry("aa") } | |
| row { cell label "size" ; cell ientry(11,{:min=>0,:max=>100,:by=>1}) } | |
| row { cell label "feeling" ; cell islider(10,{:min=>0,:max=>100,:by=>1}) } | |
| row { cell label "speedy" ; cell(toggle_button("on","off",false) {|w| w.label=w.active?() ? "Off": "On" }) } | |
| row { cell label "acceleration type" ; cell hradio_buttons(%w{aa bb cc},1) } | |
| row { cell label "mode on" ; cell check_button("",false) } | |
| row { cell label "mode off" ; cell check_button("",true) } | |
| row { cell label "Variable" ; cell combo({"aaa"=>1,"bbb"=>2,"ccc"=>3},1) } | |
| row { cell label "Couleur" ; cell color_choice() } | |
| end } | |
| frame("Buttons in frame") { | |
| flow { sloti(button("packed with sloti()") {alert("button packed with sloti()")}) | |
| @bref=sloti(button("bb")) ; slot(button("packed with slot()")) ; } | |
| } | |
| flow do | |
| stack { | |
| slot(button("Couleur") { | |
| #alert("alert !") ; error("error !") ; ask("ask !") ;trace("trace !") ; | |
| @color=ask_color() | |
| }) | |
| sloti(label('Epaisseur')) | |
| @epaisseur=sloti(islider(1,{:min=>1,:max=>30,:by=>1})) | |
| } | |
| @ldraw=[] ; @color= ::Gdk::Color.parse("#33EEFF"); | |
| slot(canvas(100,100,{ | |
| :expose => proc { |w,cr| | |
| @ldraw.each do |line| | |
| next if line.size<3 | |
| color,ep,pt0,*poly=*line | |
| cr.set_line_width(ep) | |
| cr.set_source_rgba(color.red/65000.0, color.green/65000.0, color.blue/65000.0, 1) | |
| cr.move_to(*pt0) | |
| poly.each {|px| cr.line_to(*px) } | |
| cr.stroke | |
| end | |
| }, | |
| :mouse_down => proc { |w,e| no= [e.x,e.y] ; @ldraw << [@color,@epaisseur.value,no] ; no }, | |
| :mouse_move => proc { |w,e,o| no= [e.x,e.y] ; (@ldraw.last << no) if no[0]!=o[0] || no[1]!=o[1] ; no }, | |
| :mouse_up => proc { |w,e,o| no= [e.x,e.y] ; (@ldraw.last << no) ; no} | |
| }) | |
| ) | |
| end | |
| } | |
| separator | |
| notebook do | |
| page("Page of Notebook") { | |
| table(2,2) { | |
| row { cell(button("eeee"));cell(button("dddd")) } | |
| row { cell(button("eeee"));cell(button("dddd")) } | |
| } | |
| } | |
| page("eee","#home") { | |
| sloti(button("Eeee")) | |
| sloti(button("#harddisk") { alert("image button!")}) | |
| sloti(label('#cdrom')) | |
| } | |
| end | |
| frame("") do | |
| stack { | |
| sloti(label("Test scrolled zone")) | |
| separator | |
| vbox_scrolled(-1,100) { | |
| 100.times { |i| | |
| flow { sloti(button("eeee#{i}"));sloti(button("eeee")) } | |
| } | |
| } | |
| vbox_scrolled(100,100) { | |
| 100.times { |i| | |
| flow { sloti(button("eeee#{i}"));sloti(button("eeee"));sloti(button("aaa"*100)) } | |
| } | |
| } | |
| } | |
| end | |
| } | |
| sloti(button("Test Specials Actions...") { p @bref ; do_special_actions() }) | |
| sloti( button("Exit") { exit! }) | |
| end | |
| end # endcomponent |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment