void MHRectangle::Display(MHEngine *engine) { if (! m_fRunning) return; if (m_nBoxWidth == 0 || m_nBoxHeight == 0) return; // Can't draw zero sized boxes. // The bounding box is assumed always to be True. MHRgba lineColour = GetColour(m_LineColour); MHRgba fillColour = GetColour(m_FillColour); MHContext *d = engine->GetContext(); // Fill the centre. if (m_nBoxHeight < m_nLineWidth*2 || m_nBoxWidth < m_nLineWidth*2) { // If the area is very small but non-empty fill it with the line colour d->DrawRect(m_nPosX, m_nPosY, m_nBoxWidth, m_nBoxHeight, lineColour); } else { d->DrawRect(m_nPosX + m_nLineWidth, m_nPosY + m_nLineWidth, m_nBoxWidth - m_nLineWidth*2, m_nBoxHeight - m_nLineWidth*2, fillColour); // Draw the lines round the outside. UK MHEG allows us to treat all line styles as solid. // It isn't clear when we draw dashed and dotted lines what colour to put in the spaces. d->DrawRect(m_nPosX, m_nPosY, m_nBoxWidth, m_nLineWidth, lineColour); d->DrawRect(m_nPosX, m_nPosY + m_nBoxHeight - m_nLineWidth, m_nBoxWidth, m_nLineWidth, lineColour); d->DrawRect(m_nPosX, m_nPosY + m_nLineWidth, m_nLineWidth, m_nBoxHeight - m_nLineWidth*2, lineColour); d->DrawRect(m_nPosX + m_nBoxWidth - m_nLineWidth, m_nPosY + m_nLineWidth, m_nLineWidth, m_nBoxHeight - m_nLineWidth*2, lineColour); } }
void MHSlider::Display(MHEngine *engine) { MHContext *d = engine->GetContext(); MHRgba colour; if (m_fHighlightStatus && m_fEngineResp) { colour = GetColour(m_highlightRefColour); } else { colour = GetColour(m_sliderRefColour); } int major; // Direction of change. if (m_orientation == SliderLeft || m_orientation == SliderRight) { major = m_nBoxWidth; } else { major = m_nBoxHeight; } if (max_value <= min_value) { return; // Avoid divide by zero if error. } if (m_style == SliderNormal) { // This is drawn as a 9 pixel wide "thumb" at the position. major -= 9; // Width of "thumb" int posn = major * (slider_value - min_value) / (max_value - min_value); switch (m_orientation) { case SliderLeft: d->DrawRect(m_nPosX + posn, m_nPosY, 9, m_nBoxHeight, colour); break; case SliderRight: d->DrawRect(m_nPosX + m_nBoxWidth - posn - 9, m_nPosY, 9, m_nBoxHeight, colour); break; case SliderUp: d->DrawRect(m_nPosX, m_nPosY + m_nBoxHeight - posn - 9, m_nBoxWidth, 9, colour); break; case SliderDown: d->DrawRect(m_nPosX, m_nPosY + posn, m_nBoxWidth, 9, colour); break; } } else { // Thermometer and proportional sliders are drawn as bars. Thermometers // run from the start to the position, proportional sliders from the // position for the "portion". int start = 0; int end = major * (slider_value - min_value) / (max_value - min_value); if (m_style == SliderProp) { start = end; end = major * (slider_value + portion - min_value) / (max_value - min_value); } switch (m_orientation) { case SliderLeft: d->DrawRect(m_nPosX + start, m_nPosY, end - start, m_nBoxHeight, colour); break; case SliderRight: d->DrawRect(m_nPosX + m_nBoxWidth - end, m_nPosY, end - start, m_nBoxHeight, colour); break; case SliderUp: d->DrawRect(m_nPosX, m_nPosY + m_nBoxHeight - end, m_nBoxWidth, end - start, colour); break; case SliderDown: d->DrawRect(m_nPosX, m_nPosY + start, m_nBoxWidth, end - start, colour); break; } } }