[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-users] PG_FileSelector Class structure
From: |
Keith Swyer |
Subject: |
[paragui-users] PG_FileSelector Class structure |
Date: |
Thu, 22 Aug 2002 14:37:06 -0300 |
Here is what i have layed out for the PG_FileSelector class so far. I would
really like to have suggestion from everyone. If you see any problems, or
things missing, or that should be moved around, let me know.
#ifndef PG_FILESELECTOR
#define PG_FILESELECTOR
#include "pglistbox.h"
#include "pgbutton.h"
#include "pgdropdown.h"
#include "pgwidget.h"
#include "pglineedit.h"
#include "pgwindow.h"
#include "pgfilearchive.h"
#include "pgcolumnitem.h"
#define PG_OPEN 1
#define PG_SAVE 2
#define PGDDID 9965
#define PGBTNID 99456
#define WIDTH 425
#define HEIGHT 270
#include <list.h>
#define FileListBox(x) PG_ListBox(x, PG_Rect(10, 65, WIDTH-20, HEIGHT-130))
/*! \class PG_FileSelector
The PG_FileSelector class provides dialogs that allow users to select files
or directories.
You will be able to select one or many files from a directory.
As the filesystem structure as seen by paragui is though the PhysFS
library, we will be limiting
the seen directories to only those the programmer inatiates using the
PG_FileArchive::AddArchive.
as such, only the writable directories will been seen by the save
fileselector.
There will be the ability to create a new directory in both open and save
mode. If in open mode,
the directory will NOT be set to writable, if in save mode, it will.
Also, PhysFS allows zip and other archives to be seen as 'directories'. The
will be the option
of setting zip files to be viewed as files or directories, the default will
be as directories.
*/
class PG_FileSelector: public PG_Window {
public:
friend class FileListBox;
//!constructor
/*!
@param parent the parent widget
@param type either open or save fileselector
@param modal is the fileselector going to be run modal
@param style the theme style to load from the themefile
no filefilters will be added, and as such, no files will be listed if
AddFilter is not used.
The fileselector will open with the inital directory of that of the base
directory of the
application.
*/
PG_FileSelector(PG_Widget *parent, int type=PG_OPEN, bool modal=false,const
char* style="FileSelector");
//!constructor
/*!
@param parent the parent widget
@param initaldir the inital directory to open the fileselector into
@param type either open or save fileselector
@param modal is the fileselector going to be run modal
@param style the theme style to load from the themefile
no filefilters will be added, and as such, no files will be listed if
AddFilter is not used.
*/
PG_FileSelector(PG_Widget *parent, char* initaldir, int type=PG_OPEN, bool
modal=false,const char* style="FileSelector");
//! destructor
~PG_FileSelector();
//! add a new extension filter
/*
add a new file extension to sort by
@param name the name type of the file
@param type extension type without the (.)
@param defaultf set this extension to be the default; the one that is set
when the dialogue is shown
*/
void AddFilter(char* name , const char *type, bool defaultf=false );
//! get the name of the selected file
/*!
@return the name of the currently selected file
This should be used after the dialogue is closed.
*/
const char* SelectedFile(void);
//! get the current selected file filter ie - *.mp3
/*!
@return the file extension of the currently selected filter
*/
const char* SelectedFilter(void);
//! sets the selected file
/*!
will set the selected file to \a filename in the current dir. if the file
doesn't exist
then nothing is selected
@param filename the name of the file to select
@returns false if file doesn't exist
*/
bool SetSelected(const char* filename);
//! selects/de-selectes all of the files in the current dir
/*!
@param files if true, then select, otw de-select
*/
void SelectAll(bool files = true);
//! returns a list of all the selected files
/*!
@return a PG_FileList of all selected files
the user is responsible for the deletion of the list and everything in it.
*/
const PG_FileList SelectedFiles(void);
//! get the current filepath
/*!
@return the current filepath
*/
const char* FilePath(void);
//! set the dir
/*!
@param dir the dir to set to
set the current browsing dir
*/
void SetDir(const char* dir);
//! show or hide hidden file
/*!
@param show true if you want to see files with hidden attrib
*/
void ShowHiddenFiles(bool show=true);
//! refresh the current dir
void RefreshDir(void);
//! resort the dir - used in conjunction with RefreshDir
void ResortDir(void);
/*!
\enum ViewMode
The method to view files
*/
enum ViewMode{
//! show name, size, attribs
Detail,
//! show only name
List
};
/*!
\enum SelectMode
*/
enum SelectMode{
//!single file select
SINGLESELECT,
//!multifile select
MULTISELECT
};
//! set the file select mode
/*!
@param mode the mode of selection
*/
void SetSelectMode(SelectMode mode);
//! get the select mode
/*!
@return the SelectMode
*/
int GetSelectMode(void);
//! set the view mode
/*!
@param mode the view mode
*/
void SetViewMode(ViewMode mode);
//! get the view mode
/*!
@return the view mode
*/
int GetViewMode(void);
protected:
//! file selected event
/*!
@param filename name of current filename selected
*/
virtual void eventFileSelected(const char* filename);
//! dir select event
/*!
@param dirname name of current dirname selected
*/
virtual void eventDirEntered(const char* dirname);
//! filter select event
/*!
@param filter name of current filter selected
*/
virtual void eventFilterSelected(const char* filter);
private:
PG_ListBox *my_filescroll;
PG_Button *my_btn1;
PG_Button *my_closebtn;
PG_Button *my_updirbtn;
PG_Button *my_newfolderbtn;
PG_DropDown *my_dirselect;
PG_DropDown *my_typeselect;
PG_LineEdit *my_filename;
char* selectedFile;
char* filePath;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-users] PG_FileSelector Class structure,
Keith Swyer <=