KiCad PCB EDA Suite
indicator_icon.cpp File Reference
#include <widgets/indicator_icon.h>
#include <wx/event.h>
#include <wx/settings.h>
#include <wx/sizer.h>
#include <wx/statbmp.h>

Go to the source code of this file.

Functions

wxImage createBlankImage (int size)
 
wxBitmap createArrow (int size, int aDirection, wxColour aColour)
 
wxBitmap createDiamond (int size, wxColour aColour)
 

Function Documentation

◆ createArrow()

wxBitmap createArrow ( int  size,
int  aDirection,
wxColour  aColour 
)

Definition at line 95 of file indicator_icon.cpp.

96{
97 wxImage image = createBlankImage( size );
98
99 int startX = size / 2 - 1;
100 int len = 1;
101
102 int startY = aDirection % 2;
103
104 for( int y = startY; y < startY + ( size / 2 ); ++y )
105 {
106 for( int x = startX; x < startX + len; ++x )
107 {
108 image.SetRGB( x, y, aColour.Red(), aColour.Green(), aColour.Blue() );
109 image.SetAlpha( x, y, wxIMAGE_ALPHA_OPAQUE );
110 }
111
112 // Next row will start one pixel back and be two pixels longer
113 startX -= 1;
114 len += 2;
115 }
116
117 for( int i = 0; i < aDirection; ++i )
118 image = image.Rotate90();
119
120 return wxBitmap( image );
121}
wxImage createBlankImage(int size)

References createBlankImage(), and image.

Referenced by ROW_ICON_PROVIDER::ROW_ICON_PROVIDER().

◆ createBlankImage()

wxImage createBlankImage ( int  size)

Definition at line 73 of file indicator_icon.cpp.

74{
75 wxImage image( size, size );
76
77 image.InitAlpha();
78 for( int y = 0; y < size; ++y )
79 for( int x = 0; x < size; ++x )
80 image.SetAlpha( x, y, wxIMAGE_ALPHA_TRANSPARENT );
81
82#ifdef __WXMSW__
83 // wxWidgets on Windows chokes on an empty fully transparent bitmap and draws it
84 // as a black box
85 image.SetRGB( size / 2, size / 2, 128, 128, 128 );
86 image.SetAlpha( size / 2, size / 2, 10 );
87#endif
88
89 return image;
90}

References image.

Referenced by createArrow(), createDiamond(), and ROW_ICON_PROVIDER::ROW_ICON_PROVIDER().

◆ createDiamond()

wxBitmap createDiamond ( int  size,
wxColour  aColour 
)

Definition at line 125 of file indicator_icon.cpp.

126{
127 wxImage image = createBlankImage( size );
128
129 int startX = size / 2 - 1;
130 int len = 1;
131
132 int startY = 2;
133
134 for( int y = startY; y < size && len > 0; ++y )
135 {
136 for( int x = startX; x < startX + len; ++x )
137 {
138 image.SetRGB( x, y, aColour.Red(), aColour.Green(), aColour.Blue() );
139 image.SetAlpha( x, y, wxIMAGE_ALPHA_OPAQUE );
140 }
141
142 // Next row will start one pixel back and be two pixels longer
143 if( y < ( size / 2) - 1 )
144 {
145 startX -= 1;
146 len += 2;
147 }
148 else
149 {
150 startX += 1;
151 len -= 2;
152 }
153 }
154
155 return wxBitmap( image );
156}

References createBlankImage(), and image.

Referenced by ROW_ICON_PROVIDER::ROW_ICON_PROVIDER().