2#ifndef __CXOPENFILEDIALOG_H__
3#define __CXOPENFILEDIALOG_H__
118 const std::string& pTitle =
" Open File ",
119 const std::string& pInitialDir =
"");
127 virtual std::string
cxTypeStr()
const override;
128 virtual void draw()
override;
130 virtual long showModal(
bool pShowSelf =
true,
131 bool pBringToTop =
true,
132 bool pShowSubwindows =
true)
override;
134 virtual long show(
bool pBringToTop =
false,
135 bool pShowSubwindows =
true)
override;
137 virtual void hide(
bool pHideSubwindows =
true)
override;
138 virtual void unhide(
bool pUnhideSubwindows =
true)
override;
139 virtual bool move(
int pNewRow,
int pNewCol,
bool pRefresh =
true)
override;
159 void addFilter(
const std::string& pDescription,
const std::string& pPattern);
199 std::string description;
206 std::string mCurrentPath;
207 std::string mSelectedFileName;
208 std::vector<std::string> mDirEntries;
209 std::vector<FileEntry> mFileEntries;
210 int mDirSelection = 0;
211 int mFileSelection = 0;
212 int mDirScrollOffset = 0;
213 int mFileScrollOffset = 0;
214 FocusItem mFocusItem = FocusItem::FILE_LIST;
216 std::vector<FileFilter> mFilters;
217 int mCurrentFilter = 0;
218 bool mShowHidden =
false;
219 bool mAllowNewFile =
true;
224 std::shared_ptr<cxInput> mFileNameInput;
230 void loadDirectory();
235 void drawSeparators();
236 void drawListHeaders();
239 void drawFilenameRow();
240 void drawControlsRow();
243 void setFocusItem(FocusItem pItem);
249 void moveDirSelection(
int pDelta);
250 void moveFileSelection(
int pDelta);
251 void enterSelectedDir();
252 void activateFilenameInput();
253 void cycleFilter(
int pDelta);
256 bool canAcceptSelection()
const;
259 bool matchesFilter(
const std::string& pFileName)
const;
260 static std::string formatFileSize(uintmax_t pSize);
261 static std::string truncStr(
const std::string& pStr,
int pMaxW);
This is a dialog class that is designed to allow the user to choose a filename in a specific director...
Definition cxOpenFileDialog.h:61
static constexpr int ROW_PATH
Definition cxOpenFileDialog.h:70
static constexpr int CANCEL_TEXT_W
Definition cxOpenFileDialog.h:101
void setDirectory(const std::string &pPath)
Set the initial directory to display.
Definition cxOpenFileDialog.cpp:164
static constexpr int FILENAME_INPUT_W
Definition cxOpenFileDialog.h:94
static constexpr int ROW_LIST_FIRST
Definition cxOpenFileDialog.h:73
virtual void draw() override
Fills the member ncurses window structure with the current.
Definition cxOpenFileDialog.cpp:81
static constexpr int DIALOG_WIDTH
Definition cxOpenFileDialog.h:66
void clearFilters()
Remove all file type filters.
Definition cxOpenFileDialog.cpp:210
static constexpr int DIALOG_HEIGHT
Definition cxOpenFileDialog.h:67
static constexpr int ROW_LIST_LAST
Definition cxOpenFileDialog.h:74
virtual long show(bool pBringToTop=false, bool pShowSubwindows=true) override
Shows the window.
Definition cxOpenFileDialog.cpp:124
static constexpr int LIST_VISIBLE
Definition cxOpenFileDialog.h:75
void addFilter(const std::string &pDescription, const std::string &pPattern)
Add a file type filter (e.g. "Text Files (*.txt)", "*.txt").
Definition cxOpenFileDialog.cpp:204
static constexpr int ROW_FILENAME
Definition cxOpenFileDialog.h:77
static constexpr int COL_LABEL
Definition cxOpenFileDialog.h:82
void setShowHiddenFiles(bool pShow)
Toggle display of hidden files (dotfiles).
Definition cxOpenFileDialog.cpp:216
static constexpr int FILE_COL_START
Definition cxOpenFileDialog.h:90
static constexpr int OK_TEXT_W
Definition cxOpenFileDialog.h:99
void setFileName(const std::string &pFileName)
Pre-populate the filename input.
Definition cxOpenFileDialog.cpp:199
static constexpr int DIR_COL_START
Definition cxOpenFileDialog.h:86
static constexpr int FILE_DISPLAY_W
Definition cxOpenFileDialog.h:91
static constexpr int ROW_CONTROLS
Definition cxOpenFileDialog.h:78
static constexpr int ROW_SEP_TOP
Definition cxOpenFileDialog.h:71
virtual void unhide(bool pUnhideSubwindows=true) override
Un-hides the window.
Definition cxOpenFileDialog.cpp:138
void setAllowNewFile(bool pAllow)
Definition cxOpenFileDialog.cpp:226
static constexpr int FILTER_DISPLAY_W
Definition cxOpenFileDialog.h:97
static constexpr int COL_VALUE
Definition cxOpenFileDialog.h:83
static constexpr int ROW_SEP_BOTTOM
Definition cxOpenFileDialog.h:76
std::string getDirectory() const
Returns the currently displayed directory.
Definition cxOpenFileDialog.cpp:179
bool getAllowNewFile() const
Definition cxOpenFileDialog.cpp:231
virtual bool move(int pNewRow, int pNewCol, bool pRefresh=true) override
Changes the window's position, based on a new upper-left corner.
Definition cxOpenFileDialog.cpp:146
static constexpr int COL_OK_TEXT
Definition cxOpenFileDialog.h:98
virtual long showModal(bool pShowSelf=true, bool pBringToTop=true, bool pShowSubwindows=true) override
Shows the window and waits for input.
Definition cxOpenFileDialog.cpp:88
static constexpr int COL_CANCEL_TEXT
Definition cxOpenFileDialog.h:100
virtual ~cxOpenFileDialog()
Definition cxOpenFileDialog.cpp:68
static constexpr int DIR_DISPLAY_W
Definition cxOpenFileDialog.h:87
virtual void hide(bool pHideSubwindows=true) override
Hides the window.
Definition cxOpenFileDialog.cpp:132
std::string getSelectedFilePath() const
Returns the full path of the selected file (directory + filename).
Definition cxOpenFileDialog.cpp:184
static constexpr int COL_DIVIDER
Definition cxOpenFileDialog.h:81
std::string getSelectedFileName() const
Returns just the selected filename.
Definition cxOpenFileDialog.cpp:194
virtual std::string cxTypeStr() const override
Returns the name of the cxWidgets class. This is overridden.
Definition cxOpenFileDialog.cpp:76
bool getShowHiddenFiles() const
Definition cxOpenFileDialog.cpp:221
static constexpr int ROW_HEADER
Definition cxOpenFileDialog.h:72
Represents a text-based window on the screen. Can contain a title, status, and a message to appear wi...
Definition cxWindow.h:195
cxBorderChars.h - Defines border characters to be used in drawing a box (i.e., in cxWindow and all it...
Definition cxApp.cpp:5