~ubuntu-branches/ubuntu/raring/codeblocks/raring-proposed

« back to all changes in this revision

Viewing changes to src/plugins/contrib/wxSmithContribItems/wxthings/wxthings/include/wx/things/filebrws.h

  • Committer: Bazaar Package Importer
  • Author(s): Cosme Domínguez Díaz
  • Date: 2010-08-09 04:38:38 UTC
  • mfrom: (1.1.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20100809043838-a59ygguym4eg0jgw
Tags: 10.05-0ubuntu1
* New upstream release. Closes (LP: #322350)
 - Switch to dpkg-source 3.0 (quilt) format
 - Remove unneeded README.source
 - Add debian/get-source-orig script that removes all
   Windows prebuilt binaries
* Bump Standards-Version to 3.9.1
 - Stop shipping *.la files
* debian/control
 - Add cdbs package as Build-Depend
 - Add libbz2-dev and zlib1g-dev packages as
   Build-Depends (needed by libhelp_plugin.so)
 - Remove dpatch package of Build-Depends
 - Add codeblocks-contrib-debug package
 - Split architecture-independent files of codeblocks
   package in codeblocks-common package
* debian/rules
 - Switch to CDBS rules system
 - Add parallel build support
 - Add a call to debian/get-source-orig script
 - Use lzma compression (saves 23,5 MB of free space)
* debian/patches
 - Refresh 01_codeblocks_plugin_path
 - Add 02_no_Makefiles_in_debian_dir to remove any link
   in codeblocks build system to deleted Makefiles of debian directory
 - Drop 02_ftbfs_gcc44 and 03_ftbfs_glib221 (merged in upstream)
* debian/watch
 - Update to use the new host (berlios.de)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/////////////////////////////////////////////////////////////////////////////
2
 
// Name:        filebrws.h
3
 
// Purpose:     A file browser widget with tree and/or list control views
4
 
// Author:      John Labenski
5
 
// Created:     07/01/02
6
 
// Copyright:   John Labenski, 2002
7
 
// License:     wxWidgets
8
 
/////////////////////////////////////////////////////////////////////////////
9
 
 
10
 
#ifndef __WX_FILEBROWSER_H__
11
 
#define __WX_FILEBROWSER_H__
12
 
 
13
 
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
14
 
    #pragma interface "filebrws.h"
15
 
#endif
16
 
 
17
 
#include "wx/listctrl.h"
18
 
#include "wx/dirctrl.h"
19
 
#include "wx/filedlg.h"
20
 
#include "wx/textdlg.h"
21
 
#include "wx/generic/filedlgg.h"
22
 
#include "wx/things/thingdef.h"
23
 
 
24
 
class WXDLLEXPORT wxCheckBox;
25
 
class WXDLLEXPORT wxComboBox;
26
 
class WXDLLEXPORT wxTreeEvent;
27
 
class WXDLLEXPORT wxSplitterWindow;
28
 
class WXDLLEXPORT wxGenericDirCtrl;
29
 
class WXDLLEXPORT wxListCtrl;
30
 
class WXDLLEXPORT wxListEvent;
31
 
class WXDLLEXPORT wxToolBar;
32
 
class WXDLLEXPORT wxBitmapButton;
33
 
class WXDLLEXPORT wxConfigBase;
34
 
class WXDLLEXPORT wxFileCtrl;
35
 
class WXDLLEXPORT wxFileName;
36
 
 
37
 
class WXDLLIMPEXP_THINGS wxFileBrowser;
38
 
 
39
 
#include "wx/dynarray.h"
40
 
WX_DECLARE_OBJARRAY_WITH_DECL(wxFileData, wxArrayFileData, class WXDLLIMPEXP_THINGS);
41
 
 
42
 
//----------------------------------------------------------------------------
43
 
// MultilineTextDialog : wxTextEntryDialog for multiple lines
44
 
//----------------------------------------------------------------------------
45
 
 
46
 
class WXDLLIMPEXP_THINGS MultilineTextDialog : public wxTextEntryDialog
47
 
{
48
 
public:
49
 
    MultilineTextDialog(wxWindow *parent,
50
 
                        const wxString& message,
51
 
                        const wxString& caption = wxGetTextFromUserPromptStr,
52
 
                        const wxString& value = wxEmptyString,
53
 
                        long  style = 0,
54
 
                        const wxPoint& pos = wxDefaultPosition);
55
 
};
56
 
 
57
 
//----------------------------------------------------------------------------
58
 
// wxFileBrowserEvent : events for the wxFileBrowser
59
 
//----------------------------------------------------------------------------
60
 
// wxEVT_FILEBROWSER_FILE_SELECTED  - a file has been selected (single click)
61
 
// wxEVT_FILEBROWSER_FILE_ACTIVATED - a file has been double clicked or enter pressed
62
 
// wxEVT_FILEBROWSER_DIR_SELECTED   - a dir has been selected (single click)
63
 
// wxEVT_FILEBROWSER_DIR_ACTIVATED  - a dir has been double clicked or enter pressed
64
 
 
65
 
BEGIN_DECLARE_EVENT_TYPES()
66
 
    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_THINGS, wxEVT_FILEBROWSER_FILE_SELECTED,  wxEVT_USER_FIRST + 1000)
67
 
    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_THINGS, wxEVT_FILEBROWSER_FILE_ACTIVATED, wxEVT_USER_FIRST + 1001)
68
 
    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_THINGS, wxEVT_FILEBROWSER_DIR_SELECTED,   wxEVT_USER_FIRST + 1002)
69
 
    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_THINGS, wxEVT_FILEBROWSER_DIR_ACTIVATED,  wxEVT_USER_FIRST + 1003)
70
 
END_DECLARE_EVENT_TYPES()
71
 
 
72
 
class WXDLLIMPEXP_THINGS wxFileBrowserEvent : public wxCommandEvent
73
 
{
74
 
public:
75
 
    wxFileBrowserEvent( wxEventType commandType = wxEVT_NULL,
76
 
                        wxFileBrowser *fileBrowser = NULL,
77
 
                        wxWindowID id = wxID_ANY );
78
 
 
79
 
    wxFileBrowserEvent( const wxFileBrowserEvent &event ) : wxCommandEvent(event) {}
80
 
 
81
 
    // Get the full path + filename
82
 
    wxString GetFilePath() const { return GetString(); }
83
 
    void SetFilePath(const wxString &filepath) { SetString(filepath); }
84
 
 
85
 
    virtual wxEvent *Clone() const { return new wxFileBrowserEvent(*this); }
86
 
 
87
 
private:
88
 
    DECLARE_ABSTRACT_CLASS(wxFileBrowserEvent)
89
 
};
90
 
 
91
 
typedef void (wxEvtHandler::*wxFileBrowserEventFunction)(wxFileBrowserEvent&);
92
 
 
93
 
#define wxFileBrowserEventHandler(func) \
94
 
    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxFileBrowserEventFunction, &func)
95
 
 
96
 
#define wx__DECLARE_FILEBROWSEREVT(evt, id, fn) wx__DECLARE_EVT1( evt, id, wxFileBrowserEventHandler(fn))
97
 
 
98
 
#define EVT_FILEBROWSER_FILE_SELECTED(id, fn)  wx__DECLARE_FILEBROWSEREVT( wxEVT_FILEBROWSER_FILE_SELECTED,  id, fn )
99
 
#define EVT_FILEBROWSER_FILE_ACTIVATED(id, fn) wx__DECLARE_FILEBROWSEREVT( wxEVT_FILEBROWSER_FILE_ACTIVATED, id, fn )
100
 
#define EVT_FILEBROWSER_DIR_SELECTED(id, fn)   wx__DECLARE_FILEBROWSEREVT( wxEVT_FILEBROWSER_DIR_SELECTED,   id, fn )
101
 
#define EVT_FILEBROWSER_DIR_ACTIVATED(id, fn)  wx__DECLARE_FILEBROWSEREVT( wxEVT_FILEBROWSER_DIR_ACTIVATED,  id, fn )
102
 
 
103
 
//----------------------------------------------------------------------------
104
 
// wxFileBrowser
105
 
//----------------------------------------------------------------------------
106
 
 
107
 
enum wxFileBrowserStyles_Type
108
 
{
109
 
    // note: these are wxListCtrl styles to allow normal wxWindow styles to work
110
 
 
111
 
    wxFILEBROWSER_TREE       = wxLC_SORT_DESCENDING,  // treectrl view
112
 
    wxFILEBROWSER_LIST       = wxLC_LIST,             // listctrl view
113
 
    wxFILEBROWSER_DETAILS    = wxLC_REPORT,           // listctrl details view
114
 
    wxFILEBROWSER_SMALL_ICON = wxLC_SMALL_ICON,       // listctrl icon view
115
 
    wxFILEBROWSER_LARGE_ICON = wxLC_ICON,             // NOT IMPL listctrl large icon
116
 
    wxFILEBROWSER_PREVIEW    = wxLC_SORT_ASCENDING,   // NOT implemented
117
 
 
118
 
    wxFILEBROWSER_SPLIT_VERTICAL = wxLC_NO_HEADER,    // tree and listctrl are
119
 
                                                      // split vertically else horizontal
120
 
 
121
 
    wxFILEBROWSER_SHOW_FOLDERS = wxLC_NO_SORT_HEADER, // when showing listview also show
122
 
                                                      // the folders in the treectrl
123
 
 
124
 
    wxFILEBROWSER_VIEW_MASK = wxFILEBROWSER_TREE|wxFILEBROWSER_LIST|wxFILEBROWSER_DETAILS|wxFILEBROWSER_SMALL_ICON|wxFILEBROWSER_LARGE_ICON|wxFILEBROWSER_PREVIEW,
125
 
    wxFILEBROWSER_STYLE_MASK = wxFILEBROWSER_VIEW_MASK|wxFILEBROWSER_SPLIT_VERTICAL|wxFILEBROWSER_SHOW_FOLDERS
126
 
};
127
 
 
128
 
class WXDLLIMPEXP_THINGS wxFileBrowser : public wxControl
129
 
{
130
 
public :
131
 
    wxFileBrowser() : wxControl() { Init(); }
132
 
 
133
 
    wxFileBrowser( wxWindow* parent, const wxWindowID id,
134
 
                   const wxString& dir = wxDirDialogDefaultFolderStr,
135
 
                   const wxPoint& pos = wxDefaultPosition,
136
 
                   const wxSize& size = wxDefaultSize,
137
 
                   long style = wxFILEBROWSER_DETAILS,
138
 
                   const wxString& filter = wxFileSelectorDefaultWildcardStr,
139
 
                   int defaultFilter = 0,
140
 
                   const wxString& name = wxT("wxFileBrowser")) : wxControl()
141
 
    {
142
 
        Init();
143
 
        Create(parent, id, dir, pos, size, style, filter, defaultFilter, name);
144
 
    }
145
 
 
146
 
    virtual ~wxFileBrowser();
147
 
 
148
 
    bool Create( wxWindow* parent, const wxWindowID id,
149
 
                 const wxString& dir = wxDirDialogDefaultFolderStr,
150
 
                 const wxPoint& pos = wxDefaultPosition,
151
 
                 const wxSize& size = wxDefaultSize,
152
 
                 long style = wxFILEBROWSER_DETAILS,
153
 
                 const wxString& filter = wxFileSelectorDefaultWildcardStr,
154
 
                 int defaultFilter = 0,
155
 
                 const wxString& name = wxT("wxFileBrowser") );
156
 
 
157
 
    // Get the current dir (not file), optionally add a trailing platform dependent '/' or '\'
158
 
    wxString GetPath(bool add_wxFILE_SEP_PATH = false) const;
159
 
    // Go to a directory, returns sucess
160
 
    bool SetPath(const wxString &dirName);
161
 
 
162
 
    // go to a dir or send an EVT_FILEBROWSER_FILE_ACTIVATED if a filename
163
 
    bool OpenFilePath(const wxString &filePath);
164
 
 
165
 
    // Go to a higher directory, returns sucess
166
 
    bool CanGoUpDir() const;
167
 
    bool GoUpDir();
168
 
 
169
 
    // Go to your "Home" folder "~/" in unix, "My Documents" in MSW
170
 
    bool GoToHomeDir();
171
 
 
172
 
    // Go forwards and backwards through the recent dir history
173
 
    bool CanGoPathHistoryForward();
174
 
    bool CanGoPathHistoryBackward();
175
 
    bool GoPathHistoryForward();
176
 
    bool GoPathHistoryBackward();
177
 
    // Add a new path to the history paths at the current index
178
 
    void AddPathHistory(const wxString& path);
179
 
 
180
 
    // Set the file filter to one of the filter combobox items
181
 
    bool SetFilter(int comboItem);
182
 
    // Set all the file filters, deleting previous and select one
183
 
    bool SetFilters(const wxString &filters, int select = 0);
184
 
    // Add or set the file filter, "All Files (*)|*", it must have a "|" in it
185
 
    bool AddFilter(const wxString &filter);
186
 
    // Get the current file filter
187
 
    wxString GetFilter() const { return m_filter; }
188
 
    // Get the wild card used for the filter
189
 
    wxString GetWild() const { return m_filter.AfterLast(wxT('|')); }
190
 
 
191
 
    // Set how the files are displayed - see enum wxFileBrowserStyles_Type
192
 
    void SetBrowserStyle(long style);
193
 
    long GetBrowserStyle() const { return m_browser_style; }
194
 
    bool HasBrowserStyle(int style_mask) const { return (m_browser_style & style_mask) != 0; }
195
 
 
196
 
    // Show or hide hidden files
197
 
    void ShowHidden(bool show_hidden);
198
 
    bool GetShowHidden() const { return m_show_hidden; }
199
 
 
200
 
    // When showing the files in a listctrl also show the folders in the treectrl
201
 
    //   also don't let them unsplit it
202
 
    void ShowFolders(bool show_folders);
203
 
    bool GetShowFolders() const { return HasBrowserStyle(wxFILEBROWSER_SHOW_FOLDERS); }
204
 
 
205
 
    // When splitting, split vertically or horizontally
206
 
    void SplitVertical(bool split_vertically);
207
 
    bool GetSplitVertical() const { return HasBrowserStyle(wxFILEBROWSER_SPLIT_VERTICAL); }
208
 
 
209
 
    // -----------------------------------------------------------------------
210
 
    // implementation
211
 
 
212
 
    // utility function, returns the dir part of the filepath w/ trailing wxFILE_SEP_PATH
213
 
    bool GetPathFromFilePath(const wxString &filepath, wxString &path) const;
214
 
 
215
 
    // Delete all selected items in the wxFileCtrl
216
 
    bool DeleteSelectedListItems(bool ask_ok = true);
217
 
    // Store a list of selected items that you'll copy/cut when you paste them
218
 
    bool CopyCutSelectedListItems(bool copy_them);
219
 
    // Paste the stored CopyCutSelectedListItems - based on CopyCutSelectedListItems list
220
 
    bool PasteCopyCutSelectedListItems();
221
 
 
222
 
    // Get a list of all the selected items in the list control
223
 
    wxArrayInt GetSelectedListItems() const;
224
 
    // Get the wxFileData items that are selected in the list control
225
 
    wxArrayFileData GetSelectedListFileData() const;
226
 
    // Get the currently focused list item or NULL if none selected
227
 
    wxFileData *GetFocusedListItem() const;
228
 
 
229
 
    // Create a wxFileData from a wxFileName
230
 
    wxFileData CreateFileData(const wxFileName& fileName) const;
231
 
 
232
 
    // Get the last or currently focused path + filename
233
 
    wxString GetLastFocusedFilePath();
234
 
 
235
 
    // Show a simple dialog that contains the properties of the file/dir
236
 
    void ShowPropertiesDialog(const wxFileData &fileData) const;
237
 
 
238
 
    // returns a string with the name of a program to run the file
239
 
    wxString GetOpenWithFileCmd(wxFileData* fd) const;
240
 
 
241
 
    // Get a pointer to the path history combo, can change its contents
242
 
    wxComboBox *GetPathCombo() const { return m_pathCombo; }
243
 
    // Get a pointer to the filter combo
244
 
    //   don't delete selections less than the # of filters passed in
245
 
    //   ie. check for items with GetClientData() !NULL
246
 
    wxComboBox *GetFilterCombo() const { return m_filterCombo; }
247
 
 
248
 
    // Can this file be read/opened?
249
 
    bool CanRead(const wxString& filePath) const;
250
 
    // Can this file be written to, deleted, moved, cut...
251
 
    bool CanWrite(const wxString& filePath) const;
252
 
 
253
 
    // Update the menu/toolbar items
254
 
    void UpdateMenu(wxMenu *menu);
255
 
    void UpdateToolBar(wxToolBar *toolBar);
256
 
    // Update the state of the toolbar and menu items
257
 
    void UpdateItems();
258
 
 
259
 
#if wxUSE_CONFIG
260
 
    // Load the recent paths/filters, max = 20
261
 
    void LoadConfig(wxConfigBase& config,
262
 
                    bool paths=true, bool filters=true,
263
 
                    const wxString &configPath = wxT("/wxFileBrowser"));
264
 
    // Save the recent paths, filters, if n_xxx < 0 then don't save it
265
 
    void SaveConfig(wxConfigBase& config,
266
 
                    int n_paths=10, int n_filters=10,
267
 
                    const wxString &configPath = wxT("/wxFileBrowser"));
268
 
#endif // wxUSE_CONFIG
269
 
 
270
 
protected :
271
 
    void OnSize( wxSizeEvent& event );
272
 
    void DoSize();
273
 
 
274
 
    virtual wxSize DoGetBestSize() const;
275
 
 
276
 
    // toolbar tools events
277
 
    void OnViewButtons(wxCommandEvent &event);
278
 
    void OnPathCombo(wxCommandEvent &event);
279
 
    void OnPathComboEnter(wxCommandEvent &event);
280
 
    void OnFilterCombo(wxCommandEvent &event);
281
 
    void OnFilterComboEnter(wxCommandEvent &event);
282
 
 
283
 
    // wxDirCtrl events - a wxTreeCtrl
284
 
    void OnTreeItemSelection(wxTreeEvent &event);
285
 
    void OnTreeItemActivation(wxTreeEvent &event);
286
 
    void OnTreeRightClick(wxTreeEvent& event);
287
 
 
288
 
    // wxFileCtrl events - a wxListCtrl
289
 
    void OnListColClick(wxListEvent &event);
290
 
    void OnListItemActivated(wxListEvent &event);
291
 
    void OnListItemSelected(wxListEvent &event);
292
 
    void OnListRightClick(wxListEvent &event);
293
 
 
294
 
    void OnTreeMenu(wxCommandEvent &event);
295
 
    void OnListMenu(wxCommandEvent &event);
296
 
 
297
 
    void OnIdle( wxIdleEvent &event );
298
 
 
299
 
    //for delayed set path from combo
300
 
    void OnSetPath( wxCommandEvent &event );
301
 
    void OnSetFilter( wxCommandEvent &event );
302
 
 
303
 
    // (re)inserts the item at pos, deleting it if it existed after pos
304
 
    //    keeps recent items at top
305
 
    bool InsertComboItem(wxComboBox *combo, const wxString &item, int pos = 0) const;
306
 
 
307
 
    // Send an event, returns false if event.Veto() called
308
 
    bool DoSendEvent(wxFileBrowserEvent &event) const;
309
 
 
310
 
    int FBStyleToLCStyle(int fb_style) const; // wxFileBrowserStyles_Type to wxLC_XXX
311
 
    int FBStyleToMenuID(int fb_style) const;  // wxFileBrowserStyles_Type menu id
312
 
    int MenuIDToFBStyle(int menuID) const;    // menu id to wxFileBrowserStyles_Type
313
 
 
314
 
    // Windows
315
 
    wxToolBar        *m_viewToolBar;
316
 
    wxToolBar        *m_pathToolBar;
317
 
 
318
 
    wxBitmapButton   *m_viewButton;
319
 
    wxComboBox       *m_filterCombo;
320
 
 
321
 
    wxComboBox       *m_pathCombo;
322
 
 
323
 
    wxSplitterWindow *m_splitterWin;
324
 
    wxGenericDirCtrl *m_dirCtrl;
325
 
    wxFileCtrl       *m_fileCtrl;
326
 
 
327
 
    wxMenu           *m_listMenu;   // popup menu in listctrl
328
 
    wxMenu           *m_treeMenu;   // popup menu in treectrl
329
 
    wxMenu           *m_viewMenu;   // popup menu in for changing view
330
 
 
331
 
    // data
332
 
    wxString m_filter;              // current filter
333
 
    wxString m_path;                // current path
334
 
    wxString m_lastFocusedFilePath; // path + filename of last focused item
335
 
 
336
 
    wxArrayString m_pathHistory;    // recently used paths
337
 
    int m_path_history_index;       // current index in recently used paths
338
 
 
339
 
    wxArrayFileData m_copycutFiles; // list of names when copying or cutting
340
 
    bool m_last_copy;               // last CopyCutSelectedListItems was a copy, else cut
341
 
 
342
 
    int m_init_filters;             // # of filters initially passed in
343
 
 
344
 
    bool m_ignore_tree_event;       // temporarily ignore m_dirCtrl events
345
 
    long m_browser_style;
346
 
 
347
 
    int m_filterComboSelection;     // last selection of the filter/path combo
348
 
    int m_pathComboSelection;
349
 
 
350
 
    bool m_show_hidden;             // show hidden files
351
 
 
352
 
private :
353
 
    void Init();
354
 
    DECLARE_EVENT_TABLE()
355
 
    DECLARE_DYNAMIC_CLASS(wxFileBrowser)
356
 
};
357
 
 
358
 
#endif // __WX_FILEBROWSER_H__