Class: QDA::GUI::ImageDocumentWindow
- Inherits:
-
InspectorWindow
- Object
- WorkAreaWindow
- InspectorWindow
- QDA::GUI::ImageDocumentWindow
- Defined in:
- lib/weft/wxgui/inspectors/imagedocument.rb
Constant Summary
Constants inherited from InspectorWindow
QDA::GUI::InspectorWindow::INSPECTOR_NB_STYLE
Constants inherited from WorkAreaWindow
WorkAreaWindow::W_WINDOW_DEF_SIZE
Instance Attribute Summary
Attributes inherited from InspectorWindow
Instance Method Summary collapse
-
#initialize(image_file, *args) ⇒ ImageDocumentWindow
constructor
A new instance of ImageDocumentWindow.
- #on_paint ⇒ Object
- #zoom(event) ⇒ Object
- #zoom_in(*args) ⇒ Object
- #zoom_out(*args) ⇒ Object
Methods inherited from InspectorWindow
#associated_subscribers, #get_current_category, #on_activate, #on_code, #on_key_down, #on_uncode, #receive_text_font_changed
Methods inherited from WorkAreaWindow
#active?, #layout, #layout=, #on_focus
Constructor Details
#initialize(image_file, *args) ⇒ ImageDocumentWindow
Returns a new instance of ImageDocumentWindow.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/weft/wxgui/inspectors/imagedocument.rb', line 7 def initialize(image_file, *args) @img = Wx::Image.new(image_file) # magnifier @bitmap = Wx::Bitmap.new( @img ) @zoom = 0 # check height & widget to set size of child window # @bitmap.get_height # sizer = Wx::BoxSizer.new(Wx::VERTICAL) # sizer.add(img, 1, Wx::SHAPED|Wx::GROW, 5) super(*args) do # client_size = Wx::Size.new(@bitmap.width, @bitmap.height) set_client_size(Wx::Size.new(@bitmap.width, @bitmap.height)) end self.set_cursor( Wx::Cursor.new(Wx::CURSOR_MAGNIFIER) ) evt_paint { on_paint } evt_left_up { | e | zoom_in(e) } evt_right_up { | e | zoom_out(e) } end |
Instance Method Details
#on_paint ⇒ Object
26 27 28 29 30 31 |
# File 'lib/weft/wxgui/inspectors/imagedocument.rb', line 26 def on_paint paint do | dc | dc.clear dc.draw_bitmap(@bitmap, 0, 0, false) end end |
#zoom(event) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/weft/wxgui/inspectors/imagedocument.rb', line 43 def zoom(event) img_x2 = @img.scale(@img.get_width * ( 2 ** @zoom ), @img.get_height * ( 2 ** @zoom) ) #rotate90 @bitmap = Wx::Bitmap.new( img_x2 ) dc = Wx::ClientDC.new(self) dc.clear dc.draw_bitmap(@bitmap, 0, 0, false) set_client_size(Wx::Size.new( @img.get_width * ( 2 ** @zoom ), @img.get_height * ( 2 ** @zoom) ) ) end |
#zoom_in(*args) ⇒ Object
33 34 35 36 |
# File 'lib/weft/wxgui/inspectors/imagedocument.rb', line 33 def zoom_in(*args) @zoom += 1 zoom(*args) end |
#zoom_out(*args) ⇒ Object
38 39 40 41 |
# File 'lib/weft/wxgui/inspectors/imagedocument.rb', line 38 def zoom_out(*args) @zoom -= 1 zoom(*args) end |