OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef PDF_BUTTON_H_ | |
6 #define PDF_BUTTON_H_ | |
7 | |
8 #include "pdf/control.h" | |
9 #include "ppapi/cpp/image_data.h" | |
10 #include "ppapi/cpp/rect.h" | |
11 | |
12 namespace chrome_pdf { | |
13 | |
14 class Button : public Control { | |
15 public: | |
16 enum ButtonEventIds { | |
17 EVENT_ID_BUTTON_CLICKED, | |
18 EVENT_ID_BUTTON_STATE_CHANGED, | |
19 }; | |
20 | |
21 enum ButtonStyle { | |
22 BUTTON_CLICKABLE, | |
23 BUTTON_STATE | |
24 }; | |
25 | |
26 enum ButtonState { | |
27 BUTTON_NORMAL, | |
28 BUTTON_HIGHLIGHTED, | |
29 BUTTON_PRESSED, | |
30 BUTTON_PRESSED_STICKY, | |
31 }; | |
32 | |
33 Button(); | |
34 virtual ~Button(); | |
35 virtual bool CreateButton(uint32 id, | |
36 const pp::Point& origin, | |
37 bool visible, | |
38 Control::Owner* delegate, | |
39 ButtonStyle style, | |
40 const pp::ImageData& face_normal, | |
41 const pp::ImageData& face_highlighted, | |
42 const pp::ImageData& face_pressed); | |
43 | |
44 virtual void Paint(pp::ImageData* image_data, const pp::Rect& rc); | |
45 virtual bool HandleEvent(const pp::InputEvent& event); | |
46 virtual void OnEventCaptureReleased(); | |
47 virtual void Show(bool visible, bool invalidate); | |
48 virtual void AdjustTransparency(uint8 transparency, bool invalidate); | |
49 | |
50 ButtonState state() const { return state_; } | |
51 bool IsPressed() const { return state() == BUTTON_PRESSED_STICKY; } | |
52 void SetPressedState(bool pressed); | |
53 | |
54 private: | |
55 void OnButtonClicked(); | |
56 | |
57 const pp::ImageData& GetCurrentImage(); | |
58 void ChangeState(ButtonState new_state, bool force); | |
59 | |
60 ButtonStyle style_; | |
61 ButtonState state_; | |
62 bool is_pressed_; | |
63 | |
64 pp::ImageData normal_; | |
65 pp::ImageData highlighted_; | |
66 pp::ImageData pressed_; | |
67 }; | |
68 | |
69 } // namespace chrome_pdf | |
70 | |
71 #endif // PDF_BUTTON_H_ | |
OLD | NEW |