KiCad PCB EDA Suite
indicator_icon.cpp File Reference

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

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

Definition at line 91 of file indicator_icon.cpp.

References createBlankImage(), and i.

Referenced by ROW_ICON_PROVIDER::ROW_ICON_PROVIDER().

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

Definition at line 69 of file indicator_icon.cpp.

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

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

Definition at line 121 of file indicator_icon.cpp.

References createBlankImage().

Referenced by ROW_ICON_PROVIDER::ROW_ICON_PROVIDER().

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