libt3widget
filepane.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_FILEPANE_H
15 #define T3_WIDGET_FILEPANE_H
16 
17 #include <string>
18 
19 #include <t3widget/dialogs/popup.h>
20 #include <t3widget/widgets/widget.h>
21 #include <t3widget/contentlist.h>
22 #include <t3widget/widgets/scrollbar.h>
23 #include <t3widget/widgets/textfield.h>
24 
25 #define _T3_WDIGET_FP_MAX_COLUMNS 8
26 
27 namespace t3_widget {
28 
30 class T3_WIDGET_API file_pane_t : public widget_t, public container_t {
31  private:
32  class search_panel_t;
33 
34  struct T3_WIDGET_LOCAL implementation_t {
35  scrollbar_t scrollbar;
36  size_t top_idx,
37  current;
38  file_list_t *file_list;
39  bool focus;
40  text_field_t *field;
41  int column_widths[_T3_WDIGET_FP_MAX_COLUMNS],
42  column_positions[_T3_WDIGET_FP_MAX_COLUMNS],
43  columns_visible,
44  scrollbar_range;
45  signals::connection content_changed_connection;
46  cleanup_ptr<search_panel_t>::t search_panel;
47 
48  implementation_t(void) : scrollbar(false), top_idx(0), current(0), file_list(NULL),
49  focus(false), field(NULL), columns_visible(0), scrollbar_range(1)
50  {}
51  };
52  pimpl_ptr<implementation_t>::t impl;
53 
55  void ensure_cursor_on_screen(void);
57  void draw_line(int idx, bool selected);
59  void update_column_width(int column, int start);
61  void update_column_widths(void);
63  void content_changed(void);
64 
65  void scrollbar_clicked(scrollbar_t::step_t step);
66  void scrollbar_dragged(int start);
67 
68  void search(const std::string *text);
69 
70  public:
71  file_pane_t(void);
72  virtual ~file_pane_t(void);
77  void set_text_field(text_field_t *_field);
78  virtual bool process_key(key_t key);
79  virtual bool set_size(optint height, optint width);
80  virtual void update_contents(void);
81  virtual void set_focus(focus_t _focus);
82 
83  virtual void set_child_focus(window_component_t *target);
84  virtual bool is_child(window_component_t *component);
85 
86  virtual bool process_mouse_event(mouse_event_t event);
87 
89  void reset(void);
91  void set_file_list(file_list_t *_file_list);
93  void set_file(const std::string *name);
94 
95  T3_WIDGET_SIGNAL(activate, void, const std::string *);
96 };
97 
98 
99 class T3_WIDGET_LOCAL file_pane_t::search_panel_t : public popup_t {
100  private:
101  cleanup_t3_window_ptr shadow_window;
102  file_pane_t *parent;
103  bool redraw;
104  text_line_t text;
105  public:
106  search_panel_t(file_pane_t *_parent);
107  virtual bool process_key(key_t key);
108  virtual void set_position(optint top, optint left);
109  virtual bool set_size(optint height, optint width);
110  virtual void update_contents(void);
111  virtual void show(void);
112  virtual bool process_mouse_event(mouse_event_t event);
113 };
114 
115 
116 }; // namespace
117 
118 #endif
The t3_widget namespace is contains all classes, functions and global variables in the libt3widget li...
Definition: autocompleter.cc:18
Abstract base class for all items displayed on screen.
Definition: interfaces.h:28
A widget displaying the contents of a directory.
Definition: filepane.h:30
long key_t
Integer type holding a single key symbol.
Definition: key.h:24
void redraw(void)
Force a complete redraw of the terminal contents.
Definition: main.cc:396
Definition: textline.h:36
Definition: textfield.h:27
Base class for dialogs.
Definition: popup.h:22
Base class for widgets.
Definition: widget.h:24
Base class for window_component_t's that are the parents of other window_component_t's.
Definition: interfaces.h:86
Class defining values with a separate validity check.
Definition: util.h:29
Definition: scrollbar.h:21
Structure holding the relevant elements of a mouse event.
Definition: mouse.h:23
Abstract base class for file lists.
Definition: contentlist.h:66
step_t
Definition: scrollbar.h:46