1 /* fsv - 3D File System Visualizer
2  * Copyright (C)2009-2011 Yury P. Fedorchenko <yuryfdr@users.sf.net>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18 
19 #ifndef __fsv_window_h__
20 #define __fsv_window_h__
21 #include "common.h"
22 #include <color.h>
23 
24 #if defined HAVE_FTGL
25 #include <FTGL/ftgl.h>
26 #elif defined HAVE_GL_GLC_H
27 #include <GL/glc.h>
28 extern GLint textFont;
29 #endif
30 
31 #ifdef __cplusplus
32 #include <gtkmm.h>
33 
34 class FsvDirTree : public Gtk::TreeView{
35 public:
36   struct FsvDirColumns : public Gtk::TreeModelColumnRecord{
37     Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
38     Gtk::TreeModelColumn<Glib::ustring> name;
39     Gtk::TreeModelColumn<GNode*> dnode;
FsvDirColumnsFsvDirColumns40     FsvDirColumns(){
41       add(icon);
42       add(name);
43       add(dnode);
44     }
45   } records;
46 protected:
47   virtual bool on_button_press_event(GdkEventButton* event);
48 //virtual void on_row_activated	(const Gtk::TreeModel::Path&	path,Gtk::TreeViewColumn* column);
49   virtual void on_row_collapsed	(const Gtk::TreeModel::iterator& iter,const Gtk::TreeModel::Path&	path);
50 	virtual void on_row_expanded 	(const Gtk::TreeModel::iterator& iter,const Gtk::TreeModel::Path&	path);
51 public:
52   Glib::RefPtr<Gtk::TreeStore> model;
53   Glib::RefPtr<Gdk::Pixbuf> folder_closed;
54   Glib::RefPtr<Gdk::Pixbuf> folder_opened;
55   FsvDirTree();
56   static FsvDirTree* dir_tree;
57 };
58 
59 class FsvFileList : public Gtk::TreeView{
60 public:
61   struct FsvFLColumns : public Gtk::TreeModelColumnRecord{
62     Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
63     Gtk::TreeModelColumn<Glib::ustring> name;
64     Gtk::TreeModelColumn<GNode*> node;
FsvFLColumnsFsvFLColumns65     FsvFLColumns(){
66       add(icon);
67       add(name);
68       add(node);
69     }
70   } records;
71   struct PropColumns : public Gtk::TreeModelColumnRecord{
72     Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
73     Gtk::TreeModelColumn<Glib::ustring> name;
74     Gtk::TreeModelColumn<unsigned int> count;
75     Gtk::TreeModelColumn<unsigned int> size;
PropColumnsPropColumns76     PropColumns(){
77       add(icon);
78       add(name);
79       add(count);
80       add(size);
81     }
82   } prop_cols;
83 protected:
84 /*  virtual void on_row_activated	(const Gtk::TreeModel::Path&	path,Gtk::TreeViewColumn* column);
85   virtual void on_row_collapsed	(const Gtk::TreeModel::iterator& iter,const Gtk::TreeModel::Path&	path);
86 	virtual void on_row_expanded 	(const Gtk::TreeModel::iterator& iter,const Gtk::TreeModel::Path&	path);
87 	*/
88   virtual bool on_button_press_event(GdkEventButton* event);
89 	Gtk::TreeView::Column nm;
90 	Gtk::TreeView::Column nm_s,count_s,size_s;
91 public:
92   Glib::RefPtr<Gtk::ListStore> model;
93   Glib::RefPtr<Gtk::ListStore> scan_model;
94   FsvFileList();
95   static FsvFileList* file_tree;
96   void switch_scan();
97   void switch_list();
98 };
99 
100 class FsvWindow : public Gtk::Window {
101 #if defined HAVE_FTGL
102 public:
103   FTFont *font;
104 private:
105 #elif defined HAVE_GL_GLC_H
106   GLint ctx;
107 #endif
108   static Gtk::StockID BIRDEYE;
109   static Gtk::StockItem BirdEye;
110   Gtk::VBox bx_main;
111   Gtk::VBox bx_left;
112   Gtk::VPaned pn_left;
113   Gtk::HPaned pn_main;
114   Gtk::Table  tbl_right;
115   Gtk::HScrollbar x_scroll;
116   Gtk::VScrollbar y_scroll;
117   Gtk::ScrolledWindow scr_tree;
118   Gtk::ScrolledWindow scr_list;
119   FsvDirTree tr_dirs;
120   FsvFileList tr_files;
121 public:
122   Gtk::Statusbar sbar,rsbar;
123 protected:
124   void on_change_root();
125   void on_exit();
126   void on_about();
127   void on_fsv_mode(FsvMode mode);
128   void on_birdseye_view();
129 public:
130   Glib::RefPtr<Gtk::ToggleAction> birdeye;
131   Glib::RefPtr<Gtk::ActionGroup> ag_unsetsitive;
132   Glib::RefPtr<Gtk::ActionGroup> ag_allways;
133   Glib::RefPtr<Gtk::UIManager > ui_man;
134   Gtk::Menu *popa;
135   GNode* popa_node;
136   Glib::RefPtr<Gio::File> file;
137 protected:
138   Glib::RefPtr<Gtk::ToggleAction> fullscr;
139   void on_fullscreen();
140   void on_collapse();
141   void on_expand();
142   void on_expand_all();
143   void on_look_at();
144   void on_properties();
145   void on_open();
146 
147   void on_color_type(ColorMode);
148   void on_color_setup();
149   void on_cd_root();
150   void on_cd_back();
151   void on_cd_up();
152 public:
153   static Glib::RefPtr<Gdk::Pixbuf> fsvicon;
154   static Glib::RefPtr<Gdk::Pixbuf> node_type_mini_icons[NUM_NODE_TYPES];
155   static Glib::RefPtr<Gdk::Pixbuf> get_file_icon(const GNode* node,int size);
156   FsvWindow();
157   ~FsvWindow();
158   static FsvWindow* current;
159 };
160 
161 void window_set_color_mode( ColorMode mode );
162 
163 
164 extern "C" {
165 typedef enum {
166 	SB_LEFT,
167 	SB_RIGHT
168 } StatusBarID;
169 };
170 void window_statusbar( StatusBarID sb_id, const std::string& message );
171 extern "C" {
172 #else
173 #include <gtk/gtk.h>
174 typedef enum {
175 	SB_LEFT,
176 	SB_RIGHT
177 } StatusBarID;
178 #endif
179 
180 void window_statusbar( StatusBarID sb_id, const char *message );
181 void gui_update();
182 void gui_cursor( GtkWidget *widget, int glyph );
183 void window_birdseye_view_off( void );
184 void window_set_access( boolean enabled );
185 boolean gui_adjustment_widget_busy( GtkAdjustment *adj );
186 void context_menu( GNode *node, GdkEventButton *ev_button );
187 
188 void text_init( void );
189 void text_pre( void );
190 void text_post( void );
191 void text_draw_straight( const char *text, const XYZvec *text_pos, const XYvec *text_max_dims );
192 void text_draw_straight_rotated( const char *text, const RTZvec *text_pos, const XYvec *text_max_dims );
193 void text_draw_curved( const char *text, const RTZvec *text_pos, const RTvec *text_max_dims );
194 
195 #ifdef __cplusplus
196 };
197 #endif
198 
199 #endif // __fsv_window_h__
200 
201