libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ElementScroll.h
Go to the documentation of this file.
1 /*
2  * This source file is part of libRocket, the HTML/CSS Interface Middleware
3  *
4  * For the latest information, see http://www.librocket.com
5  *
6  * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROCKETCOREELEMENTSCROLL_H
29 #define ROCKETCOREELEMENTSCROLL_H
30 
31 #include "Header.h"
32 #include "EventListener.h"
33 
34 namespace Rocket {
35 namespace Core {
36 
37 class Element;
38 class WidgetSliderScroll;
39 
47 {
48 public:
50  {
51  VERTICAL = 0,
52  HORIZONTAL = 1
53  };
54 
55  ElementScroll(Element* element);
56  virtual ~ElementScroll();
57 
59  void Update();
60 
64  void EnableScrollbar(Orientation orientation, float element_width);
67  void DisableScrollbar(Orientation orientation);
68 
71  void UpdateScrollbar(Orientation orientation);
72 
76  Element* GetScrollbar(Orientation orientation);
80  float GetScrollbarSize(Orientation orientation);
81 
83  void FormatScrollbars();
84 
85 protected:
87  void ProcessEvent(Event& event);
88 
89 private:
90  struct Scrollbar
91  {
92  Scrollbar();
93  ~Scrollbar();
94 
95  Element* element;
96  WidgetSliderScroll* widget;
97  bool enabled;
98  float size;
99  };
100 
101  // Creates one of the scroll component's scrollbar.
102  bool CreateScrollbar(Orientation orientation);
103  // Creates the scrollbar corner.
104  bool CreateCorner();
105 
106  Element* element;
107 
108  Scrollbar scrollbars[2];
109  Element* corner;
110 };
111 
112 }
113 }
114 
115 #endif
#define ROCKETCORE_API
Definition: Header.h:73
Definition: Event.h:48
Orientation
Definition: ElementScroll.h:49
Definition: Clipboard.h:33
Definition: ElementScroll.h:46
Definition: EventListener.h:46
Definition: Element.h:71