Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1 | /* |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 2 | * Progress control |
| 3 | * |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 4 | * Copyright 1997, 2002 Dimitrie O. Paun |
Eric Kohl | fa8ae2f | 1999-03-12 17:40:32 +0000 | [diff] [blame] | 5 | * Copyright 1998, 1999 Eric Kohl |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 6 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 7 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public |
| 9 | * License as published by the Free Software Foundation; either |
| 10 | * version 2.1 of the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This library is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 15 | * Lesser General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU Lesser General Public |
| 18 | * License along with this library; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 20 | * |
| 21 | * NOTE |
| 22 | * |
| 23 | * This code was audited for completeness against the documented features |
| 24 | * of Comctl32.dll version 6.0 on Sep. 9, 2002, by Dimitrie O. Paun. |
| 25 | * |
Robert Shearman | 3c6956d | 2004-03-11 00:39:53 +0000 | [diff] [blame] | 26 | * Unless otherwise noted, we believe this code to be complete, as per |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 27 | * the specification mentioned above. |
| 28 | * If you discover missing features, or bugs, please note them below. |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 29 | * |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 32 | #include <stdarg.h> |
James Juran | f4d5fef | 2001-01-26 20:43:40 +0000 | [diff] [blame] | 33 | #include <string.h> |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 34 | #include "windef.h" |
Marcus Meissner | 3480e4a | 1999-03-16 10:53:11 +0000 | [diff] [blame] | 35 | #include "winbase.h" |
Alexandre Julliard | e37c6e1 | 2003-09-05 23:08:26 +0000 | [diff] [blame] | 36 | #include "wingdi.h" |
| 37 | #include "winuser.h" |
| 38 | #include "winnls.h" |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 39 | #include "commctrl.h" |
Alexandre Julliard | f5cb3dd | 2003-09-17 20:15:21 +0000 | [diff] [blame] | 40 | #include "comctl32.h" |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 41 | #include "uxtheme.h" |
| 42 | #include "tmschema.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 43 | #include "wine/debug.h" |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 44 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 45 | WINE_DEFAULT_DEBUG_CHANNEL(progress); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 46 | |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 47 | typedef struct |
| 48 | { |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 49 | HWND Self; /* The window handle for this control */ |
| 50 | INT CurVal; /* Current progress value */ |
| 51 | INT MinVal; /* Minimum progress value */ |
| 52 | INT MaxVal; /* Maximum progress value */ |
| 53 | INT Step; /* Step to use on PMB_STEPIT */ |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 54 | INT MarqueePos; /* Marquee animation position */ |
| 55 | BOOL Marquee; /* Whether the marquee animation is enabled */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 56 | COLORREF ColorBar; /* Bar color */ |
| 57 | COLORREF ColorBk; /* Background color */ |
| 58 | HFONT Font; /* Handle to font (not unused) */ |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 59 | } PROGRESS_INFO; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 60 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 61 | /* Control configuration constants */ |
| 62 | |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 63 | #define LED_GAP 2 |
| 64 | #define MARQUEE_LEDS 5 |
| 65 | #define ID_MARQUEE_TIMER 1 |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 66 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 67 | /* Helper to obtain size of a progress bar chunk ("led"). */ |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 68 | static inline int get_led_size ( PROGRESS_INFO *infoPtr, LONG style, |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 69 | const RECT* rect ) |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 70 | { |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 71 | HTHEME theme = GetWindowTheme (infoPtr->Self); |
| 72 | if (theme) |
| 73 | { |
| 74 | int chunkSize; |
| 75 | if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSCHUNKSIZE, &chunkSize ))) |
| 76 | return chunkSize; |
| 77 | } |
| 78 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 79 | if (style & PBS_VERTICAL) |
| 80 | return MulDiv (rect->right - rect->left, 2, 3); |
| 81 | else |
| 82 | return MulDiv (rect->bottom - rect->top, 2, 3); |
| 83 | } |
| 84 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 85 | /* Helper to obtain gap between progress bar chunks */ |
| 86 | static inline int get_led_gap ( PROGRESS_INFO *infoPtr ) |
| 87 | { |
| 88 | HTHEME theme = GetWindowTheme (infoPtr->Self); |
| 89 | if (theme) |
| 90 | { |
| 91 | int spaceSize; |
| 92 | if (SUCCEEDED( GetThemeInt( theme, 0, 0, TMT_PROGRESSSPACESIZE, &spaceSize ))) |
| 93 | return spaceSize; |
| 94 | } |
| 95 | |
| 96 | return LED_GAP; |
| 97 | } |
| 98 | |
| 99 | /* Get client rect. Takes into account that theming needs no adjustment. */ |
| 100 | static inline void get_client_rect (HWND hwnd, RECT* rect) |
| 101 | { |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 102 | HTHEME theme = GetWindowTheme (hwnd); |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 103 | GetClientRect (hwnd, rect); |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 104 | if (!theme) |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 105 | InflateRect(rect, -1, -1); |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 106 | else |
| 107 | { |
| 108 | DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); |
| 109 | int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR; |
| 110 | GetThemeBackgroundContentRect (theme, 0, part, 0, rect, rect); |
| 111 | } |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 114 | /* Compute the extend of the bar */ |
| 115 | static inline int get_bar_size( LONG style, const RECT* rect ) |
| 116 | { |
| 117 | if (style & PBS_VERTICAL) |
| 118 | return rect->bottom - rect->top; |
| 119 | else |
| 120 | return rect->right - rect->left; |
| 121 | } |
| 122 | |
| 123 | /* Compute the pixel position of a progress value */ |
| 124 | static inline int get_bar_position( PROGRESS_INFO *infoPtr, LONG style, |
| 125 | const RECT* rect, INT value ) |
| 126 | { |
| 127 | return MulDiv (value - infoPtr->MinVal, get_bar_size (style, rect), |
| 128 | infoPtr->MaxVal - infoPtr->MinVal); |
| 129 | } |
| 130 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 131 | /*********************************************************************** |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 132 | * PROGRESS_Invalidate |
| 133 | * |
Mike McCormack | ab4438e | 2006-01-11 12:11:46 +0100 | [diff] [blame^] | 134 | * Don't be too clever about invalidating the progress bar. |
| 135 | * Installshield depends on this simple behaviour. |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 136 | */ |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 137 | static void PROGRESS_Invalidate( PROGRESS_INFO *infoPtr, INT old, INT new ) |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 138 | { |
Mike McCormack | ab4438e | 2006-01-11 12:11:46 +0100 | [diff] [blame^] | 139 | InvalidateRect( infoPtr->Self, NULL, old > new ); |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | /* Information for a progress bar drawing helper */ |
| 143 | typedef struct tagProgressDrawInfo |
| 144 | { |
| 145 | HDC hdc; |
| 146 | RECT rect; |
| 147 | HBRUSH hbrBar; |
| 148 | HBRUSH hbrBk; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 149 | int ledW, ledGap; |
| 150 | HTHEME theme; |
| 151 | RECT bgRect; |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 152 | } ProgressDrawInfo; |
| 153 | |
| 154 | typedef void (*ProgressDrawProc)(const ProgressDrawInfo* di, int start, int end); |
| 155 | |
| 156 | /* draw solid horizontal bar from 'start' to 'end' */ |
| 157 | static void draw_solid_bar_H (const ProgressDrawInfo* di, int start, int end) |
| 158 | { |
| 159 | RECT r; |
| 160 | r.left = di->rect.left + start; |
| 161 | r.top = di->rect.top; |
| 162 | r.right = di->rect.left + end; |
| 163 | r.bottom = di->rect.bottom; |
| 164 | FillRect (di->hdc, &r, di->hbrBar); |
| 165 | } |
| 166 | |
| 167 | /* draw solid horizontal background from 'start' to 'end' */ |
| 168 | static void draw_solid_bkg_H (const ProgressDrawInfo* di, int start, int end) |
| 169 | { |
| 170 | RECT r; |
| 171 | r.left = di->rect.left + start; |
| 172 | r.top = di->rect.top; |
| 173 | r.right = di->rect.left + end; |
| 174 | r.bottom = di->rect.bottom; |
| 175 | FillRect (di->hdc, &r, di->hbrBk); |
| 176 | } |
| 177 | |
| 178 | /* draw solid vertical bar from 'start' to 'end' */ |
| 179 | static void draw_solid_bar_V (const ProgressDrawInfo* di, int start, int end) |
| 180 | { |
| 181 | RECT r; |
| 182 | r.left = di->rect.left; |
| 183 | r.top = di->rect.bottom - end; |
| 184 | r.right = di->rect.right; |
| 185 | r.bottom = di->rect.bottom - start; |
| 186 | FillRect (di->hdc, &r, di->hbrBar); |
| 187 | } |
| 188 | |
| 189 | /* draw solid vertical background from 'start' to 'end' */ |
| 190 | static void draw_solid_bkg_V (const ProgressDrawInfo* di, int start, int end) |
| 191 | { |
| 192 | RECT r; |
| 193 | r.left = di->rect.left; |
| 194 | r.top = di->rect.bottom - end; |
| 195 | r.right = di->rect.right; |
| 196 | r.bottom = di->rect.bottom - start; |
| 197 | FillRect (di->hdc, &r, di->hbrBk); |
| 198 | } |
| 199 | |
| 200 | /* draw chunky horizontal bar from 'start' to 'end' */ |
| 201 | static void draw_chunk_bar_H (const ProgressDrawInfo* di, int start, int end) |
| 202 | { |
| 203 | RECT r; |
| 204 | int right = di->rect.left + end; |
| 205 | r.left = di->rect.left + start; |
| 206 | r.top = di->rect.top; |
| 207 | r.bottom = di->rect.bottom; |
| 208 | while (r.left < right) |
| 209 | { |
| 210 | r.right = min (r.left + di->ledW, right); |
| 211 | FillRect (di->hdc, &r, di->hbrBar); |
| 212 | r.left = r.right; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 213 | r.right = min (r.left + di->ledGap, right); |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 214 | FillRect (di->hdc, &r, di->hbrBk); |
| 215 | r.left = r.right; |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 216 | } |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 217 | } |
| 218 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 219 | /* draw chunky vertical bar from 'start' to 'end' */ |
| 220 | static void draw_chunk_bar_V (const ProgressDrawInfo* di, int start, int end) |
| 221 | { |
| 222 | RECT r; |
| 223 | int top = di->rect.bottom - end; |
| 224 | r.left = di->rect.left; |
| 225 | r.right = di->rect.right; |
| 226 | r.bottom = di->rect.bottom - start; |
| 227 | while (r.bottom > top) |
| 228 | { |
| 229 | r.top = max (r.bottom - di->ledW, top); |
| 230 | FillRect (di->hdc, &r, di->hbrBar); |
| 231 | r.bottom = r.top; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 232 | r.top = max (r.bottom - di->ledGap, top); |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 233 | FillRect (di->hdc, &r, di->hbrBk); |
| 234 | r.bottom = r.top; |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /* drawing functions for "classic" style */ |
| 239 | static const ProgressDrawProc drawProcClassic[8] = { |
| 240 | /* Smooth */ |
| 241 | /* Horizontal */ |
| 242 | draw_solid_bar_H, draw_solid_bkg_H, |
| 243 | /* Vertical */ |
| 244 | draw_solid_bar_V, draw_solid_bkg_V, |
| 245 | /* Chunky */ |
| 246 | /* Horizontal */ |
| 247 | draw_chunk_bar_H, draw_solid_bkg_H, |
| 248 | /* Vertical */ |
| 249 | draw_chunk_bar_V, draw_solid_bkg_V, |
| 250 | }; |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 251 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 252 | /* draw themed horizontal bar from 'start' to 'end' */ |
| 253 | static void draw_theme_bar_H (const ProgressDrawInfo* di, int start, int end) |
| 254 | { |
| 255 | RECT r; |
| 256 | int right = di->rect.left + end; |
| 257 | r.left = di->rect.left + start; |
| 258 | r.top = di->rect.top; |
| 259 | r.bottom = di->rect.bottom; |
| 260 | while (r.left < right) |
| 261 | { |
| 262 | r.right = min (r.left + di->ledW, right); |
| 263 | DrawThemeBackground (di->theme, di->hdc, PP_CHUNK, 0, &r, NULL); |
| 264 | r.left = r.right; |
| 265 | r.right = min (r.left + di->ledGap, right); |
| 266 | DrawThemeBackground (di->theme, di->hdc, PP_BAR, 0, &di->bgRect, &r); |
| 267 | r.left = r.right; |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | /* draw themed horizontal bar from 'start' to 'end' */ |
| 272 | static void draw_theme_bar_V (const ProgressDrawInfo* di, int start, int end) |
| 273 | { |
| 274 | RECT r; |
| 275 | int top = di->rect.bottom - end; |
| 276 | r.left = di->rect.left; |
| 277 | r.right = di->rect.right; |
| 278 | r.bottom = di->rect.bottom - start; |
| 279 | while (r.bottom > top) |
| 280 | { |
| 281 | r.top = max (r.bottom - di->ledW, top); |
| 282 | DrawThemeBackground (di->theme, di->hdc, PP_CHUNKVERT, 0, &r, NULL); |
| 283 | r.bottom = r.top; |
| 284 | r.top = max (r.bottom - di->ledGap, top); |
| 285 | DrawThemeBackground (di->theme, di->hdc, PP_BARVERT, 0, &di->bgRect, &r); |
| 286 | r.bottom = r.top; |
| 287 | } |
| 288 | } |
| 289 | |
| 290 | /* draw themed horizontal background from 'start' to 'end' */ |
| 291 | static void draw_theme_bkg_H (const ProgressDrawInfo* di, int start, int end) |
| 292 | { |
| 293 | RECT r; |
| 294 | r.left = di->rect.left + start; |
| 295 | r.top = di->rect.top; |
| 296 | r.right = di->rect.left + end; |
| 297 | r.bottom = di->rect.bottom; |
| 298 | DrawThemeBackground (di->theme, di->hdc, PP_BAR, 0, &di->bgRect, &r); |
| 299 | } |
| 300 | |
| 301 | /* draw themed vertical background from 'start' to 'end' */ |
| 302 | static void draw_theme_bkg_V (const ProgressDrawInfo* di, int start, int end) |
| 303 | { |
| 304 | RECT r; |
| 305 | r.left = di->rect.left; |
| 306 | r.top = di->rect.bottom - end; |
| 307 | r.right = di->rect.right; |
| 308 | r.bottom = di->rect.bottom - start; |
| 309 | DrawThemeBackground (di->theme, di->hdc, PP_BARVERT, 0, &di->bgRect, &r); |
| 310 | } |
| 311 | |
| 312 | /* drawing functions for themed style */ |
| 313 | static const ProgressDrawProc drawProcThemed[8] = { |
| 314 | /* Smooth */ |
| 315 | /* Horizontal */ |
| 316 | draw_theme_bar_H, draw_theme_bkg_H, |
| 317 | /* Vertical */ |
| 318 | draw_theme_bar_V, draw_theme_bkg_V, |
| 319 | /* Chunky */ |
| 320 | /* Horizontal */ |
| 321 | draw_theme_bar_H, draw_theme_bkg_H, |
| 322 | /* Vertical */ |
| 323 | draw_theme_bar_V, draw_theme_bkg_V, |
| 324 | }; |
| 325 | |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 326 | /*********************************************************************** |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 327 | * PROGRESS_Draw |
| 328 | * Draws the progress bar. |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 329 | */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 330 | static LRESULT PROGRESS_Draw (PROGRESS_INFO *infoPtr, HDC hdc) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 331 | { |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 332 | int barSize; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 333 | DWORD dwStyle; |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 334 | BOOL barSmooth; |
| 335 | const ProgressDrawProc* drawProcs; |
| 336 | ProgressDrawInfo pdi; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 337 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 338 | TRACE("(infoPtr=%p, hdc=%p)\n", infoPtr, hdc); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 339 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 340 | pdi.hdc = hdc; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 341 | pdi.theme = GetWindowTheme (infoPtr->Self); |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 342 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 343 | /* get the required bar brush */ |
| 344 | if (infoPtr->ColorBar == CLR_DEFAULT) |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 345 | pdi.hbrBar = GetSysColorBrush(COLOR_HIGHLIGHT); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 346 | else |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 347 | pdi.hbrBar = CreateSolidBrush (infoPtr->ColorBar); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 348 | |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 349 | if (infoPtr->ColorBk == CLR_DEFAULT) |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 350 | pdi.hbrBk = GetSysColorBrush(COLOR_3DFACE); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 351 | else |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 352 | pdi.hbrBk = CreateSolidBrush(infoPtr->ColorBk); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 353 | |
| 354 | /* get the window style */ |
| 355 | dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); |
| 356 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 357 | /* get client rectangle */ |
| 358 | GetClientRect (infoPtr->Self, &pdi.rect); |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 359 | if (!pdi.theme) { |
| 360 | FrameRect( hdc, &pdi.rect, pdi.hbrBk ); |
| 361 | InflateRect(&pdi.rect, -1, -1); |
| 362 | } |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 363 | else |
| 364 | { |
| 365 | RECT cntRect; |
| 366 | int part = (dwStyle & PBS_VERTICAL) ? PP_BARVERT : PP_BAR; |
| 367 | |
| 368 | GetThemeBackgroundContentRect (pdi.theme, hdc, part, 0, &pdi.rect, |
| 369 | &cntRect); |
| 370 | |
| 371 | /* Exclude content rect - content background will be drawn later */ |
| 372 | ExcludeClipRect (hdc, cntRect.left, cntRect.top, |
| 373 | cntRect.right, cntRect.bottom); |
| 374 | if (IsThemeBackgroundPartiallyTransparent (pdi.theme, part, 0)) |
| 375 | DrawThemeParentBackground (infoPtr->Self, hdc, NULL); |
| 376 | DrawThemeBackground (pdi.theme, hdc, part, 0, &pdi.rect, NULL); |
| 377 | SelectClipRgn (hdc, NULL); |
| 378 | CopyRect (&pdi.rect, &cntRect); |
| 379 | } |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 380 | |
| 381 | /* compute some drawing parameters */ |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 382 | barSmooth = (dwStyle & PBS_SMOOTH) && !pdi.theme; |
| 383 | drawProcs = &((pdi.theme ? drawProcThemed : drawProcClassic)[(barSmooth ? 0 : 4) |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 384 | + ((dwStyle & PBS_VERTICAL) ? 2 : 0)]); |
| 385 | barSize = get_bar_size( dwStyle, &pdi.rect ); |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 386 | if (pdi.theme) |
| 387 | { |
| 388 | GetWindowRect( infoPtr->Self, &pdi.bgRect ); |
| 389 | ScreenToClient( infoPtr->Self, (POINT*)&pdi.bgRect ); |
| 390 | ScreenToClient( infoPtr->Self, (POINT*)&pdi.bgRect.right ); |
| 391 | } |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 392 | |
| 393 | if (!barSmooth) |
| 394 | pdi.ledW = get_led_size( infoPtr, dwStyle, &pdi.rect); |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 395 | pdi.ledGap = get_led_gap( infoPtr ); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 396 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 397 | if (dwStyle & PBS_MARQUEE) |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 398 | { |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 399 | const int ledW = !barSmooth ? (pdi.ledW + pdi.ledGap) : 1; |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 400 | const int leds = (barSize + ledW - 1) / ledW; |
| 401 | const int ledMEnd = infoPtr->MarqueePos + MARQUEE_LEDS; |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 402 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 403 | if (ledMEnd > leds) |
| 404 | { |
| 405 | /* case 1: the marquee bar extends over the end and wraps around to |
| 406 | * the start */ |
| 407 | const int gapStart = max((ledMEnd - leds) * ledW, 0); |
| 408 | const int gapEnd = min(infoPtr->MarqueePos * ledW, barSize); |
| 409 | |
| 410 | drawProcs[0]( &pdi, 0, gapStart); |
| 411 | drawProcs[1]( &pdi, gapStart, gapEnd); |
| 412 | drawProcs[0]( &pdi, gapEnd, barSize); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 413 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 414 | else |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 415 | { |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 416 | /* case 2: the marquee bar is between start and end */ |
| 417 | const int barStart = infoPtr->MarqueePos * ledW; |
| 418 | const int barEnd = min (ledMEnd * ledW, barSize); |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 419 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 420 | drawProcs[1]( &pdi, 0, barStart); |
| 421 | drawProcs[0]( &pdi, barStart, barEnd); |
| 422 | drawProcs[1]( &pdi, barEnd, barSize); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 423 | } |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 424 | } |
| 425 | else |
| 426 | { |
| 427 | int barEnd = get_bar_position( infoPtr, dwStyle, &pdi.rect, |
| 428 | infoPtr->CurVal); |
| 429 | if (!barSmooth) |
| 430 | { |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 431 | const int ledW = pdi.ledW + pdi.ledGap; |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 432 | barEnd = min (((barEnd + ledW - 1) / ledW) * ledW, barSize); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 433 | } |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 434 | drawProcs[0]( &pdi, 0, barEnd); |
| 435 | drawProcs[1]( &pdi, barEnd, barSize); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 436 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 437 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 438 | /* delete bar brush */ |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 439 | if (infoPtr->ColorBar != CLR_DEFAULT) DeleteObject (pdi.hbrBar); |
| 440 | if (infoPtr->ColorBk != CLR_DEFAULT) DeleteObject (pdi.hbrBk); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 441 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 442 | return 0; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 443 | } |
| 444 | |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 445 | /*********************************************************************** |
| 446 | * PROGRESS_Paint |
| 447 | * Draw the progress bar. The background need not be erased. |
| 448 | * If dc!=0, it draws on it |
| 449 | */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 450 | static LRESULT PROGRESS_Paint (PROGRESS_INFO *infoPtr, HDC hdc) |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 451 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 452 | PAINTSTRUCT ps; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 453 | if (hdc) return PROGRESS_Draw (infoPtr, hdc); |
| 454 | hdc = BeginPaint (infoPtr->Self, &ps); |
| 455 | PROGRESS_Draw (infoPtr, hdc); |
| 456 | EndPaint (infoPtr->Self, &ps); |
| 457 | return 0; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | |
| 461 | /*********************************************************************** |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 462 | * PROGRESS_Timer |
| 463 | * Handle the marquee timer messages |
| 464 | */ |
| 465 | static LRESULT PROGRESS_Timer (PROGRESS_INFO *infoPtr, INT idTimer) |
| 466 | { |
| 467 | if(idTimer == ID_MARQUEE_TIMER) |
| 468 | { |
| 469 | LONG style = GetWindowLongW (infoPtr->Self, GWL_STYLE); |
| 470 | RECT rect; |
| 471 | int ledWidth, leds; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 472 | HTHEME theme = GetWindowTheme (infoPtr->Self); |
| 473 | BOOL barSmooth = (style & PBS_SMOOTH) && !theme; |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 474 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 475 | get_client_rect (infoPtr->Self, &rect); |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 476 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 477 | if(!barSmooth) |
| 478 | ledWidth = get_led_size( infoPtr, style, &rect ) + |
| 479 | get_led_gap( infoPtr ); |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 480 | else |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 481 | ledWidth = 1; |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 482 | |
| 483 | leds = (get_bar_size( style, &rect ) + ledWidth - 1) / |
| 484 | ledWidth; |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 485 | |
| 486 | /* increment the marquee progress */ |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 487 | if(++infoPtr->MarqueePos >= leds) |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 488 | { |
| 489 | infoPtr->MarqueePos = 0; |
| 490 | } |
| 491 | |
Frank Richter | 54de614 | 2005-07-27 12:07:03 +0000 | [diff] [blame] | 492 | InvalidateRect(infoPtr->Self, &rect, FALSE); |
Michael Kaufmann | e3a35a8 | 2005-08-23 10:02:25 +0000 | [diff] [blame] | 493 | UpdateWindow(infoPtr->Self); |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 494 | } |
| 495 | return 0; |
| 496 | } |
| 497 | |
| 498 | |
| 499 | /*********************************************************************** |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 500 | * PROGRESS_CoercePos |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 501 | * Makes sure the current position (CurVal) is within bounds. |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 502 | */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 503 | static void PROGRESS_CoercePos(PROGRESS_INFO *infoPtr) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 504 | { |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 505 | if(infoPtr->CurVal < infoPtr->MinVal) |
| 506 | infoPtr->CurVal = infoPtr->MinVal; |
| 507 | if(infoPtr->CurVal > infoPtr->MaxVal) |
| 508 | infoPtr->CurVal = infoPtr->MaxVal; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Eric Kohl | 8305ad5 | 1999-01-24 19:09:24 +0000 | [diff] [blame] | 511 | |
| 512 | /*********************************************************************** |
| 513 | * PROGRESS_SetFont |
| 514 | * Set new Font for progress bar |
| 515 | */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 516 | static HFONT PROGRESS_SetFont (PROGRESS_INFO *infoPtr, HFONT hFont, BOOL bRedraw) |
Eric Kohl | 8305ad5 | 1999-01-24 19:09:24 +0000 | [diff] [blame] | 517 | { |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 518 | HFONT hOldFont = infoPtr->Font; |
| 519 | infoPtr->Font = hFont; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 520 | /* Since infoPtr->Font is not used, there is no need for repaint */ |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 521 | return hOldFont; |
Eric Kohl | 8305ad5 | 1999-01-24 19:09:24 +0000 | [diff] [blame] | 522 | } |
| 523 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 524 | static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high) |
| 525 | { |
| 526 | DWORD res = MAKELONG(LOWORD(infoPtr->MinVal), LOWORD(infoPtr->MaxVal)); |
| 527 | |
| 528 | /* if nothing changes, simply return */ |
| 529 | if(infoPtr->MinVal == low && infoPtr->MaxVal == high) return res; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 530 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 531 | infoPtr->MinVal = low; |
| 532 | infoPtr->MaxVal = high; |
| 533 | PROGRESS_CoercePos(infoPtr); |
Huw Davies | 5594fce | 2003-05-11 02:38:05 +0000 | [diff] [blame] | 534 | InvalidateRect(infoPtr->Self, NULL, TRUE); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 535 | return res; |
| 536 | } |
Eric Kohl | 8305ad5 | 1999-01-24 19:09:24 +0000 | [diff] [blame] | 537 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 538 | /*********************************************************************** |
| 539 | * ProgressWindowProc |
| 540 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 541 | static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, |
Dimitrie O. Paun | bc88300 | 2004-10-27 21:16:03 +0000 | [diff] [blame] | 542 | WPARAM wParam, LPARAM lParam) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 543 | { |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 544 | PROGRESS_INFO *infoPtr; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 545 | static const WCHAR themeClass[] = {'P','r','o','g','r','e','s','s',0}; |
| 546 | HTHEME theme; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 547 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 548 | TRACE("hwnd=%p msg=%04x wparam=%x lParam=%lx\n", hwnd, message, wParam, lParam); |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 549 | |
Robert Shearman | cdb263e | 2004-08-25 17:33:01 +0000 | [diff] [blame] | 550 | infoPtr = (PROGRESS_INFO *)GetWindowLongPtrW(hwnd, 0); |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 551 | |
Dmitry Timoshkov | ec7c2a8 | 2002-02-04 18:31:17 +0000 | [diff] [blame] | 552 | if (!infoPtr && message != WM_CREATE) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 553 | return DefWindowProcW( hwnd, message, wParam, lParam ); |
Dmitry Timoshkov | ec7c2a8 | 2002-02-04 18:31:17 +0000 | [diff] [blame] | 554 | |
| 555 | switch(message) { |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 556 | case WM_CREATE: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 557 | { |
| 558 | DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 559 | |
| 560 | theme = OpenThemeData (hwnd, themeClass); |
| 561 | |
Dmitry Timoshkov | ec7c2a8 | 2002-02-04 18:31:17 +0000 | [diff] [blame] | 562 | dwExStyle &= ~(WS_EX_CLIENTEDGE | WS_EX_WINDOWEDGE); |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 563 | if (!theme) dwExStyle |= WS_EX_STATICEDGE; |
Dmitry Timoshkov | e4a33c0 | 2002-06-14 00:01:44 +0000 | [diff] [blame] | 564 | SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle); |
Dmitry Timoshkov | ec7c2a8 | 2002-02-04 18:31:17 +0000 | [diff] [blame] | 565 | /* Force recalculation of a non-client area */ |
| 566 | SetWindowPos(hwnd, 0, 0, 0, 0, 0, |
| 567 | SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); |
| 568 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 569 | /* allocate memory for info struct */ |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 570 | infoPtr = (PROGRESS_INFO *)Alloc (sizeof(PROGRESS_INFO)); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 571 | if (!infoPtr) return -1; |
Robert Shearman | cdb263e | 2004-08-25 17:33:01 +0000 | [diff] [blame] | 572 | SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 573 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 574 | /* initialize the info struct */ |
| 575 | infoPtr->Self = hwnd; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 576 | infoPtr->MinVal = 0; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 577 | infoPtr->MaxVal = 100; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 578 | infoPtr->CurVal = 0; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 579 | infoPtr->Step = 10; |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 580 | infoPtr->MarqueePos = 0; |
| 581 | infoPtr->Marquee = FALSE; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 582 | infoPtr->ColorBar = CLR_DEFAULT; |
| 583 | infoPtr->ColorBk = CLR_DEFAULT; |
| 584 | infoPtr->Font = 0; |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 585 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 586 | TRACE("Progress Ctrl creation, hwnd=%p\n", hwnd); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 587 | return 0; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 588 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 589 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 590 | case WM_DESTROY: |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 591 | TRACE("Progress Ctrl destruction, hwnd=%p\n", hwnd); |
Dimitrie O. Paun | 7de279a | 2003-09-22 21:32:33 +0000 | [diff] [blame] | 592 | Free (infoPtr); |
Robert Shearman | cdb263e | 2004-08-25 17:33:01 +0000 | [diff] [blame] | 593 | SetWindowLongPtrW(hwnd, 0, 0); |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 594 | theme = GetWindowTheme (hwnd); |
| 595 | CloseThemeData (theme); |
| 596 | return 0; |
| 597 | |
| 598 | case WM_ERASEBKGND: |
| 599 | return 1; |
| 600 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 601 | case WM_GETFONT: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 602 | return (LRESULT)infoPtr->Font; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 603 | |
| 604 | case WM_SETFONT: |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 605 | return (LRESULT)PROGRESS_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 606 | |
Michael Kaufmann | e9310da | 2005-11-08 12:52:35 +0000 | [diff] [blame] | 607 | case WM_PRINTCLIENT: |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 608 | case WM_PAINT: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 609 | return PROGRESS_Paint (infoPtr, (HDC)wParam); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 610 | |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 611 | case WM_TIMER: |
| 612 | return PROGRESS_Timer (infoPtr, (INT)wParam); |
| 613 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 614 | case WM_THEMECHANGED: |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 615 | { |
| 616 | DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); |
| 617 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 618 | theme = GetWindowTheme (hwnd); |
| 619 | CloseThemeData (theme); |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 620 | theme = OpenThemeData (hwnd, themeClass); |
| 621 | |
| 622 | /* WS_EX_STATICEDGE disappears when the control is themed */ |
| 623 | if (theme) |
| 624 | dwExStyle &= ~WS_EX_STATICEDGE; |
| 625 | else |
| 626 | dwExStyle |= WS_EX_STATICEDGE; |
| 627 | SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle); |
| 628 | |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 629 | InvalidateRect (hwnd, NULL, FALSE); |
| 630 | return 0; |
Frank Richter | 65f1044 | 2005-08-15 09:34:02 +0000 | [diff] [blame] | 631 | } |
Frank Richter | a95e3e2 | 2005-08-11 18:34:35 +0000 | [diff] [blame] | 632 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 633 | case PBM_DELTAPOS: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 634 | { |
| 635 | INT oldVal; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 636 | oldVal = infoPtr->CurVal; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 637 | if(wParam != 0) { |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 638 | infoPtr->CurVal += (INT)wParam; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 639 | PROGRESS_CoercePos (infoPtr); |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 640 | TRACE("PBM_DELTAPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 641 | PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal ); |
Michael Kaufmann | e3a35a8 | 2005-08-23 10:02:25 +0000 | [diff] [blame] | 642 | UpdateWindow( infoPtr->Self ); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 643 | } |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 644 | return oldVal; |
| 645 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 646 | |
| 647 | case PBM_SETPOS: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 648 | { |
Rolf Kalbermatter | 6c79930 | 2002-12-16 22:43:58 +0000 | [diff] [blame] | 649 | UINT oldVal; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 650 | oldVal = infoPtr->CurVal; |
| 651 | if(oldVal != wParam) { |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 652 | infoPtr->CurVal = (INT)wParam; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 653 | PROGRESS_CoercePos(infoPtr); |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 654 | TRACE("PBM_SETPOS: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 655 | PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal ); |
Michael Kaufmann | e3a35a8 | 2005-08-23 10:02:25 +0000 | [diff] [blame] | 656 | UpdateWindow( infoPtr->Self ); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 657 | } |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 658 | return oldVal; |
| 659 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 660 | |
Eric Kohl | fa8ae2f | 1999-03-12 17:40:32 +0000 | [diff] [blame] | 661 | case PBM_SETRANGE: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 662 | return PROGRESS_SetRange (infoPtr, (int)LOWORD(lParam), (int)HIWORD(lParam)); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 663 | |
| 664 | case PBM_SETSTEP: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 665 | { |
| 666 | INT oldStep; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 667 | oldStep = infoPtr->Step; |
| 668 | infoPtr->Step = (INT)wParam; |
| 669 | return oldStep; |
| 670 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 671 | |
| 672 | case PBM_STEPIT: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 673 | { |
| 674 | INT oldVal; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 675 | oldVal = infoPtr->CurVal; |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 676 | infoPtr->CurVal += infoPtr->Step; |
| 677 | if(infoPtr->CurVal > infoPtr->MaxVal) |
| 678 | infoPtr->CurVal = infoPtr->MinVal; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 679 | if(oldVal != infoPtr->CurVal) |
| 680 | { |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 681 | TRACE("PBM_STEPIT: current pos changed from %d to %d\n", oldVal, infoPtr->CurVal); |
Alexandre Julliard | 473f3de | 2002-08-13 18:08:45 +0000 | [diff] [blame] | 682 | PROGRESS_Invalidate( infoPtr, oldVal, infoPtr->CurVal ); |
Michael Kaufmann | e3a35a8 | 2005-08-23 10:02:25 +0000 | [diff] [blame] | 683 | UpdateWindow( infoPtr->Self ); |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 684 | } |
| 685 | return oldVal; |
| 686 | } |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 687 | |
Eric Kohl | fa8ae2f | 1999-03-12 17:40:32 +0000 | [diff] [blame] | 688 | case PBM_SETRANGE32: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 689 | return PROGRESS_SetRange (infoPtr, (int)wParam, (int)lParam); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 690 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 691 | case PBM_GETRANGE: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 692 | if (lParam) { |
| 693 | ((PPBRANGE)lParam)->iLow = infoPtr->MinVal; |
| 694 | ((PPBRANGE)lParam)->iHigh = infoPtr->MaxVal; |
| 695 | } |
| 696 | return wParam ? infoPtr->MinVal : infoPtr->MaxVal; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 697 | |
| 698 | case PBM_GETPOS: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 699 | return infoPtr->CurVal; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 700 | |
| 701 | case PBM_SETBARCOLOR: |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 702 | infoPtr->ColorBar = (COLORREF)lParam; |
| 703 | InvalidateRect(hwnd, NULL, TRUE); |
| 704 | return 0; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 705 | |
| 706 | case PBM_SETBKCOLOR: |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 707 | infoPtr->ColorBk = (COLORREF)lParam; |
Dmitry Timoshkov | 94d5cd4 | 2002-02-05 18:08:38 +0000 | [diff] [blame] | 708 | InvalidateRect(hwnd, NULL, TRUE); |
| 709 | return 0; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 710 | |
Thomas Weidenmueller | 7155eff | 2004-08-02 22:19:50 +0000 | [diff] [blame] | 711 | case PBM_SETMARQUEE: |
| 712 | if(wParam != 0) |
| 713 | { |
| 714 | infoPtr->Marquee = TRUE; |
| 715 | SetTimer(infoPtr->Self, ID_MARQUEE_TIMER, (UINT)lParam, NULL); |
| 716 | } |
| 717 | else |
| 718 | { |
| 719 | infoPtr->Marquee = FALSE; |
| 720 | KillTimer(infoPtr->Self, ID_MARQUEE_TIMER); |
| 721 | } |
| 722 | return infoPtr->Marquee; |
| 723 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 724 | default: |
Guy L. Albertelli | 23739a3 | 2002-07-16 01:23:59 +0000 | [diff] [blame] | 725 | if ((message >= WM_USER) && (message < WM_APP)) |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 726 | ERR("unknown msg %04x wp=%04x lp=%08lx\n", message, wParam, lParam ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 727 | return DefWindowProcW( hwnd, message, wParam, lParam ); |
| 728 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 729 | } |
| 730 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 731 | |
| 732 | /*********************************************************************** |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 733 | * PROGRESS_Register [Internal] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 734 | * |
| 735 | * Registers the progress bar window class. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 736 | */ |
Dimitrie O. Paun | bc88300 | 2004-10-27 21:16:03 +0000 | [diff] [blame] | 737 | void PROGRESS_Register (void) |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 738 | { |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 739 | WNDCLASSW wndClass; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 740 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 741 | ZeroMemory (&wndClass, sizeof(wndClass)); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 742 | wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 743 | wndClass.lpfnWndProc = (WNDPROC)ProgressWindowProc; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 744 | wndClass.cbClsExtra = 0; |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 745 | wndClass.cbWndExtra = sizeof (PROGRESS_INFO *); |
Alexandre Julliard | cf52644 | 2003-09-10 03:56:47 +0000 | [diff] [blame] | 746 | wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 747 | wndClass.lpszClassName = PROGRESS_CLASSW; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 748 | |
Dimitrie O. Paun | 187a679 | 2002-01-29 17:15:48 +0000 | [diff] [blame] | 749 | RegisterClassW (&wndClass); |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 750 | } |
| 751 | |
| 752 | |
| 753 | /*********************************************************************** |
| 754 | * PROGRESS_Unregister [Internal] |
| 755 | * |
| 756 | * Unregisters the progress bar window class. |
| 757 | */ |
Dimitrie O. Paun | bc88300 | 2004-10-27 21:16:03 +0000 | [diff] [blame] | 758 | void PROGRESS_Unregister (void) |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 759 | { |
Francois Gouget | d2667a4 | 2002-12-02 18:10:57 +0000 | [diff] [blame] | 760 | UnregisterClassW (PROGRESS_CLASSW, NULL); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 761 | } |