22#ifndef KITLIST_GUI_HPP
23#define KITLIST_GUI_HPP
26#include "wx/dataview.h"
27#include "wx/filehistory.h"
28#include "wx/richtext/richtextprint.h"
29#include "wx/splitter.h"
87 virtual bool OnInit()
override;
94 virtual int OnExit()
override;
204 void OnShow(wxShowEvent& event);
207 void OnAbout(wxCommandEvent& event);
213 void OnOpen(wxCommandEvent& event);
222 void OnSave(wxCommandEvent& event);
225 void OnSaveAs(wxCommandEvent& event);
228 void OnQuit(wxCommandEvent& event);
231 void OnAddItem(wxCommandEvent& WXUNUSED(event));
394 void load_file(
const std::string filename);
478 std::vector<std::shared_ptr<Category>>& categories);
514 void OnPrint(wxCommandEvent& event);
545 void do_open(wxString wx_path);
564 : wxSplitterWindow(parent, wxID_ANY,
565 wxDefaultPosition, wxDefaultSize,
566 wxSP_3D | wxSP_LIVE_UPDATE |
611 ItemDialog(wxWindow* parent,
const wxString& title);
619 return v.ToStdString();
ItemDialog(wxWindow *parent, const wxString &title)
wxTextCtrl * name_ctrl
The input control for the item name.
const std::string get_name() const
The name.
bool is_checked() const
Whether checkbox was checked.
wxCheckBox * checkbox_ctrl
The checkbox control.
KitListBaseApp()
Default constructor.
std::string filename
The current filename the Model was loaded from.
KitListGui()
Default constructor.
MyFrame * my_frame
The main frame of the application.
virtual bool OnCmdLineParsed(wxCmdLineParser &parser) override
Called after the command line has been successfully parsed.
virtual void OnInitCmdLine(wxCmdLineParser &parser) override
Called from OnInit() and initializes the parser with the command line options for the application.
virtual int OnExit() override
Can be used to cleanup items created during OnInit().
virtual void update_menu_state(bool is_dirty) override
Enables or disables various menu options, as appropriate.
virtual void category_entry_changed(const std::shared_ptr< Category > category) override
Called whenever a Category name changes.
virtual bool OnInit() override
Initializes the application's main window.
virtual void load_file(const std::string &filename) override
Loads the specified file.
virtual void item_entry_changed(const std::shared_ptr< Item > item) override
Called whenever a Item name changes.
check_action
Specifies what state Item checkmarks must be changed to.
static const int32_t no_category
Indicates no filtering by category.
@ unchecked
Show only unchecked items.
@ all
Show all items, i.e. no filtering.
@ checked
Show only checked items.
Implements the main frame of the GUI.
void OnShowAll(wxCommandEvent &WXUNUSED(event))
Menu event handler for showing all items.
void OnUncheckSelected(wxCommandEvent &event)
Menu handler called to mark all selected items as unchecked.
void delete_category(int32_t id)
Deletes the specified Category from the model.
wxSize get_right_panel_width()
Returns the minimum width of the right panel (the item list).
void OnRemoveCheckedItems(wxCommandEvent &WXUNUSED(event))
Menu handler called to remove checked items from a Category.
unsigned populate_category_list(int32_t select_category=Model::no_category)
Rebuilds the list of categories.
void OnUncheckAll(wxCommandEvent &WXUNUSED(event))
Menu handler called to uncheck all items in the list.
wxMenu * file_menu
The File menu.
void OnSave(wxCommandEvent &event)
Menu event handler to save the current file.
wxWindow * right_panel
Pointer to the right panel containing the list of items.
void OnNewFile(wxCommandEvent &event)
Menu event handler for creating a new blank model.
static const int ITEM_NAME_COL
The zero based indexed position of the item name column.
void OnCategoryContextMenu(wxDataViewEvent &event)
Implements a pop-up context menu for the Category list.
void OnCheckSelected(wxCommandEvent &event)
Menu handler called to mark all selected items as checked.
wxMenu * file_history_menu
The recent files menu.
void OnUnselectAllItems(wxCommandEvent &WXUNUSED(event))
Menu event handler for unselecting all items.
void OnPrintPreview(wxCommandEvent &event)
Provides a print previews of the list of items.
void CopyCheckedToCategories(wxCommandEvent &WXUNUSED(event))
Menu handler called to copy checked items to one or more categories.
void do_open(wxString wx_path)
Opens the file from the specified path.
void OnToggleAll(wxCommandEvent &WXUNUSED(event))
Menu handler called to toggle the checked state of all items in the list.
wxDataViewListCtrl * category_list_ctrl
The Category list control.
void change_selected_checked_states(Model::check_action action)
Switches the checked state of all the currently selected items in the item list.
void OnItemContextMenu(wxDataViewEvent &event)
Implements a pop-up context menu for the Item list.
std::unique_ptr< std::exception > last_error
Holds the most recent exception that occurred or nullptr if no exception.
static const int MIN_PANE_SIZE
The minimum size that the split window can be changed to by the user.
void delete_item(int32_t id)
Deletes the specified Item from the model.
wxSplitterWindow * split_window
Pointer to the Category list controller.
void OnAddCategory(wxCommandEvent &WXUNUSED(event))
Menu event handler for creating a new Category.
void update_file_menu(bool is_dirty)
KitListGui * gui_app
Pointer to the main GUI class.
void OnShowUnchecked(wxCommandEvent &WXUNUSED(event))
Menu event handler for showing only unchecked items.
void OnCategoryStartEditing(wxDataViewEvent &event)
Event handler implemented to disallow editing the first row of the Category list.
void copy_items_to_categories(std::vector< std::shared_ptr< Item > > &items, std::vector< std::shared_ptr< Category > > &categories)
Copies each of the passed items to each of the passed categories.
void load_file(const std::string filename)
Loads the specified file.
virtual ~MyFrame()
Destructor.
void OnOpen(wxCommandEvent &event)
Menu event handler to open another file.
void setup_rich_text_printing()
Sets up rich text printing.
static const int CATEGORY_NAME_COL
The zero based indexed of the category name column.
void remove_item(int32_t id)
Removes references to the item from the currently selected Category.
wxWindow * left_panel
Pointer to the left panel containing the list of categories.
void selected_item_changed()
Disables or enables menu items, depending on whether any items have been selected in the Item list.
void OnFileHistoryMenuItem(wxCommandEvent &event)
Menu event handler to open a file that has been selected from the recent files menu.
std::unique_ptr< wxRichTextPrinting > rich_text_printing
Pointer to an instance supporting rich text printing.
wxFileHistory * file_history
The list of recent files.
wxMenu * edit_menu
The Edit menu.
void OnAddItem(wxCommandEvent &WXUNUSED(event))
Menu event handler for creating a new Item.
wxMenuItem * file_history_menu_item
A pointer to the recent files menu item.
void OnPrint(wxCommandEvent &event)
Prints the list of items.
void OnQuit(wxCommandEvent &event)
Called when the user chooses to quit the application.
void OnCheckAll(wxCommandEvent &WXUNUSED(event))
Menu handler called to check all items in the list.
wxDataViewListCtrl * item_list_ctrl
Pointer to the Item list controller.
void OnShow(wxShowEvent &event)
Event handler for when the window is shown.
void OnCopySelectedItemsToCategories(wxCommandEvent &event)
Menu handler called to copy selected items to one or more categories.
void OnShowChecked(wxCommandEvent &WXUNUSED(event))
Menu event handler for showing only checked items.
void FillBuffer(wxRichTextBuffer &buf) const
Fills the passed buffer with rich text to print or preview.
void OnSelectItem(wxDataViewEvent &event)
Event handler called when a user selects a Item from the list. Calls selected_item_changed().
void OnAbout(wxCommandEvent &event)
Menu event handler showing an About dialog box.
void OnSelectAllItems(wxCommandEvent &WXUNUSED(event))
Menu event handler for selecting all items.
void OnRemoveSelectedItems(wxCommandEvent &event)
Menu handler called to remove selected items from a Category.
void populate_item_list()
Rebuilds the list of items.
static const int VSPLIT_DIST
The initial width of the category column.
void update_edit_menu()
Enables or disables menu items on the Edit menu.
void OnToggleSelected(wxCommandEvent &event)
Menu handler called to toggle the checked state of all selected items.
void select_and_copy_to_categories(std::vector< std::shared_ptr< Item > > selected_items)
Displays a dialog for user to select target categories to copy selected items to.
void OnItemListValueChanged(wxDataViewEvent &event)
Event handler called when the Item name is edited.
void save()
Saves the current Model using the current KitListBaseApp::filename.
static const int ITEM_CHECKED_COL
The zero based indexed position of the item checked column.
void OnDeleteCheckedItems(wxCommandEvent &WXUNUSED(event))
Menu handler called to delete checked items from the model.
void OnSelectCategory(wxDataViewEvent &event)
Event handler called when a user selects a Category from the list.
wxDECLARE_EVENT_TABLE()
Declares the wxWidgets event handling table.
MyFrame(KitListGui *app, const wxPoint &pos)
Constructor.
void OnCategoryListValueChanged(wxDataViewEvent &event)
Event handler called when the Category name is edited.
void OnSaveAs(wxCommandEvent &event)
Menu event handler to save the model to a new file.
MySplitterWindow(const MySplitterWindow &)=delete
Prohibits copying an instance via the default copy constructor.
void OnPositionChanged(wxSplitterEvent &event)
Implements a workaround on Linux to initialize the split window correctly on startup.
MySplitterWindow(MyFrame *parent)
Constructor.
MySplitterWindow & operator=(const MySplitterWindow &)=delete
Prohibits copying an instance via assignment.
wxDECLARE_EVENT_TABLE()
Declares the wxWidgets event handling table.
MyFrame * frame
Pointer to the parent window.