KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_unit_entry.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) 2020 Roberto Fernandez Bautista <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <eda_draw_frame.h>
27#include <string_utils.h>
28
29
31 const wxString& aLabel, long long int aDefaultValue ) :
32 WX_UNIT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
34{
35 m_label->SetLabel( aLabel );
36 m_unit_binder.SetValue( aDefaultValue );
37
38 // DIALOG_SHIM needs a title- and label-specific hash_key so we don't save/restore state between
39 // usage cases.
40 m_hash_key = TO_UTF8( aCaption + aLabel );
41
44
45 Layout();
46 bSizerMain->Fit( this );
47}
48
49
51{
52 return m_unit_binder.GetIntValue();
53}
54
55
56WX_PT_ENTRY_DIALOG::WX_PT_ENTRY_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aCaption,
57 const wxString& aLabelX, const wxString& aLabelY,
58 const VECTOR2I& aDefaultValue, bool aShowResetButt ) :
59 WX_PT_ENTRY_DIALOG_BASE( ( wxWindow* ) aParent, wxID_ANY, aCaption ),
60 m_unit_binder_x( aParent, m_labelX, m_textCtrlX, m_unitsX, true ),
62{
63 m_ButtonReset->Show( aShowResetButt );
64
65 m_labelX->SetLabel( aLabelX );
66 m_labelY->SetLabel( aLabelY );
67
70
71 m_unit_binder_x.SetValue( aDefaultValue.x );
72 m_unit_binder_y.SetValue( aDefaultValue.y );
73
74 // DIALOG_SHIM needs a title- and label-specific hash_key so we don't save/restore state between
75 // usage cases.
76 m_hash_key = TO_UTF8( aCaption + aLabelX + aLabelY );
77
80
82}
83
84
86{
87 return VECTOR2I( m_unit_binder_x.GetIntValue(), m_unit_binder_y.GetIntValue() );
88}
89
90void WX_PT_ENTRY_DIALOG::ResetValues( wxCommandEvent& event )
91{
92 m_unit_binder_x.SetValue( 0 );
93 m_unit_binder_y.SetValue( 0 );
94}
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition dialog_shim.h:82
void SetupStandardButtons(std::map< int, wxString > aLabels={})
std::string m_hash_key
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
The base class for create windows for drawing purpose.
wxStaticText * m_unitsY
WX_PT_ENTRY_DIALOG_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Move Point to Location"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticText * m_labelX
wxStaticText * m_labelY
wxStaticText * m_unitsX
wxTextCtrl * m_textCtrlY
wxTextCtrl * m_textCtrlX
wxButton * m_ButtonReset
UNIT_BINDER m_unit_binder_x
WX_PT_ENTRY_DIALOG(EDA_DRAW_FRAME *aParent, const wxString &aCaption, const wxString &aLabelX, const wxString &aLabelY, const VECTOR2I &aDefaultValue, bool aShowResetButt)
VECTOR2I GetValue()
Return the value in internal units.
void ResetValues(wxCommandEvent &event) override
UNIT_BINDER m_unit_binder_y
wxStaticText * m_unit_label
wxBoxSizer * bSizerMain
WX_UNIT_ENTRY_DIALOG_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Title"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxStaticText * m_label
wxTextCtrl * m_textCtrl
UNIT_BINDER m_unit_binder
WX_UNIT_ENTRY_DIALOG(EDA_DRAW_FRAME *aParent, const wxString &aCaption, const wxString &aLabel, long long int aDefaultValue)
int GetValue()
Return the value in internal units.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695