class Metasm::Gui::ContainerVBoxWidget

Public Class Methods

new(*a, &b) click to toggle source
Calls superclass method
# File metasm/gui/gtk.rb, line 116
def initialize(*a, &b)
        super()

        signal_connect('realize') { initialize_visible } if respond_to? :initialize_visible

        signal_connect('size_request') { |w, alloc| resize(*alloc) } if respond_to? :resize

        self.spacing = 2

        initialize_widget(*a, &b)
end

Public Instance Methods

add(w, opts={}) click to toggle source
# File metasm/gui/win32.rb, line 1554
def add(w, opts={})
        @views << w
        w.parent = self
        w.hwnd = @hwnd
        resized_(@width, @height)
        w.initialize_visible_ if @visible
end
click(x, y) click to toggle source
# File metasm/gui/win32.rb, line 1562
def click(x, y)
        cy = 0
        pv = []
        @views.each_with_index { |v, i|
                if y >= cy+1 and y < cy + v.height - 1
                        if @focus_idx != i
                                @focus_idx = i
                                redraw
                        end
                        v.click(x, y-v.y) if v.respond_to? :click
                        return
                end
                cy += v.height
                if y >= cy-1 and y < cy+@spacing+1
                        @resizing = v
                        @wantheight[@resizing] ||= v.height
                        @tmpwantheight = []
                        pv.each { |vv| @tmpwantheight << vv if not @wantheight[vv] ; @wantheight[vv] ||= vv.height }
                        return
                end
                cy += @spacing
                pv << v
        }
end
find_view_y(ty, update_focus=false) click to toggle source
# File metasm/gui/win32.rb, line 1675
def find_view_y(ty, update_focus=false)
        y = 0
        @views.each_with_index { |v, i|
                if ty >= y and ty < y + v.height
                        if update_focus and @focus_idx != i
                                @focus_idx = i
                                redraw
                        end
                        return v
                end
                y += v.height + @spacing
        }
        nil
end
has_focus?(c) click to toggle source
# File metasm/gui/win32.rb, line 1705
def has_focus?(c)
        c == @views[@focus_idx]
end
hwnd=(h) click to toggle source
# File metasm/gui/win32.rb, line 1690
def hwnd=(h)
        @hwnd = h
        @views.each { |v| v.hwnd = h }
end
initialize_visible_() click to toggle source
# File metasm/gui/win32.rb, line 1549
def initialize_visible_
        @visible = true
        @views.each { |v| v.initialize_visible_ }
end
mousemove(x, y) click to toggle source
# File metasm/gui/win32.rb, line 1587
def mousemove(x, y)
        if @resizing
                @wantheight[@resizing] = [0, y - @resizing.y].max
                resized_(@width, @height)
        elsif v = @views[@focus_idx]
                v.mousemove(x, y-v.y) if v.respond_to? :mousemove
        end
end
mouserelease(x, y) click to toggle source
# File metasm/gui/win32.rb, line 1596
def mouserelease(x, y)
        if @resizing
                @wantheight[@resizing] = [0, y - @resizing.y].max
                @resizing = nil
                @tmpwantheight.each { |vv| @wantheight.delete vv }
                @tmpwantheight = nil
                resized_(@width, @height)
        elsif v = @views[@focus_idx]
                v.mouserelease(x, y-v.y) if v.respond_to? :mouserelease
        end
end
paint_(hdc) click to toggle source
# File metasm/gui/win32.rb, line 1631
def paint_(hdc)
        # TODO check invalidated rectangle
        x = @x
        y = @y
        Win32Gui.selectobject(hdc, Win32Gui.getstockobject(Win32Gui::DC_BRUSH))
        Win32Gui.selectobject(hdc, Win32Gui.getstockobject(Win32Gui::DC_PEN))
        col = Win32Gui.getsyscolor(Win32Gui::COLOR_BTNFACE)
        Win32Gui.setdcbrushcolor(hdc, col)
        Win32Gui.setdcpencolor(hdc, col)
        @views.each { |v|
                v.paint_(hdc) if v.height > 0
                y += v.height
                Win32Gui.rectangle(hdc, x, y, x+@width, y+@spacing)
                y += @spacing
        }
        Win32Gui.rectangle(hdc, x, y, x+@width, y+@height)
end
redraw() click to toggle source
# File metasm/gui/gtk.rb, line 141
def redraw
end
resize_child(cld, w, h) click to toggle source
# File metasm/gui/gtk.rb, line 128
def resize_child(cld, w, h)
        pk = query_child_packing(cld)
        if h <= 0
                pk[0] = true
                h = 1
        else
                pk[0] = false
        end
        return if h == cld.allocation.height
        set_child_packing(cld, *pk)
        cld.set_height_request(h)
end
resized_(w, h) click to toggle source
# File metasm/gui/win32.rb, line 1649
def resized_(w, h)
        @width = w
        @height = h
        x = @x
        y = @y
        freesize = h
        freesize -= @spacing*(@views.length-1)
        nrfree = 0
        @views.each { |v|
                if @wantheight[v]
                        freesize -= @wantheight[v]
                else
                        nrfree += 1
                end
        }
        freesize = 0 if freesize < 0
        @views.each { |v|
                v.x = x
                v.y = y
                ch = @wantheight[v] || freesize/nrfree
                v.resized_(w, ch)
                y += ch + @spacing
        }
        redraw
end
set_focus(c) click to toggle source
# File metasm/gui/win32.rb, line 1709
def set_focus(c)
        @focus_idx = @views.index(c)
        grab_focus
        redraw
end