Planeshift

pawsfilenavigation.h

Go to the documentation of this file.
00001 /*
00002  * Author: Andrew Mann
00003  *
00004  * Copyright (C) 2004 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 
00020 #ifndef PAWS_FILENAVIGATION_HEADER
00021 #define PAWS_FILENAVIGATION_HEADER
00022 
00023 #include "paws/pawswidget.h"
00024 
00025 class pawsEditTextBox;
00026 class pawsTextBox;
00027 class pawsButton;
00028 class pawsListBox;
00029 class pawsComboBox;
00030 
00035 class iOnFileSelectedAction
00036 {
00037 public:
00038     virtual void Execute(const csString &string) = 0;
00039     // can be -1
00040     virtual ~iOnFileSelectedAction() {};
00041 };
00042 
00043 class pawsFileNavigation : public pawsWidget
00044 {
00045 public:
00046     pawsFileNavigation();
00047     virtual ~pawsFileNavigation();
00048     pawsFileNavigation(const pawsFileNavigation &origin);
00049 
00050     // implemented virtual functions from pawsWidgets
00051     virtual bool PostSetup();
00052     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00053     virtual bool OnChange(pawsWidget* widget);
00054     virtual void OnListAction(pawsListBox* selected, int status);
00055     virtual bool OnKeyDown(utf32_char keyCode, utf32_char key, int modifiers);
00056 
00058     virtual void Show();
00059 
00060 
00062     // filename edit box.
00063     virtual const char* GetFullPathFilename();
00064 
00066     virtual const char* GetCurrentPath();
00067 
00075     virtual int GetSelectionState();
00076 
00078     virtual void SetActionButtonText(const char* actiontext);
00079 
00081     virtual bool SetSelectedFilename(const char* filename);
00082 
00083     virtual bool SetFileFilters(const char* filename);
00084 
00086     virtual bool FillFileList();
00087 
00088     void Initialize(const csString &filename, const csString &filter, iOnFileSelectedAction* action);
00089 
00090     static pawsFileNavigation* Create(
00091         const csString &label, const csString &filter, iOnFileSelectedAction* action, const char* xmlWidget = "filenavigation.xml");
00092 
00093 protected:
00095     virtual bool SetFilterForSelection(const char* filename);
00096     virtual const char* GetFilterForSelection();
00098     virtual bool SmartAppendPath(const char* append);
00100     virtual bool SmartSetPath(const char* path);
00101     virtual bool UpOnePath();
00102     virtual bool DownOnePath(const char* pathstring,int pathlen);
00103     virtual bool RelativeIsFile(const char* filename);
00104 
00105 protected:
00107     csRef<iVFS> vfs;
00108 
00110     csString current_path;
00111 
00112     csArray<csString> zip_mounts;
00113 
00115     pawsListBox* dirlistbox;
00116 
00118     pawsListBox* filelistbox;
00119 
00121     // reconstructed on each call to GetFullPathFilename()
00122     char* fullpathandfilename;
00123 
00125     int selection_state;
00126 
00127     iOnFileSelectedAction* action;
00128 };
00129 
00130 CREATE_PAWS_FACTORY(pawsFileNavigation);
00131 
00134 #endif // #ifndef PAWS_FILENAVIGATION_HEADER
00135