start toying with DIALOG_SHIM
This commit is contained in:
parent
87aa22f13f
commit
df494fc83e
|
@ -38,7 +38,30 @@
|
|||
#include <confirm.h>
|
||||
#include <sch_text.h>
|
||||
|
||||
#include <dialog_edit_label.h>
|
||||
#include <dialog_edit_label_base.h>
|
||||
#include <dialog_helpers.h>
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SCH_TEXT;
|
||||
|
||||
|
||||
DIALOG_EXTEND_WITH_SHIM( DialogLabelEditor, DialogLabelEditor_Base )
|
||||
{
|
||||
public:
|
||||
DialogLabelEditor( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
|
||||
|
||||
private:
|
||||
void InitDialog( );
|
||||
virtual void OnEnterKey( wxCommandEvent& aEvent );
|
||||
virtual void OnOkClick( wxCommandEvent& aEvent );
|
||||
virtual void OnCancelClick( wxCommandEvent& aEvent );
|
||||
void TextPropertiesAccept( wxCommandEvent& aEvent );
|
||||
|
||||
SCH_EDIT_FRAME* m_Parent;
|
||||
SCH_TEXT* m_CurrentText;
|
||||
wxTextCtrl* m_textLabel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* Edit the properties of the text (Label, Global label, graphic text).. )
|
||||
|
@ -56,7 +79,7 @@ void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem )
|
|||
|
||||
|
||||
DialogLabelEditor::DialogLabelEditor( SCH_EDIT_FRAME* aParent, SCH_TEXT* aTextItem ) :
|
||||
DialogLabelEditor_Base( aParent )
|
||||
DialogLabelEditor_Base_SHIM( aParent )
|
||||
{
|
||||
m_Parent = aParent;
|
||||
m_CurrentText = aTextItem;
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dialog_edit_label.h
|
||||
// Author: jean-pierre Charras
|
||||
// Modified by:
|
||||
// Licence: GPL
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _DIALOG_EDIT_LABEL_H_
|
||||
#define _DIALOG_EDIT_LABEL_H_
|
||||
|
||||
#include <dialog_edit_label_base.h>
|
||||
|
||||
|
||||
class SCH_EDIT_FRAME;
|
||||
class SCH_TEXT;
|
||||
|
||||
|
||||
class DialogLabelEditor : public DialogLabelEditor_Base
|
||||
{
|
||||
private:
|
||||
SCH_EDIT_FRAME* m_Parent;
|
||||
SCH_TEXT* m_CurrentText;
|
||||
wxTextCtrl* m_textLabel;
|
||||
|
||||
public:
|
||||
DialogLabelEditor( SCH_EDIT_FRAME* parent, SCH_TEXT* aTextItem );
|
||||
~DialogLabelEditor(){};
|
||||
|
||||
|
||||
public:
|
||||
|
||||
private:
|
||||
void InitDialog( );
|
||||
virtual void OnEnterKey( wxCommandEvent& aEvent );
|
||||
virtual void OnOkClick( wxCommandEvent& aEvent );
|
||||
virtual void OnCancelClick( wxCommandEvent& aEvent );
|
||||
void TextPropertiesAccept( wxCommandEvent& aEvent );
|
||||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_EDIT_LABEL_H_
|
|
@ -55,6 +55,7 @@
|
|||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
|
||||
/* Library editor wxConfig entry names. */
|
||||
const wxString lastLibExportPathEntry( wxT( "LastLibraryExportPath" ) );
|
||||
const wxString lastLibImportPathEntry( wxT( "LastLibraryImportPath" ) );
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
|
||||
*/
|
||||
|
||||
#ifndef _DIALOG_HELPERS_H_
|
||||
#define _DIALOG_HELPERS_H_
|
||||
#ifndef DIALOG_HELPERS_H_
|
||||
#define DIALOG_HELPERS_H_
|
||||
|
||||
|
||||
#include <common.h> // EDA_UNITS_T
|
||||
|
@ -183,4 +183,71 @@ public:
|
|||
};
|
||||
|
||||
|
||||
#endif // _DIALOG_HELPERS_H_
|
||||
/**
|
||||
* Template DIALOG_SHIM
|
||||
* is a way to have a common way of handling KiCad dialog windows:
|
||||
* <ul>
|
||||
* <li>class specific: static s_LastPos and static s_LastSize for retentative
|
||||
* dialog window positioning, per class.
|
||||
* <li> invocation of SetFocus() to allow ESC key to work on Linux.
|
||||
* <li> future others...
|
||||
* </ul>
|
||||
* by wedging in a class (a SHIM) between the wxFormbuilder coded base class and
|
||||
* our derived dialog classes. Use it via the macro named DIALOG_EXTEND_WITH_SHIM
|
||||
* and be sure to code your constructor to invoke *_SHIM() base class constructor,
|
||||
* not the one from wxFormbuilder.
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
template <class T>
|
||||
class DIALOG_SHIM : public T
|
||||
{
|
||||
public:
|
||||
|
||||
DIALOG_SHIM( wxFrame* aParent ) :
|
||||
T( aParent )
|
||||
{
|
||||
wxDialog::SetFocus();
|
||||
}
|
||||
|
||||
// overload wxDialog::Show
|
||||
bool Show( bool show )
|
||||
{
|
||||
bool ret;
|
||||
|
||||
if( show )
|
||||
{
|
||||
ret = wxDialog::Show( show );
|
||||
if( s_LastPos.x != -1 )
|
||||
wxDialog::SetSize( s_LastPos.x, s_LastPos.y, s_LastSize.x, s_LastSize.y, 0 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Save the dialog's position before hiding
|
||||
s_LastPos = wxDialog::GetPosition();
|
||||
s_LastSize = wxDialog::GetSize();
|
||||
ret = wxDialog::Show( show );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
static wxPoint s_LastPos;
|
||||
static wxSize s_LastSize;
|
||||
};
|
||||
|
||||
template<class T>
|
||||
wxPoint DIALOG_SHIM<T>::s_LastPos( -1, -1 );
|
||||
|
||||
template<class T>
|
||||
wxSize DIALOG_SHIM<T>::s_LastSize( 0, 0 );
|
||||
|
||||
/**
|
||||
* Macro DIALOG_EXTEND_WITH_SHIM
|
||||
* instantiates the template DIALOG_SHIM<> and thereby declares a shim class.
|
||||
* @author Dick Hollenbeck
|
||||
*/
|
||||
#define DIALOG_EXTEND_WITH_SHIM( DERRIVED, BASE ) \
|
||||
typedef DIALOG_SHIM<BASE> BASE##_SHIM; \
|
||||
class DERRIVED : public BASE##_SHIM
|
||||
|
||||
#endif // DIALOG_HELPERS_H_
|
||||
|
|
|
@ -50,8 +50,9 @@
|
|||
* Function Clamp
|
||||
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
|
||||
* on temporary expressions, since they are evaluated only once, and it should work
|
||||
* on most if not all numeric types. The arguments are accepted in this order so you
|
||||
* can remember the expression as a memory aid:
|
||||
* on most if not all numeric types, string types, or any type for which "operator < ()"
|
||||
* is present. The arguments are accepted in this order so you can remember the
|
||||
* expression as a memory aid:
|
||||
* <p>
|
||||
* result is: lower <= value <= upper
|
||||
*/
|
||||
|
@ -60,7 +61,7 @@ template <typename T> inline const T& Clamp( const T& lower, const T& value, con
|
|||
wxASSERT( lower <= upper );
|
||||
if( value < lower )
|
||||
return lower;
|
||||
else if( value > upper )
|
||||
else if( upper < value )
|
||||
return upper;
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,35 @@
|
|||
#include <class_board.h>
|
||||
#include <class_pcb_text.h>
|
||||
|
||||
#include <dialog_pcb_text_properties.h>
|
||||
#include <vector>
|
||||
#include <wx/wx.h>
|
||||
#include <dialog_pcb_text_properties_base.h>
|
||||
|
||||
|
||||
class PCB_EDIT_FRAME;
|
||||
class TEXTE_PCB;
|
||||
|
||||
|
||||
/// Implement DIALOG_PCB_TEXT_PROPERTIES_BASE with interposing
|
||||
/// DIALOG_PCB_TEXT_PROPERTIES_BASE_SHIM class
|
||||
DIALOG_EXTEND_WITH_SHIM( DIALOG_PCB_TEXT_PROPERTIES, DIALOG_PCB_TEXT_PROPERTIES_BASE )
|
||||
{
|
||||
public:
|
||||
DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC );
|
||||
|
||||
private:
|
||||
PCB_EDIT_FRAME* m_Parent;
|
||||
wxDC* m_DC;
|
||||
TEXTE_PCB* m_SelectedPCBText;
|
||||
std::vector<int> layerList;
|
||||
|
||||
void MyInit();
|
||||
|
||||
// Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events.
|
||||
void OnClose( wxCloseEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
@ -50,7 +78,7 @@
|
|||
|
||||
DIALOG_PCB_TEXT_PROPERTIES::DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent,
|
||||
TEXTE_PCB* passedTextPCB, wxDC* DC )
|
||||
: DIALOG_PCB_TEXT_PROPERTIES_BASE( parent )
|
||||
: DIALOG_PCB_TEXT_PROPERTIES_BASE_SHIM( parent )
|
||||
{
|
||||
m_Parent = parent;
|
||||
m_DC = DC;
|
||||
|
@ -78,8 +106,6 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
|
|||
|
||||
void DIALOG_PCB_TEXT_PROPERTIES::MyInit()
|
||||
{
|
||||
SetFocus();
|
||||
|
||||
// Put units symbols to text labels where appropriate
|
||||
AddUnitSymbol( *m_SizeXLabel );
|
||||
AddUnitSymbol( *m_SizeYLabel );
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#ifndef DIALOG_PCB_TEXT_PROPERTIES_H
|
||||
#define DIALOG_PCB_TEXT_PROPERTIES_H
|
||||
|
||||
#include <vector>
|
||||
#include <wx/wx.h>
|
||||
#include <dialog_pcb_text_properties_base.h>
|
||||
|
||||
class PCB_EDIT_FRAME;
|
||||
class TEXTE_PCB;
|
||||
|
||||
/** Implementing DIALOG_PCB_TEXT_PROPERTIES_BASE */
|
||||
class DIALOG_PCB_TEXT_PROPERTIES : public DIALOG_PCB_TEXT_PROPERTIES_BASE
|
||||
{
|
||||
private:
|
||||
PCB_EDIT_FRAME* m_Parent;
|
||||
wxDC* m_DC;
|
||||
TEXTE_PCB* m_SelectedPCBText;
|
||||
std::vector<int> layerList;
|
||||
|
||||
void MyInit();
|
||||
|
||||
protected:
|
||||
// Handlers for DIALOG_PCB_TEXT_PROPERTIES_BASE events.
|
||||
void OnClose( wxCloseEvent& event );
|
||||
void OnCancelClick( wxCommandEvent& event );
|
||||
void OnOkClick( wxCommandEvent& event );
|
||||
|
||||
public:
|
||||
DIALOG_PCB_TEXT_PROPERTIES( PCB_EDIT_FRAME* parent, TEXTE_PCB* passedTextPCB, wxDC* DC );
|
||||
};
|
||||
|
||||
#endif // DIALOG_PCB_TEXT_PROPERTIES_H
|
Loading…
Reference in New Issue