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
32dfdb48
Commit
32dfdb48
authored
Jan 08, 2010
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
changes
parent
0e6dd578
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
79 deletions
+134
-79
layer_panel_base.cpp
pcbnew/layer_panel_base.cpp
+1
-1
layer_widget.cpp
pcbnew/layer_widget.cpp
+132
-77
panel_layer_select.fbp
pcbnew/panel_layer_select.fbp
+1
-1
No files found.
pcbnew/layer_panel_base.cpp
View file @
32dfdb48
...
...
@@ -25,7 +25,7 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
m_LayerScrolledWindow
=
new
wxScrolledWindow
(
m_LayerPanel
,
wxID_ANY
,
wxDefaultPosition
,
wxDefaultSize
,
wxVSCROLL
);
m_LayerScrolledWindow
->
SetScrollRate
(
5
,
5
);
m_LayersFlexGridSizer
=
new
wxFlexGridSizer
(
0
,
4
,
3
,
3
);
m_LayersFlexGridSizer
=
new
wxFlexGridSizer
(
0
,
4
,
3
,
5
);
m_LayersFlexGridSizer
->
SetFlexibleDirection
(
wxHORIZONTAL
);
m_LayersFlexGridSizer
->
SetNonFlexibleGrowMode
(
wxFLEX_GROWMODE_SPECIFIED
);
...
...
pcbnew/layer_widget.cpp
View file @
32dfdb48
...
...
@@ -44,48 +44,47 @@
//#include "rightarrow.xpm"
/* XPM */
static
const
char
*
clear_xpm
[]
=
{
"
32
14 1 1"
,
"
28
14 1 1"
,
" c None"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
,
"
"
};
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
,
" "
};
/* XPM */
static
const
char
*
rightarrow_xpm
[]
=
{
"
32
14 5 1"
,
"
28
14 5 1"
,
" c None"
,
". c white"
,
"X c #8080ff"
,
"o c BLUE"
,
"O c gray56"
,
"
. ..
"
,
"
.XX
"
,
"
.XXX
"
,
"
.XXXX
"
,
"
....................XXXXX
"
,
"
.XXXXXXXXXXXXXXXXXXXXXXXX
"
,
"
.XXXXXXXXXXXXXXXXXXXXXXXXX
"
,
"
.oooooooooooooooooooooooooO
"
,
"
.ooooooooooooooooooooooooO
"
,
" OOOOOOOOOOOOOOO
OOoooooO
"
,
"
ooooO
"
,
"
oooO
"
,
"
ooO
"
,
"
oO
"
};
"
. ..
"
,
"
.XX
"
,
"
.XXX
"
,
"
.XXXX
"
,
"
................XXXXX
"
,
"
XXXXXXXXXXXXXXXXXXXXXX
"
,
"
XXXXXXXXXXXXXXXXXXXXXXX
"
,
"
oooooooooooooooooooooooO
"
,
"
ooooooooooooooooooooooO
"
,
" OOOOOOOOOOOOOOO
oooooO
"
,
"
ooooO
"
,
"
oooO
"
,
"
ooO
"
,
"
oO
"
};
...
...
@@ -95,15 +94,14 @@ static const char * rightarrow_xpm[] = {
*/
struct
LAYER_SPEC
{
int
colorIndex
;
int
checkBoxId
;
int
layer
;
wxString
layerName
;
int
layer
;
int
colorIndex
;
LAYER_SPEC
(
const
wxString
&
aLayerName
,
int
aColorIndex
=
0
)
LAYER_SPEC
(
const
wxString
&
aLayerName
,
int
aLayer
,
int
aColorIndex
=
0
)
{
layerName
=
aLayerName
;
layer
=
aLayer
;
colorIndex
=
aColorIndex
;
}
};
...
...
@@ -124,7 +122,7 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
wxBitmap
*
m_RightArrowBitmap
;
wxSize
m_BitmapSize
;
wxStaticBitmap
*
m_Bitmaps
[
32
];
wxStaticBitmap
*
m_Bitmaps
[
64
];
int
m_CurrentRow
;
...
...
@@ -132,26 +130,6 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
#define LAYER_COLUMN_COUNT 4
class
MYSTATICTEXT
:
public
wxStaticText
{
public
:
MYSTATICTEXT
(
LAYER_PANEL
*
aLayerPanel
,
wxWindowID
id
,
const
wxString
&
label
,
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxDefaultSize
,
long
style
=
0
,
const
wxString
&
name
=
wxStaticTextNameStr
)
:
wxStaticText
(
aLayerPanel
->
m_LayerScrolledWindow
,
id
,
label
,
pos
,
size
,
style
,
name
)
{
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnLeftDownLayers
),
NULL
,
aLayerPanel
);
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnRightDownLayers
),
NULL
,
aLayerPanel
);
}
~
MYSTATICTEXT
()
{
Disconnect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnLeftDownLayers
),
NULL
,
NULL
);
Disconnect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnRightDownLayers
),
NULL
,
NULL
);
}
};
/**
* Function getLayerSpec
* returns a LAYER_SPEC from \a aLayer
...
...
@@ -172,7 +150,7 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
*/
static
wxBitmapButton
*
makeColorButton
(
int
aColorIndex
,
int
aID
,
wxWindow
*
aParent
)
wxBitmapButton
*
makeColorButton
(
int
aColorIndex
,
int
aID
)
{
const
int
BUTT_SIZE_X
=
32
;
const
int
BUTT_SIZE_Y
=
22
;
...
...
@@ -193,12 +171,24 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
iconDC
.
DrawRectangle
(
0
,
0
,
BUTT_SIZE_X
,
BUTT_SIZE_Y
);
wxBitmapButton
*
ret
=
new
wxBitmapButton
(
aParent
,
aID
,
bitmap
,
wxBitmapButton
*
ret
=
new
wxBitmapButton
(
m_LayerScrolledWindow
,
aID
,
bitmap
,
wxDefaultPosition
,
wxSize
(
BUTT_SIZE_X
,
BUTT_SIZE_Y
),
wxBORDER_RAISED
);
ret
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnLeftDownLayers
),
NULL
,
this
);
ret
->
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnRightDownLayers
),
NULL
,
this
);
/* cannot get this event without also the wxEVT_LEFT_DOWN firing first
ret->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( LAYER_PANEL::OnLeftDClickLayers ), NULL, this );
*/
return
ret
;
}
/**
* Function insertLayerRow
* appends or inserts a new row in the layer portion of the widget.
*/
void
insertLayerRow
(
int
aRow
,
const
LAYER_SPEC
&
aSpec
)
{
wxASSERT
(
aRow
>=
0
);
...
...
@@ -210,30 +200,25 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
flags
.
Align
(
wxALIGN_CENTER_HORIZONTAL
|
wxALIGN_CENTER_VERTICAL
);
// column 0
#if 1
m_Bitmaps
[
aRow
]
=
new
wxStaticBitmap
(
m_LayerScrolledWindow
,
-
1
,
*
m_BlankBitmap
,
m_Bitmaps
[
aRow
]
=
new
wxStaticBitmap
(
m_LayerScrolledWindow
,
aSpec
.
layer
,
*
m_BlankBitmap
,
wxDefaultPosition
,
m_BitmapSize
);
m_Bitmaps
[
aRow
]
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnLeftDownLayers
),
NULL
,
this
);
m_LayersFlexGridSizer
->
Insert
(
index
+
0
,
m_Bitmaps
[
aRow
],
wxSizerFlags
().
Align
(
wxALIGN_CENTER_VERTICAL
)
);
#else
m_LayersFlexGridSizer
->
Insert
(
index
+
0
,
makeColorButton
(
aSpec
.
colorIndex
,
0
,
m_LayerScrolledWindow
),
flags
);
#endif
// column 1
wxBitmapButton
*
b
b
=
makeColorButton
(
aSpec
.
colorIndex
,
0
,
m_LayerScrolledWindow
);
b
b
->
SetToolTip
(
_
(
"Double
click to change layer color"
)
);
m_LayersFlexGridSizer
->
Insert
(
index
+
1
,
bb
,
flags
);
wxBitmapButton
*
b
mb
=
makeColorButton
(
aSpec
.
colorIndex
,
aSpec
.
layer
);
b
mb
->
SetToolTip
(
_
(
"Right
click to change layer color"
)
);
m_LayersFlexGridSizer
->
Insert
(
index
+
1
,
b
m
b
,
flags
);
// column 2
MYSTATICTEXT
*
st
=
new
MYSTATICTEXT
(
this
,
-
1
,
aSpec
.
layerName
);
wxStaticText
*
st
=
new
wxStaticText
(
m_LayerScrolledWindow
,
aSpec
.
layer
,
aSpec
.
layerName
);
st
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_PANEL
::
OnLeftDownLayers
),
NULL
,
this
);
st
->
SetToolTip
(
_
(
"Click here to select this layer"
)
);
m_LayersFlexGridSizer
->
Insert
(
index
+
2
,
st
,
wxSizerFlags
().
Align
(
wxALIGN_CENTER_VERTICAL
)
);
// column 3
wxCheckBox
*
cb
=
new
wxCheckBox
(
m_LayerScrolledWindow
,
aSpec
.
checkBoxId
,
wxEmptyString
);
wxCheckBox
*
cb
=
new
wxCheckBox
(
m_LayerScrolledWindow
,
aSpec
.
layer
,
wxEmptyString
);
cb
->
SetToolTip
(
_
(
"Enable this for visibility"
)
);
m_LayersFlexGridSizer
->
Insert
(
index
+
3
,
cb
,
flags
);
}
...
...
@@ -241,27 +226,91 @@ class LAYER_PANEL : public LAYER_PANEL_BASE
void
OnLeftDownLayers
(
wxMouseEvent
&
event
)
{
printf
(
"OnLeftDownLayers
\n
"
);
wxObject
*
eventSource
=
event
.
GetEventObject
();
// if mouse event is coming from the m_LayerScrolledWindow and not one
// of its children, we have to find the row manually based on y coord.
if
(
eventSource
==
(
wxObject
*
)
m_LayerScrolledWindow
)
{
int
y
=
event
.
GetY
();
wxArrayInt
heights
=
m_LayersFlexGridSizer
->
GetRowHeights
();
int
height
=
0
;
int
rowCount
=
GetLayerRowCount
();
int
row
;
for
(
row
=
0
;
row
<
rowCount
;
++
row
)
{
if
(
y
<
height
+
heights
[
row
]
)
break
;
height
+=
heights
[
row
];
}
if
(
row
>=
rowCount
)
row
=
rowCount
-
1
;
SelectLayerRow
(
row
);
}
// all nested controls on a given row will have the layer index as their ID
else
{
int
layer
=
((
wxWindow
*
)
eventSource
)
->
GetId
();
int
row
=
findLayerRow
(
layer
);
SelectLayerRow
(
row
);
}
}
void
OnRightDownLayers
(
wxMouseEvent
&
event
)
{
printf
(
"OnRightDownLayers
\n
"
);
}
/**
* Function OnLeftDClickLayers
* is called when a user double clicks on one of the color buttons.
void OnLeftDClickLayers( wxMouseEvent& event )
{
printf("OnLeftDblClickLayers\n");
}
*/
/**
* Function getLayerComp
* returns the component within the m_LayersFlexGridSizer at aSizerNdx.
*
* @param aSizerNdx is the 0 based index into all the wxWindows which have
* been added to the m_LayersFlexGridSizer.
*/
wxWindow
*
getLayerComp
(
int
aSizerNdx
)
{
return
m_LayersFlexGridSizer
->
GetChildren
()[
aSizerNdx
]
->
GetWindow
();
}
/**
* Function findLayerRow
* returns the row index that \a aLayer resides in, or -1 if not found.
*/
int
findLayerRow
(
int
aLayer
)
{
int
count
=
GetLayerRowCount
();
for
(
int
row
=
0
;
row
<
count
;
++
row
)
{
// column 0 in the layer scroll window has a wxStaticBitmap, get its ID.
wxStaticBitmap
*
bm
=
(
wxStaticBitmap
*
)
getLayerComp
(
row
*
LAYER_COLUMN_COUNT
+
0
);
if
(
aLayer
==
bm
->
GetId
()
)
return
row
;
}
return
-
1
;
}
public
:
...
...
@@ -278,6 +327,8 @@ public:
void
SelectLayerRow
(
int
aRow
)
{
wxASSERT
(
(
unsigned
)
aRow
<
GetLayerRowCount
()
);
int
newNdx
=
LAYER_COLUMN_COUNT
*
aRow
;
int
oldNdx
=
LAYER_COLUMN_COUNT
*
m_CurrentRow
;
...
...
@@ -286,6 +337,8 @@ public:
oldbm
->
SetBitmap
(
*
m_BlankBitmap
);
newbm
->
SetBitmap
(
*
m_RightArrowBitmap
);
m_CurrentRow
=
aRow
;
}
...
...
@@ -297,15 +350,17 @@ public:
m_CurrentRow
=
0
;
memset
(
m_Bitmaps
,
0
,
sizeof
(
m_Bitmaps
)
);
m_RightArrowBitmap
=
new
wxBitmap
(
rightarrow_xpm
);
m_BlankBitmap
=
new
wxBitmap
(
clear_xpm
);
// translucent
m_BitmapSize
=
wxSize
(
m_BlankBitmap
->
GetWidth
(),
m_BlankBitmap
->
GetHeight
());
insertLayerRow
(
0
,
LAYER_SPEC
(
wxT
(
"layer 1"
),
RED
)
);
insertLayerRow
(
1
,
LAYER_SPEC
(
wxT
(
"layer 2"
),
GREEN
)
);
insertLayerRow
(
2
,
LAYER_SPEC
(
wxT
(
"
layer_3_you"
),
BLUE
)
);
insertLayerRow
(
3
,
LAYER_SPEC
(
wxT
(
"
brown_layer"
),
BROWN
)
);
insertLayerRow
(
0
,
LAYER_SPEC
(
wxT
(
"layer 1"
),
0
,
RED
)
);
insertLayerRow
(
1
,
LAYER_SPEC
(
wxT
(
"layer 2"
),
1
,
GREEN
)
);
insertLayerRow
(
2
,
LAYER_SPEC
(
wxT
(
"
brown_layer"
),
2
,
BROWN
)
);
insertLayerRow
(
3
,
LAYER_SPEC
(
wxT
(
"
layer_4_you"
),
3
,
BLUE
)
);
SelectLayerRow
(
1
);
}
...
...
pcbnew/panel_layer_select.fbp
View file @
32dfdb48
...
...
@@ -219,7 +219,7 @@
<property
name=
"flexible_direction"
>
wxHORIZONTAL
</property>
<property
name=
"growablecols"
></property>
<property
name=
"growablerows"
></property>
<property
name=
"hgap"
>
3
</property>
<property
name=
"hgap"
>
5
</property>
<property
name=
"minimum_size"
></property>
<property
name=
"name"
>
m_LayersFlexGridSizer
</property>
<property
name=
"non_flexible_grow_mode"
>
wxFLEX_GROWMODE_SPECIFIED
</property>
...
...
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