wxruby3 0.9.0.pre.beta.13 → 0.9.0.pre.rc.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (166) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +47 -4
  4. data/assets/hello_button.png +0 -0
  5. data/assets/hello_button_clicked.png +0 -0
  6. data/assets/hello_world.png +0 -0
  7. data/assets/repo-social-preview.png +0 -0
  8. data/ext/wxruby3/include/wxruby-runtime.h +1 -0
  9. data/ext/wxruby3/swig/memory_management.i +6 -10
  10. data/ext/wxruby3/swig/wx.i +17 -6
  11. data/lib/wx/accessors.rb +8 -2
  12. data/lib/wx/core/art_locator.rb +2 -2
  13. data/lib/wx/core/artprovider.rb +2 -2
  14. data/lib/wx/core/bitmap.rb +6 -5
  15. data/lib/wx/core/bitmap_combobox.rb +34 -0
  16. data/lib/wx/core/controlwithitems.rb +52 -14
  17. data/lib/wx/core/cursor.rb +1 -1
  18. data/lib/wx/core/dc.rb +0 -20
  19. data/lib/wx/core/event_blocker.rb +14 -0
  20. data/lib/wx/core/evthandler.rb +36 -0
  21. data/lib/wx/core/find_replace_dialog.rb +24 -0
  22. data/lib/wx/core/icon.rb +1 -1
  23. data/lib/wx/core/image.rb +1 -1
  24. data/lib/wx/core/paintdc.rb +8 -0
  25. data/lib/wx/core/text_entry.rb +15 -0
  26. data/lib/wx/core/v_list_box.rb +13 -0
  27. data/lib/wx/core/window.rb +1 -1
  28. data/lib/wx/doc/busy_info.rb +21 -0
  29. data/lib/wx/doc/client_dc.rb +28 -0
  30. data/lib/wx/doc/controlwithitems.rb +11 -0
  31. data/lib/wx/doc/dc.rb +0 -14
  32. data/lib/wx/doc/event_blocker.rb +27 -0
  33. data/lib/wx/doc/evthandler.rb +4 -0
  34. data/lib/wx/doc/extra/02_lifecycles.md +49 -0
  35. data/lib/wx/doc/extra/10_art.md +1 -1
  36. data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
  37. data/lib/wx/doc/memory_dc.rb +75 -0
  38. data/lib/wx/doc/mirror_dc.rb +16 -0
  39. data/lib/wx/doc/prt/printer_dc.rb +26 -0
  40. data/lib/wx/doc/screen_dc.rb +10 -6
  41. data/lib/wx/doc/svg_file_dc.rb +20 -0
  42. data/lib/wx/doc/v_list_box.rb +9 -0
  43. data/lib/wx/doc/window_disabler.rb +10 -0
  44. data/lib/wx/global_const.rb +24 -18
  45. data/lib/wx/html/keyword_defs.rb +6 -7
  46. data/lib/wx/html/require.rb +1 -0
  47. data/lib/wx/html/simple_html_listbox.rb +105 -0
  48. data/lib/wx/keyword_defs.rb +7 -0
  49. data/lib/wx/version.rb +1 -1
  50. data/lib/wx/wxruby/cmd/test.rb +1 -1
  51. data/rakelib/install.rb +3 -1
  52. data/rakelib/lib/core/mapping.rb +5 -5
  53. data/rakelib/lib/core/spec.rb +7 -3
  54. data/rakelib/lib/core/spec_helper.rb +9 -1
  55. data/rakelib/lib/director/accelerator.rb +1 -1
  56. data/rakelib/lib/director/app.rb +25 -3
  57. data/rakelib/lib/director/art_provider.rb +5 -1
  58. data/rakelib/lib/director/aui_pane_info.rb +1 -1
  59. data/rakelib/lib/director/aui_tab_ctrl.rb +1 -1
  60. data/rakelib/lib/director/bitmap.rb +2 -1
  61. data/rakelib/lib/director/bitmap_combobox.rb +32 -0
  62. data/rakelib/lib/director/brush.rb +1 -0
  63. data/rakelib/lib/director/busy_info.rb +1 -1
  64. data/rakelib/lib/director/choice.rb +1 -0
  65. data/rakelib/lib/director/clipboard.rb +1 -1
  66. data/rakelib/lib/director/colour.rb +1 -0
  67. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -1
  68. data/rakelib/lib/director/combobox.rb +1 -2
  69. data/rakelib/lib/director/ctrl_with_items.rb +3 -0
  70. data/rakelib/lib/director/cursor.rb +1 -0
  71. data/rakelib/lib/director/data_object.rb +5 -7
  72. data/rakelib/lib/director/dc.rb +5 -1
  73. data/rakelib/lib/director/defs.rb +3 -0
  74. data/rakelib/lib/director/derived_dc.rb +278 -27
  75. data/rakelib/lib/director/dialog.rb +4 -1
  76. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -1
  77. data/rakelib/lib/director/event.rb +3 -3
  78. data/rakelib/lib/director/event_blocker.rb +41 -0
  79. data/rakelib/lib/director/event_filter.rb +20 -0
  80. data/rakelib/lib/director/event_handler.rb +29 -2
  81. data/rakelib/lib/director/file_picker_ctrl.rb +1 -1
  82. data/rakelib/lib/director/find_replace_data.rb +1 -0
  83. data/rakelib/lib/director/font.rb +2 -1
  84. data/rakelib/lib/director/font_data.rb +1 -0
  85. data/rakelib/lib/director/font_picker_ctrl.rb +1 -1
  86. data/rakelib/lib/director/gdi_object.rb +1 -0
  87. data/rakelib/lib/director/graphics_context.rb +6 -6
  88. data/rakelib/lib/director/grid_table_message.rb +1 -1
  89. data/rakelib/lib/director/html_cell.rb +1 -1
  90. data/rakelib/lib/director/html_data_object.rb +5 -7
  91. data/rakelib/lib/director/html_listbox.rb +65 -1
  92. data/rakelib/lib/director/icon.rb +2 -0
  93. data/rakelib/lib/director/listbox.rb +1 -0
  94. data/rakelib/lib/director/locale.rb +2 -1
  95. data/rakelib/lib/director/palette.rb +1 -0
  96. data/rakelib/lib/director/pen.rb +2 -1
  97. data/rakelib/lib/director/pgproperties.rb +1 -1
  98. data/rakelib/lib/director/pgproperty.rb +1 -1
  99. data/rakelib/lib/director/pgvalidation_info.rb +1 -1
  100. data/rakelib/lib/director/platform_info.rb +1 -1
  101. data/rakelib/lib/director/print_data.rb +1 -1
  102. data/rakelib/lib/director/property_grid_interface.rb +1 -1
  103. data/rakelib/lib/director/property_grid_page_state.rb +1 -1
  104. data/rakelib/lib/director/region.rb +1 -0
  105. data/rakelib/lib/director/ribbon_art_provider.rb +1 -1
  106. data/rakelib/lib/director/richtext_buffer_data_object.rb +5 -7
  107. data/rakelib/lib/director/richtext_header_footer_data.rb +1 -1
  108. data/rakelib/lib/director/searchctrl.rb +24 -0
  109. data/rakelib/lib/director/sizer.rb +2 -2
  110. data/rakelib/lib/director/styled_text_ctrl.rb +2 -0
  111. data/rakelib/lib/director/text_entry.rb +2 -2
  112. data/rakelib/lib/director/tree_ctrl.rb +6 -3
  113. data/rakelib/lib/director/uiaction_simulator.rb +20 -0
  114. data/rakelib/lib/director/variant.rb +1 -1
  115. data/rakelib/lib/director/vlistbox.rb +25 -0
  116. data/rakelib/lib/director/window.rb +0 -6
  117. data/rakelib/lib/director/with_images.rb +1 -1
  118. data/rakelib/lib/director/xml_node.rb +1 -1
  119. data/rakelib/lib/extractor/function.rb +5 -3
  120. data/rakelib/lib/generate/doc/about_dialog_info.yaml +46 -0
  121. data/rakelib/lib/generate/doc/accelerator.yaml +21 -0
  122. data/rakelib/lib/generate/doc/art_provider.yaml +35 -0
  123. data/rakelib/lib/generate/doc/bitmap.yaml +37 -0
  124. data/rakelib/lib/generate/doc/box_sizer.yaml +15 -0
  125. data/rakelib/lib/generate/doc/busy_info.yaml +74 -0
  126. data/rakelib/lib/generate/doc/client_dc.yaml +19 -0
  127. data/rakelib/lib/generate/doc/clipboard.yaml +43 -0
  128. data/rakelib/lib/generate/doc/collapsible_pane.yaml +21 -0
  129. data/rakelib/lib/generate/doc/colour_dialog.yaml +32 -0
  130. data/rakelib/lib/generate/doc/control.yaml +46 -0
  131. data/rakelib/lib/generate/doc/cursor.yaml +40 -0
  132. data/rakelib/lib/generate/doc/data_object.yaml +55 -0
  133. data/rakelib/lib/generate/doc/dc.yaml +14 -0
  134. data/rakelib/lib/generate/doc/dialog.yaml +36 -0
  135. data/rakelib/lib/generate/doc/dir_dialog.yaml +25 -0
  136. data/rakelib/lib/generate/doc/events.yaml +152 -0
  137. data/rakelib/lib/generate/doc/evt_handler.yaml +63 -0
  138. data/rakelib/lib/generate/doc.rb +77 -14
  139. data/rakelib/lib/generate/interface.rb +11 -0
  140. data/rakelib/lib/specs/interfaces.rb +5 -4
  141. data/rakelib/lib/swig_runner.rb +3 -3
  142. data/rakelib/lib/typemap/common.rb +15 -3
  143. data/rakelib/lib/util/string.rb +1 -0
  144. data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
  145. data/samples/bigdemo/wxArtProvider.rbw +5 -4
  146. data/samples/controls/controls.rb +2 -2
  147. data/samples/controls/htlbox.rb +411 -0
  148. data/samples/controls/tn_htlbox.png +0 -0
  149. data/samples/drawing/graphics_drawing.rb +1 -2
  150. data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
  151. data/samples/drawing/tn_image_prt.png +0 -0
  152. data/samples/propgrid/propgrid.rb +23 -21
  153. data/samples/ribbon/ribbon.rb +47 -46
  154. data/tests/lib/wxapp_runner.rb +3 -3
  155. data/tests/lib/wxframe_runner.rb +59 -0
  156. data/tests/test_app_event_filter.rb +74 -0
  157. data/tests/test_art_provider.rb +52 -0
  158. data/tests/test_clipboard.rb +2 -1
  159. data/tests/test_event_handling.rb +199 -16
  160. data/tests/test_events.rb +4 -11
  161. data/tests/test_gdi_object.rb +161 -0
  162. data/tests/test_intl.rb +11 -14
  163. data/tests/test_item_data.rb +33 -1
  164. data/tests/test_std_controls.rb +147 -0
  165. metadata +56 -4
  166. data/samples/drawing/tn_svgtest.png +0 -0
@@ -0,0 +1,35 @@
1
+ ---
2
+ :wxArtProvider:
3
+ :detail:
4
+ :pre:
5
+ :para:
6
+ - :pattern: !ruby/regexp /<programlisting>.*MyProvider/
7
+ :replace: |
8
+
9
+ Example:
10
+
11
+ ```ruby
12
+ class MyArtProvider < Wx::ArtProvider
13
+
14
+ def create_bitmap(id, client, size)
15
+ # ... create and return bitmap
16
+ end
17
+
18
+ end
19
+
20
+ Wx::ArtProvider.push(MyArtProvider.new)
21
+ ```
22
+
23
+ - :pattern: !ruby/regexp /Note\s+that,\s+as\s+usual\s+in\s+wxWidgets\s+API.*/
24
+ :replace: ''
25
+ - :pattern: !ruby/regexp /wxNO_IMPLICIT_WXSTRING_ENCODING/
26
+ :replace: ''
27
+ :programlisting:
28
+ - :pattern: !ruby/regexp /ifdef.*__WXGTK__/
29
+ :replace: |
30
+
31
+ ```ruby
32
+ if Wx::PLATFORM == 'WXGTK'
33
+ bmp = Wx::ArtProvider.get_bitmap("gtk-cdrom", Wx::ART_MENU)
34
+ end
35
+ ```
@@ -0,0 +1,37 @@
1
+ ---
2
+ :wxBitmap.wxBitmap:
3
+ :detail:
4
+ :pre:
5
+ :para:
6
+ - :pattern: !ruby/regexp /<programlisting>.*GetSubBitmap/
7
+ :replace: |
8
+ ```ruby
9
+ newBitmap = oldBitmap.get_sub_bitmap(
10
+ Wx::Rect.new(0, 0, oldBitmap.width, oldBitmap.height))
11
+ ```
12
+ :wxBitmapBundle:
13
+ :detail:
14
+ :pre:
15
+ :para:
16
+ - :pattern: !ruby/regexp /<programlisting>.*MyFrame::MyFrame/
17
+ :replace: |
18
+ ```ruby
19
+ class MyFrame < Wx::Frame
20
+
21
+ def initialize
22
+ super(nil, Wx::ID_ANY, "My frame")
23
+ # ...
24
+ tool_bar = create_toolBar
25
+
26
+ bitmaps = [
27
+ Wx::Bitmap(:open_32x32, Wx::BitmapType::BITMAP_TYPE_PNG),
28
+ Wx::Bitmap(:open_48x48, Wx::BitmapType::BITMAP_TYPE_PNG),
29
+ Wx::Bitmap(:open_64x64, Wx::BitmapType::BITMAP_TYPE_PNG)
30
+ ]
31
+
32
+ tool_bar.add_tool(Wx::ID_OPEN, "Open", Wx::BitmapBundle.from_bitmaps(bitmaps))
33
+ end
34
+ ```
35
+
36
+ - :pattern: !ruby/regexp /For\s+the\s+platforms\s+with\s+resources\s+support/
37
+ :replace: ''
@@ -0,0 +1,15 @@
1
+ ---
2
+ :wxBoxSizer.AddSpacer:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /wxBoxSizer::IsVertical/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ if box_sizer.vertical?
11
+ box_sizer.add(0, size, 0)
12
+ else
13
+ box_size.add(size, 0, 0)
14
+ end
15
+ ```
@@ -0,0 +1,74 @@
1
+ ---
2
+ :wxBusyInfo:
3
+ :detail:
4
+ :pre:
5
+ :detaileddescription:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+ Normally the main thread should always return to the main loop to continue dispatching events as quickly as possible,
9
+ hence this class shouldn't be needed. However if the main thread does need to block, this class provides a simple
10
+ way to at least show this to the user: just call {Wx::BusyInfo.busy} with a block and for the duration of the
11
+ execution of the block a message window will be shown.
12
+ For example:
13
+ ```ruby
14
+ BusyInfo.busy('Working, please wait...') do
15
+ 100000.times { do_a_calculation }
16
+ end
17
+ ```
18
+
19
+ The displayed window is rather plain by default but can be customized by passing {Wx::BusyInfo.busy} an object of
20
+ {Wx::BusyInfoFlags} class instead of a simple message. Here is an example:
21
+
22
+ ```ruby
23
+ Wx::BusyInfo.busy(
24
+ Wx::BusyInfoFlags.new
25
+ .parent(self)
26
+ .icon(Wx::ArtProvider.get_icon(Wx::ART_PRINT,Wx::ART_OTHER, [128, 128]))
27
+ .title("<b>Printing your document</b>")
28
+ .text("Please wait...")
29
+ .foreground(Wx::WHITE)
30
+ .background(Wx::BLACK)
31
+ .transparency(4*Wx::ALPHA_OPAQUE/5)) do |bi|
32
+ end
33
+ ```
34
+
35
+ This shows that separate title and text can be set, and that simple markup ({Wx::Control#set_label_markup}) can be used in them, and that it's also possible to add an icon and customize the colours and transparency of the window.
36
+ You may also want to call `Wx.get_app.yield` to refresh the window periodically (in case it had been obscured by other windows, for example) like this:
37
+ ```ruby
38
+ Wx::WindowDisabler.disable do
39
+ BusyInfo.busy('Working, please wait...') do
40
+ 100000.times do |i|
41
+ do_a_calculation }
42
+ Wx.get_app.yield if (i % 1000) == 0
43
+ end
44
+ end
45
+ end
46
+ ```
47
+
48
+ but take care to not cause undesirable re-entrance when doing it (see {Wx::App#yield} for more details). The simplest way to do it is to use {Wx::WindowDisabler} class as illustrated in the above example.
49
+ Note that a {Wx::BusyInfo} is always built with the {Wx::STAY_ON_TOP} window style (see {Wx::Frame} window styles for more info).
50
+
51
+ ===
52
+
53
+ Category: Common Dialogs
54
+
55
+
56
+ :wxBusyInfoFlags:
57
+ :detail:
58
+ :pre:
59
+ :programlisting:
60
+ - :pattern: !ruby/regexp /.*/
61
+ :replace: |
62
+
63
+ ```ruby
64
+ Wx::BusyInfo.busy(
65
+ Wx::BusyInfoFlags.new
66
+ .parent(self)
67
+ .icon(Wx::ArtProvider.get_icon(Wx::ART_PRINT,Wx::ART_OTHER, [128, 128]))
68
+ .title("<b>Printing your document</b>")
69
+ .text("Please wait...")
70
+ .foreground(Wx::WHITE)
71
+ .background(Wx::BLACK)
72
+ .transparency(4*Wx::ALPHA_OPAQUE/5)) do |bi|
73
+ end
74
+ ```
@@ -0,0 +1,19 @@
1
+ ---
2
+ :wxClientDC:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # Create the initially empty label with the size big enough to show
11
+ # the given string.
12
+ text = Wx::ClientDC.draw_on(self) do |dc|
13
+ Wx::StaticText.new(
14
+ self, Wx::ID_ANY, "",
15
+ Wx::Point.new,
16
+ dc.get_text_extent("String of max length"),
17
+ Wx::ST_NO_AUTORESIZE)
18
+ end
19
+ ```
@@ -0,0 +1,43 @@
1
+ ---
2
+ :wxClipboard:
3
+ :detail:
4
+ :pre:
5
+ :detaileddescription:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+ To use the clipboard, you call member functions of the global {Wx::Clipboard} object passed to the block for {Wx::Clipboard.open}.
9
+ See the {Wx::DataObject} Overview for further information.
10
+ Call {Wx::Clipboard.open} to get ownership of the (global) clipboard and execute the given block. You now
11
+ own the clipboard passed to the given block. Call {Wx::Clipboard#set_data} to put data on the clipboard, or
12
+ {Wx::Clipboard#get_data} to retrieve data from the clipboard. The clipboard is closed and ownership
13
+ relinquished when the block returns. You should keep the clipboard open only momentarily.
14
+ For example:
15
+
16
+ ```ruby
17
+ # Write some text to the clipboard
18
+ Wx::Clipboard.open do |clip|
19
+ # This data object is held by the clipboard
20
+ clip.place(Wx::TextDataObject.new("Some text"))
21
+ # or alternatively
22
+ # clip.set_data(Wx::TextDataObject.new("Some text"))
23
+ end
24
+
25
+ # Read some text
26
+ data = Wx::TextDataObject.new
27
+ Wx::Clipboard.open do |clip|
28
+ if clip.supported?(Wx::DF_TEXT)
29
+ clip.fetch(data) # or clip.get_data(data)
30
+ end
31
+ end
32
+ Wx.message_box(data.get_text)
33
+ ```
34
+
35
+ On GTK, the clipboard behavior can vary depending on the configuration of the end-user's machine. In order
36
+ for the clipboard data to persist after the window closes, a clipboard manager must be installed. Some
37
+ clipboard managers will automatically flush the clipboard after each new piece of data is added, while others
38
+ will not. The {Wx::Clipboard#flush} function will force the clipboard manager to flush the data.
39
+
40
+ ===
41
+
42
+ Category: Clipboard and Drag & Drop
43
+ @see Wx::DataObject
@@ -0,0 +1,21 @@
1
+ ---
2
+ :wxCollapsiblePane:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ collpane = Wx::CollapsiblePane.new(self, Wx::ID_ANY, "Details:")
11
+
12
+ # add the pane with a zero proportion value to the 'sz' sizer which contains it
13
+ sz.add(collpane, 0, Wx::GROW|Wx::ALL, 5)
14
+
15
+ #/ now add a test label in the collapsible pane using a sizer to layout it:
16
+ win = collpane.get_pane
17
+ pane_sz = Wx::VBoxSizer
18
+ pane_sz.add(Wx::StaticText.new(win, Wx::ID_ANY, "test!"), 1, Wx::GROW|Wx::ALL, 2)
19
+ win.set_sizer(pane_sz)
20
+ pane_sz.set_size_hints(win)
21
+ ```
@@ -0,0 +1,32 @@
1
+ ---
2
+ :wxColourDialog:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # Some function for redrawing using the given colour. Ideally, it
11
+ # shouldn't do anything if the colour is the same as the one used
12
+ # before.
13
+ # def redraw(colour) ... end
14
+
15
+ data = Wx::ColourData.new
16
+ data.set_colour(initialColourToUse)
17
+ Wx::ColourDialog(self, data) do |dlg|
18
+ dlg.evt_colour_changed { |event| redraw(event.get_colour) }
19
+ if dlg.show_modal == Wx::ID_OK
20
+ # Colour did change.
21
+ else
22
+ # Colour didn't change.
23
+ end
24
+ end
25
+
26
+ # This call is unnecessary under platforms generating
27
+ # Wx::EVT_COLOUR_CHANGED if the dialog was accepted and unnecessary
28
+ # under the platforms not generating this event if it was cancelled,
29
+ # so we could check for the different cases explicitly to avoid it,
30
+ # but it's simpler to just always call it.
31
+ redraw(data.get_colour)
32
+ ```
@@ -0,0 +1,46 @@
1
+ ---
2
+ :wxControl.GetSizeFromTextSize:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # Create a control for post code entry.
11
+ postcode = Wx::TextCtrl.new(self, ...)
12
+
13
+ # And set its initial and minimal size to be big enough for
14
+ # entering 5 digits.
15
+ postcode.set_initial_size(
16
+ postcode.get_size_from_text_size(
17
+ postcode.get_text_extent("99999")))
18
+ ```
19
+
20
+ :wxControl.GetSizeFromText:
21
+ :detail:
22
+ :pre:
23
+ :programlisting:
24
+ - :pattern: !ruby/regexp /.*/
25
+ :replace: |
26
+
27
+ ```ruby
28
+ def get_size_from_text(text)
29
+ get_size_from_text_size(get_text_extent(text))
30
+ end
31
+ ```
32
+
33
+ :wxControl.SetLabelMarkup:
34
+ :detail:
35
+ :pre:
36
+ :programlisting:
37
+ - :pattern: !ruby/regexp /.*/
38
+ :replace: |
39
+
40
+ ```ruby
41
+ text = Wx::StaticText.new
42
+ ...
43
+ text.set_label_markup("<b>&amp;Bed</b> &amp;mp; "+
44
+ "<span foreground='red'>breakfast</span> "+
45
+ "available <big>HERE</big>")
46
+ ```
@@ -0,0 +1,40 @@
1
+ ---
2
+ :wxCursor:
3
+ :detail:
4
+ :pre:
5
+ :detaileddescription:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+ As with icons, cursors in X and MS Windows are created in a different manner. Therefore, separate cursors
9
+ will be created for the different environments. Platform-specific methods for creating a {Wx::Cursor} object
10
+ are catered for, and this is an occasion where conditional compilation will probably be required
11
+ (see {Wx::Icon} for an example).
12
+ A single cursor object may be used in many windows (any subwindow type). The wxWidgets convention is to set
13
+ the cursor for a window, as in X, rather than to set it globally as in MS Windows, although a global
14
+ {set_cursor} function is also available for MS Windows use.
15
+
16
+ ===
17
+
18
+ Category: Graphics Device Interface (GDI)
19
+ Predefined objects/pointers:
20
+ - {Wx::NULL_CURSOR}
21
+ - {Wx::STANDARD_CURSOR}
22
+ - {Wx::HOURGLASS_CURSOR}
23
+ - {Wx::CROSS_CURSOR}
24
+ @see Wx::Bitmap
25
+ @see Wx::Icon
26
+ @see Wx::Window#set_cursor
27
+ @see Wx.set_cursor
28
+ @see Wx::StockCursor
29
+
30
+ :wxCursor.wxCursor:
31
+ :detail:
32
+ :pre:
33
+ :programlisting:
34
+ - :pattern: !ruby/regexp /.*/
35
+ :replace: |
36
+
37
+ ```ruby
38
+ image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotX)
39
+ image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotSpotY)
40
+ ```
@@ -0,0 +1,55 @@
1
+ ---
2
+ :wxDataObjectComposite:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ class MyDropTarget < Wx::DropTarget
11
+
12
+ def initialize
13
+ dataobj = Wx::DataObjectComposite.new
14
+ dataobj.add(Wx::BitmapDataObject.new, true)
15
+ dataobj.add(Wx::FileDataObject.new)
16
+ set_data_object(dataobj)
17
+ end
18
+
19
+ def on_data(x, y, defaultDragResult)
20
+ return Wx::DragNone unless get_data
21
+
22
+ dataobj_comp = get_data_object
23
+
24
+ format = dataobj_comp.get_received_format
25
+ dataobj = dataobj_comp.get_object(format)
26
+ case format.get_type
27
+ when Wx::DataFormatId::DF_BITMAP
28
+ # dataobj is Wx::BitmapDataObject
29
+
30
+ ... use dataobj.get_bitmap ...
31
+
32
+ when Wx::DataFormatId::DF_FILENAME
33
+ # dataobj is Wx::FileDataObject
34
+
35
+ ... use dataobj->GetFilenames() ...
36
+
37
+ else
38
+ Wx.log_error("unexpected data object format")
39
+ end
40
+
41
+ defaultDragResult
42
+ end
43
+
44
+ end
45
+ ```
46
+ :wxURLDataObject:
47
+ :detail:
48
+ :pre:
49
+ :programlisting:
50
+ - :pattern: !ruby/regexp /.*/
51
+ :replace: |
52
+
53
+ ```ruby
54
+ Wx::Clipboard.open { |clip| clip.place(Wx::URLDataObject.new(url))
55
+ ```
@@ -0,0 +1,14 @@
1
+ ---
2
+ :wxDC.GetSize:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ sz = dc.get_dimensions
11
+ scaleX = (maxX.to_f / sz.width)
12
+ scaleY = (maxY.to_f / sz.height);
13
+ dc.set_user_scale([scaleX, scaleY].min,[scaleX, scaleY].min)
14
+ ```
@@ -0,0 +1,36 @@
1
+ ---
2
+ :wxDialog:
3
+ :detail:
4
+ :pre:
5
+ :para:
6
+ - :pattern: !ruby/regexp /Note\s+that\s+the\s+modal\s+dialog\s+is\s+one\s+of\s+the\s+very\s+few\s+examples/
7
+ :replace: |
8
+ Note that dialogs need to be explicitly destroyed when closed and not used anymore. The traditional code for this would be like:
9
+ :programlisting:
10
+ - :pattern: !ruby/regexp /MyAskDialog.*\*dlg/
11
+ :replace: |
12
+
13
+ ```ruby
14
+ def ask_user
15
+ dlg = MyAskDialog.new(...)
16
+ if dlg.show_modal == Wx::ID_OK
17
+ # ...
18
+ #else: dialog was cancelled or some another button pressed
19
+ end
20
+
21
+ dlg.destroy
22
+ end
23
+ ```
24
+ - :pattern: !ruby/regexp /dlg\.ShowModal\(\)/
25
+ :replace: |
26
+
27
+ ```ruby
28
+ def ask_user
29
+ MyAskDialog(...) do |dlg|
30
+ if dlg.show_modal == Wx::ID_OK
31
+ # ...
32
+ #else: dialog was cancelled or some another button pressed
33
+ end
34
+ end
35
+ end
36
+ ```
@@ -0,0 +1,25 @@
1
+ ---
2
+ :wxDirSelector:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ dir = Wx.dir_selector('Choose a folder')
11
+ unless dir.empty?
12
+ ...
13
+ end
14
+ ```
15
+ :wxDirDialog:
16
+ :detail:
17
+ :pre:
18
+ :programlisting:
19
+ - :pattern: !ruby/regexp /.*/
20
+ :replace: |
21
+
22
+ ```ruby
23
+ Wx::DirDialog(nil, 'Choose input directory', '',
24
+ Wx::DD_DEFAULT_STYLE | Wx::DD_DIR_MUST_EXIST)
25
+ ```
@@ -0,0 +1,152 @@
1
+ ---
2
+ :wxKeyEvent.GetKeyCode:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ def on_char(event)
11
+ uc = event.get_unicode_key
12
+ if uc
13
+ # It's a "normal" character. Notice that this includes
14
+ # control characters in 1..31 range, e.g. Wx::K_RETURN or
15
+ # Wx::K_BACK, so check for them explicitly.
16
+ if uc.ord >= 32
17
+ Wx.log_message("You pressed '#{uc}'")
18
+ else
19
+ # It's a control character
20
+ ...
21
+ end
22
+ else # No Unicode equivalent.
23
+ # It's a special key, deal with all the known ones:
24
+ case event.get_key_code
25
+ when Wx::K_LEFT, Wx::K_RIGHT
26
+ ... move cursor ...
27
+
28
+ when Wx::K_F1:
29
+ ... give help ...
30
+ end
31
+ end
32
+ end
33
+ ```
34
+ :post:
35
+ - :pattern: !ruby/regexp /returns\s+\{Wx::K_NONE\}\)/
36
+ :subst: 'returns nil)'
37
+ :wxKeyEvent.GetUnicodeKey:
38
+ :detail:
39
+ :post:
40
+ - :pattern: !ruby/regexp /return\s+\{Wx::K_NONE\}\./
41
+ :subst: 'return nil.'
42
+ :wxKeyEvent.GetModifiers:
43
+ :detail:
44
+ :pre:
45
+ :programlisting:
46
+ - :pattern: !ruby/regexp /ControlDown/
47
+ :replace: |
48
+
49
+ ```ruby
50
+ if event.control_down && !event.alt_down && !event.shift_down && !event.meta_down
51
+ # ... handle Ctrl-XXX ...
52
+ ```
53
+ - :pattern: !ruby/regexp /GetModifiers/
54
+ :replace: |
55
+
56
+ ```ruby
57
+ if event.get_modifiers == Wx::KeyModifier::MOD_CONTROL
58
+ # ... handle Ctrl-XXX ...
59
+ ```
60
+ :wxMouseEvent.GetModifiers:
61
+ :detail:
62
+ :pre:
63
+ :programlisting:
64
+ - :pattern: !ruby/regexp /ControlDown/
65
+ :replace: |
66
+
67
+ ```ruby
68
+ if event.control_down && !event.alt_down && !event.shift_down && !event.meta_down
69
+ # ... handle Ctrl-XXX ...
70
+ ```
71
+ - :pattern: !ruby/regexp /GetModifiers/
72
+ :replace: |
73
+
74
+ ```ruby
75
+ if event.get_modifiers == Wx::KeyModifier::MOD_CONTROL
76
+ # ... handle Ctrl-XXX ...
77
+ ```
78
+ :wxUpdateUIEvent.IsCheckable:
79
+ :detail:
80
+ :pre:
81
+ :programlisting:
82
+ - :pattern: !ruby/regexp /.*/
83
+ :replace: |
84
+
85
+ ```ruby
86
+ def on_update_ui(event)
87
+ ....
88
+ if event.is_checkable
89
+ event.check(...some condition...)
90
+ end
91
+ ```
92
+ :wxPaintEvent:
93
+ :detail:
94
+ :pre:
95
+ :programlisting:
96
+ - :pattern: !ruby/regexp /DrawMyDocument/
97
+ :replace: |
98
+
99
+ ```ruby
100
+ def on_paint(event)
101
+ self.pain do |dc|
102
+ draw_my_document(dc)
103
+ end
104
+ end
105
+ ```
106
+ - :pattern: !ruby/regexp /GetViewStart/
107
+ :replace: |
108
+
109
+ ```ruby
110
+ # Called when window needs to be repainted.
111
+ def on_paint(event)
112
+ self.paint do |dc|
113
+ # Find Out where the window has scrolled to
114
+ vb_pt = get_view_start # Top left corner of client
115
+
116
+ Wx::RegionIterator.for_region(get_update_region) do |region_it|
117
+
118
+ int vX,vY,vW,vH
119
+ wxRegionIterator upd(GetUpdateRegion()) # get the update rect list
120
+
121
+ region_it.each do |rct|
122
+ # rct == Dimensions of client area to repaint in pixels
123
+
124
+ # Repaint this rectangle
125
+ ...some code...
126
+ end
127
+ end
128
+ end
129
+ end
130
+ ```
131
+ :wxCloseEvent:
132
+ :detail:
133
+ :pre:
134
+ :programlisting:
135
+ - :pattern: !ruby/regexp /.*/
136
+ :replace: |
137
+
138
+ ```ruby
139
+ def on_close(event)
140
+ if event.can_veto? && @file_not_saved
141
+ if Wx.message_box("The file has not been saved... continue closing?",
142
+ "Please confirm",
143
+ Wx::ICON_QUESTION | Wx::YES_NO) != Wx::YES)
144
+ event.veto
145
+ return
146
+ end
147
+ end
148
+
149
+ destroy # you may also do: event.skip
150
+ # since the default event handler does call #destroy too
151
+ end
152
+ ```