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
9d395aa0
Commit
9d395aa0
authored
Apr 02, 2008
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MAC alpha support
parent
1a063f6a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
191 additions
and
119 deletions
+191
-119
gr_basic.cpp
common/gr_basic.cpp
+70
-58
colors.h
include/colors.h
+117
-61
class_track.cpp
pcbnew/class_track.cpp
+4
-0
No files found.
common/gr_basic.cpp
View file @
9d395aa0
...
@@ -257,33 +257,39 @@ void SetPenMinWidth( int minwidth )
...
@@ -257,33 +257,39 @@ void SetPenMinWidth( int minwidth )
}
}
/* Routine de changement de couleurs et epaisseur de la plume courante */
/**
* Function GRSetColorPen
* sets a pen style, width, color, and alpha into the given device context.
*/
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
,
int
style
)
void
GRSetColorPen
(
wxDC
*
DC
,
int
Color
,
int
width
,
int
style
)
{
{
Color
&=
MASKCOLOR
;
// Pour 32 couleurs Max
if
(
width
<
PenMinWidth
)
if
(
width
<
PenMinWidth
)
width
=
PenMinWidth
;
width
=
PenMinWidth
;
if
(
ForceBlackPen
&&
Color
!=
WHITE
)
if
(
ForceBlackPen
&&
Color
!=
WHITE
)
{
Color
=
BLACK
;
Color
=
BLACK
;
}
if
(
(
lastcolor
!=
Color
)
||
(
lastwidth
!=
width
)
||
(
s_Last_Pen_Style
!=
style
)
if
(
lastcolor
!=
Color
||
(
lastDC
!=
DC
)
)
||
lastwidth
!=
width
||
s_Last_Pen_Style
!=
style
||
lastDC
!=
DC
)
{
{
wxPen
DrawPen
;
wxPen
pen
;
DrawPen
.
SetColour
(
ColorRefs
[
Color
].
m_Red
,
ColorRefs
[
Color
].
m_Green
,
ColorRefs
[
Color
].
m_Blue
);
DrawPen
.
SetWidth
(
width
);
wxColour
wx_color
=
MakeColour
(
Color
);
DrawPen
.
SetStyle
(
style
);
pen
.
SetColour
(
wx_color
);
pen
.
SetWidth
(
width
);
pen
.
SetStyle
(
style
);
DC
->
SetPen
(
pen
);
lastcolor
=
Color
;
lastwidth
=
width
;
lastDC
=
DC
;
// if ( &DC->GetPen() != DrawPen )
DC
->
SetPen
(
DrawPen
);
lastcolor
=
Color
;
lastwidth
=
width
;
lastDC
=
DC
;
s_Last_Pen_Style
=
style
;
s_Last_Pen_Style
=
style
;
}
}
}
}
...
@@ -337,7 +343,11 @@ void GRMouseWarp( WinEDA_DrawPanel* panel, const wxPoint& pos )
...
@@ -337,7 +343,11 @@ void GRMouseWarp( WinEDA_DrawPanel* panel, const wxPoint& pos )
void
GRSetDrawMode
(
wxDC
*
DC
,
int
draw_mode
)
void
GRSetDrawMode
(
wxDC
*
DC
,
int
draw_mode
)
{
{
if
(
draw_mode
&
GR_OR
)
if
(
draw_mode
&
GR_OR
)
#if defined(__WXMAC__) && wxMAC_USE_CORE_GRAPHICS
DC
->
SetLogicalFunction
(
wxCOPY
);
#else
DC
->
SetLogicalFunction
(
wxOR
);
DC
->
SetLogicalFunction
(
wxOR
);
#endif
else
if
(
draw_mode
&
GR_XOR
)
else
if
(
draw_mode
&
GR_XOR
)
DC
->
SetLogicalFunction
(
wxXOR
);
DC
->
SetLogicalFunction
(
wxXOR
);
else
if
(
draw_mode
&
GR_NXOR
)
else
if
(
draw_mode
&
GR_NXOR
)
...
@@ -861,7 +871,9 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, int Fill,
...
@@ -861,7 +871,9 @@ void GRSPoly( EDA_Rect* ClipBox, wxDC* DC, int n, int* Points, int Fill,
}
}
else
else
{
{
startx
=
Points
[
n
*
2
-
2
];
starty
=
Points
[
n
*
2
-
1
];
startx
=
Points
[
n
*
2
-
2
];
starty
=
Points
[
n
*
2
-
1
];
GRSetBrush
(
DC
,
Color
);
GRSetBrush
(
DC
,
Color
);
DC
->
DrawLines
(
n
,
(
wxPoint
*
)
Points
);
DC
->
DrawLines
(
n
,
(
wxPoint
*
)
Points
);
}
}
...
...
include/colors.h
View file @
9d395aa0
...
@@ -11,12 +11,38 @@
...
@@ -11,12 +11,38 @@
/* Definitions des Numeros des Couleurs ( palette de 32) */
/* Definitions des Numeros des Couleurs ( palette de 32) */
#define NBCOLOR 32
#define NBCOLOR 32
#define MASKCOLOR 31 // masque pour bits significatifs
/* bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs*/
#define MASKCOLOR 31 ///< mask for color index into ColorRefs[]
#define ITEM_NOT_SHOW 0x40000
/* Definition du bit de surbrillance */
/// bit indicateur d'affichage (vu / non vu) des items : (defini dans les valeurs des couleurs
#define HIGHT_LIGHT_FLAG 0x80000
#define ITEM_NOT_SHOW (1<<18) // 0x40000
/// Definition du bit de surbrillance
#define HIGHT_LIGHT_FLAG (1<<19) // 0x80000
/**
* Function SetAlpha
* ORs in the alpha blend parameter in to a color index.
*/
static
inline
void
SetAlpha
(
int
*
aColor
,
int
aBlend
)
{
const
int
MASKALPHA
=
0xFF
;
*
aColor
=
(
*
aColor
&
~
(
MASKALPHA
<<
24
))
|
((
aBlend
&
MASKALPHA
)
<<
24
);
}
/**
* Function GetAlpha
* returns the alpha blend parameter from a color index.
*/
static
inline
int
GetAlpha
(
int
aColor
)
{
const
int
MASKALPHA
=
0xFF
;
return
(
aColor
>>
24
)
&
MASKALPHA
;
}
enum
EDA_Colors
enum
EDA_Colors
{
{
...
@@ -44,17 +70,22 @@ enum EDA_Colors
...
@@ -44,17 +70,22 @@ enum EDA_Colors
DARKMAGENTA
,
DARKMAGENTA
,
DARKBROWN
,
DARKBROWN
,
LIGHTYELLOW
,
LIGHTYELLOW
,
LASTCOLOR
LASTCOLOR
};
};
class
StructColors
struct
StructColors
{
{
public
:
unsigned
char
m_Blue
;
unsigned
char
m_Blue
,
m_Green
,
m_Red
,
m_Numcolor
;
unsigned
char
m_Green
;
unsigned
char
m_Red
;
unsigned
char
m_Numcolor
;
const
wxChar
*
m_Name
;
const
wxChar
*
m_Name
;
int
m_LightColor
;
int
m_LightColor
;
};
};
extern
StructColors
ColorRefs
[
NBCOLOR
];
extern
StructColors
ColorRefs
[
NBCOLOR
];
#ifdef MAIN
#ifdef MAIN
StructColors
ColorRefs
[
NBCOLOR
]
=
StructColors
ColorRefs
[
NBCOLOR
]
=
...
@@ -87,4 +118,29 @@ StructColors ColorRefs[NBCOLOR] =
...
@@ -87,4 +118,29 @@ StructColors ColorRefs[NBCOLOR] =
#endif
/* ifdef MAIN */
#endif
/* ifdef MAIN */
/**
* Function MakeColour
* returns a wxWidgets wxColor from a KICAD color index with alpha value.
* Note that alpha support is not available on every wxWidgets platform. On
* such platform the behavior is the same as for wxALPHA_OPAQUE and that
* means the alpha value has no effect and will be ignored. wxGtk 2.8.4 is
* not supporting alpha.
* @return wxColour - given a KICAD color index with alpha value
*/
static
inline
wxColour
MakeColour
(
int
aColor
)
{
int
alpha
=
GetAlpha
(
aColor
);
alpha
=
alpha
?
alpha
:
wxALPHA_OPAQUE
;
int
ndx
=
aColor
&
MASKCOLOR
;
return
wxColour
(
ColorRefs
[
ndx
].
m_Red
,
ColorRefs
[
ndx
].
m_Green
,
ColorRefs
[
ndx
].
m_Blue
,
(
unsigned
char
)
alpha
);
}
#endif
/* ifndef _COLORS_H */
#endif
/* ifndef _COLORS_H */
pcbnew/class_track.cpp
View file @
9d395aa0
...
@@ -670,9 +670,12 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
...
@@ -670,9 +670,12 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
else
else
color
|=
HIGHT_LIGHT_FLAG
;
color
|=
HIGHT_LIGHT_FLAG
;
}
}
if
(
color
&
HIGHT_LIGHT_FLAG
)
if
(
color
&
HIGHT_LIGHT_FLAG
)
color
=
ColorRefs
[
color
&
MASKCOLOR
].
m_LightColor
;
color
=
ColorRefs
[
color
&
MASKCOLOR
].
m_LightColor
;
SetAlpha
(
&
color
,
150
);
zoom
=
panel
->
GetZoom
();
zoom
=
panel
->
GetZoom
();
l_piste
=
m_Width
>>
1
;
l_piste
=
m_Width
>>
1
;
...
@@ -682,6 +685,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
...
@@ -682,6 +685,7 @@ void TRACK::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
rayon
=
l_piste
;
rayon
=
l_piste
;
if
(
rayon
<
zoom
)
if
(
rayon
<
zoom
)
rayon
=
zoom
;
rayon
=
zoom
;
GRCircle
(
&
panel
->
m_ClipBox
,
DC
,
m_Start
.
x
,
m_Start
.
y
,
rayon
,
color
);
GRCircle
(
&
panel
->
m_ClipBox
,
DC
,
m_Start
.
x
,
m_Start
.
y
,
rayon
,
color
);
if
(
rayon
>
(
4
*
zoom
)
)
if
(
rayon
>
(
4
*
zoom
)
)
{
{
...
...
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