wex v24.04.0
Public Member Functions | List of all members
wex::file_history Class Reference

Offers file history methods. More...

#include <wex/ui/file-history.h>

Public Member Functions

 file_history (size_t max_files=9, wxWindowID id_base=wxID_FILE1, const std::string &key=std::string())
 Default constructor.
 
 ~file_history ()
 Destructor.
 
const path operator[] (size_t index) const
 Returns the path at this index (zero-based).
 
bool append (const path &p)
 Appends a file (if file exists) to the file history list.
 
void clear ()
 Clears history.
 
bool empty () const
 Returns true if history is empty.
 
wxWindowID get_base_id () const
 Returns baseid.
 
std::vector< pathget_history_files (size_t max) const
 Returns a vector of max recent opened files.
 
size_t get_max_files () const
 Returns max files.
 
void popup_menu (wxWindow *win, int clear_id=-1, const wxPoint &pos=wxDefaultPosition) const
 Shows popup menu containing all recent opened files.
 
void save ()
 Saves the file history into the config.
 
size_t size () const
 Returns number of items.
 
void use_menu (wxWindowID id, wex::menu *menu)
 Adds a recent file submenu to specified menu, and sets the file history to use it.
 

Detailed Description

Offers file history methods.

Constructor & Destructor Documentation

◆ file_history()

wex::file_history::file_history ( size_t max_files = 9,
wxWindowID id_base = wxID_FILE1,
const std::string & key = std::string() )

Default constructor.

Fills the file history with items available from the config.

Parameters
max_filesmax number of files to use
id_basebase for menu id
keyif key is empty string, files are loaded / saved to default keys, otherwise to specified key.

Member Function Documentation

◆ append()

bool wex::file_history::append ( const path & p)

Appends a file (if file exists) to the file history list.

Returns true if file is appended.

◆ popup_menu()

void wex::file_history::popup_menu ( wxWindow * win,
int clear_id = -1,
const wxPoint & pos = wxDefaultPosition ) const

Shows popup menu containing all recent opened files.

Parameters
winwindow which will get the popup menu
clear_idadds a clear menu items as well (if not -1)
posposition for popup menu