File: pgscrollwidget.h

package info (click to toggle)
asc 2.6.1.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 81,740 kB
  • sloc: cpp: 158,704; sh: 11,544; ansic: 6,736; makefile: 604; perl: 138
file content (179 lines) | stat: -rw-r--r-- 4,798 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/*
    ParaGUI - crossplatform widgetset
    Copyright (C) 2000,2001,2002  Alexander Pipelka
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
 
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
 
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
    Alexander Pipelka
    pipelka@teleweb.at
 
    Last Update:      $Author: mbickel $
    Update Date:      $Date: 2009-04-18 13:48:39 $
    Source File:      $Source: /home/martin/asc/v2/svntest/games/asc/source/libs/paragui/include/pgscrollwidget.h,v $
    CVS/RCS Revision: $Revision: 1.3 $
    Status:           $State: Exp $
*/

/** \file pgscrollwidget.h
	Header file for the PG_ScrollWidget class.
*/

#ifndef PG_SCROLLWIDGET_H
#define PG_SCROLLWIDGET_H

#include "pgthemewidget.h"
#include "pgscrollbar.h"
#include "pgscrollarea.h"


/**
	@author Alexander Pipelka
 
	@short Encapsulation of the PG_ScrollArea widget providing scrollbars.
 
	Generally used to make a large 'pane' of widgets that can be scrolled
	through in a smaller 'portal' with scrollbars.
*/

class DECLSPEC PG_ScrollWidget : public PG_ThemeWidget  {
public:

	enum {
	    IDWIDGETLIST_VSCROLL = PG_WIDGETID_INTERNAL + 10, IDWIDGETLIST_HSCROLL
	};

	/**
	Constructor of the PG_Widget class
	*/
	PG_ScrollWidget(PG_Widget* parent, const PG_Rect& r = PG_Rect::null, const std::string& style="ScrollWidget");

	/**
	Destructor of the PG_Widget class
	*/
	~PG_ScrollWidget();

	/**  */
	void LoadThemeStyle(const std::string& widgettype);

	/**
	Enable / disable the Scrollbar (override automatic display)
	@param enable true - enable scrollbar / false - disable scrollbar
	@param direction modified scrollbar (PG_ScrollBar::VERTICAL | PG_ScrollBar::HORIZONTAL)
	*/
	void EnableScrollBar(bool enable, PG_ScrollBar::ScrollDirection direction = PG_ScrollBar::VERTICAL);

	/**
	scroll to a give X/Y-Coordinate within the client area.
	@param x X-Position
	@param y Y-Position
	*/
	void ScrollTo( int x, int y);

	/**
	Scroll to a widget
	@param widget the target widget
	@param bVertical scroll direction
	*/
	void ScrollToWidget(PG_Widget* widget, bool bVertical = true);

	Uint16 GetListHeight();

	Uint16 GetListWidth();

	Uint16 GetWidgetCount();

	PG_Widget* GetFirstInList();

	virtual void DeleteAll();

	virtual void RemoveAll();

	void AddChild(PG_Widget* child);

	/** Linesize is the scroll distance that is scrolled if one of the arrow buttons is pressed  */
   void SetLineSize( int linesize );
   int GetLineSize();

	/**
	Shift widgets on removal.
	@param shiftx shift all widgets to the right of the removed widgets.
	@param shifty shift all widgets beneath the removed one.
	This method controls the behaviour if a widget will be removed from the client
	context.
	*/
	void SetShiftOnRemove(bool shiftx, bool shifty);

	/**
	Get x offset of current scroll position.
	*/
	Uint16 GetScrollPosX();

	/**
	Get y offset of current scroll position.
	*/
	Uint16 GetScrollPosY();

	/**
	Automatically adjusts the widget's size to the actual scroll area size;
	@param bRemove adjusts size when removing a child
	@param bAdd adjusts size when adding a child
	*/
	void SetAutoResize(bool bRemove, bool bAdd);

	PG_ScrollArea::SignalAreaChangedHeight sigAreaChangedHeight;

	PG_ScrollArea::SignalAreaChangedWidth sigAreaChangedWidth;

protected:

	/**  */
	void eventSizeWidget(Uint16 w, Uint16 h);

   bool eventMouseButtonDown(const SDL_MouseButtonEvent* button);
   
	bool handleScrollPos_horiz(long data);
	bool handleScrollPos_vert(long data);

	bool handleScrollTrack_horiz(long data);
	bool handleScrollTrack_vert(long data);

	bool handleAreaChangedHeight(PG_ScrollArea* area, Uint16 h);

	bool handleAreaChangedWidth(PG_ScrollArea* area, Uint16 w);

	PG_ScrollBar* my_objVerticalScrollbar;
	PG_ScrollBar* my_objHorizontalScrollbar;
	PG_ScrollArea* my_scrollarea;

	int my_widthScrollbar;
	int my_heightHorizontalScrollbar;

	bool my_enableVerticalScrollbar;
	bool my_enableHorizontalScrollbar;
	int my_scrollLineSize;

	void CheckScrollBars();

private:

	PG_ScrollWidget(const PG_ScrollWidget&);

	PG_ScrollWidget& operator=(const PG_ScrollWidget&);

	DLLLOCAL void CalcScrollbarVisibility();
	DLLLOCAL void RecalcPositions(bool bV, bool bH);
};

#endif // PG_SCROLLWIDGET_H