* Draw a widget to the display. * * @param w The widget to draw. */
| 141 | * @param w The widget to draw. |
| 142 | */ |
| 143 | void GUI_Widget_Draw(Widget *w) |
| 144 | { |
| 145 | uint16 positionLeft, positionRight; |
| 146 | uint16 positionTop, positionBottom; |
| 147 | uint16 offsetX, offsetY; |
| 148 | uint16 drawMode; |
| 149 | uint8 fgColour, bgColour; |
| 150 | WidgetDrawParameter drawParam; |
| 151 | |
| 152 | if (w == NULL) return; |
| 153 | |
| 154 | if (w->flags.invisible) { |
| 155 | if (!w->flags.greyWhenInvisible) return; |
| 156 | |
| 157 | GUI_Widget_DrawBlocked(w, 12); |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | if (!w->state.hover2) { |
| 162 | if (!w->state.selected) { |
| 163 | drawMode = w->drawModeNormal; |
| 164 | drawParam = w->drawParameterNormal; |
| 165 | fgColour = w->fgColourNormal; |
| 166 | bgColour = w->bgColourNormal; |
| 167 | } else { |
| 168 | drawMode = w->drawModeSelected; |
| 169 | drawParam = w->drawParameterSelected; |
| 170 | fgColour = w->fgColourSelected; |
| 171 | bgColour = w->bgColourSelected; |
| 172 | |
| 173 | } |
| 174 | } else { |
| 175 | drawMode = w->drawModeDown; |
| 176 | drawParam = w->drawParameterDown; |
| 177 | fgColour = w->fgColourDown; |
| 178 | bgColour = w->bgColourDown; |
| 179 | } |
| 180 | |
| 181 | offsetX = w->offsetX; |
| 182 | if (w->offsetX < 0) { |
| 183 | offsetX = (g_widgetProperties[w->parentID].width << 3) + w->offsetX; |
| 184 | } |
| 185 | positionLeft = (g_widgetProperties[w->parentID].xBase << 3) + offsetX; |
| 186 | positionRight = positionLeft + w->width - 1; |
| 187 | |
| 188 | offsetY = w->offsetY; |
| 189 | if (w->offsetY < 0) { |
| 190 | offsetY = g_widgetProperties[w->parentID].height + w->offsetY; |
| 191 | } |
| 192 | positionTop = g_widgetProperties[w->parentID].yBase + offsetY; |
| 193 | positionBottom = positionTop + w->height - 1; |
| 194 | |
| 195 | assert(drawMode < DRAW_MODE_MAX); |
| 196 | if (drawMode != DRAW_MODE_NONE && drawMode != DRAW_MODE_CUSTOM_PROC && GFX_Screen_IsActive(SCREEN_0)) { |
| 197 | GUI_Mouse_Hide_InRegion(positionLeft, positionTop, positionRight, positionBottom); |
| 198 | } |
| 199 | |
| 200 | switch (drawMode) { |
no test coverage detected