Implement border width and bar bgcolor in Windows splash window

This commit is contained in:
rdb 2015-09-01 04:02:52 +02:00
parent 0bba09fc96
commit 965ed034b2
2 changed files with 24 additions and 7 deletions

View File

@ -37,6 +37,7 @@ P3DWinSplashWindow(P3DInstance *inst, bool make_visible) :
_fg_brush = NULL;
_bg_brush = NULL;
_bar_brush = NULL;
_bar_bg_brush = NULL;
_thread_running = false;
_install_progress = 0.0;
_progress_known = true;
@ -500,6 +501,7 @@ make_window() {
_fg_brush = CreateSolidBrush(RGB(_fgcolor_r, _fgcolor_g, _fgcolor_b));
_bg_brush = CreateSolidBrush(RGB(_bgcolor_r, _bgcolor_g, _bgcolor_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);
_bar_brush = NULL;
}
if (_bar_bg_brush != NULL) {
DeleteObject(_bar_bg_brush);
_bar_bg_brush = NULL;
}
_background_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 };
// 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).
if (_drawn_progress_known) {
@ -820,7 +826,17 @@ paint_progress_bar(HDC dc) {
}
// 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()) {
// 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_height = text_size.cy;
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.
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
// Description: The windows event-processing handler.
////////////////////////////////////////////////////////////////////
LONG P3DWinSplashWindow::
LRESULT P3DWinSplashWindow::
window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
switch (msg) {
case WM_DESTROY:
@ -937,7 +953,7 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
// Access: Private, Static
// Description: The windows event-processing handler, static version.
////////////////////////////////////////////////////////////////////
LONG P3DWinSplashWindow::
LRESULT P3DWinSplashWindow::
st_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
LONG_PTR self = GetWindowLongPtr(hwnd, GWLP_USERDATA);
if (self == NULL) {

View File

@ -68,8 +68,8 @@ private:
void paint_window(HDC dc);
bool paint_image(HDC dc, const WinImageData &image, bool use_alpha);
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:
class WinImageData : public ImageData {
@ -112,6 +112,7 @@ private:
HBRUSH _fg_brush;
HBRUSH _bg_brush;
HBRUSH _bar_brush;
HBRUSH _bar_bg_brush;
static bool _registered_window_class;
};