wxruby 1.9.6-x86-linux → 1.9.7-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '1.9.6'
2
+ WXRUBY_VERSION = '1.9.7'
3
3
  end
Binary file
@@ -0,0 +1,177 @@
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
+ # This sample demonstrates the use of the Clipboard and Drag and Drop
11
+ # classes. Whilst the functionality of these is slightly different, they
12
+ # are both based around the use of the DataObject classes to exchange
13
+ # data of various sorts between applications (i.e. into and out of
14
+ # wxRuby)
15
+
16
+ # A ListBox that collects file names dropped onto it
17
+ class FileDropList < Wx::ListBox
18
+ def initialize(*args)
19
+ super
20
+ # Set the handler for drag and drop actions
21
+ self.drop_target = ListFileDropTarget.new(self)
22
+ end
23
+
24
+ # The class that actually handles the dropped files; it keeps a
25
+ # reference to the ListBox, and appends items as they are added
26
+ class ListFileDropTarget < Wx::FileDropTarget
27
+ def initialize(list)
28
+ super()
29
+ @list = list
30
+ end
31
+
32
+ # This method is overridden to specify what happens when a file is
33
+ # dropped
34
+ def on_drop_files(x, y, files)
35
+ files.each { | file | @list.append(file) }
36
+ true # currently need to return boolean from this method
37
+ end
38
+ end
39
+ end
40
+
41
+ class FileDropPane < Wx::Panel
42
+ LABEL = "Drag and drop files from Explorer/Finder/etc to here\n" +
43
+ "to add them to the list."
44
+ def initialize(parent)
45
+ super
46
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
47
+ txt = Wx::StaticText.new( self, :label => LABEL)
48
+ sizer.add(txt, 0, Wx::ALL, 4)
49
+
50
+ @drop = FileDropList.new(self)
51
+ sizer.add(@drop, 1, Wx::GROW|Wx::ALL, 4)
52
+ self.sizer = sizer
53
+ end
54
+ end
55
+
56
+ # A canvas which can display a pasted image
57
+ class PasteCanvas < Wx::Window
58
+ attr_accessor :bitmap
59
+ def initialize(parent)
60
+ super(parent, :style => Wx::SUNKEN_BORDER)
61
+ self.size = [ 200, 200 ]
62
+ @bitmap = Wx::NULL_BITMAP
63
+ evt_paint :on_paint
64
+ end
65
+
66
+ def on_paint(evt)
67
+ paint do | dc |
68
+ dc.clear
69
+ if bitmap.ok?
70
+ dc.draw_bitmap(bitmap, 0, 0, false)
71
+ end
72
+ dc.pen = Wx::BLACK_PEN
73
+ end
74
+ end
75
+ end
76
+
77
+ # A Notebook panel to hold an image-paste canvas
78
+ class PastePane < Wx::Panel
79
+ LABEL = "Use the buttons below to paste text and images from\n" +
80
+ "the system clipboard, and then to copy them back."
81
+ def initialize(parent)
82
+ super
83
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
84
+ txt = Wx::StaticText.new( self, :label => LABEL)
85
+ sizer.add(txt, 0, Wx::ALL, 4)
86
+
87
+ # Sizer for displaying text and image from the clipboard
88
+ paste_sizer = Wx::FlexGridSizer.new(2, 2, 2, 2)
89
+ paste_sizer.add_growable_col(0, 1)
90
+ paste_sizer.add_growable_col(1, 1)
91
+ paste_sizer.add_growable_row(1)
92
+
93
+ paste_sizer.add( Wx::StaticText.new(self, :label => 'Clipboard text') )
94
+ paste_sizer.add( Wx::StaticText.new(self, :label => 'Clipboard image') )
95
+
96
+ # Target for displaying text from the clipboard
97
+ @text = Wx::TextCtrl.new(self, :style => Wx::TE_MULTILINE)
98
+ paste_sizer.add(@text, 1, Wx::GROW)
99
+
100
+ # Target for displaying images from the clipboard
101
+ @canvas = PasteCanvas.new(self)
102
+ paste_sizer.add(@canvas, 1, Wx::GROW)
103
+
104
+ sizer.add(paste_sizer, 1, Wx::ALL|Wx::GROW, 4)
105
+
106
+ button_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
107
+
108
+ @paste_bt = Wx::Button.new(self, :label => 'Paste')
109
+ evt_button @paste_bt, :on_paste
110
+ button_sizer.add(@paste_bt, 0, Wx::ALL, 4)
111
+
112
+ @copy_img_bt = Wx::Button.new(self, :label => 'Copy image')
113
+ evt_button @copy_img_bt, :on_copy_image
114
+ button_sizer.add(@copy_img_bt, 0, Wx::ALL, 4)
115
+
116
+ @copy_txt_bt = Wx::Button.new(self, :label => 'Copy text')
117
+ evt_button @copy_txt_bt, :on_copy_text
118
+ button_sizer.add(@copy_txt_bt, 0, Wx::ALL, 4)
119
+
120
+ sizer.add(button_sizer, 0)
121
+ self.sizer = sizer
122
+ end
123
+
124
+ # Receive data from the clipboard
125
+ def on_paste(evt)
126
+ # Temporarily open the clipboard
127
+ Wx::Clipboard.open do | clip |
128
+ # Test if bitmap data is available on the clipboard; if so, copy
129
+ if clip.supported?(Wx::DF_BITMAP)
130
+ bmp = Wx::BitmapDataObject.new
131
+ clip.get_data(bmp) # Fill the data object with bitmap`
132
+ @canvas.bitmap = bmp.bitmap
133
+ @canvas.refresh
134
+ end
135
+ # Test if text data is available on the clipboard; if so, copy
136
+ if clip.supported?(Wx::DF_TEXT)
137
+ txt = Wx::TextDataObject.new
138
+ clip.get_data(txt) # Fill the data object with text
139
+ @text.value = txt.text
140
+ end
141
+ end
142
+ end
143
+
144
+ # Paste an image to the clipboard
145
+ def on_copy_image
146
+ Wx::Clipboard.open do | clip |
147
+ clip.data = Wx::BitmapDataObject.new(@canvas.bitmap)
148
+ end
149
+ end
150
+
151
+ # Paste text to the clipboard
152
+ def on_copy_text
153
+ Wx::Clipboard.open do | clip |
154
+ clip.data = Wx::TextDataObject.new(@text.value)
155
+ end
156
+ end
157
+ end
158
+
159
+ class DataObjectFrame < Wx::Frame
160
+ def initialize(parent)
161
+ super
162
+ panel = Wx::Panel.new(self)
163
+ panel.sizer = Wx::BoxSizer.new(Wx::VERTICAL)
164
+ nb = Wx::Notebook.new(panel)
165
+ panel.sizer.add(nb, 1, Wx::ALL|Wx::GROW, 8)
166
+ fd = FileDropPane.new(nb)
167
+ nb.add_page(fd, 'Drag and Drop')
168
+ cv = PastePane.new(nb)
169
+ nb.add_page(cv, 'Clipboard')
170
+ # urldrop = URLDropList.new(self)
171
+ end
172
+ end
173
+
174
+ Wx::App.run do
175
+ frame = DataObjectFrame.new(nil)
176
+ frame.show
177
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wxruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.6
4
+ version: 1.9.7
5
5
  platform: x86-linux
6
6
  authors:
7
7
  - wxRuby development team
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-01 00:00:00 +01:00
12
+ date: 2008-05-10 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -105,14 +105,14 @@ files:
105
105
  - samples/grid
106
106
  - samples/grid/grid.rb
107
107
  - samples/grid/gridtablebase.rb
108
+ - samples/listbook
109
+ - samples/listbook/listbook.xrc
110
+ - samples/listbook/listbook.rb
108
111
  - samples/minimal
109
112
  - samples/minimal/mondrian.ico
110
113
  - samples/minimal/minimal.rb
111
114
  - samples/minimal/nothing.rb
112
115
  - samples/minimal/mondrian.png
113
- - samples/listbook
114
- - samples/listbook/listbook.xrc
115
- - samples/listbook/listbook.rb
116
116
  - samples/printing
117
117
  - samples/printing/mondrian.ico
118
118
  - samples/printing/mondrian.xpm
@@ -127,6 +127,8 @@ files:
127
127
  - samples/caret
128
128
  - samples/caret/caret.rb
129
129
  - samples/caret/mondrian.xpm
130
+ - samples/dragdrop
131
+ - samples/dragdrop/dragdrop.rb
130
132
  - samples/controls
131
133
  - samples/controls/icons
132
134
  - samples/controls/icons/radio.xpm