KiCad PCB EDA Suite
dialog_shim.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) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2012-2018 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 #ifndef DIALOG_SHIM_
26 #define DIALOG_SHIM_
27 
28 #include <wx/dialog.h>
29 #include <hashtables.h>
30 #include <kiway_player.h>
31 
32 #ifdef __WXMAC__
33 
36 #define DLGSHIM_USE_SETFOCUS 1
37 #else
38 #define DLGSHIM_USE_SETFOCUS 0
39 #endif
40 
41 #ifdef __WXMAC__
42 
46 #define DLGSHIM_SELECT_ALL_IN_TEXT_CONTROLS 1
47 #else
48 #define DLGSHIM_SELECT_ALL_IN_TEXT_CONTROLS 0
49 #endif
50 
51 class WDO_ENABLE_DISABLE;
52 class EVENT_LOOP;
53 
54 // These macros are for DIALOG_SHIM only, NOT for KIWAY_PLAYER. KIWAY_PLAYER
55 // has its own support for quasi modal and its platform specific issues are different
56 // than for a wxDialog.
57  #define SHOWQUASIMODAL ShowQuasiModal
58  #define ENDQUASIMODAL EndQuasiModal
59 
60 
70 class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
71 {
78  void OnCloseWindow( wxCloseEvent& aEvent );
79 
86  void OnButton( wxCommandEvent& aEvent );
87 
88 public:
89 
90  DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& title,
91  const wxPoint& pos = wxDefaultPosition,
92  const wxSize& size = wxDefaultSize,
93  long style = wxDEFAULT_DIALOG_STYLE,
94  const wxString& name = wxDialogNameStr
95  );
96 
97  ~DIALOG_SHIM();
98 
99  int ShowQuasiModal(); // disable only the parent window, otherwise modal.
100 
101  void EndQuasiModal( int retCode ); // End quasi-modal mode
102 
103  bool IsQuasiModal() { return m_qmodal_showing; }
104 
105  bool Show( bool show ) override;
106 
107  bool Enable( bool enable ) override;
108 
109  void OnPaint( wxPaintEvent &event );
110 
111 protected:
112 
128  void FinishDialogSettings();
129 
135  void SetSizeInDU( int x, int y );
136 
141  int HorizPixelsFromDU( int x );
142 
147  int VertPixelsFromDU( int y );
148 
150 
151  std::string m_hash_key; // alternate for class_map when classname re-used.
152 
153  // variables for quasi-modal behavior support, only used by a few derivatives.
154  EVENT_LOOP* m_qmodal_loop; // points to nested event_loop, NULL means not qmodal and dismissed
157 };
158 
159 #endif // DIALOG_SHIM_
bool m_qmodal_showing
Definition: dialog_shim.h:155
Class KIWAY_HOLDER is a mix in class which holds the location of a wxWindow&#39;s KIWAY.
Definition: kiway_player.h:48
void OnButton(wxCommandEvent &aEvent)
Function OnCloseWindow.
std::string m_hash_key
Definition: dialog_shim.h:151
void FinishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:70
EVENT_LOOP * m_qmodal_loop
Definition: dialog_shim.h:154
void OnCloseWindow(wxCloseEvent &aEvent)
Function OnCloseWindow.
int ShowQuasiModal()
void SetSizeInDU(int x, int y)
Set the dialog to the given dimensions in "dialog units".
bool IsQuasiModal()
Definition: dialog_shim.h:103
void OnPaint(wxPaintEvent &event)
bool Show(bool show) override
int VertPixelsFromDU(int y)
Convert an integer number of dialog units to pixels, vertically.
WDO_ENABLE_DISABLE * m_qmodal_parent_disabler
Definition: dialog_shim.h:156
void EndQuasiModal(int retCode)
DIALOG_SHIM(wxWindow *aParent, wxWindowID id, const wxString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const wxString &name=wxDialogNameStr)
Definition: dialog_shim.cpp:57
const char * name
Definition: DXF_plotter.cpp:61
Toggle a window&#39;s "enable" status to disabled, then enabled on destruction.
Definition: dialog_shim.cpp:33
bool m_fixupsRun
Definition: dialog_shim.h:149
int HorizPixelsFromDU(int x)
Convert an integer number of dialog units to pixels, horizontally.
bool Enable(bool enable) override