diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 52ba3677..d2e5a620 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -817,14 +817,15 @@ bool CMeter::Draw(Graphics& graphics) int x = GetX(); int y = GetY(); + Rect r(x, y, m_W, m_H); + if (m_SolidColor.GetValue() == m_SolidColor2.GetValue()) { SolidBrush solid(m_SolidColor); - graphics.FillRectangle(&solid, x, y, m_W, m_H); + graphics.FillRectangle(&solid, r); } else { - Rect r(x, y, m_W, m_H); LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE); graphics.FillRectangle(&gradient, r); } @@ -835,15 +836,18 @@ bool CMeter::Draw(Graphics& graphics) int x = GetX(); int y = GetY(); - Pen light(Color(255, 255, 255, 255)); - Pen dark(Color(255, 0, 0, 0)); + Color lightColor(255, 255, 255, 255); + Color darkColor(255, 0, 0, 0); if (m_SolidBevel == BEVELTYPE_DOWN) { - light.SetColor(Color(255, 0, 0, 0)); - dark.SetColor(Color(255, 255, 255, 255)); + lightColor.SetValue(Color::MakeARGB(255, 0, 0, 0)); + darkColor.SetValue(Color::MakeARGB(255, 255, 255, 255)); } + Pen light(lightColor); + Pen dark(darkColor); + // The bevel is drawn outside the meter Rect rect(x - 2, y - 2, m_W + 4, m_H + 4); DrawBevel(graphics, rect, light, dark); @@ -857,7 +861,7 @@ bool CMeter::Draw(Graphics& graphics) ** ** Draws a bevel inside the given area */ -void CMeter::DrawBevel(Graphics& graphics, Rect& rect, Pen& light, Pen& dark) +void CMeter::DrawBevel(Graphics& graphics, const Rect& rect, const Pen& light, const Pen& dark) { int l = rect.GetLeft(); int r = rect.GetRight() - 1; diff --git a/Library/Meter.h b/Library/Meter.h index bd5c9a9f..079eb690 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -94,7 +94,7 @@ public: static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow); - static void DrawBevel(Gdiplus::Graphics& graphics, Gdiplus::Rect& rect, Gdiplus::Pen& light, Gdiplus::Pen& dark); + static void DrawBevel(Gdiplus::Graphics& graphics, const Gdiplus::Rect& rect, const Gdiplus::Pen& light, const Gdiplus::Pen& dark); protected: diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 439dbcfd..a65c4199 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -2258,40 +2258,6 @@ bool CMeterWindow::ResizeWindow(bool reset) m_Background = GrabDesktop(m_ScreenX, m_ScreenY, m_WindowW, m_WindowH); } } - else - { - if (m_WindowW != 0 && m_WindowH != 0) - { - // Create a solid color bitmap for the background - m_Background = new Bitmap(m_WindowW, m_WindowH, PixelFormat32bppARGB); - Graphics graphics(m_Background); - - if (m_SolidColor.GetValue() == m_SolidColor2.GetValue()) - { - graphics.Clear(m_SolidColor); - } - else - { - Rect r(0, 0, m_WindowW, m_WindowH); - LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE); - graphics.FillRectangle(&gradient, r); - } - - if (m_SolidBevel != BEVELTYPE_NONE) - { - Pen light(Color(255, 255, 255, 255)); - Pen dark(Color(255, 0, 0, 0)); - - if (m_SolidBevel == BEVELTYPE_DOWN) - { - light.SetColor(Color(255, 0, 0, 0)); - dark.SetColor(Color(255, 255, 255, 255)); - } - Rect rect(0, 0, m_WindowW, m_WindowH); - CMeter::DrawBevel(graphics, rect, light, dark); - } - } - } } return true; @@ -2379,6 +2345,44 @@ void CMeterWindow::Redraw() Rect r(0, 0, m_WindowW, m_WindowH); graphics.DrawImage(m_Background, r, 0, 0, m_Background->GetWidth(), m_Background->GetHeight(), UnitPixel); } + else if (m_BackgroundMode == BGMODE_SOLID) + { + // Draw the solid color background + if (m_WindowW != 0 && m_WindowH != 0) + { + Rect r(0, 0, m_WindowW, m_WindowH); + + if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0) + { + if (m_SolidColor.GetValue() == m_SolidColor2.GetValue()) + { + graphics.Clear(m_SolidColor); + } + else + { + LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE); + graphics.FillRectangle(&gradient, r); + } + } + + if (m_SolidBevel != BEVELTYPE_NONE) + { + Color lightColor(255, 255, 255, 255); + Color darkColor(255, 0, 0, 0); + + if (m_SolidBevel == BEVELTYPE_DOWN) + { + lightColor.SetValue(Color::MakeARGB(255, 0, 0, 0)); + darkColor.SetValue(Color::MakeARGB(255, 255, 255, 255)); + } + + Pen light(lightColor); + Pen dark(darkColor); + + CMeter::DrawBevel(graphics, r, light, dark); + } + } + } // Draw the meters std::list::const_iterator j = m_Meters.begin();