KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_edit_table_tool.cpp
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 (C) 2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#include <ee_actions.h>
26#include <dialogs/dialog_table_properties.h>
27
28
30 EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.TableEditor" )
31{
32}
33
34
36{
38
40
41 return true;
42}
43
44
46{
48 bool clearSelection = selection.IsHover();
49 SCH_TABLE* parentTable = nullptr;
50
51 for( EDA_ITEM* item : selection.Items() )
52 {
53 if( item->Type() != SCH_TABLECELL_T )
54 return 0;
55
56 SCH_TABLE* table = static_cast<SCH_TABLE*>( item->GetParent() );
57
58 if( !parentTable )
59 {
60 parentTable = table;
61 }
62 else if( parentTable != table )
63 {
64 parentTable = nullptr;
65 break;
66 }
67 }
68
69 if( parentTable )
70 {
71 DIALOG_TABLE_PROPERTIES dlg( m_frame, parentTable );
72
73 // QuasiModal required for Scintilla auto-complete
74 dlg.ShowQuasiModal();
75 }
76
77 if( clearSelection )
79
80 return 0;
81}
82
83
85{
86 SCH_TABLECELL* cell = new SCH_TABLECELL();
87
88 cell->SetStart( aSource->GetStart() );
89 cell->SetEnd( aSource->GetEnd() );
90 cell->SetFillMode( aSource->GetFillMode() );
91 cell->SetFillColor( aSource->GetFillColor() );
92
93 return cell;
94}
95
96
98{
100}
101
102
104{
107
110
113
116
118}
static TOOL_ACTION addRowAbove
Definition: actions.h:87
static TOOL_ACTION addColBefore
Definition: actions.h:89
static TOOL_ACTION deleteRows
Definition: actions.h:91
static TOOL_ACTION addRowBelow
Definition: actions.h:88
static TOOL_ACTION deleteColumns
Definition: actions.h:92
static TOOL_ACTION unmergeCells
Definition: actions.h:94
static TOOL_ACTION mergeCells
Definition: actions.h:93
static TOOL_ACTION addColAfter
Definition: actions.h:90
static TOOL_ACTION editTable
Definition: actions.h:95
int ShowQuasiModal()
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:88
FILL_T GetFillMode() const
Definition: eda_shape.h:102
void SetFillColor(const COLOR4D &aColor)
Definition: eda_shape.h:107
const VECTOR2I & GetEnd() const
Return the ending point of the graphic.
Definition: eda_shape.h:152
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:131
const VECTOR2I & GetStart() const
Return the starting point of the graphic.
Definition: eda_shape.h:127
COLOR4D GetFillColor() const
Definition: eda_shape.h:106
void SetEnd(const VECTOR2I &aEnd)
Definition: eda_shape.h:156
void SetFillMode(FILL_T aFill)
Definition: eda_shape.h:101
static TOOL_ACTION clearSelection
Clears the current selection.
Definition: ee_actions.h:56
static const std::vector< KICAD_T > EditableItems
Definition: ee_collectors.h:42
EE_SELECTION & RequestSelection(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T }, bool aPromoteCellSelections=false)
Return either an existing selection (filtered), or the selection at the current cursor position if th...
A foundation class for a tool operating on a schematic or symbol.
Definition: ee_tool_base.h:48
EE_SELECTION_TOOL * m_selectionTool
Definition: ee_tool_base.h:200
bool Init() override
Init() is called once upon a registration of the tool.
Definition: ee_tool_base.h:64
Schematic editor (Eeschema) main window.
void setTransitions() override
< Set up handlers for various events.
int DeleteRows(const TOOL_EVENT &aEvent)
int MergeCells(const TOOL_EVENT &aEvent)
void clearSelection() override
int UnmergeCells(const TOOL_EVENT &aEvent)
int AddRowBelow(const TOOL_EVENT &aEvent)
int AddColumnBefore(const TOOL_EVENT &aEvent)
int EditTable(const TOOL_EVENT &aEvent)
const SELECTION & getTableCellSelection() override
int DeleteColumns(const TOOL_EVENT &aEvent)
bool Init() override
Init() is called once upon a registration of the tool.
int AddColumnAfter(const TOOL_EVENT &aEvent)
int AddRowAbove(const TOOL_EVENT &aEvent)
SCH_TABLECELL * copyCell(SCH_TABLECELL *aSource) override
bool IsHover() const
Definition: selection.h:83
std::deque< EDA_ITEM * > & Items()
Definition: selection.h:213
TOOL_MANAGER * m_toolMgr
Definition: tool_base.h:216
Generic, UI-independent tool event.
Definition: tool_event.h:167
void Go(int(T::*aStateFunc)(const TOOL_EVENT &), const TOOL_EVENT_LIST &aConditions=TOOL_EVENT(TC_ANY, TA_ANY))
Define which state (aStateFunc) to go when a certain event arrives (aConditions).
TOOL_MENU & GetToolMenu()
bool RunAction(const std::string &aActionName, T aParam)
Run the specified action immediately, pausing the current action to run the new one.
Definition: tool_manager.h:145
CONDITIONAL_MENU & GetMenu()
Definition: tool_menu.cpp:44
@ SCH_TABLECELL_T
Definition: typeinfo.h:154