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 Append( const wxArrayString& aItemStr );
79  void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
80 
88  wxString GetTextSelection( int aColumn = 0 );
89 
90 private:
91  void onClose( wxCloseEvent& event ) override;
92  void onCancelClick( wxCommandEvent& event ) override;
93  void onOkClick( wxCommandEvent& event ) override;
94  void onListItemSelected( wxListEvent& event ) override;
95  void onListItemActivated( wxListEvent& event ) override;
96  void textChangeInFilterBox(wxCommandEvent& event) override;
97 
98  void initDialog( const wxArrayString& aItemHeaders,
99  const wxString& aSelection);
100  void sortList();
102  void (* m_cb_func)( wxString& text, void* data );
103  void* m_cb_data;
104  const std::vector<wxArrayString>* m_itemsListCp;
105 };
106 
107 
113 {
114 public:
116 
117  wxTextCtrl* m_FrameText;
118  wxTextCtrl* m_FrameSize;
119 private:
120  wxStaticText* m_Title;
121 
122 public:
123  EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title,
124  const wxString& TextToEdit, int textsize,
125  EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen = 200 );
126 
128 
129  const wxString GetText() const;
130  int GetTextSize();
131  void Enable( bool state );
132  void SetTitle( const wxString& title );
133 
134  void SetFocus() { m_FrameText->SetFocus(); }
135  void SetValue( const wxString& value );
136  void SetValue( int value );
137 
142  static wxString FormatSize( EDA_UNITS_T user_unit, int textSize );
143 
144  static int ParseSize( const wxString& sizeText, EDA_UNITS_T user_unit );
145 };
146 
147 
148 /**************************************************************************/
149 /* Class to edit/enter a coordinate (pair of values) ( INCHES or MM ) in */
150 /* dialog boxes, */
151 /**************************************************************************/
153 {
154 public:
157 
158  wxTextCtrl* m_FramePosX;
159  wxTextCtrl* m_FramePosY;
160 private:
161  wxStaticText* m_TextX, * m_TextY;
162 
163 public:
164  EDA_POSITION_CTRL( wxWindow* parent, const wxString& title,
165  const wxPoint& pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
166 
168 
169  void Enable( bool x_win_on, bool y_win_on );
170  void SetValue( int x_value, int y_value );
171  wxPoint GetValue();
172 };
173 
174 
175 /*************************************************************
176  * Class to edit/enter a size (pair of values for X and Y size)
177  * ( INCHES or MM ) in dialog boxes
178  ***************************************************************/
180 {
181 public:
182  EDA_SIZE_CTRL( wxWindow* parent, const wxString& title,
183  const wxSize& size_to_edit, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
184 
186  wxSize GetValue();
187 };
188 
189 
190 /****************************************************************/
191 /* Class to edit/enter a value ( INCHES or MM ) in dialog boxes */
192 /****************************************************************/
194 {
195 public:
197  int m_Value;
198  wxTextCtrl* m_ValueCtrl;
199 private:
200  wxStaticText* m_Text;
201 
202 public:
203  EDA_VALUE_CTRL( wxWindow* parent, const wxString& title, int value,
204  EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer );
205 
206  ~EDA_VALUE_CTRL();
207 
208  int GetValue();
209  void SetValue( int new_value );
210  void Enable( bool enbl );
211 
212  void SetToolTip( const wxString& text )
213  {
214  m_ValueCtrl->SetToolTip( text );
215  }
216 };
217 
218 #endif // DIALOG_HELPERS_H_
void onCancelClick(wxCommandEvent &event) override
Definition: displlst.cpp:201
EDA_GRAPHIC_TEXT_CTRL(wxWindow *parent, const wxString &Title, const wxString &TextToEdit, int textsize, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer, int framelen=200)
Definition: wxwineda.cpp:39
void initDialog(const wxArrayString &aItemHeaders, const wxString &aSelection)
Definition: displlst.cpp:67
void onOkClick(wxCommandEvent &event) override
Definition: displlst.cpp:225
wxString GetTextSelection(int aColumn=0)
Function GetTextSelection return the selected text from aColumn in the wxListCtrl in the dialog...
Definition: displlst.cpp:137
wxTextCtrl * m_FrameText
void textChangeInFilterBox(wxCommandEvent &event) override
Definition: displlst.cpp:113
void Enable(bool state)
Definition: wxwineda.cpp:146
void Enable(bool x_win_on, bool y_win_on)
Definition: wxwineda.cpp:219
wxPoint GetValue()
Definition: wxwineda.cpp:208
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:36
EDA_UNITS_T m_UserUnit
void Append(const wxArrayString &aItemStr)
Definition: displlst.cpp:160
static int ParseSize(const wxString &sizeText, EDA_UNITS_T user_unit)
Definition: wxwineda.cpp:123
const std::vector< wxArrayString > * m_itemsListCp
class EDA_LIST_DIALOG
void Enable(bool enbl)
Definition: wxwineda.cpp:320
wxStaticText * m_Title
void SetTitle(const wxString &title)
Definition: wxwineda.cpp:97
wxTextCtrl * m_ValueCtrl
Class EDA_DRAW_FRAME is the base class for create windows for drawing purpose.
Definition: draw_frame.h:54
const wxString GetText() const
Definition: wxwineda.cpp:116
EDA_POSITION_CTRL(wxWindow *parent, const wxString &title, const wxPoint &pos_to_edit, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer)
Definition: wxwineda.cpp:155
void SetValue(int new_value)
Definition: wxwineda.cpp:309
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:231
Class EDA_LIST_DIALOG_BASE.
wxTextCtrl * m_FramePosX
EDA_SIZE_CTRL(wxWindow *parent, const wxString &title, const wxSize &size_to_edit, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer)
Definition: wxwineda.cpp:246
wxSize GetValue()
Definition: wxwineda.cpp:255
void SetValue(const wxString &value)
Definition: wxwineda.cpp:103
void onListItemSelected(wxListEvent &event) override
Definition: displlst.cpp:207
wxStaticText * m_Text
wxTextCtrl * m_FrameSize
wxTextCtrl * m_FramePosY
void SetToolTip(const wxString &text)
The common library.
EDA_VALUE_CTRL(wxWindow *parent, const wxString &title, int value, EDA_UNITS_T user_unit, wxBoxSizer *BoxSizer)
Definition: wxwineda.cpp:269
wxStaticText * m_TextX
static wxString FormatSize(EDA_UNITS_T user_unit, int textSize)
Function FormatSize formats a string containing the size in the desired units.
Definition: wxwineda.cpp:84
void SetValue(int x_value, int y_value)
Definition: wxwineda.cpp:226
EDA_UNITS_T
Definition: common.h:143
void InsertItems(const std::vector< wxArrayString > &aItemList, int aPosition=0)
Definition: displlst.cpp:174
void(* m_cb_func)(wxString &text, void *data)
void onListItemActivated(wxListEvent &event) override
Definition: displlst.cpp:219