Class: QDA::GUI::SideBar

Inherits:
Wx::Frame
  • Object
show all
Defined in:
lib/weft/wxgui/sidebar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parent, weft_client) ⇒ SideBar

Returns a new instance of SideBar.



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/weft/wxgui/sidebar.rb', line 96

def initialize(parent, weft_client)
  super(parent, -1, Lang::SIDEBAR_TITLE,
        Wx::Point.new(0, 0), 
        parent.proportional_size(0.3, 0.995) )
  @client = weft_client
  self.icon = @client.fetch_icon('project')
  @splitter = DocumentsAndCategories.new(self, @client)

  conf = Wx::ConfigBase::get()
  conf.path = "/SideFrame"
  x = conf.read_int("x", -1)
  x = DEF_POS.x if x < 0
  y = conf.read_int("y", -1)
  y = DEF_POS.y if y < 0
  w = conf.read_int("w", -1)
  w = ( DEF_SIZE.width / 2 ) if w < 160
  h = conf.read_int("h", -1)
  h = DEF_SIZE.height if h < 160
  max = conf.read_bool("max", false)
  
  if max
    maximize(true)
  else
    move( Wx::Point.new(x, y) )
    set_size( Wx::Size.new(w, h) )
  end
  
  split = conf.read_int("split", 200)
  # sometimes weirdly ends up with negative value
  split = client_size.height / 2 if split <= 0
  @splitter.set_sash_position(split)

  evt_close() { | e | on_close(e) }
end

Instance Attribute Details

#doc_listObject (readonly)

Returns the value of attribute doc_list.



94
95
96
# File 'lib/weft/wxgui/sidebar.rb', line 94

def doc_list
  @doc_list
end

#tree_listObject (readonly)

Returns the value of attribute tree_list.



94
95
96
# File 'lib/weft/wxgui/sidebar.rb', line 94

def tree_list
  @tree_list
end

Instance Method Details

#on_close(e) ⇒ Object



131
132
133
134
135
136
# File 'lib/weft/wxgui/sidebar.rb', line 131

def on_close(e)
  if shown?
    @client.on_toggle_dandc(e)
  end
  e.veto() # don't actually destroy the window
end

#remember_sizeObject

save layout to Config so window is same position next time



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/weft/wxgui/sidebar.rb', line 139

def remember_size()
  conf = Wx::ConfigBase::get()
  # global window size settings
  if conf
    size = get_size()
    pos = get_position()
    conf.path = '/SideFrame'
    conf.write("x", pos.x)
    conf.write("y", pos.y)
    conf.write("w", size.width)
    conf.write("h", size.height)
    conf.write("split", @splitter.sash_position)
    conf.write("max", maximized?)
  end
end