KiCad PCB EDA Suite
dialog_helpers.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 (C) 2010 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
5  * Copyright (C) 1992-2012 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 
31 #ifndef DIALOG_HELPERS_H_
32 #define DIALOG_HELPERS_H_
33 
34 
35 #include <common.h> // EDA_UNITS_T
36 #include <dialog_shim.h>
37 #include <../common/dialogs/dialog_list_selector_base.h>
38 
39 
40 class EDA_DRAW_FRAME;
41 
42 #define SORT_LIST true
43 
54 {
55 public:
56 
68  EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
69  const wxArrayString& aItemHeaders,
70  const std::vector<wxArrayString>& aItemList,
71  const wxString& aRefText,
72  void (* aCallBackFunction)( wxString& text, void* data ) = NULL,
73  void* aCallBackFunctionData = NULL,
74  bool aSortList = false );
75 
76  // ~EDA_LIST_DIALOG() {}
77 
78  void SetFilterLabel( const wxString& aLabel );
79  void SetListLabel( const wxString& aLabel );
80 
81  void Append( const wxArrayString& aItemStr );
82  void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
83 
91  wxString GetTextSelection( int aColumn = 0 );
92 
93 private:
94  void onClose( wxCloseEvent& event ) override;
95  void onCancelClick( wxCommandEvent& event ) override;
96  void onOkClick( wxCommandEvent& event ) override;
97  void onListItemSelected( wxListEvent& event ) override;
98  void onListItemActivated( wxListEvent& event ) override;
99  void textChangeInFilterBox(wxCommandEvent& event) override;
100 
101  void initDialog( const wxArrayString& aItemHeaders,
102  const wxString& aSelection);
103  void sortList();
105  void (* m_cb_func)( wxString& text, void* data );
106  void* m_cb_data;
107  const std::vector<wxArrayString>* m_itemsListCp;
108 };
109 
110 
116 {
117 public:
119 
120  wxTextCtrl* m_FrameText;
121  wxTextCtrl* m_FrameSize;
122 private:
123  wxStaticText* m_Title;
124 
125 public:
126  EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title,
127  const wxString& TextToEdit, int textsize,
128  EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200 );
129 
131 
132  const wxString GetText() const;
133  int GetTextSize();
134  void Enable( bool state );
135  void SetTitle( const wxString& title );
136 
137  void SetFocus() { m_FrameText->SetFocus(); }
138  void SetValue( const wxString& value );
139  void SetValue( int value );
140 
145  static wxString FormatSize( EDA_UNITS_T user_unit, int textSize );
146 
147  static int ParseSize( const wxString& sizeText, EDA_UNITS_T user_unit );
148 };
149 
150 
151 /**************************************************************************/
152 /* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */
153 /* dialog boxes, */
154 /**************************************************************************/
156 {
157 public:
160 
161  wxTextCtrl* m_FramePosX;
162  wxTextCtrl* m_FramePosY;
163 private:
164  wxStaticText* m_TextX, * m_TextY;
165 
166 public:
167  EDA_POSITION_CTRL( wxWindow* parent, const wxString& title,
168  const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
169 
171 
172  void Enable( bool x_win_on, bool y_win_on );
173  void SetValue( int x_value, int y_value );
174  wxPoint GetValue();
175 };
176 
177 
178 /*************************************************************
179  * Class to edit/enter a size (pair of values for X and Y size)
180  * ( INCHES or MM ) in dialog boxes
181  ***************************************************************/
183 {
184 public:
185  EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
186  const wxSize& size_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
187 
189  wxSize GetValue();
190 };
191 
192 
193 /****************************************************************/
194 /* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */
195 /****************************************************************/
197 {
198 public:
200  int m_Value;
201  wxTextCtrl* m_ValueCtrl;
202 private:
203  wxStaticText* m_Text;
204 
205 public:
206  EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value,
207  EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
208 
209  ~EDA_VALUE_CTRL();
210 
211  int GetValue();
212  void SetValue( int new_value );
213  void Enable( bool enbl );
214 
215  void SetToolTip( const wxString& text )
216  {
217  m_ValueCtrl->SetToolTip( text );
218  }
219 };
220 
221 #endif // DIALOG_HELPERS_H_
void onCancelClick(wxCommandEvent &event) override
Definition: displlst.cpp:219
void initDialog(const wxArrayString &aItemHeaders, const wxString &aSelection)
Definition: displlst.cpp:78
void onOkClick(wxCommandEvent &event) override
Definition: displlst.cpp:243
wxString GetTextSelection(int aColumn=0)
Function GetTextSelection return the selected text from aColumn in the wxListCtrl in the dialog...
Definition: displlst.cpp:148
wxTextCtrl * m_FrameText
void textChangeInFilterBox(wxCommandEvent &event) override
Definition: displlst.cpp:124
EDA_LIST_DIALOG(EDA_DRAW_FRAME *aParent, const wxString &aTitle, const wxArrayString &aItemHeaders, const std::vector< wxArrayString > &aItemList, const wxString &aRefText, void(*aCallBackFunction)(wxString &text, void *data)=NULL, void *aCallBackFunctionData=NULL, bool aSortList=false)
Constructor:
Definition: displlst.cpp:45
EDA_UNITS_T m_UserUnit
void Append(const wxArrayString &aItemStr)
Definition: displlst.cpp:171
const std::vector< wxArrayString > * m_itemsListCp
class EDA_LIST_DIALOG
wxStaticText * m_Title
wxTextCtrl * m_ValueCtrl
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:55
wxSize GetTextSize(const wxString &aSingleLine, wxWindow *aWindow)
Function GetTextSize returns the size of aSingleLine of text when it is rendered in aWindow using wha...
Definition: common.cpp:94
void SetFilterLabel(const wxString &aLabel)
Definition: displlst.cpp:112
Class EDA_GRAPHIC_TEXT_CTRL is a custom text edit control to edit/enter Kicad dimensions ( INCHES or ...
wxStaticText * m_TextY
EDA_UNITS_T m_UserUnit
void onClose(wxCloseEvent &event) override
Definition: displlst.cpp:249
Class EDA_LIST_DIALOG_BASE.
wxString GetText(GRAPHIC_PINSHAPE shape)
Definition: pin_shape.cpp:33
wxTextCtrl * m_FramePosX
void onListItemSelected(wxListEvent &event) override
Definition: displlst.cpp:225
wxStaticText * m_Text
wxTextCtrl * m_FrameSize
wxTextCtrl * m_FramePosY
void SetToolTip(const wxString &text)
The common library.
bool Enable(bool enable) override
EDA_UNITS_T
Definition: common.h:144
void InsertItems(const std::vector< wxArrayString > &aItemList, int aPosition=0)
Definition: displlst.cpp:185
void(* m_cb_func)(wxString &text, void *data)
void onListItemActivated(wxListEvent &event) override
Definition: displlst.cpp:237
void SetListLabel(const wxString &aLabel)
Definition: displlst.cpp:118