KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_generated_table_properties.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef DIALOG_GENERATED_TABLE_PROPERTIES_H
21#define DIALOG_GENERATED_TABLE_PROPERTIES_H
22
23#include <functional>
24#include <optional>
25#include <vector>
26
29#include <widgets/unit_binder.h>
30
31
35
36
46
47
51class GENERATED_TABLE_OPTIONS_PANEL : public wxPanel
52{
53public:
54 using wxPanel::wxPanel;
55
56 virtual void TransferToWindow( const PCB_GENERATED_TABLE& aTable ) = 0;
57
59 virtual bool TransferFromWindow( PCB_GENERATED_TABLE& aTable, GENERATED_TABLE_REFRESH& aRefresh ) = 0;
60
62 std::function<std::optional<GENERATED_TABLE_FORMAT>()> m_GetFormat;
63
65 std::function<void( const GENERATED_TABLE_FORMAT& )> m_SetFormat;
66};
67
68
70using GENERATED_TABLE_OPTIONS_FACTORY = std::function<GENERATED_TABLE_OPTIONS_PANEL*( wxWindow* aParent )>;
71
72
81{
82public:
86
87private:
88 bool TransferDataToWindow() override;
89 bool TransferDataFromWindow() override;
90
91 void onBorderChecked( wxCommandEvent& aEvent ) override;
92 void onMoveUp( wxCommandEvent& aEvent ) override;
93 void onMoveDown( wxCommandEvent& aEvent ) override;
94 void onResetColumns( wxCommandEvent& aEvent ) override;
95
100 void setColumns( const std::vector<GENERATED_TABLE_COLUMN>& aColumns );
101
102 std::vector<GENERATED_TABLE_COLUMN> shownColumns() const;
103
107 std::vector<GENERATED_TABLE_COLUMN> placedColumns() const;
108
109 std::optional<GENERATED_TABLE_FORMAT> getFormat();
110 void setFormat( const GENERATED_TABLE_FORMAT& aFormat );
111
115 void fillColumnGrid();
116
120 bool harvestColumnGrid();
121
122 void moveColumn( int aDelta );
123
127 void fitColumnGrid();
128
129 void onColumnGridSize( wxSizeEvent& aEvent );
130
134
141
147 std::vector<COLUMN_ROW> m_rows;
148
151};
152
153#endif // DIALOG_GENERATED_TABLE_PROPERTIES_H
DIALOG_GENERATED_TABLE_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Table Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void setColumns(const std::vector< GENERATED_TABLE_COLUMN > &aColumns)
Show aColumns checked and in order, then every other schema column unchecked so turning one back on d...
std::vector< GENERATED_TABLE_COLUMN > placedColumns() const
The columns the table has, or is given now, in order and marked shown or hidden.
bool harvestColumnGrid()
Read the grid back into m_rows.
void onMoveUp(wxCommandEvent &aEvent) override
void onResetColumns(wxCommandEvent &aEvent) override
DIALOG_GENERATED_TABLE_PROPERTIES(PCB_BASE_EDIT_FRAME *aFrame, PCB_GENERATED_TABLE *aTable, GENERATED_TABLE_OPTIONS_FACTORY aOptions)
aOptions may be empty. When given, the panel is created on the dialog and put below the column grid
void setFormat(const GENERATED_TABLE_FORMAT &aFormat)
void fillColumnGrid()
Fill the column grid from m_rows.
std::vector< GENERATED_TABLE_COLUMN > shownColumns() const
void onMoveDown(wxCommandEvent &aEvent) override
void onBorderChecked(wxCommandEvent &aEvent) override
std::optional< GENERATED_TABLE_FORMAT > getFormat()
std::vector< COLUMN_ROW > m_rows
Every known column, the table's own first in the table's order, then any it has never had.
void fitColumnGrid()
Share the grid's width out across its columns so none of it goes unused.
Settings only one kind of generated table has, shown below the shared column grid.
virtual bool TransferFromWindow(PCB_GENERATED_TABLE &aTable, GENERATED_TABLE_REFRESH &aRefresh)=0
Applies to the table. Board state goes into aRefresh so Cancel leaves the board alone.
std::function< std::optional< GENERATED_TABLE_FORMAT >()> m_GetFormat
The dialog's columns, units and precision as edited so far, or nothing when a grid edit is invalid.
virtual void TransferToWindow(const PCB_GENERATED_TABLE &aTable)=0
std::function< void(const GENERATED_TABLE_FORMAT &)> m_SetFormat
Hands the dialog a new column set, units and precision, e.g. from an imported template.
One pass of rebuilding tables.
Common, abstract interface for edit frames.
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
std::function< GENERATED_TABLE_OPTIONS_PANEL *(wxWindow *aParent)> GENERATED_TABLE_OPTIONS_FACTORY
The options panel must be created with its real parent, since a wxPanel cannot be reparented reliably...
GENERATED_TABLE_UNITS
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
What the shared dialog edits that a template also carries.
std::vector< GENERATED_TABLE_COLUMN > m_Columns
Shown columns only, in table order.