Module: QDA::GUI::InspectorWindowManager
- Includes:
- Subscriber
- Included in:
- MDIWorkArea, MultiFrameWorkArea
- Defined in:
- lib/weft/wxgui/workarea.rb
Overview
The main application window, where docuemnts, categories, searches etc are displayed. Only one instance per application.
Instance Attribute Summary collapse
-
#active_child ⇒ Object
writeonly
This sets the last-focussed child.
Instance Method Summary collapse
- #app ⇒ Object
- #close_all ⇒ Object
-
#get_open_window(bound_obj) ⇒ Object
gets the open MDI window representing
bound_obj
, if there is one. - #get_open_windows(type_of) ⇒ Object
-
#launch_window(klass, bound_obj) ⇒ Object
launch a child window of the type
klass
(which should be a constant of the name of a subclass of QDA::GUI::InspectorWindow), optionally bound to the database objectbound_obj
(typically a document or category). - #notify(ev, content = nil) ⇒ Object
-
#proportional_size(w, h) ⇒ Object
returns a Wx::Size object that has a width equal to that of the current window times
w
, and a height equal to that of the current window timesh
. - #remember_layout(window_id, window, open = false) ⇒ Object
-
#remember_layouts ⇒ Object
remember how the windows were arranged.
- #remember_size ⇒ Object
- #restore_layout(window_id) ⇒ Object
- #restore_layouts ⇒ Object
-
#restore_size ⇒ Object
Resizes the workarea to the state when the application was last used.
- #set_active_category(category) ⇒ Object
Methods included from Subscriber
Instance Attribute Details
#active_child=(value) ⇒ Object (writeonly)
This sets the last-focussed child. However, when later requesting info on the currently active window, MDI reports the active_child() call, whereas the @active_child variable is read by MultiframeWindowManager
-
in MDI there is a foremost window which may not have received focus.
11 12 13 |
# File 'lib/weft/wxgui/workarea.rb', line 11 def active_child=(value) @active_child = value end |
Instance Method Details
#app ⇒ Object
199 200 201 |
# File 'lib/weft/wxgui/workarea.rb', line 199 def app() @client.app end |
#close_all ⇒ Object
174 175 176 177 |
# File 'lib/weft/wxgui/workarea.rb', line 174 def close_all() @window_map.values.each { | child | child.close() } close_d_and_c() end |
#get_open_window(bound_obj) ⇒ Object
gets the open MDI window representing bound_obj
, if there is one
114 115 116 |
# File 'lib/weft/wxgui/workarea.rb', line 114 def get_open_window(bound_obj) @window_map[ window_ident(bound_obj) ] end |
#get_open_windows(type_of) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/weft/wxgui/workarea.rb', line 119 def get_open_windows(type_of) if type_of == QDA::Document doc_wins = @window_map.keys.grep(/^doc-/) return @window_map.values_at( *doc_wins ) elsif type_of == QDA::Category cat_wins = @window_map.keys.grep(/^cat-/) return @window_map.values_at( *cat_wins ) else return [] end end |
#launch_window(klass, bound_obj) ⇒ Object
launch a child window of the type klass
(which should be a constant of the name of a subclass of QDA::GUI::InspectorWindow), optionally bound to the database object bound_obj
(typically a document or category). Returns a reference to the newly opened inspector window.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/weft/wxgui/workarea.rb', line 69 def launch_window(klass, bound_obj) win = nil Wx::BusyCursor.busy(self) do if win = get_open_window(bound_obj) win.activate() else w_i = window_ident(bound_obj) last_layout = restore_layout( w_i ) win = klass.new( bound_obj, @client, self, last_layout ) @window_map[w_i] = win # set up a hook to clean up when this window is closed later win.evt_close() do | e | remember_layout(w_i, win) @window_map.delete(w_i) win.hide() e.skip() end win.activate() end end # should go over D & C window now self.raise() return win end |
#notify(ev, content = nil) ⇒ Object
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/weft/wxgui/workarea.rb', line 179 def notify(ev, content = nil) case ev when :focus_category return # ignore when :ended title = 'Weft QDA' when :saved, :started title = 'Weft QDA' if self.app.dbfile title << " - #{app.dbfile}" else title << " - [New Project]" end else title = get_title() title << '*' if title[-1,1] != '*' end set_title(title) end |
#proportional_size(w, h) ⇒ Object
returns a Wx::Size object that has a width equal to that of the current window times w
, and a height equal to that of the current window times h
. This is used to help size MDI children when they are first created.
58 59 60 61 62 |
# File 'lib/weft/wxgui/workarea.rb', line 58 def proportional_size(w, h) size = client_size() Wx::Size.new( ( size.get_width * w ).to_i, ( size.get_height * h ).to_i ) end |
#remember_layout(window_id, window, open = false) ⇒ Object
141 142 143 144 145 146 147 148 |
# File 'lib/weft/wxgui/workarea.rb', line 141 def remember_layout(window_id, window, open = false) if self.app layouts = app.get_preference('Layouts') || {} layouts[window_id] = window.layout layouts[window_id][:open] = open app.save_preference('Layouts', layouts) end end |
#remember_layouts ⇒ Object
remember how the windows were arranged
132 133 134 135 136 137 138 139 |
# File 'lib/weft/wxgui/workarea.rb', line 132 def remember_layouts() # project specific settings if self.app @window_map.each do | key, window | remember_layout(key, window, true) unless key.nil? end end end |
#remember_size ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/weft/wxgui/workarea.rb', line 39 def remember_size() conf = Wx::ConfigBase::get() # global window size settings if conf size = get_size() pos = get_position conf.path = '/MainFrame' conf.write("x", pos.x) conf.write("y", pos.y) conf.write("w", size.width) conf.write("h", size.height) conf.write("max", is_maximized) end end |
#restore_layout(window_id) ⇒ Object
150 151 152 153 154 155 |
# File 'lib/weft/wxgui/workarea.rb', line 150 def restore_layout(window_id) if self.app layouts = app.get_preference('Layouts') || {} return layouts[window_id] end end |
#restore_layouts ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/weft/wxgui/workarea.rb', line 157 def restore_layouts() if self.app layouts = app.get_preference('Layouts') return unless layouts # get all previously open windows open = layouts.find_all { | x | x[1][:open] } open.each do | ident, layout | if ident =~ /^Document(\w+)$/ @client.on_document_open($1) elsif ident =~ /^Category(\w+)/ and cat = app.get_category($1, true) @client.on_category_open(cat) end end end end |
#restore_size ⇒ Object
Resizes the workarea to the state when the application was last used
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/weft/wxgui/workarea.rb', line 13 def restore_size() conf = Wx::ConfigBase::get() conf.path = "/MainFrame" x = conf.read_int( "x", -1 ) y = conf.read_int( "y", -1 ) w = conf.read_int( "w", -1 ) h = conf.read_int( "h", -1 ) max = conf.read_bool("max", false) x = DEF_POS.x if x < 0 y = DEF_POS.y if y < 0 w = DEF_SIZE.width if w < 200 h = DEF_SIZE.height if h < 200 if max maximize(true) else move( Wx::Point.new(x, y) ) set_size( Wx::Size.new(w, h) ) end end |
#set_active_category(category) ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/weft/wxgui/workarea.rb', line 95 def set_active_category(category) @window_map.each do | name, win | if win.respond_to?(:set_active_category) win.set_active_category(category) end end end |