132{
133 int textWidth = 0, textHeight = 0;
134 wxFontMetrics fm;
135
136 if (m_flags & wxAUI_TB_TEXT)
137 {
138 dc.SetFont(m_font);
139 fm = dc.GetFontMetrics();
140 textHeight = fm.ascent + fm.descent;
141 dc.GetTextExtent(item.GetLabel(), &textWidth, nullptr);
142 }
143
144 int bmpX = 0, bmpY = 0;
145 int textX = 0, textY = 0;
146
147
148
149
150 const wxBitmap bmp = item.GetCurrentBitmapFor(wnd);
151
152 const wxSize bmpSize = bmp.IsOk() ? bmp.GetScaledSize() : wxSize(0, 0);
153
154 if (m_textOrientation == wxAUI_TBTOOL_TEXT_BOTTOM)
155 {
156 bmpX = rect.x +
157 (rect.width / 2) -
158 (bmpSize.x / 2);
159
160 bmpY = rect.y +
161 ((rect.height - textHeight) / 2) -
162 (bmpSize.y / 2);
163
164 textX = rect.x + (rect.width / 2) - (textWidth / 2) + 1;
165 textY = rect.y + rect.height - textHeight - 1;
166 }
167 else if (m_textOrientation == wxAUI_TBTOOL_TEXT_RIGHT)
168 {
169 bmpX = rect.x + wnd->FromDIP(3);
170
171 bmpY = rect.y +
172 (rect.height / 2) -
173 (bmpSize.y / 2);
174
175 textX = bmpX + wnd->FromDIP(3) + bmpSize.x;
176 textY = bmpY + bmpSize.y / 2 - textHeight / 2 - fm.externalLeading + 1;
177 }
178
179
180 if (!(item.GetState() & wxAUI_BUTTON_STATE_DISABLED))
181 {
182 if (item.GetState() & wxAUI_BUTTON_STATE_PRESSED)
183 {
186 dc.DrawRectangle(rect);
187 }
188 else if ((item.GetState() & wxAUI_BUTTON_STATE_HOVER) || item.IsSticky())
189 {
192
193
194
195 if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
197
198 dc.DrawRectangle(rect);
199 }
200 else if (item.GetState() & wxAUI_BUTTON_STATE_CHECKED)
201 {
202
203
206 dc.DrawRectangle(rect);
207 }
208 }
209
210 if (bmp.IsOk())
211 dc.DrawBitmap(bmp, bmpX, bmpY, true);
212
213
214#ifdef __WINDOWS__
215 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT));
216#else
217 dc.SetTextForeground(*wxWHITE);
218#endif
219 if (item.GetState() & wxAUI_BUTTON_STATE_DISABLED)
220 {
221 dc.SetTextForeground(wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT));
222 }
223
224 if ((m_flags & wxAUI_TB_TEXT) && !item.GetLabel().empty())
225 {
226 dc.DrawText(item.GetLabel(), textX, textY);
227 }
228}
static wxColour darkModeColorFor(wxColour const &color)
Definition StateColor.cpp:219