Kitlist
A list manager for maintaining kit lists
Loading...
Searching...
No Matches
MyFrame Class Reference

Implements the main frame of the GUI. More...

#include "kitlistgui.hpp"

Inheritance diagram for MyFrame:

Public Member Functions

 MyFrame (KitListGui *app, const wxPoint &pos)
 Constructor.
virtual ~MyFrame ()
 Destructor.
void OnShow (wxShowEvent &event)
 Event handler for when the window is shown.
void OnAbout (wxCommandEvent &event)
 Menu event handler showing an About dialog box.
void OnNewFile (wxCommandEvent &event)
 Menu event handler for creating a new blank model.
void OnOpen (wxCommandEvent &event)
 Menu event handler to open another file.
void OnFileHistoryMenuItem (wxCommandEvent &event)
 Menu event handler to open a file that has been selected from the recent files menu.
void OnSave (wxCommandEvent &event)
 Menu event handler to save the current file.
void OnSaveAs (wxCommandEvent &event)
 Menu event handler to save the model to a new file.
void OnQuit (wxCommandEvent &event)
 Called when the user chooses to quit the application.
void OnAddItem (wxCommandEvent &WXUNUSED(event))
 Menu event handler for creating a new Item.
void OnAddCategory (wxCommandEvent &WXUNUSED(event))
 Menu event handler for creating a new Category.
void OnSelectCategory (wxDataViewEvent &event)
 Event handler called when a user selects a Category from the list.
void OnSelectItem (wxDataViewEvent &event)
 Event handler called when a user selects a Item from the list. Calls selected_item_changed().
void selected_item_changed ()
 Disables or enables menu items, depending on whether any items have been selected in the Item list.
void OnCategoryStartEditing (wxDataViewEvent &event)
 Event handler implemented to disallow editing the first row of the Category list.
void OnCategoryContextMenu (wxDataViewEvent &event)
 Implements a pop-up context menu for the Category list.
void OnItemContextMenu (wxDataViewEvent &event)
 Implements a pop-up context menu for the Item list.
void OnCategoryListValueChanged (wxDataViewEvent &event)
 Event handler called when the Category name is edited.
void OnItemListValueChanged (wxDataViewEvent &event)
 Event handler called when the Item name is edited.
void OnShowAll (wxCommandEvent &WXUNUSED(event))
 Menu event handler for showing all items.
void OnShowChecked (wxCommandEvent &WXUNUSED(event))
 Menu event handler for showing only checked items.
void OnShowUnchecked (wxCommandEvent &WXUNUSED(event))
 Menu event handler for showing only unchecked items.
void OnSelectAllItems (wxCommandEvent &WXUNUSED(event))
 Menu event handler for selecting all items.
void OnUnselectAllItems (wxCommandEvent &WXUNUSED(event))
 Menu event handler for unselecting all items.
void OnCheckAll (wxCommandEvent &WXUNUSED(event))
 Menu handler called to check all items in the list.
void OnUncheckAll (wxCommandEvent &WXUNUSED(event))
 Menu handler called to uncheck all items in the list.
void OnToggleAll (wxCommandEvent &WXUNUSED(event))
 Menu handler called to toggle the checked state of all items in the list.
void OnCheckSelected (wxCommandEvent &event)
 Menu handler called to mark all selected items as checked.
void OnUncheckSelected (wxCommandEvent &event)
 Menu handler called to mark all selected items as unchecked.
void OnToggleSelected (wxCommandEvent &event)
 Menu handler called to toggle the checked state of all selected items.
void CopyCheckedToCategories (wxCommandEvent &WXUNUSED(event))
 Menu handler called to copy checked items to one or more categories.
void OnCopySelectedItemsToCategories (wxCommandEvent &event)
 Menu handler called to copy selected items to one or more categories.
void OnRemoveSelectedItems (wxCommandEvent &event)
 Menu handler called to remove selected items from a Category.
void OnRemoveCheckedItems (wxCommandEvent &WXUNUSED(event))
 Menu handler called to remove checked items from a Category.
void OnDeleteCheckedItems (wxCommandEvent &WXUNUSED(event))
 Menu handler called to delete checked items from the model.
wxSize get_right_panel_width ()
 Returns the minimum width of the right panel (the item list).

Static Public Attributes

static const int VSPLIT_DIST = 200
 The initial width of the category column.

Private Member Functions

void load_file (const std::string filename)
 Loads the specified file.
unsigned populate_category_list (int32_t select_category=Model::no_category)
 Rebuilds the list of categories.
void populate_item_list ()
 Rebuilds the list of items.
void delete_category (int32_t id)
 Deletes the specified Category from the model.
void delete_item (int32_t id)
 Deletes the specified Item from the model.
void remove_item (int32_t id)
 Removes references to the item from the currently selected Category.
void change_selected_checked_states (Model::check_action action)
 Switches the checked state of all the currently selected items in the item list.
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 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 save ()
 Saves the current Model using the current KitListBaseApp::filename.
void update_file_menu (bool is_dirty)
void update_edit_menu ()
 Enables or disables menu items on the Edit menu.
void setup_rich_text_printing ()
 Sets up rich text printing.
void OnPrint (wxCommandEvent &event)
 Prints the list of items.
void OnPrintPreview (wxCommandEvent &event)
 Provides a print previews of the list of items.
void FillBuffer (wxRichTextBuffer &buf) const
 Fills the passed buffer with rich text to print or preview.
void do_open (wxString wx_path)
 Opens the file from the specified path.
 wxDECLARE_EVENT_TABLE ()
 Declares the wxWidgets event handling table.

Private Attributes

std::unique_ptr< wxRichTextPrinting > rich_text_printing
 Pointer to an instance supporting rich text printing.
KitListGuigui_app
 Pointer to the main GUI class.
wxDataViewListCtrl * category_list_ctrl
 The Category list control.
wxMenu * file_menu
 The File menu.
wxMenu * edit_menu
 The Edit menu.
wxMenu * file_history_menu
 The recent files menu.
wxFileHistory * file_history
 The list of recent files.
wxMenuItem * file_history_menu_item
 A pointer to the recent files menu item.
std::unique_ptr< std::exception > last_error
 Holds the most recent exception that occurred or nullptr if no exception.
wxWindow * left_panel = nullptr
 Pointer to the left panel containing the list of categories.
wxWindow * right_panel = nullptr
 Pointer to the right panel containing the list of items.
wxDataViewListCtrl * item_list_ctrl = nullptr
 Pointer to the Item list controller.
wxSplitterWindow * split_window = nullptr
 Pointer to the Category list controller.

Static Private Attributes

static const int MIN_PANE_SIZE = 1
 The minimum size that the split window can be changed to by the user.
static const int ITEM_CHECKED_COL = 1
 The zero based indexed position of the item checked column.
static const int ITEM_NAME_COL = 0
 The zero based indexed position of the item name column.
static const int CATEGORY_NAME_COL = 0
 The zero based indexed of the category name column.

Friends

class KitListGui

Detailed Description

Implements the main frame of the GUI.

Definition at line 118 of file kitlistgui.hpp.

Constructor & Destructor Documentation

◆ MyFrame()

MyFrame::MyFrame ( KitListGui * app,
const wxPoint & pos )

Constructor.

◆ ~MyFrame()

MyFrame::~MyFrame ( )
virtual

Destructor.

Saves the current window position to the application's configuration file.

Definition at line 364 of file kitlistgui.cpp.

Member Function Documentation

◆ change_selected_checked_states()

void MyFrame::change_selected_checked_states ( Model::check_action action)
private

Switches the checked state of all the currently selected items in the item list.

Parameters
actionThe type of Model::check_action to take.

Definition at line 451 of file kitlistgui.cpp.

◆ copy_items_to_categories()

void MyFrame::copy_items_to_categories ( std::vector< std::shared_ptr< Item > > & items,
std::vector< std::shared_ptr< Category > > & categories )
private

Copies each of the passed items to each of the passed categories.

Each of the items are associated with each of the selected categories. If the category is already associated with the item, the item is ignored, ensuring there are no duplicate items with a Category.

Parameters
itemsa list of the items to copy.
categoriesa list of the target categories.

◆ CopyCheckedToCategories()

void MyFrame::CopyCheckedToCategories ( wxCommandEvent & WXUNUSEDevent)

Menu handler called to copy checked items to one or more categories.

Definition at line 506 of file kitlistgui.cpp.

◆ delete_category()

void MyFrame::delete_category ( int32_t id)
inlineprivate

Deletes the specified Category from the model.

Parameters
idThe ID of the Category to delete.

Definition at line 417 of file kitlistgui.hpp.

◆ delete_item()

void MyFrame::delete_item ( int32_t id)
inlineprivate

Deletes the specified Item from the model.

Parameters
idThe ID of the Item to delete.

Definition at line 428 of file kitlistgui.hpp.

◆ do_open()

void MyFrame::do_open ( wxString wx_path)
private

Opens the file from the specified path.

The current model is replaced with the file's contents.

Parameters
wx_pathThe pathname of the file to load.

Definition at line 923 of file kitlistgui.cpp.

◆ FillBuffer()

void MyFrame::FillBuffer ( wxRichTextBuffer & buf) const
private

Fills the passed buffer with rich text to print or preview.

Basically adds a paragraph for each of the items in the current category, or all items. Only items that are not excluded by the current filter are added.

Parameters
bufThe buffer to fill.
See also
OnPrint()
OnPrintPreview()
KitListBaseApp::get_items_for_selected_category()

Definition at line 718 of file kitlistgui.cpp.

◆ get_right_panel_width()

wxSize MyFrame::get_right_panel_width ( )
inline

Returns the minimum width of the right panel (the item list).

Definition at line 364 of file kitlistgui.hpp.

◆ load_file()

void MyFrame::load_file ( const std::string filename)
private

Loads the specified file.

Loads the Model from the specified filename.

Parameters
filenameThe name of the file to load.
Exceptions
KitParser::parse_exceptionThrown if there is an error parsing the file.
KitListBaseApp::file_not_found

throws KitParser::parse_exception throws KitListGui::file_not_found

Definition at line 945 of file kitlistgui.cpp.

◆ OnAbout()

void MyFrame::OnAbout ( wxCommandEvent & event)

Menu event handler showing an About dialog box.

Definition at line 868 of file kitlistgui.cpp.

◆ OnAddCategory()

void MyFrame::OnAddCategory ( wxCommandEvent & WXUNUSEDevent)

Menu event handler for creating a new Category.

Definition at line 1008 of file kitlistgui.cpp.

◆ OnAddItem()

void MyFrame::OnAddItem ( wxCommandEvent & WXUNUSEDevent)

Menu event handler for creating a new Item.

Definition at line 993 of file kitlistgui.cpp.

◆ OnCategoryContextMenu()

void MyFrame::OnCategoryContextMenu ( wxDataViewEvent & event)

Implements a pop-up context menu for the Category list.

Definition at line 554 of file kitlistgui.cpp.

◆ OnCategoryListValueChanged()

void MyFrame::OnCategoryListValueChanged ( wxDataViewEvent & event)

Event handler called when the Category name is edited.

Definition at line 380 of file kitlistgui.cpp.

◆ OnCategoryStartEditing()

void MyFrame::OnCategoryStartEditing ( wxDataViewEvent & event)
inline

Event handler implemented to disallow editing the first row of the Category list.

Definition at line 264 of file kitlistgui.hpp.

◆ OnCheckAll()

void MyFrame::OnCheckAll ( wxCommandEvent & WXUNUSEDevent)
inline

Menu handler called to check all items in the list.

Definition at line 313 of file kitlistgui.hpp.

◆ OnCheckSelected()

void MyFrame::OnCheckSelected ( wxCommandEvent & event)

Menu handler called to mark all selected items as checked.

Definition at line 433 of file kitlistgui.cpp.

◆ OnCopySelectedItemsToCategories()

void MyFrame::OnCopySelectedItemsToCategories ( wxCommandEvent & event)

Menu handler called to copy selected items to one or more categories.

See also
select_and_copy_to_categories().

Definition at line 516 of file kitlistgui.cpp.

◆ OnDeleteCheckedItems()

void MyFrame::OnDeleteCheckedItems ( wxCommandEvent & WXUNUSEDevent)

Menu handler called to delete checked items from the model.

Definition at line 498 of file kitlistgui.cpp.

◆ OnFileHistoryMenuItem()

void MyFrame::OnFileHistoryMenuItem ( wxCommandEvent & event)

Menu event handler to open a file that has been selected from the recent files menu.

Definition at line 893 of file kitlistgui.cpp.

◆ OnItemContextMenu()

void MyFrame::OnItemContextMenu ( wxDataViewEvent & event)

Implements a pop-up context menu for the Item list.

Definition at line 581 of file kitlistgui.cpp.

◆ OnItemListValueChanged()

void MyFrame::OnItemListValueChanged ( wxDataViewEvent & event)

Event handler called when the Item name is edited.

Definition at line 395 of file kitlistgui.cpp.

◆ OnNewFile()

void MyFrame::OnNewFile ( wxCommandEvent & event)

Menu event handler for creating a new blank model.

Definition at line 880 of file kitlistgui.cpp.

◆ OnOpen()

void MyFrame::OnOpen ( wxCommandEvent & event)

Menu event handler to open another file.

Definition at line 904 of file kitlistgui.cpp.

◆ OnPrint()

void MyFrame::OnPrint ( wxCommandEvent & event)
private

Prints the list of items.

Displays a dialog where the user can choose print parameters.

See also
OnPrintPreview()

Definition at line 700 of file kitlistgui.cpp.

◆ OnPrintPreview()

void MyFrame::OnPrintPreview ( wxCommandEvent & event)
private

Provides a print previews of the list of items.

See also
OnPrintP()

Definition at line 709 of file kitlistgui.cpp.

◆ OnQuit()

void MyFrame::OnQuit ( wxCommandEvent & event)

Called when the user chooses to quit the application.

Definition at line 978 of file kitlistgui.cpp.

◆ OnRemoveCheckedItems()

void MyFrame::OnRemoveCheckedItems ( wxCommandEvent & WXUNUSEDevent)

Menu handler called to remove checked items from a Category.

Definition at line 490 of file kitlistgui.cpp.

◆ OnRemoveSelectedItems()

void MyFrame::OnRemoveSelectedItems ( wxCommandEvent & event)

Menu handler called to remove selected items from a Category.

Definition at line 465 of file kitlistgui.cpp.

◆ OnSave()

void MyFrame::OnSave ( wxCommandEvent & event)

Menu event handler to save the current file.

Definition at line 950 of file kitlistgui.cpp.

◆ OnSaveAs()

void MyFrame::OnSaveAs ( wxCommandEvent & event)

Menu event handler to save the model to a new file.

Definition at line 956 of file kitlistgui.cpp.

◆ OnSelectAllItems()

void MyFrame::OnSelectAllItems ( wxCommandEvent & WXUNUSEDevent)
inline

Menu event handler for selecting all items.

Definition at line 301 of file kitlistgui.hpp.

◆ OnSelectCategory()

void MyFrame::OnSelectCategory ( wxDataViewEvent & event)

Event handler called when a user selects a Category from the list.

When the user chooses the first row, all items are shown, subject to filtering by their checked status.

Otherwise only items belonging to the selected category are shown, filtered by their checked status.

Definition at line 621 of file kitlistgui.cpp.

◆ OnSelectItem()

void MyFrame::OnSelectItem ( wxDataViewEvent & event)

Event handler called when a user selects a Item from the list. Calls selected_item_changed().

Definition at line 641 of file kitlistgui.cpp.

◆ OnShow()

void MyFrame::OnShow ( wxShowEvent & event)

Event handler for when the window is shown.

If there was an error during startup, this method will display the error message to the user.

See also
last_error

Definition at line 856 of file kitlistgui.cpp.

◆ OnShowAll()

void MyFrame::OnShowAll ( wxCommandEvent & WXUNUSEDevent)
inline

Menu event handler for showing all items.

Definition at line 283 of file kitlistgui.hpp.

◆ OnShowChecked()

void MyFrame::OnShowChecked ( wxCommandEvent & WXUNUSEDevent)
inline

Menu event handler for showing only checked items.

Definition at line 289 of file kitlistgui.hpp.

◆ OnShowUnchecked()

void MyFrame::OnShowUnchecked ( wxCommandEvent & WXUNUSEDevent)
inline

Menu event handler for showing only unchecked items.

Definition at line 295 of file kitlistgui.hpp.

◆ OnToggleAll()

void MyFrame::OnToggleAll ( wxCommandEvent & WXUNUSEDevent)
inline

Menu handler called to toggle the checked state of all items in the list.

Definition at line 327 of file kitlistgui.hpp.

◆ OnToggleSelected()

void MyFrame::OnToggleSelected ( wxCommandEvent & event)

Menu handler called to toggle the checked state of all selected items.

Definition at line 445 of file kitlistgui.cpp.

◆ OnUncheckAll()

void MyFrame::OnUncheckAll ( wxCommandEvent & WXUNUSEDevent)
inline

Menu handler called to uncheck all items in the list.

Definition at line 320 of file kitlistgui.hpp.

◆ OnUncheckSelected()

void MyFrame::OnUncheckSelected ( wxCommandEvent & event)

Menu handler called to mark all selected items as unchecked.

Definition at line 439 of file kitlistgui.cpp.

◆ OnUnselectAllItems()

void MyFrame::OnUnselectAllItems ( wxCommandEvent & WXUNUSEDevent)
inline

Menu event handler for unselecting all items.

Definition at line 307 of file kitlistgui.hpp.

◆ populate_category_list()

unsigned MyFrame::populate_category_list ( int32_t select_category = Model::no_category)
private

Rebuilds the list of categories.

Should be called whenever a Category is created, updated, or deleted.

Definition at line 651 of file kitlistgui.cpp.

◆ populate_item_list()

void MyFrame::populate_item_list ( )
private

Rebuilds the list of items.

Includes only those items that belong to the selected category or are not excluded by the current filter of their checked states.

Definition at line 673 of file kitlistgui.cpp.

◆ remove_item()

void MyFrame::remove_item ( int32_t id)
inlineprivate

Removes references to the item from the currently selected Category.

The model relationships are updated appropriately.

Remarks
The item itself is not deleted from the model and therefore will still be returned by a call to KitListBaseApp::get_all_items.

Definition at line 442 of file kitlistgui.hpp.

◆ save()

void MyFrame::save ( )
private

Saves the current Model using the current KitListBaseApp::filename.

Definition at line 1023 of file kitlistgui.cpp.

◆ select_and_copy_to_categories()

void MyFrame::select_and_copy_to_categories ( std::vector< std::shared_ptr< Item > > selected_items)
private

Displays a dialog for user to select target categories to copy selected items to.

Each of the items are associated with each of the selected categories. If the category is already associated with the item, the item is ignored, ensuring there are no duplicate items with a Category.

Parameters
selected_itemsa list of the items to copy.
See also
copy_items_to_categories().

Definition at line 533 of file kitlistgui.cpp.

◆ selected_item_changed()

void MyFrame::selected_item_changed ( )

Disables or enables menu items, depending on whether any items have been selected in the Item list.

Definition at line 646 of file kitlistgui.cpp.

◆ setup_rich_text_printing()

void MyFrame::setup_rich_text_printing ( )
private

Sets up rich text printing.

See also
OnPrint()
OnPrintPreview()

Definition at line 688 of file kitlistgui.cpp.

◆ update_edit_menu()

void MyFrame::update_edit_menu ( )
private

Enables or disables menu items on the Edit menu.

Menu items are disabled or enabled depending whether there are any items visible in the item list.

Definition at line 1040 of file kitlistgui.cpp.

◆ update_file_menu()

void MyFrame::update_file_menu ( bool is_dirty)
private

Enables or disables menu items on the File menu according to the is_dirty flag.

Parameters
is_dirtyFlag. True if the model has been modified since it was last saved.

Definition at line 1033 of file kitlistgui.cpp.

◆ wxDECLARE_EVENT_TABLE()

MyFrame::wxDECLARE_EVENT_TABLE ( )
private

Declares the wxWidgets event handling table.

◆ KitListGui

friend class KitListGui
friend

Definition at line 120 of file kitlistgui.hpp.

Member Data Documentation

◆ category_list_ctrl

wxDataViewListCtrl* MyFrame::category_list_ctrl
private

The Category list control.

Definition at line 141 of file kitlistgui.hpp.

◆ CATEGORY_NAME_COL

const int MyFrame::CATEGORY_NAME_COL = 0
staticprivate

The zero based indexed of the category name column.

Definition at line 182 of file kitlistgui.hpp.

◆ edit_menu

wxMenu* MyFrame::edit_menu
private

The Edit menu.

Definition at line 147 of file kitlistgui.hpp.

◆ file_history

wxFileHistory* MyFrame::file_history
private

The list of recent files.

The list is populated from the application's configuration file.

Definition at line 157 of file kitlistgui.hpp.

◆ file_history_menu

wxMenu* MyFrame::file_history_menu
private

The recent files menu.

Definition at line 150 of file kitlistgui.hpp.

◆ file_history_menu_item

wxMenuItem* MyFrame::file_history_menu_item
private

A pointer to the recent files menu item.

Used to enable or disable the recent files menu option.

Definition at line 164 of file kitlistgui.hpp.

◆ file_menu

wxMenu* MyFrame::file_menu
private

The File menu.

Definition at line 144 of file kitlistgui.hpp.

◆ gui_app

KitListGui* MyFrame::gui_app
private

Pointer to the main GUI class.

See also
KitListGui

Definition at line 138 of file kitlistgui.hpp.

◆ ITEM_CHECKED_COL

const int MyFrame::ITEM_CHECKED_COL = 1
staticprivate

The zero based indexed position of the item checked column.

Definition at line 178 of file kitlistgui.hpp.

◆ item_list_ctrl

wxDataViewListCtrl* MyFrame::item_list_ctrl = nullptr
private

Pointer to the Item list controller.

Definition at line 377 of file kitlistgui.hpp.

◆ ITEM_NAME_COL

const int MyFrame::ITEM_NAME_COL = 0
staticprivate

The zero based indexed position of the item name column.

Definition at line 180 of file kitlistgui.hpp.

◆ last_error

std::unique_ptr<std::exception> MyFrame::last_error
private

Holds the most recent exception that occurred or nullptr if no exception.

Primarily used when attempting to load the most recent file on startup. When an error occurs during startup, the GUI is not sufficiently initialized to be able to show the error to the user. Instead the error is displayed when OnShow() is called.

Definition at line 175 of file kitlistgui.hpp.

◆ left_panel

wxWindow* MyFrame::left_panel = nullptr
private

Pointer to the left panel containing the list of categories.

Definition at line 372 of file kitlistgui.hpp.

◆ MIN_PANE_SIZE

const int MyFrame::MIN_PANE_SIZE = 1
staticprivate

The minimum size that the split window can be changed to by the user.

Definition at line 131 of file kitlistgui.hpp.

◆ rich_text_printing

std::unique_ptr<wxRichTextPrinting> MyFrame::rich_text_printing
private

Pointer to an instance supporting rich text printing.

See also
OnPrint()
OnPrintPreview()

Definition at line 128 of file kitlistgui.hpp.

◆ right_panel

wxWindow* MyFrame::right_panel = nullptr
private

Pointer to the right panel containing the list of items.

Definition at line 374 of file kitlistgui.hpp.

◆ split_window

wxSplitterWindow* MyFrame::split_window = nullptr
private

Pointer to the Category list controller.

Definition at line 380 of file kitlistgui.hpp.

◆ VSPLIT_DIST

const int MyFrame::VSPLIT_DIST = 200
static

The initial width of the category column.

Definition at line 369 of file kitlistgui.hpp.


The documentation for this class was generated from the following files:
Copyright 2008-2025 Frank Dean