libt3widget
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
listpane.h
1 /* Copyright (C) 2011-2013 G.P. Halkes
2  This program is free software: you can redistribute it and/or modify
3  it under the terms of the GNU General Public License version 3, as
4  published by the Free Software Foundation.
5 
6  This program is distributed in the hope that it will be useful,
7  but WITHOUT ANY WARRANTY; without even the implied warranty of
8  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  GNU General Public License for more details.
10 
11  You should have received a copy of the GNU General Public License
12  along with this program. If not, see <http://www.gnu.org/licenses/>.
13 */
14 #ifndef T3_WIDGET_LISTPANE_H
15 #define T3_WIDGET_LISTPANE_H
16 
17 #include <t3widget/widgets/widget.h>
18 #include <t3widget/widgets/scrollbar.h>
19 
20 namespace t3_widget {
21 
22 class T3_WIDGET_API list_pane_t : public widget_t, public container_t {
23  private:
24  class T3_WIDGET_LOCAL indicator_widget_t : public widget_t {
25  private:
26  bool has_focus;
27  public:
28  indicator_widget_t(void);
29  virtual bool process_key(key_t key);
30  virtual void update_contents(void);
31  virtual void set_focus(focus_t focus);
32  virtual bool set_size(optint height, optint width);
33  virtual bool accepts_focus(void);
34  };
35 
36  struct T3_WIDGET_LOCAL implementation_t {
37  size_t top_idx, current;
38  cleanup_t3_window_ptr widgets_window;
39  widgets_t widgets;
40  bool has_focus;
41  scrollbar_t scrollbar;
42  bool indicator;
43  bool single_click_activate;
44  cleanup_ptr<indicator_widget_t>::t indicator_widget;
45 
46  implementation_t(bool _indicator) : top_idx(0), current(0),
47  has_focus(false), scrollbar(true), indicator(_indicator),
48  single_click_activate(false)
49  {}
50  };
51  pimpl_ptr<implementation_t>::t impl;
52 
53 
54  void ensure_cursor_on_screen(void);
55  void scroll(int change);
56  void scrollbar_clicked(scrollbar_t::step_t step);
57  void scrollbar_dragged(int start);
58 
59  protected:
60  virtual bool set_widget_parent(window_component_t *widget);
61 
62  public:
63  list_pane_t(bool _indicator);
64  virtual ~list_pane_t(void);
65  virtual bool process_key(key_t key);
66  virtual void set_position(optint top, optint left);
67  virtual bool set_size(optint height, optint width);
68  virtual void update_contents(void);
69  virtual void set_focus(focus_t focus);
70  virtual void set_anchor(window_component_t *anchor, int relation);
71  virtual void force_redraw(void);
72  virtual void set_child_focus(window_component_t *target);
73  virtual bool is_child(window_component_t *widget);
74  virtual bool process_mouse_event(mouse_event_t event);
75  void reset(void);
76  void update_positions(void);
77 
78  void push_back(widget_t *widget);
79  void push_front(widget_t *widget);
80  void pop_back(void);
81  void pop_front(void);
82  widget_t *back(void);
83  widget_t *operator[](int idx);
84  size_t size(void);
85  bool empty(void);
86 
87  typedef size_t iterator;
88 
89  iterator erase(iterator position);
90  iterator begin(void);
91  iterator end(void);
92 
93  size_t get_current(void) const;
94  void set_current(size_t idx);
95 
96  void set_single_click_activate(bool sca);
97 
98  T3_WIDGET_SIGNAL(activate, void);
99  T3_WIDGET_SIGNAL(selection_changed, void);
100 };
101 
102 }; // namespace
103 #endif