wxruby-ruby19 1.9.8-x86-darwin-9 → 1.9.10-x86-darwin-9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +53 -0
- data/README +297 -0
- data/lib/wx.rb +2 -2
- data/lib/wx/accessors.rb +7 -1
- data/lib/wx/classes/app.rb +10 -4
- data/lib/wx/classes/bitmap.rb +29 -1
- data/lib/wx/classes/clipboard.rb +19 -3
- data/lib/wx/classes/colour.rb +6 -4
- data/lib/wx/classes/data_object.rb +14 -0
- data/lib/wx/classes/data_object_simple.rb +6 -0
- data/lib/wx/classes/dataformat.rb +23 -0
- data/lib/wx/classes/evthandler.rb +79 -4
- data/lib/wx/classes/genericdirctrl.rb +36 -0
- data/lib/wx/classes/grid.rb +8 -0
- data/lib/wx/classes/hboxsizer.rb +6 -0
- data/lib/wx/classes/icon.rb +12 -1
- data/lib/wx/classes/image.rb +13 -1
- data/lib/wx/classes/listctrl.rb +12 -0
- data/lib/wx/classes/point.rb +8 -0
- data/lib/wx/classes/rect.rb +10 -1
- data/lib/wx/classes/richtextctrl.rb +63 -0
- data/lib/wx/classes/size.rb +9 -0
- data/lib/wx/classes/sizer.rb +18 -3
- data/lib/wx/classes/standardpaths.rb +9 -0
- data/lib/wx/classes/texturlevent.rb +14 -2
- data/lib/wx/classes/toolbar.rb +4 -6
- data/lib/wx/classes/vboxsizer.rb +6 -0
- data/lib/wx/classes/window.rb +7 -0
- data/lib/wx/classes/xmlresource.rb +17 -0
- data/lib/wx/helpers.rb +16 -1
- data/lib/wx/keyword_ctors.rb +3 -2
- data/lib/wx/keyword_defs.rb +56 -5
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.bundle +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1356 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +23 -0
- data/samples/bigdemo/GridSimple.rbw +78 -0
- data/samples/bigdemo/MDIDemo.rbw +57 -0
- data/samples/bigdemo/PopupMenu.rbw +149 -0
- data/samples/bigdemo/ShapedWindow.rbw +131 -0
- data/samples/bigdemo/Sizers.rbw +543 -0
- data/samples/bigdemo/bigdemo.rb +823 -0
- data/samples/bigdemo/demoTemplate.rbw +33 -0
- data/samples/bigdemo/helpfile.htb +0 -0
- data/samples/bigdemo/icons/Test 015.jpg +0 -0
- data/samples/bigdemo/icons/Test 015.png +0 -0
- data/samples/bigdemo/icons/choice.bmp +0 -0
- data/samples/bigdemo/icons/choice.xpm +27 -0
- data/samples/bigdemo/icons/combo.bmp +0 -0
- data/samples/bigdemo/icons/combo.xpm +27 -0
- data/samples/bigdemo/icons/copy.xpm +25 -0
- data/samples/bigdemo/icons/cut.xpm +24 -0
- data/samples/bigdemo/icons/gauge.bmp +0 -0
- data/samples/bigdemo/icons/gauge.xpm +27 -0
- data/samples/bigdemo/icons/help.xpm +25 -0
- data/samples/bigdemo/icons/list.bmp +0 -0
- data/samples/bigdemo/icons/list.xpm +27 -0
- data/samples/bigdemo/icons/mondrian.ico +0 -0
- data/samples/bigdemo/icons/mondrian.xpm +44 -0
- data/samples/bigdemo/icons/new.xpm +24 -0
- data/samples/bigdemo/icons/ogl.ico +0 -0
- data/samples/bigdemo/icons/ogl.xpm +45 -0
- data/samples/bigdemo/icons/open.xpm +26 -0
- data/samples/bigdemo/icons/paste.bmp +0 -0
- data/samples/bigdemo/icons/paste.xpm +38 -0
- data/samples/bigdemo/icons/pointy.png +0 -0
- data/samples/bigdemo/icons/preview.xpm +26 -0
- data/samples/bigdemo/icons/print.xpm +26 -0
- data/samples/bigdemo/icons/radio.bmp +0 -0
- data/samples/bigdemo/icons/radio.xpm +27 -0
- data/samples/bigdemo/icons/robert.xpm +415 -0
- data/samples/bigdemo/icons/ruby.png +0 -0
- data/samples/bigdemo/icons/sashtest.ico +0 -0
- data/samples/bigdemo/icons/save.xpm +25 -0
- data/samples/bigdemo/icons/smiles.bmp +0 -0
- data/samples/bigdemo/icons/smiles.xpm +39 -0
- data/samples/bigdemo/icons/smiley.ico +0 -0
- data/samples/bigdemo/icons/smiley.xpm +42 -0
- data/samples/bigdemo/icons/stattext.xpm +24 -0
- data/samples/bigdemo/icons/test2.bmp +0 -0
- data/samples/bigdemo/icons/test2.png +0 -0
- data/samples/bigdemo/icons/test2.xpm +79 -0
- data/samples/bigdemo/icons/text.bmp +0 -0
- data/samples/bigdemo/icons/text.xpm +27 -0
- data/samples/bigdemo/icons/tog1.bmp +0 -0
- data/samples/bigdemo/icons/tog1.xpm +38 -0
- data/samples/bigdemo/icons/tog2.bmp +0 -0
- data/samples/bigdemo/icons/tog2.xpm +38 -0
- data/samples/bigdemo/icons/wxwin.ico +0 -0
- data/samples/bigdemo/icons/wxwin16x16.png +0 -0
- data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
- data/samples/bigdemo/icons/wxwin32x32.png +0 -0
- data/samples/bigdemo/icons/wxwin48x48.png +0 -0
- data/samples/bigdemo/run.rb +90 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +281 -0
- data/samples/bigdemo/wxBitmapButton.rbw +65 -0
- data/samples/bigdemo/wxButton.rbw +64 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
- data/samples/bigdemo/wxCheckBox.rbw +50 -0
- data/samples/bigdemo/wxCheckListBox.rbw +65 -0
- data/samples/bigdemo/wxChoice.rbw +47 -0
- data/samples/bigdemo/wxChoicebook.rbw +78 -0
- data/samples/bigdemo/wxColourDialog.rbw +31 -0
- data/samples/bigdemo/wxComboBox.rbw +77 -0
- data/samples/bigdemo/wxCursor.rbw +136 -0
- data/samples/bigdemo/wxDialog.rbw +74 -0
- data/samples/bigdemo/wxDirDialog.rbw +29 -0
- data/samples/bigdemo/wxDragImage.rbw +70 -0
- data/samples/bigdemo/wxFileDialog.rbw +37 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
- data/samples/bigdemo/wxFontDialog.rbw +173 -0
- data/samples/bigdemo/wxFrame.rbw +53 -0
- data/samples/bigdemo/wxGauge.rbw +71 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
- data/samples/bigdemo/wxGrid.rbw +66 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
- data/samples/bigdemo/wxListBox.rbw +140 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
- data/samples/bigdemo/wxMDIWindows.rbw +50 -0
- data/samples/bigdemo/wxMenu.rbw +236 -0
- data/samples/bigdemo/wxMessageDialog.rbw +27 -0
- data/samples/bigdemo/wxMiniFrame.rbw +70 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
- data/samples/bigdemo/wxNotebook.rbw +136 -0
- data/samples/bigdemo/wxProgressDialog.rbw +43 -0
- data/samples/bigdemo/wxRadioBox.rbw +72 -0
- data/samples/bigdemo/wxRadioButton.rbw +125 -0
- data/samples/bigdemo/wxSashWindow.rbw +141 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
- data/samples/bigdemo/wxSlider.rbw +42 -0
- data/samples/bigdemo/wxSpinButton.rbw +50 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
- data/samples/bigdemo/wxStaticText.rbw +55 -0
- data/samples/bigdemo/wxStatusBar.rbw +126 -0
- data/samples/bigdemo/wxTextCtrl.rbw +149 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
- data/samples/bigdemo/wxToggleButton.rbw +49 -0
- data/samples/bigdemo/wxToolBar.rbw +131 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
- data/samples/calendar/calendar.rb +256 -0
- data/samples/caret/caret.rb +282 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1136 -0
- data/samples/controls/get_item_sample.rb +87 -0
- data/samples/controls/icons/choice.xpm +27 -0
- data/samples/controls/icons/combo.xpm +27 -0
- data/samples/controls/icons/gauge.xpm +27 -0
- data/samples/controls/icons/list.xpm +27 -0
- data/samples/controls/icons/radio.xpm +27 -0
- data/samples/controls/icons/stattext.xpm +24 -0
- data/samples/controls/icons/text.xpm +27 -0
- data/samples/controls/mondrian.ico +0 -0
- data/samples/controls/mondrian.xpm +44 -0
- data/samples/controls/test2.bmp +0 -0
- data/samples/dialogs/dialogs.rb +797 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/drawing/graphics_drawing.rb +235 -0
- data/samples/drawing/images.rb +37 -0
- data/samples/drawing/paperclip.png +0 -0
- data/samples/etc/activation.rb +102 -0
- data/samples/etc/choice.rb +67 -0
- data/samples/etc/miniframe.rb +79 -0
- data/samples/etc/sash.rb +130 -0
- data/samples/etc/scrollwin.rb +110 -0
- data/samples/etc/system_settings.rb +252 -0
- data/samples/etc/threaded.rb +72 -0
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/etc/wizard.rb +74 -0
- data/samples/event/event.rb +182 -0
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/grid.rb +198 -0
- data/samples/grid/gridtablebase.rb +148 -0
- data/samples/html/html.rb +262 -0
- data/samples/listbook/listbook.rb +174 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +85 -0
- data/samples/media/mediactrl.rb +167 -0
- data/samples/minimal/minimal.rb +77 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +16 -0
- data/samples/opengl/cube.rb +117 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +487 -0
- data/samples/sockets/SocketPackets.rb +27 -0
- data/samples/sockets/res/message-new.png +0 -0
- data/samples/sockets/res/user.png +0 -0
- data/samples/sockets/wxClient.rb +395 -0
- data/samples/sockets/wxServer.rb +422 -0
- data/samples/sockets/wxSocketGUI.rb +97 -0
- data/samples/text/format-text-bold.png +0 -0
- data/samples/text/format-text-italic.png +0 -0
- data/samples/text/format-text-underline.png +0 -0
- data/samples/text/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/rich_textctrl.rb +98 -0
- data/samples/text/scintilla.rb +169 -0
- data/samples/text/textctrl.rb +111 -0
- data/samples/text/unicode.rb +242 -0
- data/samples/text/utf8.txt +15 -0
- data/samples/treectrl/icon1.xpm +79 -0
- data/samples/treectrl/icon2.xpm +53 -0
- data/samples/treectrl/icon3.xpm +79 -0
- data/samples/treectrl/icon4.xpm +43 -0
- data/samples/treectrl/icon5.xpm +79 -0
- data/samples/treectrl/treectrl.rb +1166 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +76 -0
- metadata +17 -3
@@ -0,0 +1,87 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Written by Nobuaki Arima
|
3
|
+
|
4
|
+
require 'wx'
|
5
|
+
|
6
|
+
class ListctrlFrame < Wx::Frame
|
7
|
+
def initialize(title,pos,size)
|
8
|
+
super(nil,-1,title,pos,size,Wx::DEFAULT_FRAME_STYLE)
|
9
|
+
|
10
|
+
list = Wx::ListCtrl.new(self, -1, Wx::DEFAULT_POSITION,
|
11
|
+
Wx::DEFAULT_SIZE,
|
12
|
+
Wx::LC_REPORT)
|
13
|
+
list.insert_column(0,"column0",Wx::LIST_FORMAT_LEFT, -1)
|
14
|
+
list.insert_column(1,"column1",Wx::LIST_FORMAT_LEFT, -1)
|
15
|
+
list.insert_item(0, 'line0:column0')
|
16
|
+
list.set_item(0, 1, 'line0:column1')
|
17
|
+
list.insert_item(1, 'line1:column0')
|
18
|
+
list.set_text_colour(Wx::CYAN)
|
19
|
+
list.set_item(1, 1, 'line1:column1')
|
20
|
+
list.set_text_colour(Wx::RED)
|
21
|
+
list.insert_item(2, 'line2:column0')
|
22
|
+
list.set_item(2, 1, 'line2:column1')
|
23
|
+
item = Wx::ListItem.new
|
24
|
+
item.set_id(0)
|
25
|
+
item.set_text_colour(Wx::RED)
|
26
|
+
list.set_item( item )
|
27
|
+
item.set_id(1)
|
28
|
+
item.set_text_colour(Wx::GREEN)
|
29
|
+
list.set_item( item )
|
30
|
+
item.set_id(2)
|
31
|
+
item.set_text_colour(Wx::BLUE)
|
32
|
+
item.set_font(Wx::ITALIC_FONT)
|
33
|
+
item.set_background_colour(Wx::LIGHT_GREY)
|
34
|
+
list.set_item( item )
|
35
|
+
|
36
|
+
# test of get_item method
|
37
|
+
0.upto(2) do |i|
|
38
|
+
if item = list.get_item(i)
|
39
|
+
print "ID:",item.get_id,"\n"
|
40
|
+
print "column: ",item.get_column,"\n"
|
41
|
+
print "text: ",item.get_text,"\n"
|
42
|
+
print "text color:",show_color(item.get_text_colour),"\n"
|
43
|
+
print "BG color: ",show_color(item.get_background_colour),"\n"
|
44
|
+
print "font: ",show_font(item.get_font),"\n\n"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
# test other column
|
48
|
+
0.upto(2) do |i|
|
49
|
+
if item = list.get_item(i, 1)
|
50
|
+
print "ID:",item.get_id,"\n"
|
51
|
+
print "column: ",item.get_column,"\n"
|
52
|
+
print "text: ",item.get_text,"\n"
|
53
|
+
print "text color:",show_color(item.get_text_colour),"\n"
|
54
|
+
print "BG color: ",show_color(item.get_background_colour),"\n"
|
55
|
+
print "font: ",show_font(item.get_font),"\n\n"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def show_color(color)
|
61
|
+
if color.is_ok
|
62
|
+
return '(%i, %i, %i)' % [color.red, color.green, color.blue]
|
63
|
+
else
|
64
|
+
return '(N/A)'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def show_font(font)
|
69
|
+
if font.get_style == Wx::ITALIC
|
70
|
+
return "Italic"
|
71
|
+
end
|
72
|
+
return "Normal"
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
class RbApp < Wx::App
|
78
|
+
def on_init
|
79
|
+
frame = ListctrlFrame.new("Listctrl test",Wx::Point.new(50, 50), Wx::Size.new(450, 340))
|
80
|
+
|
81
|
+
frame.show(true)
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
a = RbApp.new
|
87
|
+
a.main_loop()
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * choice_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #c0c0c0",
|
9
|
+
"@ c #808080",
|
10
|
+
"# c #ffffff",
|
11
|
+
/* pixels */
|
12
|
+
"@@@@@@@@@@@@@@@@",
|
13
|
+
"@..............@",
|
14
|
+
"@.########+++++@",
|
15
|
+
"@.########.....@",
|
16
|
+
"@.########+...+@",
|
17
|
+
"@.########++.++@",
|
18
|
+
"@.+++++++++++++@",
|
19
|
+
"@@@@@@@@@@@@@@@@",
|
20
|
+
" ##############",
|
21
|
+
" ..............",
|
22
|
+
" .#########+.+.",
|
23
|
+
" .#########....",
|
24
|
+
" .#########+++.",
|
25
|
+
" .#########....",
|
26
|
+
" .#########+.+.",
|
27
|
+
" .............."};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * combo_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #c0c0c0",
|
9
|
+
"@ c #808080",
|
10
|
+
"# c #ffffff",
|
11
|
+
/* pixels */
|
12
|
+
"@@@@@@@@@@@@@@@@",
|
13
|
+
"@..............@",
|
14
|
+
"@....#####+++++@",
|
15
|
+
"@.#.######.....@",
|
16
|
+
"@.#.######+...+@",
|
17
|
+
"@....#####++.++@",
|
18
|
+
"@.+++++++++++++@",
|
19
|
+
"@@@@@@@@@@@@@@@@",
|
20
|
+
" ##############",
|
21
|
+
" ..............",
|
22
|
+
" .#########+.+.",
|
23
|
+
" .#########....",
|
24
|
+
" .#########+++.",
|
25
|
+
" .#########....",
|
26
|
+
" .#########+.+.",
|
27
|
+
" .............."};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * gauge_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #000080",
|
9
|
+
"@ c #c0c0c0",
|
10
|
+
"# c #808080",
|
11
|
+
/* pixels */
|
12
|
+
" ",
|
13
|
+
" ",
|
14
|
+
" ",
|
15
|
+
"################",
|
16
|
+
"#..............#",
|
17
|
+
"#.++++++++@@@@@#",
|
18
|
+
"#.++++++++@@@@@#",
|
19
|
+
"#.++++++++@@@@@#",
|
20
|
+
"#.++++++++@@@@@#",
|
21
|
+
"#.++++++++@@@@@#",
|
22
|
+
"#.++++++++@@@@@#",
|
23
|
+
"#.++++++++@@@@@#",
|
24
|
+
"################",
|
25
|
+
" ",
|
26
|
+
" ",
|
27
|
+
" "};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * list_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #c0c0c0",
|
9
|
+
"@ c #808080",
|
10
|
+
"# c #ffffff",
|
11
|
+
/* pixels */
|
12
|
+
"@@@@@@@@@@@@@@@@",
|
13
|
+
"@..............@",
|
14
|
+
"@.##########+++@",
|
15
|
+
"@.##########+.+@",
|
16
|
+
"@.++++++++++...@",
|
17
|
+
"@.##########+++@",
|
18
|
+
"@.##########+++@",
|
19
|
+
"@.+++++++++++++@",
|
20
|
+
"@.##########+++@",
|
21
|
+
"@.##########+++@",
|
22
|
+
"@.+++++++++++++@",
|
23
|
+
"@.##########+++@",
|
24
|
+
"@.##########...@",
|
25
|
+
"@.##########+.+@",
|
26
|
+
"@.+++++++++++++@",
|
27
|
+
"@@@@@@@@@@@@@@@@"};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * radio_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #c0c0c0",
|
9
|
+
"@ c #808080",
|
10
|
+
"# c #ffffff",
|
11
|
+
/* pixels */
|
12
|
+
" . ",
|
13
|
+
" .. .. ",
|
14
|
+
"+++.+.++...++++.",
|
15
|
+
"+@.@...@@..@@@@.",
|
16
|
+
"+@.+++.+....++@.",
|
17
|
+
"+@++++++++++++@.",
|
18
|
+
"+@++++++++++++@.",
|
19
|
+
"+@++++...+++++@.",
|
20
|
+
"+@+++.###@++++@.",
|
21
|
+
"+@+++.#.#@++++@.",
|
22
|
+
"+@+++.###@++++@.",
|
23
|
+
"+@++++@@@+++++@.",
|
24
|
+
"+@++++++++++++@.",
|
25
|
+
"+@++++++++++++@.",
|
26
|
+
"+@@@@@@@@@@@@@@.",
|
27
|
+
"................"};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * stattext_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 2 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
/* pixels */
|
9
|
+
" ",
|
10
|
+
" ",
|
11
|
+
" ",
|
12
|
+
" .. ",
|
13
|
+
" .. ",
|
14
|
+
" .... ",
|
15
|
+
" .... .... ",
|
16
|
+
" . . .. .. ",
|
17
|
+
" .. .. .... ",
|
18
|
+
" .. .. .. .. ",
|
19
|
+
" ...... .. .. ",
|
20
|
+
".. .. .. .. ",
|
21
|
+
".. .. ..... ",
|
22
|
+
" ",
|
23
|
+
" ",
|
24
|
+
" "};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char * text_xpm[] = {
|
3
|
+
/* width height ncolors chars_per_pixel */
|
4
|
+
"16 16 5 1",
|
5
|
+
/* colors */
|
6
|
+
" s None c None",
|
7
|
+
". c #000000",
|
8
|
+
"+ c #c0c0c0",
|
9
|
+
"@ c #808080",
|
10
|
+
"# c #ffffff",
|
11
|
+
/* pixels */
|
12
|
+
" ",
|
13
|
+
" ",
|
14
|
+
" ",
|
15
|
+
"@@@@@@@@@@@@@@@@",
|
16
|
+
"@..............@",
|
17
|
+
"@.############+@",
|
18
|
+
"@.#...########+@",
|
19
|
+
"@.##.#########+@",
|
20
|
+
"@.##.#########+@",
|
21
|
+
"@.#...########+@",
|
22
|
+
"@.############+@",
|
23
|
+
"@.+++++++++++++@",
|
24
|
+
"@@@@@@@@@@@@@@@@",
|
25
|
+
" ",
|
26
|
+
" ",
|
27
|
+
" "};
|
Binary file
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char *mondrian_xpm[] = {
|
3
|
+
/* columns rows colors chars-per-pixel */
|
4
|
+
"32 32 6 1",
|
5
|
+
" c Black",
|
6
|
+
". c Blue",
|
7
|
+
"X c #00bf00",
|
8
|
+
"o c Red",
|
9
|
+
"O c Yellow",
|
10
|
+
"+ c Gray100",
|
11
|
+
/* pixels */
|
12
|
+
" ",
|
13
|
+
" oooooo +++++++++++++++++++++++ ",
|
14
|
+
" oooooo +++++++++++++++++++++++ ",
|
15
|
+
" oooooo +++++++++++++++++++++++ ",
|
16
|
+
" oooooo +++++++++++++++++++++++ ",
|
17
|
+
" oooooo +++++++++++++++++++++++ ",
|
18
|
+
" oooooo +++++++++++++++++++++++ ",
|
19
|
+
" oooooo +++++++++++++++++++++++ ",
|
20
|
+
" ",
|
21
|
+
" ++++++ ++++++++++++++++++ .... ",
|
22
|
+
" ++++++ ++++++++++++++++++ .... ",
|
23
|
+
" ++++++ ++++++++++++++++++ .... ",
|
24
|
+
" ++++++ ++++++++++++++++++ .... ",
|
25
|
+
" ++++++ ++++++++++++++++++ .... ",
|
26
|
+
" ++++++ ++++++++++++++++++ ",
|
27
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
28
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
29
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
30
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
31
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
32
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
33
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
34
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
35
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
36
|
+
" ++++++ ++++ ",
|
37
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
38
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
39
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
40
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
41
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
42
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
43
|
+
" "
|
44
|
+
};
|
Binary file
|
@@ -0,0 +1,797 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
|
11
|
+
require 'wx'
|
12
|
+
|
13
|
+
|
14
|
+
include Wx
|
15
|
+
|
16
|
+
DIALOGS_CHOOSE_COLOUR = 1
|
17
|
+
DIALOGS_CHOOSE_COLOUR_GENERIC = 2
|
18
|
+
DIALOGS_CHOOSE_FONT = 3
|
19
|
+
DIALOGS_CHOOSE_FONT_GENERIC = 4
|
20
|
+
DIALOGS_MESSAGE_BOX = 5
|
21
|
+
DIALOGS_SINGLE_CHOICE = 6
|
22
|
+
DIALOGS_MULTI_CHOICE = 7
|
23
|
+
DIALOGS_TEXT_ENTRY = 8
|
24
|
+
DIALOGS_PASSWORD_ENTRY = 9
|
25
|
+
DIALOGS_FILE_OPEN = 10
|
26
|
+
DIALOGS_FILE_OPEN2 = 11
|
27
|
+
DIALOGS_FILES_OPEN = 12
|
28
|
+
DIALOGS_FILE_SAVE = 13
|
29
|
+
DIALOGS_DIR_CHOOSE = 14
|
30
|
+
DIALOGS_GENERIC_DIR_CHOOSE = 15
|
31
|
+
DIALOGS_TIP = 16
|
32
|
+
DIALOGS_NUM_ENTRY = 17
|
33
|
+
DIALOGS_LOG_DIALOG = 18
|
34
|
+
DIALOGS_MODAL = 19
|
35
|
+
DIALOGS_MODELESS = 20
|
36
|
+
DIALOGS_MODELESS_BTN = 21
|
37
|
+
DIALOGS_PROGRESS = 22
|
38
|
+
DIALOGS_BUSYINFO = 23
|
39
|
+
DIALOGS_FIND = 24
|
40
|
+
DIALOGS_REPLACE = 25
|
41
|
+
DIALOGS_PREFS = 26
|
42
|
+
|
43
|
+
$my_canvas = nil
|
44
|
+
|
45
|
+
class MyModalDialog < Dialog
|
46
|
+
def initialize(parent)
|
47
|
+
super(parent, -1, "Modal dialog")
|
48
|
+
|
49
|
+
sizer_top = BoxSizer.new(HORIZONTAL)
|
50
|
+
|
51
|
+
@btn_focused = Button.new(self, -1, "Default button")
|
52
|
+
@btn_delete = Button.new(self, -1, "&Delete button")
|
53
|
+
btn_ok = Button.new(self, ID_CANCEL, "&Close")
|
54
|
+
sizer_top.add(@btn_focused, 0, ALIGN_CENTER | ALL, 5)
|
55
|
+
sizer_top.add(@btn_delete, 0, ALIGN_CENTER | ALL, 5)
|
56
|
+
sizer_top.add(btn_ok, 0, ALIGN_CENTER | ALL, 5)
|
57
|
+
|
58
|
+
set_auto_layout(true)
|
59
|
+
set_sizer(sizer_top)
|
60
|
+
|
61
|
+
sizer_top.set_size_hints(self)
|
62
|
+
sizer_top.fit(self)
|
63
|
+
|
64
|
+
@btn_focused.set_focus()
|
65
|
+
@btn_focused.set_default()
|
66
|
+
|
67
|
+
evt_button(-1) {|event| on_button(event) }
|
68
|
+
end
|
69
|
+
|
70
|
+
def on_button(event)
|
71
|
+
id = event.get_id
|
72
|
+
|
73
|
+
if id == @btn_delete.get_id
|
74
|
+
@btn_focused.destroy
|
75
|
+
@btn_focused = nil
|
76
|
+
|
77
|
+
@btn_delete.disable()
|
78
|
+
elsif @btn_focused && id == @btn_focused.get_id
|
79
|
+
get_text_from_user("Dummy prompt", "Modal dialog called from dialog",
|
80
|
+
"", self)
|
81
|
+
else
|
82
|
+
event.skip()
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
class MyModelessDialog < Dialog
|
89
|
+
def initialize(parent)
|
90
|
+
super(parent, -1, "Modeless dialog")
|
91
|
+
|
92
|
+
sizer_top = BoxSizer.new(VERTICAL)
|
93
|
+
|
94
|
+
btn = Button.new(self, DIALOGS_MODELESS_BTN, "Press me")
|
95
|
+
check = CheckBox.new(self, -1, "Should be disabled")
|
96
|
+
check.disable()
|
97
|
+
|
98
|
+
sizer_top.add(btn, 1, EXPAND | ALL, 5)
|
99
|
+
sizer_top.add(check, 1, EXPAND | ALL, 5)
|
100
|
+
|
101
|
+
set_auto_layout(true)
|
102
|
+
set_sizer(sizer_top)
|
103
|
+
|
104
|
+
sizer_top.set_size_hints(self)
|
105
|
+
sizer_top.fit(self)
|
106
|
+
|
107
|
+
evt_button(DIALOGS_MODELESS_BTN) {|event| on_button(event) }
|
108
|
+
|
109
|
+
evt_close() {|event| on_close(event) }
|
110
|
+
|
111
|
+
end
|
112
|
+
|
113
|
+
def on_button(event)
|
114
|
+
message_box("Button pressed in modeless dialog", "Info",
|
115
|
+
OK | ICON_INFORMATION, self)
|
116
|
+
end
|
117
|
+
|
118
|
+
def on_close(event)
|
119
|
+
if event.can_veto()
|
120
|
+
message_box("Use the menu item to close self dialog",
|
121
|
+
"Modeless dialog",
|
122
|
+
OK | ICON_INFORMATION, self)
|
123
|
+
|
124
|
+
event.veto()
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# PropertySheetDialog is specialised for doing preferences dialogs; it
|
130
|
+
# contains a BookCtrl of some sort
|
131
|
+
class MyPrefsDialog < Wx::PropertySheetDialog
|
132
|
+
def initialize(parent)
|
133
|
+
# Using Book type other than Notebook needs two-step construction
|
134
|
+
super()
|
135
|
+
self.sheet_style = Wx::PROPSHEET_BUTTONTOOLBOOK
|
136
|
+
self.sheet_outer_border = 1
|
137
|
+
self.sheet_inner_border = 2
|
138
|
+
img_list = Wx::ImageList.new(32, 32)
|
139
|
+
img_list << std_bitmap(Wx::ART_NORMAL_FILE)
|
140
|
+
img_list << std_bitmap(Wx::ART_CDROM)
|
141
|
+
img_list << std_bitmap(Wx::ART_REPORT_VIEW)
|
142
|
+
|
143
|
+
create(parent, -1, "Preferences")
|
144
|
+
create_buttons(Wx::ID_OK|Wx::ID_CANCEL)
|
145
|
+
book_ctrl.image_list = img_list
|
146
|
+
book_ctrl.add_page(file_panel(book_ctrl), "File", false, 0)
|
147
|
+
book_ctrl.add_page(cdrom_panel(book_ctrl), "CD ROM", false, 1)
|
148
|
+
|
149
|
+
layout_dialog
|
150
|
+
end
|
151
|
+
|
152
|
+
# Gets one of the rather ugly standard bitmaps from ArtProvider
|
153
|
+
def std_bitmap(art_id)
|
154
|
+
Wx::ArtProvider.bitmap(art_id, Wx::ART_TOOLBAR, [32, 32])
|
155
|
+
end
|
156
|
+
|
157
|
+
def file_panel(book)
|
158
|
+
panel = Wx::Panel.new(book)
|
159
|
+
panel.sizer = Wx::VBoxSizer.new
|
160
|
+
|
161
|
+
cb1 = Wx::CheckBox.new(panel, :label => 'Show hidden files')
|
162
|
+
panel.sizer.add(cb1, 0, Wx::ALL, 5)
|
163
|
+
|
164
|
+
cb2 = Wx::CheckBox.new(panel, :label => 'Always show extensions')
|
165
|
+
panel.sizer.add(cb2, 0, Wx::ALL, 5)
|
166
|
+
|
167
|
+
cb3 = Wx::CheckBox.new(panel, :label => 'Show icons')
|
168
|
+
panel.sizer.add(cb3, 0, Wx::ALL, 5)
|
169
|
+
|
170
|
+
cb4 = Wx::CheckBox.new(panel, :label => 'Show owner')
|
171
|
+
panel.sizer.add(cb4, 0, Wx::ALL, 5)
|
172
|
+
|
173
|
+
st = Wx::StaticText.new(panel, :label => "Sort by:")
|
174
|
+
panel.sizer.add(st, 0, Wx::ALL, 5)
|
175
|
+
|
176
|
+
cb1 = Wx::Choice.new(panel, :choices => %w|Name Created Modified Size|)
|
177
|
+
panel.sizer.add(cb1, 0, Wx::ALL, 5)
|
178
|
+
panel
|
179
|
+
end
|
180
|
+
|
181
|
+
def cdrom_panel(book)
|
182
|
+
panel = Wx::Panel.new(book)
|
183
|
+
panel.sizer = Wx::VBoxSizer.new
|
184
|
+
|
185
|
+
choices = [ 'Show files', 'Play media', 'Run CD', 'Do nothing' ]
|
186
|
+
rb = Wx::RadioBox.new( panel,
|
187
|
+
:label => 'When opening CD',
|
188
|
+
:choices => choices,
|
189
|
+
:major_dimension => 1)
|
190
|
+
panel.sizer.add(rb, 0, Wx::GROW|Wx::ALL, 5)
|
191
|
+
panel
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
class MyCanvas < ScrolledWindow
|
196
|
+
def initialize(parent)
|
197
|
+
super(parent,-1,DEFAULT_POSITION,DEFAULT_SIZE, NO_FULL_REPAINT_ON_RESIZE)
|
198
|
+
evt_paint { |event| on_paint(event) }
|
199
|
+
end
|
200
|
+
|
201
|
+
def clear
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
def on_paint(event)
|
206
|
+
paint do |dc|
|
207
|
+
dc.set_text_foreground( get_app.canvas_text_colour )
|
208
|
+
dc.set_font( get_app.canvas_font )
|
209
|
+
dc.draw_text("Windows common dialogs test application", 10, 10)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
class MyFrame < Frame
|
215
|
+
def initialize(parent,
|
216
|
+
title,
|
217
|
+
pos,
|
218
|
+
size)
|
219
|
+
super(parent, -1, title, pos, size)
|
220
|
+
|
221
|
+
@dialog = nil
|
222
|
+
|
223
|
+
@dlg_find = nil
|
224
|
+
@dlg_replace = nil
|
225
|
+
|
226
|
+
@find_data = FindReplaceData.new
|
227
|
+
|
228
|
+
@ext_def = ""
|
229
|
+
@index = -1
|
230
|
+
|
231
|
+
@max = 10
|
232
|
+
|
233
|
+
create_status_bar()
|
234
|
+
|
235
|
+
evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) }
|
236
|
+
evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) }
|
237
|
+
evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) }
|
238
|
+
evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) }
|
239
|
+
evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) }
|
240
|
+
evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) }
|
241
|
+
evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) }
|
242
|
+
evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) }
|
243
|
+
evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) }
|
244
|
+
evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) }
|
245
|
+
evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) }
|
246
|
+
evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) }
|
247
|
+
evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) }
|
248
|
+
evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) }
|
249
|
+
evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
|
250
|
+
evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) }
|
251
|
+
evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) }
|
252
|
+
evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) }
|
253
|
+
evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) }
|
254
|
+
evt_menu(DIALOGS_PREFS) {|event| on_show_prefs(event) }
|
255
|
+
evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) }
|
256
|
+
evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) }
|
257
|
+
evt_find(-1) {|event| on_find_dialog(event) }
|
258
|
+
evt_find_next(-1) {|event| on_find_dialog(event) }
|
259
|
+
evt_find_replace(-1) {|event| on_find_dialog(event) }
|
260
|
+
evt_find_replace_all(-1) {|event| on_find_dialog(event) }
|
261
|
+
evt_find_close(-1) {|event| on_find_dialog(event) }
|
262
|
+
evt_menu(ID_EXIT) {|event| on_exit(event) }
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
def on_choose_colour(event)
|
267
|
+
|
268
|
+
col = $my_canvas.get_background_colour()
|
269
|
+
|
270
|
+
data = ColourData.new
|
271
|
+
data.set_colour(col)
|
272
|
+
data.set_choose_full(true)
|
273
|
+
for i in 0 ... 16
|
274
|
+
colour = Colour.new(i*16, i*16, i*16)
|
275
|
+
data.set_custom_colour(i, colour)
|
276
|
+
end
|
277
|
+
|
278
|
+
dialog = ColourDialog.new(self, data)
|
279
|
+
dialog.set_title("Choose the background colour (not OS X)")
|
280
|
+
if dialog.show_modal() == ID_OK
|
281
|
+
retData = dialog.get_colour_data()
|
282
|
+
col = retData.get_colour()
|
283
|
+
$my_canvas.set_background_colour(col)
|
284
|
+
#$my_canvas.clear()
|
285
|
+
$my_canvas.refresh()
|
286
|
+
end
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
def on_choose_font(event)
|
291
|
+
data = FontData.new
|
292
|
+
data.set_initial_font(Wx::get_app.canvas_font)
|
293
|
+
data.set_colour(Wx::get_app.canvas_text_colour)
|
294
|
+
|
295
|
+
dialog = FontDialog.new(self, data)
|
296
|
+
|
297
|
+
if dialog.show_modal() == ID_OK
|
298
|
+
ret_data = dialog.get_font_data()
|
299
|
+
Wx::get_app.canvas_font = ret_data.get_chosen_font()
|
300
|
+
Wx::get_app.canvas_text_colour = ret_data.get_colour()
|
301
|
+
font = ret_data.get_chosen_font
|
302
|
+
msg = "Font = %s, %i pt" % [ font.get_face_name,
|
303
|
+
font.get_point_size ]
|
304
|
+
dialog2 = MessageDialog.new(self, msg, "Got font")
|
305
|
+
dialog2.show_modal()
|
306
|
+
# $my_canvas.refresh()
|
307
|
+
end
|
308
|
+
#else: cancelled by the user, don't change the font
|
309
|
+
end
|
310
|
+
|
311
|
+
|
312
|
+
def on_log_dialog(event)
|
313
|
+
|
314
|
+
# calling yield() (as ~BusyCursor does) shouldn't result in messages
|
315
|
+
# being flushed -- test it
|
316
|
+
|
317
|
+
BusyCursor.busy() do
|
318
|
+
|
319
|
+
log_message("This is some message - everything is ok so far.")
|
320
|
+
log_message("Another message...\n... self one is on multiple lines")
|
321
|
+
log_warning("And then something went wrong!")
|
322
|
+
|
323
|
+
# and if ~BusyCursor doesn't do it, then call it manually
|
324
|
+
Wx::get_app.yield()
|
325
|
+
|
326
|
+
log_error("Intermediary error handler decided to abort.")
|
327
|
+
log_error("DEMO: The top level caller detected an unrecoverable error.")
|
328
|
+
|
329
|
+
Log::flush_active()
|
330
|
+
|
331
|
+
log_message("And this is the same dialog but with only one message.")
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
def on_message_box(event)
|
336
|
+
|
337
|
+
dialog = MessageDialog.new(nil, "This is a message box\nA long, long string to test out the message box properly",
|
338
|
+
"Message box text", NO_DEFAULT|YES_NO|CANCEL|ICON_INFORMATION)
|
339
|
+
|
340
|
+
case dialog.show_modal()
|
341
|
+
when ID_YES
|
342
|
+
log_status("You pressed \"Yes\"")
|
343
|
+
when ID_NO
|
344
|
+
log_status("You pressed \"No\"")
|
345
|
+
when ID_CANCEL
|
346
|
+
log_status("You pressed \"Cancel\"")
|
347
|
+
else
|
348
|
+
log_error("Unexpected MessageDialog return code!")
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
|
353
|
+
def on_numeric_entry(event)
|
354
|
+
|
355
|
+
res = get_number_from_user( "This is some text, actually a lot of text.\n" +
|
356
|
+
"Even two rows of text.",
|
357
|
+
"Enter a number:", "Numeric input test",
|
358
|
+
50, 0, 100, self )
|
359
|
+
|
360
|
+
if res == -1
|
361
|
+
msg = "Invalid number entered or dialog cancelled."
|
362
|
+
icon = ICON_HAND
|
363
|
+
else
|
364
|
+
msg = sprintf("You've entered %d", res )
|
365
|
+
icon = ICON_INFORMATION
|
366
|
+
end
|
367
|
+
|
368
|
+
message_box(msg, "Numeric test result", OK | icon, self)
|
369
|
+
end
|
370
|
+
|
371
|
+
def on_password_entry(event)
|
372
|
+
|
373
|
+
pwd = get_password_from_user("Enter password:",
|
374
|
+
"Password entry dialog",
|
375
|
+
"", self)
|
376
|
+
if pwd
|
377
|
+
message_box(sprintf("Your password is '%s'", pwd),
|
378
|
+
"Got password", OK | ICON_INFORMATION, self)
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
|
383
|
+
def on_text_entry(event)
|
384
|
+
|
385
|
+
dialog = TextEntryDialog.new(self,
|
386
|
+
"This is a small sample\n" +
|
387
|
+
"A long, long string to test out the text entrybox",
|
388
|
+
"Please enter a string",
|
389
|
+
"Default value",
|
390
|
+
OK | CANCEL)
|
391
|
+
|
392
|
+
if dialog.show_modal() == ID_OK
|
393
|
+
dialog2 = MessageDialog.new(self, dialog.get_value(), "Got string")
|
394
|
+
dialog2.show_modal()
|
395
|
+
end
|
396
|
+
end
|
397
|
+
|
398
|
+
def on_single_choice(event)
|
399
|
+
|
400
|
+
choices = ["One", "Two", "Three", "Four", "Five"]
|
401
|
+
|
402
|
+
dialog = SingleChoiceDialog.new(self,
|
403
|
+
"This is a small sample\n" +
|
404
|
+
"A single-choice convenience dialog",
|
405
|
+
"Please select a value",
|
406
|
+
choices, nil, OK | CANCEL)
|
407
|
+
|
408
|
+
dialog.set_selection(2)
|
409
|
+
|
410
|
+
if dialog.show_modal() == ID_OK
|
411
|
+
dialog2 = MessageDialog.new(self, dialog.get_string_selection(), "Got string")
|
412
|
+
dialog2.show_modal()
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
|
417
|
+
def on_multi_choice(event)
|
418
|
+
|
419
|
+
choices = [
|
420
|
+
"One", "Two", "Three", "Four", "Five",
|
421
|
+
"Six", "Seven", "Eight", "Nine", "Ten",
|
422
|
+
"Eleven", "Twelve", "Seventeen"]
|
423
|
+
|
424
|
+
selections = get_multiple_choices("This is a small sample\n" +
|
425
|
+
"A multi-choice convenience dialog",
|
426
|
+
"Please select a value",
|
427
|
+
choices,
|
428
|
+
self)
|
429
|
+
if selections
|
430
|
+
msg = sprintf("You selected %d items:\n", selections.length)
|
431
|
+
for n in 0 ... selections.length
|
432
|
+
msg += sprintf("\t%d: %d (%s)\n", n, selections[n],
|
433
|
+
choices[selections[n]])
|
434
|
+
end
|
435
|
+
log_message(msg)
|
436
|
+
end
|
437
|
+
#else: cancelled or nothing selected
|
438
|
+
end
|
439
|
+
|
440
|
+
|
441
|
+
def on_file_open(event)
|
442
|
+
|
443
|
+
dialog = FileDialog.new(
|
444
|
+
self,
|
445
|
+
"Testing open file dialog",
|
446
|
+
"",
|
447
|
+
"",
|
448
|
+
"C++ files (*.h;*.cpp)|*.h;*.cpp"
|
449
|
+
)
|
450
|
+
|
451
|
+
dialog.set_directory(get_home_dir())
|
452
|
+
|
453
|
+
if dialog.show_modal() == ID_OK
|
454
|
+
info = sprintf("Full file name: %s\n" +
|
455
|
+
"Path: %s\n" +
|
456
|
+
"Name: %s",
|
457
|
+
dialog.get_path(),
|
458
|
+
dialog.get_directory(),
|
459
|
+
dialog.get_filename())
|
460
|
+
dialog2 = MessageDialog.new(self, info, "Selected file")
|
461
|
+
dialog2.show_modal()
|
462
|
+
end
|
463
|
+
end
|
464
|
+
|
465
|
+
|
466
|
+
# this shows how to take advantage of specifying a default extension in the
|
467
|
+
# call to FileSelector: it is remembered after each new call and the next
|
468
|
+
# one will use it by default
|
469
|
+
def on_file_open2(event)
|
470
|
+
|
471
|
+
path = file_selector(
|
472
|
+
"Select the file to load",
|
473
|
+
"", "",
|
474
|
+
@ext_def,
|
475
|
+
"Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*",
|
476
|
+
CHANGE_DIR,
|
477
|
+
self
|
478
|
+
)
|
479
|
+
|
480
|
+
if path == nil
|
481
|
+
return nil
|
482
|
+
end
|
483
|
+
|
484
|
+
# it is just a sample, would use SplitPath in real program
|
485
|
+
@ext_def = path[/[^\.]*$/]
|
486
|
+
|
487
|
+
log_message("You selected the file '%s', remembered extension '%s'",
|
488
|
+
path, @ext_def)
|
489
|
+
end
|
490
|
+
|
491
|
+
|
492
|
+
def on_files_open(event)
|
493
|
+
|
494
|
+
dialog = FileDialog.new(self, "Testing open multiple file dialog",
|
495
|
+
"", "", FILE_SELECTOR_DEFAULT_WILDCARD_STR,
|
496
|
+
MULTIPLE)
|
497
|
+
|
498
|
+
if dialog.show_modal() == ID_OK
|
499
|
+
|
500
|
+
paths = dialog.get_paths()
|
501
|
+
filenames = dialog.get_filenames()
|
502
|
+
|
503
|
+
count = paths.length
|
504
|
+
msg = ""
|
505
|
+
for n in 0 ... count
|
506
|
+
s = sprintf("File %d: %s (%s)\n",
|
507
|
+
n, paths[n], filenames[n])
|
508
|
+
msg += s
|
509
|
+
end
|
510
|
+
|
511
|
+
dialog2 = MessageDialog.new(self, msg, "Selected files")
|
512
|
+
dialog2.show_modal()
|
513
|
+
end
|
514
|
+
end
|
515
|
+
|
516
|
+
|
517
|
+
def on_file_save(event)
|
518
|
+
|
519
|
+
dialog = FileDialog.new(self,
|
520
|
+
"Testing save file dialog",
|
521
|
+
"",
|
522
|
+
"myletter.doc",
|
523
|
+
"Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
|
524
|
+
SAVE|OVERWRITE_PROMPT)
|
525
|
+
|
526
|
+
dialog.set_filter_index(1)
|
527
|
+
|
528
|
+
if dialog.show_modal() == ID_OK
|
529
|
+
|
530
|
+
log_message("%s, filter %d",
|
531
|
+
dialog.get_path(), dialog.get_filter_index())
|
532
|
+
end
|
533
|
+
end
|
534
|
+
|
535
|
+
def on_dir_choose(event)
|
536
|
+
|
537
|
+
# pass some initial dir to DirDialog
|
538
|
+
dir_home = get_home_dir()
|
539
|
+
|
540
|
+
dialog = DirDialog.new(self, "Testing directory picker", dir_home)
|
541
|
+
|
542
|
+
if dialog.show_modal() == ID_OK
|
543
|
+
log_message("Selected path: %s", dialog.get_path())
|
544
|
+
end
|
545
|
+
end
|
546
|
+
|
547
|
+
|
548
|
+
def on_modal_dlg(event)
|
549
|
+
dlg = MyModalDialog.new(self)
|
550
|
+
dlg.show_modal()
|
551
|
+
end
|
552
|
+
|
553
|
+
def on_modeless_dlg(event)
|
554
|
+
show = get_menu_bar().is_checked(event.get_id())
|
555
|
+
if show
|
556
|
+
if !@dialog
|
557
|
+
@dialog = MyModelessDialog.new(self)
|
558
|
+
end
|
559
|
+
@dialog.show(true)
|
560
|
+
else # hide
|
561
|
+
@dialog.hide()
|
562
|
+
end
|
563
|
+
end
|
564
|
+
|
565
|
+
|
566
|
+
def on_show_tip(event)
|
567
|
+
|
568
|
+
if @index == -1
|
569
|
+
@index = rand(5)
|
570
|
+
end
|
571
|
+
|
572
|
+
tip_src = File.join( File.dirname(__FILE__), 'tips.txt')
|
573
|
+
tip_provider = create_file_tip_provider(tip_src, @index)
|
574
|
+
|
575
|
+
show_at_startup = show_tip(self, tip_provider)
|
576
|
+
|
577
|
+
if show_at_startup
|
578
|
+
message_box("Will show tips on startup", "Tips dialog",
|
579
|
+
OK | ICON_INFORMATION, self)
|
580
|
+
end
|
581
|
+
|
582
|
+
@index = tip_provider.get_current_tip()
|
583
|
+
|
584
|
+
end
|
585
|
+
|
586
|
+
def on_exit(event)
|
587
|
+
close(true)
|
588
|
+
end
|
589
|
+
|
590
|
+
|
591
|
+
def on_show_prefs(event)
|
592
|
+
dialog = MyPrefsDialog.new(self)
|
593
|
+
dialog.show_modal
|
594
|
+
end
|
595
|
+
|
596
|
+
def on_show_progress(event)
|
597
|
+
|
598
|
+
dialog = ProgressDialog.new("Progress dialog example",
|
599
|
+
"An informative message",
|
600
|
+
@max, # range
|
601
|
+
self, # parent
|
602
|
+
PD_CAN_ABORT|PD_APP_MODAL|
|
603
|
+
PD_ELAPSED_TIME|PD_ESTIMATED_TIME|
|
604
|
+
PD_REMAINING_TIME)
|
605
|
+
|
606
|
+
cont = true
|
607
|
+
for i in 0 .. @max
|
608
|
+
sleep(1)
|
609
|
+
if i == @max
|
610
|
+
cont = dialog.update(i, "That's all, folks!")
|
611
|
+
elsif i == @max / 2
|
612
|
+
cont = dialog.update(i, "Only a half left (very long message)!")
|
613
|
+
else
|
614
|
+
cont = dialog.update(i)
|
615
|
+
end
|
616
|
+
|
617
|
+
if !cont
|
618
|
+
if message_box("Do you really want to cancel?",
|
619
|
+
"Progress dialog question", # caption
|
620
|
+
YES_NO | ICON_QUESTION) == YES
|
621
|
+
dialog.end_modal(ID_CANCEL)
|
622
|
+
break
|
623
|
+
end
|
624
|
+
dialog.resume()
|
625
|
+
end
|
626
|
+
end
|
627
|
+
|
628
|
+
|
629
|
+
if !cont
|
630
|
+
log_status("Progress dialog aborted!")
|
631
|
+
else
|
632
|
+
log_status("Countdown from %d finished", @max)
|
633
|
+
end
|
634
|
+
end
|
635
|
+
|
636
|
+
def on_show_busy_info(event)
|
637
|
+
WindowDisabler.disable(self) do
|
638
|
+
info = BusyInfo.busy("Working, please wait...", self) do
|
639
|
+
|
640
|
+
for i in 0 ... 18
|
641
|
+
Wx::get_app.yield()
|
642
|
+
end
|
643
|
+
sleep(2)
|
644
|
+
end
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
def on_show_replace_dialog(event)
|
649
|
+
|
650
|
+
if @dlg_replace
|
651
|
+
#@dlg_replace.destroy
|
652
|
+
@dlg_replace = nil
|
653
|
+
else
|
654
|
+
@dlg_replace = FindReplaceDialog.new(
|
655
|
+
self,
|
656
|
+
@find_data,
|
657
|
+
"Find and replace dialog",
|
658
|
+
FR_REPLACEDIALOG
|
659
|
+
)
|
660
|
+
|
661
|
+
@dlg_replace.show(true)
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
def on_show_find_dialog(event)
|
666
|
+
|
667
|
+
if @dlg_find
|
668
|
+
@dlg_find.destroy
|
669
|
+
@dlg_find = nil
|
670
|
+
else
|
671
|
+
@dlg_find = FindReplaceDialog.new(
|
672
|
+
self,
|
673
|
+
@find_data,
|
674
|
+
"Find dialog", # just for testing
|
675
|
+
FR_NOWHOLEWORD
|
676
|
+
)
|
677
|
+
|
678
|
+
@dlg_find.show(true)
|
679
|
+
end
|
680
|
+
end
|
681
|
+
|
682
|
+
def decode_find_dialog_event_flags(flags)
|
683
|
+
str = ""
|
684
|
+
str << ((flags & FR_DOWN) != 0 ? "down" : "up") << ", " \
|
685
|
+
<< ((flags & FR_WHOLEWORD) != 0 ? "whole words only, " : "") \
|
686
|
+
<< ((flags & FR_MATCHCASE) != 0 ? "" : "not ") \
|
687
|
+
<< "case sensitive"
|
688
|
+
|
689
|
+
return str
|
690
|
+
end
|
691
|
+
|
692
|
+
def on_find_dialog(event)
|
693
|
+
|
694
|
+
type = event.get_event_type()
|
695
|
+
|
696
|
+
if type == EVT_COMMAND_FIND || type == EVT_COMMAND_FIND_NEXT
|
697
|
+
log_message("Find %s'%s' (flags: %s)",
|
698
|
+
type == EVT_COMMAND_FIND_NEXT ? "next " : "",
|
699
|
+
event.get_find_string(),
|
700
|
+
decode_find_dialog_event_flags(event.get_flags()))
|
701
|
+
elsif type == EVT_COMMAND_FIND_REPLACE || type == EVT_COMMAND_FIND_REPLACE_ALL
|
702
|
+
log_message("Replace %s'%s' with '%s' (flags: %s)",
|
703
|
+
type == EVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
|
704
|
+
event.get_find_string(),
|
705
|
+
event.get_replace_string(),
|
706
|
+
decode_find_dialog_event_flags(event.get_flags()))
|
707
|
+
elsif type == EVT_COMMAND_FIND_CLOSE
|
708
|
+
dlg = event.get_dialog()
|
709
|
+
if dlg == @dlg_find
|
710
|
+
txt = "Find"
|
711
|
+
id_menu = DIALOGS_FIND
|
712
|
+
@dlg_find = nil
|
713
|
+
elsif dlg == @dlg_replace
|
714
|
+
txt = "Replace"
|
715
|
+
id_menu = DIALOGS_REPLACE
|
716
|
+
@dlg_replace = nil
|
717
|
+
else
|
718
|
+
txt = "Unknown"
|
719
|
+
id_menu = -1
|
720
|
+
log_error("unexpected event")
|
721
|
+
end
|
722
|
+
|
723
|
+
log_message("%s dialog is being closed.", txt)
|
724
|
+
|
725
|
+
if id_menu != -1
|
726
|
+
get_menu_bar().check(id_menu, false)
|
727
|
+
end
|
728
|
+
|
729
|
+
dlg.destroy()
|
730
|
+
else
|
731
|
+
log_error("Unknown find dialog event!")
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
end
|
736
|
+
|
737
|
+
|
738
|
+
class MyApp < App
|
739
|
+
attr_accessor :canvas_text_colour, :canvas_font
|
740
|
+
|
741
|
+
def on_init()
|
742
|
+
self.canvas_text_colour = Wx::Colour.new("BLACK")
|
743
|
+
self.canvas_font = Wx::NORMAL_FONT
|
744
|
+
# Create the main frame window
|
745
|
+
frame = MyFrame.new(nil, "Windows dialogs example",
|
746
|
+
Point.new(20, 20), Size.new(400, 300))
|
747
|
+
|
748
|
+
# Make a menubar
|
749
|
+
file_menu = Menu.new
|
750
|
+
|
751
|
+
file_menu.append(DIALOGS_CHOOSE_COLOUR, "&Choose colour")
|
752
|
+
file_menu.append_separator()
|
753
|
+
file_menu.append(DIALOGS_CHOOSE_FONT, "Choose &font")
|
754
|
+
file_menu.append_separator()
|
755
|
+
file_menu.append(DIALOGS_LOG_DIALOG, "&Log dialog\tCtrl-L")
|
756
|
+
file_menu.append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M")
|
757
|
+
file_menu.append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E")
|
758
|
+
file_menu.append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P")
|
759
|
+
file_menu.append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N")
|
760
|
+
file_menu.append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C")
|
761
|
+
file_menu.append(DIALOGS_MULTI_CHOICE, "M&ultiple choice\tCtrl-U")
|
762
|
+
file_menu.append_separator()
|
763
|
+
file_menu.append(DIALOGS_TIP, "&Tip of the day\tCtrl-T")
|
764
|
+
file_menu.append_separator()
|
765
|
+
file_menu.append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O")
|
766
|
+
file_menu.append(DIALOGS_FILE_OPEN2, "&Second open file\tCtrl-2")
|
767
|
+
file_menu.append(DIALOGS_FILES_OPEN, "Open &files\tShift-Ctrl-O")
|
768
|
+
file_menu.append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S")
|
769
|
+
file_menu.append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D")
|
770
|
+
file_menu.append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G")
|
771
|
+
file_menu.append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B")
|
772
|
+
file_menu.append(DIALOGS_PREFS, "Propert&y sheet dialog\tCtrl-Y")
|
773
|
+
file_menu.append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", ITEM_CHECK)
|
774
|
+
file_menu.append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", ITEM_CHECK)
|
775
|
+
|
776
|
+
file_menu.append_separator()
|
777
|
+
file_menu.append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-W")
|
778
|
+
file_menu.append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", ITEM_CHECK)
|
779
|
+
file_menu.append_separator()
|
780
|
+
file_menu.append(ID_EXIT, "E&xit\tAlt-X")
|
781
|
+
menu_bar = MenuBar.new
|
782
|
+
menu_bar.append(file_menu, "&File")
|
783
|
+
frame.set_menu_bar(menu_bar)
|
784
|
+
|
785
|
+
$my_canvas = MyCanvas.new(frame)
|
786
|
+
$my_canvas.set_background_colour(WHITE)
|
787
|
+
|
788
|
+
frame.centre(BOTH)
|
789
|
+
|
790
|
+
# Show the frame
|
791
|
+
frame.show()
|
792
|
+
end
|
793
|
+
end
|
794
|
+
|
795
|
+
app = MyApp.new()
|
796
|
+
app.main_loop()
|
797
|
+
|