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
cd27245c
Commit
cd27245c
authored
Jan 10, 2010
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow user to change layer color
parent
816c1596
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
30 deletions
+66
-30
layer_panel_base.cpp
pcbnew/layer_panel_base.cpp
+1
-2
layer_panel_base.h
pcbnew/layer_panel_base.h
+1
-1
layer_widget.cpp
pcbnew/layer_widget.cpp
+62
-25
panel_layer_select.fbp
pcbnew/panel_layer_select.fbp
+2
-2
No files found.
pcbnew/layer_panel_base.cpp
View file @
cd27245c
...
...
@@ -11,7 +11,7 @@
LAYER_PANEL_BASE
::
LAYER_PANEL_BASE
(
wxWindow
*
parent
,
wxWindowID
id
,
const
wxPoint
&
pos
,
const
wxSize
&
size
,
long
style
)
:
wxPanel
(
parent
,
id
,
pos
,
size
,
style
)
{
this
->
SetMinSize
(
wxSize
(
400
,
4
00
)
);
this
->
SetMinSize
(
wxSize
(
100
,
1
00
)
);
wxBoxSizer
*
boxSizer
;
boxSizer
=
new
wxBoxSizer
(
wxVERTICAL
);
...
...
@@ -51,7 +51,6 @@ LAYER_PANEL_BASE::LAYER_PANEL_BASE( wxWindow* parent, wxWindowID id, const wxPoi
this
->
SetSizer
(
boxSizer
);
this
->
Layout
();
boxSizer
->
Fit
(
this
);
// Connect Events
m_LayerScrolledWindow
->
Connect
(
wxEVT_LEFT_DCLICK
,
wxMouseEventHandler
(
LAYER_PANEL_BASE
::
OnLeftDblClickLayers
),
NULL
,
this
);
...
...
pcbnew/layer_panel_base.h
View file @
cd27245c
...
...
@@ -47,7 +47,7 @@ class LAYER_PANEL_BASE : public wxPanel
public
:
LAYER_PANEL_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
-
1
,
-
1
),
long
style
=
wxTAB_TRAVERSAL
);
LAYER_PANEL_BASE
(
wxWindow
*
parent
,
wxWindowID
id
=
wxID_ANY
,
const
wxPoint
&
pos
=
wxDefaultPosition
,
const
wxSize
&
size
=
wxSize
(
183
,
184
),
long
style
=
wxTAB_TRAVERSAL
);
~
LAYER_PANEL_BASE
();
};
...
...
pcbnew/layer_widget.cpp
View file @
cd27245c
...
...
@@ -37,7 +37,7 @@
#include <wx/statbmp.h>
#include <wx/aui/aui.h>
//#include "fctsy
s.h"
#include "macro
s.h"
#include "common.h"
#include "layer_panel_base.h"
...
...
@@ -101,13 +101,13 @@ struct LAYER_SPEC
{
wxString
layerName
;
int
layer
;
int
color
Index
;
int
color
;
LAYER_SPEC
(
const
wxString
&
aLayerName
,
int
aLayer
,
int
aColor
Index
=
0
)
LAYER_SPEC
(
const
wxString
&
aLayerName
,
int
aLayer
,
int
aColor
=
0
)
{
layerName
=
aLayerName
;
layer
=
aLayer
;
color
Index
=
aColorIndex
;
color
=
aColor
;
}
};
...
...
@@ -132,6 +132,8 @@ class LAYER_WIDGET : public LAYER_PANEL_BASE
#define MAX_LAYER_ROWS 64
#define LAYER_COLUMN_COUNT 4
#define BUTT_SIZE_X 32
#define BUTT_SIZE_Y 22
protected
:
wxBitmap
*
m_BlankBitmap
;
...
...
@@ -140,34 +142,40 @@ protected:
wxStaticBitmap
*
m_Bitmaps
[
MAX_LAYER_ROWS
];
int
m_CurrentRow
;
///< selected row of layer list
/**
* Function makeColorButton
* creates a wxBitmapButton and assigns it a solid color and a control ID
*/
wxBitmapButton
*
makeColorButton
(
int
aColorIndex
,
int
aID
)
wxBitmap
makeBitmap
(
int
aColor
)
{
const
int
BUTT_SIZE_X
=
32
;
const
int
BUTT_SIZE_Y
=
22
;
// dynamically make a wxBitMap and brush it with the appropriate color,
// then create a wxBitmapButton from it.
wxBitmap
bitmap
(
BUTT_SIZE_X
,
BUTT_SIZE_Y
);
wxBrush
brush
;
wxMemoryDC
iconDC
;
iconDC
.
SelectObject
(
bitmap
);
brush
.
SetColour
(
MakeColour
(
aColor
Index
)
);
brush
.
SetColour
(
MakeColour
(
aColor
)
);
brush
.
SetStyle
(
wxSOLID
);
iconDC
.
SetBrush
(
brush
);
iconDC
.
DrawRectangle
(
0
,
0
,
BUTT_SIZE_X
,
BUTT_SIZE_Y
);
return
bitmap
;
}
/**
* Function makeColorButton
* creates a wxBitmapButton and assigns it a solid color and a control ID
*/
wxBitmapButton
*
makeColorButton
(
int
aColor
,
int
aID
)
{
// dynamically make a wxBitMap and brush it with the appropriate color,
// then create a wxBitmapButton from it.
wxBitmap
bitmap
=
makeBitmap
(
aColor
);
wxBitmapButton
*
ret
=
new
wxBitmapButton
(
m_LayerScrolledWindow
,
aID
,
bitmap
,
wxDefaultPosition
,
wxSize
(
BUTT_SIZE_X
,
BUTT_SIZE_Y
),
wxBORDER_RAISED
);
// save the color value in the name, no where else to put it.
ret
->
SetName
(
makeColorTxt
(
aColor
)
);
ret
->
Connect
(
wxEVT_LEFT_DOWN
,
wxMouseEventHandler
(
LAYER_WIDGET
::
OnLeftDownLayers
),
NULL
,
this
);
ret
->
Connect
(
wxEVT_RIGHT_DOWN
,
wxMouseEventHandler
(
LAYER_WIDGET
::
OnRightDownLayers
),
NULL
,
this
);
...
...
@@ -219,9 +227,40 @@ protected:
SelectLayerRow
(
row
);
}
/**
* Function makeColorTxt
* returns a string containing the numeric value of the color.
* in a form like 0x00000000. (Color is currently an index, not RGB).
*/
wxString
makeColorTxt
(
int
aColor
)
{
char
colorValue
[
64
];
sprintf
(
colorValue
,
"0x%08x"
,
aColor
);
return
wxString
(
CONV_FROM_UTF8
(
colorValue
)
);
}
/**
* Function OnRightDownLayers
* is called only from the color button when user right clicks.
*/
void
OnRightDownLayers
(
wxMouseEvent
&
event
)
{
printf
(
"OnRightDownLayers
\n
"
);
wxBitmapButton
*
eventSource
=
(
wxBitmapButton
*
)
event
.
GetEventObject
();
wxString
colorTxt
=
eventSource
->
GetName
();
int
oldColor
=
strtoul
(
CONV_TO_UTF8
(
colorTxt
),
NULL
,
0
);
int
newColor
=
DisplayColorFrame
(
this
,
oldColor
);
if
(
newColor
>=
0
)
{
eventSource
->
SetName
(
makeColorTxt
(
newColor
)
);
wxBitmap
bm
=
makeBitmap
(
newColor
);
eventSource
->
SetBitmapLabel
(
bm
);
}
}
/**
...
...
@@ -277,7 +316,7 @@ protected:
new
wxSizerItem
(
m_Bitmaps
[
aRow
],
wxSizerFlags
().
Align
(
wxALIGN_CENTER_VERTICAL
)
)
);
// column 1
wxBitmapButton
*
bmb
=
makeColorButton
(
aSpec
.
color
Index
,
aSpec
.
layer
);
wxBitmapButton
*
bmb
=
makeColorButton
(
aSpec
.
color
,
aSpec
.
layer
);
bmb
->
SetToolTip
(
_
(
"Right click to change layer color, left click to select layer"
)
);
m_LayersFlexGridSizer
->
Insert
(
index
+
1
,
new
wxSizerItem
(
bmb
,
flags
)
);
...
...
@@ -317,10 +356,7 @@ public:
SelectLayerRow
(
1
);
m_LayerScrolledWindow
->
FitInside
();
m_LayerScrolledWindow
->
SetMinSize
(
m_LayerScrolledWindow
->
GetSize
()
);
Fit
();
FitInside
();
SetMinSize
(
GetSize
()
);
}
...
...
@@ -463,7 +499,7 @@ public:
// add the panes to the manager
wxAuiPaneInfo
li
;
li
.
MinSize
(
ayerWidget
->
GetSize
()
);
// ignored on linux
li
.
MinSize
(
l
ayerWidget
->
GetSize
()
);
// ignored on linux
li
.
BestSize
(
layerWidget
->
GetSize
()
);
li
.
Left
();
li
.
MaximizeButton
(
false
);
...
...
@@ -491,7 +527,8 @@ private:
// our normal wxApp-derived class, as usual
class
MyApp
:
public
wxApp
{
class
MyApp
:
public
wxApp
{
public
:
bool
OnInit
()
...
...
pcbnew/panel_layer_select.fbp
View file @
cd27245c
...
...
@@ -27,10 +27,10 @@
<property
name=
"hidden"
>
0
</property>
<property
name=
"id"
>
wxID_ANY
</property>
<property
name=
"maximum_size"
></property>
<property
name=
"minimum_size"
>
400,4
00
</property>
<property
name=
"minimum_size"
>
100,1
00
</property>
<property
name=
"name"
>
LAYER_PANEL_BASE
</property>
<property
name=
"pos"
></property>
<property
name=
"size"
>
-1,-1
</property>
<property
name=
"size"
>
183,184
</property>
<property
name=
"subclass"
>
;
</property>
<property
name=
"tooltip"
></property>
<property
name=
"window_extra_style"
></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