Browse Source

Implement border width and bar bgcolor in Windows splash window

rdb 10 years ago
parent
commit
965ed034b2
2 changed files with 24 additions and 7 deletions
  1. 21 5
      direct/src/plugin/p3dWinSplashWindow.cxx
  2. 3 2
      direct/src/plugin/p3dWinSplashWindow.h

+ 21 - 5
direct/src/plugin/p3dWinSplashWindow.cxx

@@ -37,6 +37,7 @@ P3DWinSplashWindow(P3DInstance *inst, bool make_visible) :
   _fg_brush = NULL;
   _fg_brush = NULL;
   _bg_brush = NULL;
   _bg_brush = NULL;
   _bar_brush = NULL;
   _bar_brush = NULL;
+  _bar_bg_brush = NULL;
   _thread_running = false;
   _thread_running = false;
   _install_progress = 0.0;
   _install_progress = 0.0;
   _progress_known = true;
   _progress_known = true;
@@ -500,6 +501,7 @@ make_window() {
   _fg_brush = CreateSolidBrush(RGB(_fgcolor_r, _fgcolor_g, _fgcolor_b));
   _fg_brush = CreateSolidBrush(RGB(_fgcolor_r, _fgcolor_g, _fgcolor_b));
   _bg_brush = CreateSolidBrush(RGB(_bgcolor_r, _bgcolor_g, _bgcolor_b));
   _bg_brush = CreateSolidBrush(RGB(_bgcolor_r, _bgcolor_g, _bgcolor_b));
   _bar_brush = CreateSolidBrush(RGB(_barcolor_r, _barcolor_g, _barcolor_b));
   _bar_brush = CreateSolidBrush(RGB(_barcolor_r, _barcolor_g, _barcolor_b));
+  _bar_bg_brush = CreateSolidBrush(RGB(_bar_bgcolor_r, _bar_bgcolor_g, _bar_bgcolor_b));
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -635,6 +637,10 @@ close_window() {
     DeleteObject(_bar_brush);
     DeleteObject(_bar_brush);
     _bar_brush = NULL;
     _bar_brush = NULL;
   }
   }
+  if (_bar_bg_brush != NULL) {
+    DeleteObject(_bar_bg_brush);
+    _bar_bg_brush = NULL;
+  }
 
 
   _background_image.dump_image();
   _background_image.dump_image();
   _button_ready_image.dump_image();
   _button_ready_image.dump_image();
@@ -794,7 +800,7 @@ paint_progress_bar(HDC dc) {
   RECT bar_rect = { bar_x, bar_y, bar_x + bar_width, bar_y + bar_height };
   RECT bar_rect = { bar_x, bar_y, bar_x + bar_width, bar_y + bar_height };
 
 
   // Clear the entire progress bar to white (or the background color).
   // Clear the entire progress bar to white (or the background color).
-  FillRect(dc, &bar_rect, _bg_brush);
+  FillRect(dc, &bar_rect, _bar_bg_brush);
 
 
   // Draw the interior of the progress bar in blue (or the bar color).
   // Draw the interior of the progress bar in blue (or the bar color).
   if (_drawn_progress_known) {
   if (_drawn_progress_known) {
@@ -820,7 +826,17 @@ paint_progress_bar(HDC dc) {
   }
   }
 
 
   // Now draw a black (or foreground) border around the progress bar.
   // Now draw a black (or foreground) border around the progress bar.
-  FrameRect(dc, &bar_rect, _fg_brush);
+  if (_bar_border >= 0) {
+    RECT border_rect = bar_rect;
+
+    for (int i = 0; i < _bar_border; ++i) {
+      --border_rect.left;
+      --border_rect.top;
+      ++border_rect.right;
+      ++border_rect.bottom;
+      FrameRect(dc, &border_rect, _fg_brush);
+    }
+  }
 
 
   if (!_drawn_label.empty()) {
   if (!_drawn_label.empty()) {
     // Now draw the install_label right above it.
     // Now draw the install_label right above it.
@@ -836,7 +852,7 @@ paint_progress_bar(HDC dc) {
     int text_width = text_size.cx;
     int text_width = text_size.cx;
     int text_height = text_size.cy;
     int text_height = text_size.cy;
     int text_x = (_win_width - text_width) / 2;
     int text_x = (_win_width - text_width) / 2;
-    int text_y = bar_y - (int)(text_height * 1.5);
+    int text_y = bar_y - (int)(text_height * 1.5) - _bar_border;
 
 
     // Clear the rectangle behind the text to white.
     // Clear the rectangle behind the text to white.
     RECT text_rect = { text_x - 2, text_y - 2, text_x + text_width + 4, text_y + text_height + 4 };
     RECT text_rect = { text_x - 2, text_y - 2, text_x + text_width + 4, text_y + text_height + 4 };
@@ -856,7 +872,7 @@ paint_progress_bar(HDC dc) {
 //       Access: Private
 //       Access: Private
 //  Description: The windows event-processing handler.
 //  Description: The windows event-processing handler.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-LONG P3DWinSplashWindow::
+LRESULT P3DWinSplashWindow::
 window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
 window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
   switch (msg) {
   switch (msg) {
   case WM_DESTROY:
   case WM_DESTROY:
@@ -937,7 +953,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
 //       Access: Private, Static
 //       Access: Private, Static
 //  Description: The windows event-processing handler, static version.
 //  Description: The windows event-processing handler, static version.
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
-LONG P3DWinSplashWindow::
+LRESULT P3DWinSplashWindow::
 st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
 st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
   LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA);
   LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA);
   if (self == NULL) {
   if (self == NULL) {

+ 3 - 2
direct/src/plugin/p3dWinSplashWindow.h

@@ -68,8 +68,8 @@ private:
   void paint_window(HDC dc);
   void paint_window(HDC dc);
   bool paint_image(HDC dc, const WinImageData &image, bool use_alpha);
   bool paint_image(HDC dc, const WinImageData &image, bool use_alpha);
   void paint_progress_bar(HDC dc);
   void paint_progress_bar(HDC dc);
-  LONG window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
-  static LONG WINAPI st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+  LRESULT window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
+  static LRESULT WINAPI st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
 
 
 private:
 private:
   class WinImageData : public ImageData {
   class WinImageData : public ImageData {
@@ -112,6 +112,7 @@ private:
   HBRUSH _fg_brush;
   HBRUSH _fg_brush;
   HBRUSH _bg_brush;
   HBRUSH _bg_brush;
   HBRUSH _bar_brush;
   HBRUSH _bar_brush;
+  HBRUSH _bar_bg_brush;
 
 
   static bool _registered_window_class;
   static bool _registered_window_class;
 };
 };