00001 //********************************************************************** 00002 // 00003 // REGCOM: Regimental Command 00004 // Copyright (C) 2008 Randi J. Relander 00005 // <rjrelander@users.sourceforge.net> 00006 // 00007 // This program is free software; you can redistribute it and/or 00008 // modify it under the terms of the GNU General Public License 00009 // as published by the Free Software Foundation; either version 3 00010 // of the License, or (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public 00018 // License along with this program. If not, see 00019 // <http://www.gnu.org/licenses/>. 00020 // 00021 //********************************************************************** 00022 00023 #ifndef REGCOM_GUI_SCROLLVIEW_H 00024 #define REGCOM_GUI_SCROLLVIEW_H 00025 00026 // PROJECT INCLUDES 00027 #include "regcom/gui/Window.h" 00028 #include "regcom/gui/Rect.h" 00029 00030 // NAMESPACES 00031 namespace regcom { 00032 namespace gui { 00033 00034 // FORWARD REFERENCES 00035 class Surface; 00036 class Point; 00037 00039 // CLASS: ScrollView 00045 class ScrollView : public Window 00046 { 00047 public: 00048 00049 // PUBLIC METHODS 00050 00052 ScrollView(); 00053 00055 virtual ~ScrollView(); 00056 00058 virtual void FrameResized(int w, int h); 00059 00061 void Scroll(int dx, int dy); 00062 00064 void Warp(int x, int y); 00065 00067 virtual void Draw(Rect rect); 00068 00070 Rect GetViewport() { return m_viewport; } 00071 00073 void Refresh(); 00074 00076 void SetVelocity(float vel) { m_pixel_vel = vel; } 00077 00079 void SetAcceleration(float acc) { m_pixel_acc = acc; } 00080 00082 virtual void OnTimer(float dt); 00083 00085 Point GetCenter(); 00086 00088 void SetCenter(Point point); 00089 00091 void SetCorner(Point point); 00092 00094 void SetState(int state) { m_state |= state; } 00095 00097 void ClearState(int state) { m_state &= ~state; } 00098 00100 enum SCROLL_STATE 00101 { 00102 SCROLL_STATE_UP = 0x0001, 00103 SCROLL_STATE_DOWN = 0x0002, 00104 SCROLL_STATE_LEFT = 0x0004, 00105 SCROLL_STATE_RIGHT = 0x0008 00106 }; 00107 00108 protected: 00109 00110 // PROTECTED METHODS 00111 00113 virtual void DrawImage( 00114 Rect rect, Surface* surface, int x, int y) = 0; 00115 00117 virtual void ViewportChanged() = 0; 00118 00120 void UpdateRect(Rect& rect, bool clip = true); 00121 00123 virtual int GetImageWidth() = 0; 00124 00126 virtual int GetImageHeight() = 0; 00127 00129 void UpdateVScroll(float dt); 00130 00132 void UpdateHScroll(float dt); 00133 00134 private: 00135 00136 // MEMBER VARIABLES 00137 00139 Surface* m_buffer; 00140 00142 Rect m_viewport; 00143 00145 float m_vx; 00146 00148 float m_vy; 00149 00151 float m_xmin; 00152 00154 float m_xmax; 00155 00157 float m_ymin; 00158 00160 float m_ymax; 00161 00163 float m_pixel_vel; // pixels/sec 00164 00166 float m_pixel_acc; // pixels/sec/sec 00167 00169 int m_oldx; 00170 00172 int m_oldy; 00173 00175 int m_state; 00176 00178 float m_px; 00179 00181 float m_py; 00182 }; 00183 00184 } // namespace gui 00185 } // namespace regcom 00186 00187 #endif
Navigation
Home Page
Screen Shots
Developers
Documentation
Doxygen
Namespace List
Class List
Class Hierarchy
File List
Todo List
Links
SDL Library
License
SourceForge Project
Forums
Download
Regimental Command
Copyright © 2008
Randi J. Relander