Class: QDA::GUI::DocumentsAndCategories

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

Instance Method Summary collapse

Constructor Details

#initialize(parent, weft_client) ⇒ DocumentsAndCategories

Returns a new instance of DocumentsAndCategories.



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/weft/wxgui/sidebar.rb', line 3

def initialize(parent, weft_client)
  @client = weft_client
  @app = @client.app
  super(parent, -1, DEF_POS, DEF_SIZE, Wx::SP_3DSASH)
  
  minimum_pane_size = 75
  panel_docs = Wx::Panel.new(self)
  panel_docs_sizer = Wx::BoxSizer.new(Wx::VERTICAL)

  doc_label = Wx::StaticBox.new(panel_docs, -1, Lang::DOC_PANEL_TITLE)
  doc_box_sizer = Wx::StaticBoxSizer.new(doc_label, Wx::VERTICAL)

  # Document List
  @doc_list = DocumentList.new(@client, panel_docs)
  doc_box_sizer.add(@doc_list, 1, Wx::GROW|Wx::ALL|Wx::ADJUST_MINSIZE, 4)

  # Buttons Below Document List
  butt_panel = Wx::Panel.new(panel_docs)
  butt_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)

  @view_doc_button = Wx::Button.new(butt_panel, -1, 
                                      Lang::VIEW_DOC_BUTTON )
  @view_doc_button.evt_button(@view_doc_button.get_id) do | e |
    if @doc_list.selected_document
      @client.on_document_open( @doc_list.selected_document )
    end
  end
  
  @view_doc_button.disable()
  evt_listbox( @doc_list.get_id ) { | e | @view_doc_button.enable(true) }

  butt_sizer.add(@view_doc_button, 0, Wx::ALL|Wx::ALIGN_LEFT, 4)

  button = Wx::Button.new(butt_panel, -1, Lang::IMPORT_DOC_BUTTON)
  button.evt_button(button.get_id) { | e | @client.on_import_document(e) }
  butt_sizer.add(button, 0, Wx::ALL|Wx::ALIGN_RIGHT, 4)

  butt_panel.set_sizer(butt_sizer)
  doc_box_sizer.add(butt_panel, 0, Wx::ALL|Wx::GROW|Wx::ADJUST_MINSIZE)
  panel_docs_sizer.add(doc_box_sizer, 1, Wx::ALL|Wx::GROW, 4)
  panel_docs.set_sizer(panel_docs_sizer)

  # Category Tree
  panel_cats = Wx::Panel.new(self)
  panel_cats_sizer = Wx::BoxSizer.new(Wx::VERTICAL)

  cats_label = Wx::StaticBox.new(panel_cats, -1, Lang::CAT_PANEL_TITLE)
  cats_box_sizer = Wx::StaticBoxSizer.new(cats_label, Wx::VERTICAL)

  @tree_list = CategoryTree.new(@client, panel_cats, false)
  cats_box_sizer.add(@tree_list, 3, Wx::GROW|Wx::ALL, 4)

  # Buttons below Category Tree
  butt_panel = Wx::Panel.new(panel_cats)
  butt_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)

  button = Wx::Button.new(butt_panel, -1, Lang::VIEW_CAT_BUTTON)
  button.evt_button(button.get_id) do | e |
    if @tree_list.selected_category
      @client.on_category_open( @tree_list.selected_category )
    end
  end      
  button.disable()
  @view_cat_button = button
  evt_tree_sel_changing( @tree_list.get_id ) do | e |
    @tree_list.valid_selection?(e) ?
      @view_cat_button.enable(true) : @view_cat_button.disable()
  end
  butt_sizer.add(button, 0, Wx::ALL|Wx::ALIGN_RIGHT, 4)

  button = Wx::Button.new(butt_panel, -1, Lang::NEW_CAT_BUTTON)
  button.evt_button(button.get_id) { | e | @tree_list.on_create_item() }
  butt_sizer.add(button, 0, Wx::ALL|Wx::ALIGN_LEFT, 4)

  butt_panel.set_sizer(butt_sizer)
  cats_box_sizer.add(butt_panel, 0, Wx::ALL|Wx::GROW|Wx::ADJUST_MINSIZE)
  panel_cats_sizer.add(cats_box_sizer, 1, Wx::ALL|Wx::GROW, 4)
  panel_cats.set_sizer(panel_cats_sizer)


  @app.each_doc { | d | @doc_list.append_item(d) }
  @tree_list.populate( @app.get_all_categories() )
  if opened = @app.get_preference('TreeLayout')
    @tree_list.expand_items(opened)
  end
  
  split_horizontally(panel_docs, panel_cats, 200)
end