Class: Wee::Examples::Window

Inherits:
Component show all
Defined in:
lib/wee/examples/window.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Component

#add_decoration, #backtrack_state, #backtrack_state_chain, #decoration, #decoration=, #do_render_chain, #each_decoration, #process_callbacks_chain, #remove_decoration, #remove_decoration_if

Methods inherited from Presenter

#backtrack_state, #do_render, #get_property, #lookup_property, #properties, #properties=, #session, template, uses_property

Constructor Details

#initialize(&block) ⇒ Window

Returns a new instance of Window.



5
6
7
8
9
10
# File 'lib/wee/examples/window.rb', line 5

def initialize(&block)
  super()
  @status = :normal  
  @pos_x, @pos_y = "0px", "0px"
  block.call(self) if block
end

Instance Attribute Details

#childObject

Returns the value of attribute child.



3
4
5
# File 'lib/wee/examples/window.rb', line 3

def child
  @child
end

#pos_xObject

Returns the value of attribute pos_x.



3
4
5
# File 'lib/wee/examples/window.rb', line 3

def pos_x
  @pos_x
end

#pos_yObject

Returns the value of attribute pos_y.



3
4
5
# File 'lib/wee/examples/window.rb', line 3

def pos_y
  @pos_y
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/wee/examples/window.rb', line 3

def title
  @title
end

Instance Method Details

#childrenObject



12
13
14
# File 'lib/wee/examples/window.rb', line 12

def children
  [@child].uniq
end

#closeObject



55
56
57
# File 'lib/wee/examples/window.rb', line 55

def close
  @status = :closed
end

#maximizeObject



51
52
53
# File 'lib/wee/examples/window.rb', line 51

def maximize
  @status = :normal
end

#minimizeObject



47
48
49
# File 'lib/wee/examples/window.rb', line 47

def minimize
  @status = :minimized
end

#process_callbacks(&block) ⇒ Object



16
17
18
19
# File 'lib/wee/examples/window.rb', line 16

def process_callbacks(&block)
  return if @status == :closed
  super
end

#renderObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/wee/examples/window.rb', line 21

def render
  return if @status == :closed

  r.table.cellspacing(0).style("border:solid 1px grey; position: absolute; left: #{@pos_x}; top: #{@pos_y};").with do
    r.table_row.style("background-color: lightblue; width: 100%").with do
      r.table_data.style("text-align: left; width: 66%").with(@title)
      r.table_data.style("text-align: right").with do
        if @status == :minimized
          r.anchor.callback(:maximize).with("^")
        else
          r.anchor.callback(:minimize).with("_")
        end
        r.space
        r.anchor.callback(:close).with("x")
      end
    end
    r.table_row do
      r.table_data.colspan(2).with do
        r.render(@child) if @child and @status == :normal
      end
    end
  end
end