OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file implements a simple generic version of the WebKitThemeEngine, | 5 // This file implements a simple generic version of the WebKitThemeEngine, |
6 // Since WebThemeEngine is unfortunately defined in terms of the Windows | 6 // Since WebThemeEngine is unfortunately defined in terms of the Windows |
7 // Theme parameters and values, we need to translate all the values into | 7 // Theme parameters and values, we need to translate all the values into |
8 // generic equivalents that we can more easily understand. This file does | 8 // generic equivalents that we can more easily understand. This file does |
9 // that translation (acting as a Facade design pattern) and then uses | 9 // that translation (acting as a Facade design pattern) and then uses |
10 // TestShellWebTheme::Control for the actual rendering of the widgets. | 10 // TestShellWebTheme::Control for the actual rendering of the widgets. |
11 // | 11 // |
(...skipping 21 matching lines...) Expand all Loading... |
33 namespace { | 33 namespace { |
34 const int kDFCSNormal = 0x0000; | 34 const int kDFCSNormal = 0x0000; |
35 } | 35 } |
36 | 36 |
37 using WebKit::WebCanvas; | 37 using WebKit::WebCanvas; |
38 using WebKit::WebColor; | 38 using WebKit::WebColor; |
39 using WebKit::WebRect; | 39 using WebKit::WebRect; |
40 | 40 |
41 namespace TestShellWebTheme { | 41 namespace TestShellWebTheme { |
42 | 42 |
43 SkIRect webRectToSkIRect(const WebRect &web_rect) { | 43 SkIRect webRectToSkIRect(const WebRect& web_rect) { |
44 SkIRect irect; | 44 SkIRect irect; |
45 irect.set(web_rect.x, web_rect.y, web_rect.x + web_rect.width, | 45 irect.set(web_rect.x, web_rect.y, web_rect.x + web_rect.width, |
46 web_rect.y + web_rect.height); | 46 web_rect.y + web_rect.height); |
47 return irect; | 47 return irect; |
48 } | 48 } |
49 | 49 |
50 void drawControl(WebCanvas *canvas, const WebRect &rect, Control::Type ctype, | 50 void drawControl(WebCanvas* canvas, const WebRect& rect, Control::Type ctype, |
51 Control::State cstate) { | 51 Control::State cstate) { |
52 Control control(canvas, webRectToSkIRect(rect), ctype, cstate); | 52 Control control(canvas, webRectToSkIRect(rect), ctype, cstate); |
53 control.draw(); | 53 control.draw(); |
54 } | 54 } |
55 | 55 |
56 void drawTextField(WebCanvas *canvas, const WebRect &rect, | 56 void drawTextField(WebCanvas* canvas, const WebRect& rect, |
57 Control::Type ctype, Control::State cstate, | 57 Control::Type ctype, Control::State cstate, |
58 bool draw_edges, bool fill_content_area, WebColor color) { | 58 bool draw_edges, bool fill_content_area, WebColor color) { |
59 Control control(canvas, webRectToSkIRect(rect), ctype, cstate); | 59 Control control(canvas, webRectToSkIRect(rect), ctype, cstate); |
60 control.drawTextField(draw_edges, fill_content_area, color); | 60 control.drawTextField(draw_edges, fill_content_area, color); |
61 } | 61 } |
62 | 62 |
| 63 void drawProgressBar(WebCanvas* canvas, |
| 64 Control::Type ctype, Control::State cstate, |
| 65 const WebRect& bar_rect, const WebRect& fill_rect) { |
| 66 Control control(canvas, webRectToSkIRect(bar_rect), ctype, cstate); |
| 67 control.drawProgressBar(webRectToSkIRect(fill_rect)); |
| 68 } |
| 69 |
63 void Engine::paintButton(WebCanvas* canvas, int part, int state, | 70 void Engine::paintButton(WebCanvas* canvas, int part, int state, |
64 int classic_state, const WebRect& rect) { | 71 int classic_state, const WebRect& rect) { |
65 Control::Type ctype = Control::kUnknown_Type; | 72 Control::Type ctype = Control::kUnknown_Type; |
66 Control::State cstate = Control::kUnknown_State; | 73 Control::State cstate = Control::kUnknown_State; |
67 | 74 |
68 if (part == BP_CHECKBOX) { | 75 if (part == BP_CHECKBOX) { |
69 switch (state) { | 76 switch (state) { |
70 case CBS_UNCHECKEDNORMAL: | 77 case CBS_UNCHECKEDNORMAL: |
71 CHECK_EQ(classic_state, kDFCSNormal); | 78 CHECK_EQ(classic_state, kDFCSNormal); |
72 ctype = Control::kUncheckedBox_Type; | 79 ctype = Control::kUncheckedBox_Type; |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 CHECK_EQ(part, TUS_NORMAL); | 533 CHECK_EQ(part, TUS_NORMAL); |
527 CHECK_EQ(classic_state, kDFCSNormal); | 534 CHECK_EQ(classic_state, kDFCSNormal); |
528 cstate = Control::kNormal_State; | 535 cstate = Control::kNormal_State; |
529 } else { | 536 } else { |
530 NOTREACHED(); | 537 NOTREACHED(); |
531 } | 538 } |
532 | 539 |
533 drawControl(canvas, rect, ctype, cstate); | 540 drawControl(canvas, rect, ctype, cstate); |
534 } | 541 } |
535 | 542 |
| 543 |
| 544 void Engine::paintProgressBar(WebKit::WebCanvas* canvas, |
| 545 const WebKit::WebRect& barRect, |
| 546 int valuePart, const WebKit::WebRect& valueRect) { |
| 547 Control::Type ctype = Control::kProgressBar_Type; |
| 548 Control::State cstate = valuePart == PP_FILL ? |
| 549 Control::kNormal_State : Control::kIndeterminate_State; |
| 550 drawProgressBar(canvas, ctype, cstate, barRect, valueRect); |
| 551 } |
| 552 |
536 } // namespace TestShellWebTheme | 553 } // namespace TestShellWebTheme |
OLD | NEW |