| 1 | $LOAD_PATH << File.expand_path("lib")
|
|---|
| 2 | require "ruwin"
|
|---|
| 3 |
|
|---|
| 4 | class MyWindow < Ruwin::Window
|
|---|
| 5 | include Ruwin::Component::Clickable
|
|---|
| 6 |
|
|---|
| 7 | attr_reader :children
|
|---|
| 8 | def initialize *args
|
|---|
| 9 | @children = {}
|
|---|
| 10 | super
|
|---|
| 11 | end
|
|---|
| 12 | end
|
|---|
| 13 |
|
|---|
| 14 | window = MyWindow.new 0, 0, 500, 500 do |window|
|
|---|
| 15 | window.hscroll.visible = true
|
|---|
| 16 | window.vscroll.visible = true
|
|---|
| 17 | end
|
|---|
| 18 | # サブウィンドウの設定
|
|---|
| 19 | window.children[:button] = Ruwin::Button.new window, 0, 0, 100, 30 do |control|
|
|---|
| 20 | control.caption = "Change"
|
|---|
| 21 | end
|
|---|
| 22 | def (window.children[:button]).clicked
|
|---|
| 23 | @parent.children[:checkbox].indeterminate = !@parent.children[:checkbox].indeterminate
|
|---|
| 24 | @parent.children[:checkbox].caption =
|
|---|
| 25 | if @parent.children[:checkbox].indeterminate
|
|---|
| 26 | "3STATE"
|
|---|
| 27 | else
|
|---|
| 28 | "CHECKBOX"
|
|---|
| 29 | end
|
|---|
| 30 | end
|
|---|
| 31 |
|
|---|
| 32 | def window.on_command msg
|
|---|
| 33 | case msg.lParam
|
|---|
| 34 | when @children[:button].hWnd
|
|---|
| 35 | @children[:button].clicked
|
|---|
| 36 | end
|
|---|
| 37 | end
|
|---|
| 38 | def window.on_focus msg
|
|---|
| 39 | p :WM_SETFOCUS
|
|---|
| 40 | end
|
|---|
| 41 | # window.addEvent Ruwin::Message::WM_KEYDOWN
|
|---|
| 42 | # window.vscroll.auto_disable = true
|
|---|
| 43 | # p window.vscroll.__send__(:get_scroll_info)
|
|---|
| 44 | window.vscroll.min = -100
|
|---|
| 45 | window.vscroll.max = 100
|
|---|
| 46 | window.vscroll.page_size = 0
|
|---|
| 47 | window.vscroll.position = 95
|
|---|
| 48 | window.hscroll.page_size = 1
|
|---|
| 49 | window.hscroll.max = 100
|
|---|
| 50 |
|
|---|
| 51 | window.children[:checkbox] = Ruwin::CheckBox.new window, 0, 30, 100, 30 do |control|
|
|---|
| 52 | control.indeterminate = true
|
|---|
| 53 | control.caption = "3STATE"
|
|---|
| 54 | end
|
|---|
| 55 | =begin
|
|---|
| 56 | Ruwin::RadioButton.new window, 0, 60, 100, 30 do |control|
|
|---|
| 57 | control.caption = "caption"
|
|---|
| 58 | end
|
|---|
| 59 | Ruwin::RadioButton.new window, 0, 90, 100, 30 do |control|
|
|---|
| 60 | control.caption = "caption"
|
|---|
| 61 | end
|
|---|
| 62 | Ruwin::RadioButton.new window, 0, 120, 100, 30 do |control|
|
|---|
| 63 | control.caption = "caption"
|
|---|
| 64 | end
|
|---|
| 65 | =end
|
|---|
| 66 |
|
|---|
| 67 | window.children[:scroll_value] = Ruwin::Static.new window, 200, 200, 100, 30
|
|---|
| 68 | control = Ruwin::ScrollBar::Horz.new window, 0, 150, 100, 30
|
|---|
| 69 | control.min = -100
|
|---|
| 70 | control.max = 100
|
|---|
| 71 | control.position = 50
|
|---|
| 72 | control.page_size = 10
|
|---|
| 73 | def control.changed value
|
|---|
| 74 | @parent.children[:scroll_value].caption = value.to_s
|
|---|
| 75 | p @parent.children[:list_box].position
|
|---|
| 76 | @parent.children[:list_box].selection value
|
|---|
| 77 | p @parent.children[:list_box].position
|
|---|
| 78 | end
|
|---|
| 79 |
|
|---|
| 80 | list_box = window.children[:list_box] = Ruwin::ListBox::Multiple.new(window, 300, 200, 100, 100)
|
|---|
| 81 | 10.times{|i| list_box.push "text_#{i}" }
|
|---|
| 82 | 10.times{|i| list_box.insert 0, "text_#{i}" }
|
|---|
| 83 | p list_box.each.with_index{|v, i| list_box.selection i if v.match /9$/ }
|
|---|
| 84 |
|
|---|
| 85 | window.show
|
|---|
| 86 |
|
|---|
| 87 | SWin::Application.messageloop
|
|---|