behavior when gadget is being drawn.
| 221 | |
| 222 | // behavior when gadget is being drawn. |
| 223 | void UIButton::OnDraw() { |
| 224 | // do state based drawing |
| 225 | // determine colors here. |
| 226 | if (IsDisabled()) |
| 227 | m_State = UI_BTS_DISABLED; |
| 228 | |
| 229 | switch (m_State) { |
| 230 | case UI_BTS_ACTIVATED: |
| 231 | case UI_BTS_HILITE: |
| 232 | ui_DrawLTBox(GR_BLACK, GR_LIGHTGRAY, 0, 0, m_W, m_H); |
| 233 | break; |
| 234 | |
| 235 | case UI_BTS_INACTIVE: |
| 236 | ui_DrawLTBox(GR_LIGHTGRAY, GR_BLACK, 0, 0, m_W, m_H); |
| 237 | break; |
| 238 | |
| 239 | case UI_BTS_DISABLED: |
| 240 | ui_DrawLTBox(GR_DARKGRAY, GR_DARKGRAY, 0, 0, m_W, m_H); |
| 241 | break; |
| 242 | |
| 243 | default: |
| 244 | Int3(); |
| 245 | } |
| 246 | |
| 247 | ui_DrawRect(m_Colors[m_State], 1, 1, m_W - 1, m_H - 1); |
| 248 | |
| 249 | if (m_Items[m_State]) { |
| 250 | int x = (m_W / 2 - m_Items[m_State]->width() / 2); |
| 251 | int y = (m_H / 2 - m_Items[m_State]->height() / 2); |
| 252 | m_Items[m_State]->draw(x, y, IsDisabled() ? uiDrawFaded : uiDrawNormal); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | // behavior when key is pressed. |
| 257 | void UIButton::OnKeyDown(int key) {} |
nothing calls this directly
no test coverage detected