Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site













SourceForge.net Logo

FileList

 

class FileList : public ColumnList, private Display

 

 

This class is the ColumnList specialization for displaying lists of files or similar items. List consists of File structures with elements appropriate to describe and display individual files.

 

 

Public Member List

 

Callback2<const String&, const String&> WhenRename

This callback is called when filename was renamed by user. First argument is the original filename, second one is the new filename.

 


 

void StartEdit()

Starts the editation of the current item for rename.

 


 

void EndEdit()

Ends the editation of item.

 


 

bool IsEdit() const

True if editation is active.

 


 

void OkEdit()

Ends the editation and calls WhenRename to actually rename the filename.

 

 


 

void SetIcon(int ii, const Image& icon)

Replaces an icon of file item.

 


 

void Add(const String& name, const Image& icon = Null, Font font = StdFont(), Color ink = SColorText(), bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null, const String& desc = Null, Font descfont = Null, Value data = Null, Color underline = Null, bool unixexe = false, bool hidden = false)

Adds a new file item at the end of list.

 


 

const File& Get(int iconst

Returns the file item structure at specified index.

 


 

const File& operator[](int iconst

Same as Get(i).

 


 

void Insert(int ii, const String& name, const Image& icon = Null, Font font = StdFont(), Color ink = SColorText(), bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null, const String& desc = Null, Font descfont = Null, Value data = Null, Color underline = Null, bool unixexe = false, bool hidden = false)

Inserts a new file item at specified position.

 


 

void Set(int ii, const String& name, const Image& icon = Null, Font font = StdFont(), Color ink = SColorText(), bool isdir = false, int64 length = 0, Time time = Null, Color extink = Null, const String& desc = Null, Font descfont = Null, Value data = Null, Color underline = Null, bool unixexe = false, bool hidden = false)

Replaces an information about a file item at specified position.

 


 

void Set(int ii, const File& f)

Replaces an information about a file item at specified position.

 


 

String GetCurrentName() const

Returns the filename of item with cursor. If there is no cursor, returns empty String.

 


 

int Find(const char *name)

The index of the item with specified name or negative value if not in the list. Search is linear.

 


 

bool FindSetCursor(const char *name)

If item with name.is in the list, sets the cursor to it and returns true, otherwise returns false.

 


 

void Sort(const Order& order)

Sorts the list. Order contains single virtual method for ordering File structures.

 


 

FileList& IconWidth(int w)

Sets the space reserved for painting the file icon.

 


 

int GetIconWidth() const

Returns the value set by IconWidth.

 


 

FileList& Renaming(bool b = true)

In renaming mode, user is allowed to edit the name of item (by holding mouse button over the item). WhenRename callback is called when user accepts the new name.

 


 

FileList& JustName(bool b = true)

In JustName mode, if filename contains \ or / characters, only the part after last such character is displayed as filename.

 


 

FileList& AccelKey(bool b = true)

AccelKey activates searching for file starting on key press (first letter of filename is matched).

 


 

void SelectDir(bool b = true)

In SelectDir mode, directories can be selected (important for multiselecting directories in FileSel).

 

 

 

FileList::File

 

struct File

Structure used to hold information about the item. Some items, like file length, are in fact not directly used by FileList and are only provided to make FileList usage simpler for its primary applications (e.g. file selectors).

 

 

Public Member List

 

bool isdir

If true, item contains directory.

 


 

bool unixexe

If true, item in POSIX has executable rights.

 


 

bool hidden

If true, item is hidden.

 


 

Image icon

File icon.

 


 

String name

Filename.

 


 

Font font

Font used to display the filename.

 


 

Color ink

Color used to display the filename.

 


 

int64 length

Length of file.

 


 

Time time

Last write time.

 


 

Color extink

Color used to display the file extension.

 


 

String desc

Additional description of file, displayed after the filename.

 


 

Font descfont

Font used for additional description.

 


 

operator const String&() const

Returns name.

 

 

 

 

FileList routines

 

bool Load(FileList& list, const String& dir, const char *patterns, bool dirs = false, Callback3<bool, const String&, Image&> WhenIcon = CNULL, FileSystemInfo& filesystem = StdFileSystemInfo(), const String& search = String(), bool hidden = true)

This function loads list with file items in dir. patterns contain allowed file masks separated by semicolon (e.g. "*.cpp;*.h"). If dirs is false, files in the list are displayed with "disabled" color (useful for directory selection). WhenIcon specifies icon assignment for individual filenames (first bool paremeter is true for directories). filesystem specifies the file system interface.

 


 

void SortByName(FileList& list)

Sorts the list by names.

 


 

void SortByExt(FileList& list)

Sorts the list by extensions.

 


 

Image GetDriveImage(char drive_style)

Returns the OS dependent icon of drive_style.

 

 

Last edit by cxl on 01/19/2013. Do you want to contribute?. T++