Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
df494fc8
Commit
df494fc8
authored
Mar 19, 2012
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start toying with DIALOG_SHIM
parent
87aa22f1
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
130 additions
and
85 deletions
+130
-85
dialog_edit_label.cpp
eeschema/dialogs/dialog_edit_label.cpp
+25
-2
dialog_edit_label.h
eeschema/dialogs/dialog_edit_label.h
+0
-41
libeditframe.cpp
eeschema/libeditframe.cpp
+1
-0
dialog_helpers.h
include/dialog_helpers.h
+70
-3
fctsys.h
include/fctsys.h
+4
-3
dialog_pcb_text_properties.cpp
pcbnew/dialogs/dialog_pcb_text_properties.cpp
+30
-4
dialog_pcb_text_properties.h
pcbnew/dialogs/dialog_pcb_text_properties.h
+0
-32
No files found.
eeschema/dialogs/dialog_edit_label.cpp
View file @
df494fc8
...
@@ -38,7 +38,30 @@
...
@@ -38,7 +38,30 @@
#include <confirm.h>
#include <confirm.h>
#include <sch_text.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).. )
/* Edit the properties of the text (Label, Global label, graphic text).. )
...
@@ -56,7 +79,7 @@ void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem )
...
@@ -56,7 +79,7 @@ void SCH_EDIT_FRAME::EditSchematicText( SCH_TEXT* aTextItem )
DialogLabelEditor
::
DialogLabelEditor
(
SCH_EDIT_FRAME
*
aParent
,
SCH_TEXT
*
aTextItem
)
:
DialogLabelEditor
::
DialogLabelEditor
(
SCH_EDIT_FRAME
*
aParent
,
SCH_TEXT
*
aTextItem
)
:
DialogLabelEditor_Base
(
aParent
)
DialogLabelEditor_Base
_SHIM
(
aParent
)
{
{
m_Parent
=
aParent
;
m_Parent
=
aParent
;
m_CurrentText
=
aTextItem
;
m_CurrentText
=
aTextItem
;
...
...
eeschema/dialogs/dialog_edit_label.h
deleted
100644 → 0
View file @
87aa22f1
/////////////////////////////////////////////////////////////////////////////
// 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_
eeschema/libeditframe.cpp
View file @
df494fc8
...
@@ -55,6 +55,7 @@
...
@@ -55,6 +55,7 @@
#include <boost/foreach.hpp>
#include <boost/foreach.hpp>
/* Library editor wxConfig entry names. */
/* Library editor wxConfig entry names. */
const
wxString
lastLibExportPathEntry
(
wxT
(
"LastLibraryExportPath"
)
);
const
wxString
lastLibExportPathEntry
(
wxT
(
"LastLibraryExportPath"
)
);
const
wxString
lastLibImportPathEntry
(
wxT
(
"LastLibraryImportPath"
)
);
const
wxString
lastLibImportPathEntry
(
wxT
(
"LastLibraryImportPath"
)
);
...
...
include/dialog_helpers.h
View file @
df494fc8
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
* @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
* @note Due to use of wxFormBuilder to create dialogs many of them should be removed.
*/
*/
#ifndef
_
DIALOG_HELPERS_H_
#ifndef DIALOG_HELPERS_H_
#define
_
DIALOG_HELPERS_H_
#define DIALOG_HELPERS_H_
#include <common.h> // EDA_UNITS_T
#include <common.h> // EDA_UNITS_T
...
@@ -183,4 +183,71 @@ public:
...
@@ -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_
include/fctsys.h
View file @
df494fc8
...
@@ -50,8 +50,9 @@
...
@@ -50,8 +50,9 @@
* Function Clamp
* Function Clamp
* limits @a value within the range @a lower <= @a value <= @a upper. It will work
* 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 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
* on most if not all numeric types, string types, or any type for which "operator < ()"
* can remember the expression as a memory aid:
* is present. The arguments are accepted in this order so you can remember the
* expression as a memory aid:
* <p>
* <p>
* result is: lower <= value <= upper
* result is: lower <= value <= upper
*/
*/
...
@@ -60,7 +61,7 @@ template <typename T> inline const T& Clamp( const T& lower, const T& value, con
...
@@ -60,7 +61,7 @@ template <typename T> inline const T& Clamp( const T& lower, const T& value, con
wxASSERT
(
lower
<=
upper
);
wxASSERT
(
lower
<=
upper
);
if
(
value
<
lower
)
if
(
value
<
lower
)
return
lower
;
return
lower
;
else
if
(
value
>
upper
)
else
if
(
upper
<
value
)
return
upper
;
return
upper
;
return
value
;
return
value
;
}
}
...
...
pcbnew/dialogs/dialog_pcb_text_properties.cpp
View file @
df494fc8
...
@@ -38,7 +38,35 @@
...
@@ -38,7 +38,35 @@
#include <class_board.h>
#include <class_board.h>
#include <class_pcb_text.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 @@
...
@@ -50,7 +78,7 @@
DIALOG_PCB_TEXT_PROPERTIES
::
DIALOG_PCB_TEXT_PROPERTIES
(
PCB_EDIT_FRAME
*
parent
,
DIALOG_PCB_TEXT_PROPERTIES
::
DIALOG_PCB_TEXT_PROPERTIES
(
PCB_EDIT_FRAME
*
parent
,
TEXTE_PCB
*
passedTextPCB
,
wxDC
*
DC
)
TEXTE_PCB
*
passedTextPCB
,
wxDC
*
DC
)
:
DIALOG_PCB_TEXT_PROPERTIES_BASE
(
parent
)
:
DIALOG_PCB_TEXT_PROPERTIES_BASE
_SHIM
(
parent
)
{
{
m_Parent
=
parent
;
m_Parent
=
parent
;
m_DC
=
DC
;
m_DC
=
DC
;
...
@@ -78,8 +106,6 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
...
@@ -78,8 +106,6 @@ void PCB_EDIT_FRAME::InstallTextPCBOptionsFrame( TEXTE_PCB* TextPCB, wxDC* DC )
void
DIALOG_PCB_TEXT_PROPERTIES
::
MyInit
()
void
DIALOG_PCB_TEXT_PROPERTIES
::
MyInit
()
{
{
SetFocus
();
// Put units symbols to text labels where appropriate
// Put units symbols to text labels where appropriate
AddUnitSymbol
(
*
m_SizeXLabel
);
AddUnitSymbol
(
*
m_SizeXLabel
);
AddUnitSymbol
(
*
m_SizeYLabel
);
AddUnitSymbol
(
*
m_SizeYLabel
);
...
...
pcbnew/dialogs/dialog_pcb_text_properties.h
deleted
100644 → 0
View file @
87aa22f1
#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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment