This file is indexed.

/usr/include/paragui/pgwidget.h is in libparagui1.1-dev 1.1.8-3.1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
/*
    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: braindead $
    Update Date:      $Date: 2004/09/05 10:51:41 $
    Source File:      $Source: /cvsroot/paragui/paragui/include/pgwidget.h,v $
    CVS/RCS Revision: $Revision: 1.3.6.3.2.17 $
    Status:           $State: Exp $
*/

#ifndef PG_WIDGET_H
#define PG_WIDGET_H

#include "pgmessageobject.h"
#include "pgrectlist.h"
#include "pgfont.h"
#include "pgstring.h"

#include MAP_INC

class PG_Widget;
class PG_WidgetDataInternal;

/**
	@author Alexander Pipelka
	
	@short Base class of all widgets.
 
	Provides graphics context and message handling functionality.
 
	\anchor theme_PG_Widget
 
	<h2>Theme support</h2><p>
 
	This class provides themeing capabilities only for subclassed widgets.<p>
 
	<b>widget type:</b>		none (managed through subclass)<br>
	<b>object name:</b>		none (managed through subclass)<br>
 
	<h3>Theme sample:</h3>
 
	\code
	<widget>
		<type value="xxx"/>
			<object>
			<name value="xxx"/>
			<property color="textcolor" value="0x00FFFFFF"/>
			<property color="bordercolor0" value="0x00202020"/>
			<property color="bordercolor1" value="0x00E0E0E0"/>
		</object>
	</widget>
	\endcode
	<p>
	<h2>Code:</h2><p>
*/

class DECLSPEC PG_Widget : public PG_MessageObject, public PG_Rect  {
public:


	//! Keyevent actions
	typedef enum {
		ACT_ACTIVATE,	//!< Widget got the input focus
		ACT_DEACTIVATE,	//!< Widget has lost the input focus
		ACT_OK,	//!< Widget action event (e.g. button press on a PG_Button object)
		ACT_CANCEL,	//!< Widget cancel-action
		ACT_LEFT,	//!< Cursor left was pressed
		ACT_RIGHT,	//!< Cursor right was pressed
		ACT_UP,	//!< Cursor up was pressed
		ACT_DOWN	//!< Cursor down was pressed
	} KeyAction;

	/**
	Creates a PG_Widget without an object-surface

	@param parent	the parentobject for the new widget or NULL if it is a toplevel widget
	@param rect	initial position for the widget

	This is the constructor for the PG_Widget class (really!)
	*/
	//PG_Widget(PG_Widget* parent, const PG_Rect& rect);

	/**
	Creates a PG_Widget with an internal object surface

	@param parent		the parentobject for the new widget or NULL if it is a toplevel widget
	@param rect		initial position for the widget
	@param bObjectSurface	flag if a surface for the object should be created
	*/
	PG_Widget(PG_Widget* parent, const PG_Rect& rect = PG_Rect::null, bool bObjectSurface = false);

	/**
	Destroys a PG_Widget

	This is the destructor for the PG_Widget class
	*/
	virtual ~PG_Widget();

	/**
	Load a style from the theme definition

	@param widgettype	name of the widgettype

	Loads the defined style for a given widgettype
	*/
	void LoadThemeStyle(const char* widgettype);

	/**
	Load a style from the theme definition

	@param widgettype	name of the widgettype
	@param objectname	name of the object

	Loads the defined style of a given widgettype and objectname.
	*/
	virtual void LoadThemeStyle(const char* widgettype, const char* objectname);

	/**
	Start to drag a widget

	StartWidgetDrag prepares to widget to be dragged.
	*/
	void StartWidgetDrag();

	/**
	Drag the widget to a given position (in screen coordinates)

	@param x	x-position
	@param y	y-position
	*/
	void WidgetDrag(int x, int y);

	/**
	Finishes a drag operation

	@param x	x endposition
	@param y	y endposition
	*/
	void EndWidgetDrag(int x, int y);

	/**
	Move a widget

	@param x	new x-position (in parent context)
	@param y	new y-position (in parent context)
	@param update true - update screen content / false - no screen update
	@return		function succeeded

	This function moves the widget
	*/
	bool MoveWidget(int x, int y, bool update = true);

	/**
	Move and resize widget

	@param r	new widget rectangle (client coordinates)
	@param update	is the update true
	@return		function succeeded

	This function moves and resizes the widget to fit the given rectangle.
	*/
	bool MoveWidget(const PG_Rect& r, bool update = true);

	/**
	Resize a widget

	@param w	new widget-width
	@param h	new widget-height
	@param update true - update widget after resizing / false - do not display changes
	@return		function succeeded

	This function resizes the widget
	*/
	virtual bool SizeWidget(Uint16 w, Uint16 h, bool update = true);

	/**
	Convert a client (widget) coordinate to a screen position

	@param x	x - widgetcoordinate
	@param y	y - widgetcoordinate
	@return		PG_Point structure with the screen position
	*/
	PG_Point ClientToScreen(int x, int y);

	/**
	Convert a screen position to a client (widget) coordinate

	@param x	x - screenposition
	@param y	y - screenposition
	@return		PG_Point structure with the client position
	*/
	PG_Point ScreenToClient(int x, int y);

	/**
	Return the pointer to the widget's drawing surface

	@return SDL_Surface pointer to the drawing surface
	*/
	SDL_Surface* GetWidgetSurface();

	/**
	Check if the object is visible
	@return							true if object is visible
	*/
	bool IsVisible();

	/**
	Get the parentwidget of a widget	

	@return	a pointer to the parentwidget or NULL if there is no parentwidget
	*/
	PG_Widget* GetParent();

	/**
	Add a clientwidget (which will be embedded into this widget)

	@param child	the widget to add
	*/
	virtual void AddChild(PG_Widget* child);

	/**
	Process a native PG_ event

	@param event PG_ event to process
	@param bModal set to true if processing takes place in a modal loop
	@return	true if the event was sucessfully processed

	ProcessEvent asks the widget to process a given event. It also asks its
    parent and, if bModal is true, its children.
	*/
	virtual bool ProcessEvent(const SDL_Event* event, bool bModal = false);

	/**
	Set the widgetid

	@param id	a number which can be used to identify the widget

	This id can be used in callbacks or eventhandlers to identify the
	widget. It can also be used to find a child within the group of
	children.
	*/
	void SetID(int id);

	/**
	Return the widgetid
	@return	id of the widget
	*/
	int GetID();

	/**
	Find a child that is identified by the given ID.
	@param id   the id of the child to return
	@return A pointer to the child with the given ID or 0 if no such child exists.
	*/
	PG_Widget* FindChild(int id);

	/**
	Find a child that is identified by the given name.
	@param name   the name of the child to return
	@return A pointer to the child with the given name or 0 if no such child exists.
	*/
	PG_Widget* FindChild(const char *name);

	/**
	Check if the mousepointer is currently inside the widget
	@return	true if the mousepointer is inside
	*/
	bool IsMouseInside();

	/**
	Redraw the widget and all embedded child widgets
	@param	update	if true Update() is called after the redraw
	@return		true if the redraw operation succeeded
	*/
	bool Redraw(bool update = true);

	/**
	Blit the widget to the screen
	@param recursive	if true all embedded widget will also be blitted to screen
	@param restore		restore the background before blitting if true
	This function only performs a SDL_BlitSurface() the screen content will NOT be updated
	*/
	virtual void Blit(bool recursive = true, bool restore = true);

	/**
	Update the widget's screen area
	@param doBlit	if true a Blit() operation is done before the update
	*/
	void Update(bool doBlit = true);

	/**
	Update a screen area
	@param r	update rectangle
	*/
	static void UpdateRect(const PG_Rect& r);

	/**
	Update (render) the whole application screen
	*/
	static void UpdateScreen();

	/**
	Make a widget visible
	@param fade	do a smooth fade in if true
	*/
	void Show(bool fade = false);

	/**
	Hide a widget
	@param fade	do a smooth fade out if true
	*/
	void Hide(bool fade = false);

	/**
	Check if the widget is in front of another one
	*/
	bool IsInFrontOf(PG_Widget*);

	/**
	Send the widget back to the end of the list
	*/
	void SendToBack();

	/**
	Reorder the widget in front of all others
	*/
	void BringToFront();

	/**
	Get the toplevel widget
	*/
	PG_Widget* GetToplevelWidget();

	/**
	Hide all widgets of an application
	*/
	static void HideAll();

	void RecalcClipRect();

	/**
	Restore the background (all widgets behind this one)
	@param clip clipping rectangle
	@param force force to redraw the background even if dirty updates are enabled.
	*/
	virtual bool RestoreBackground(PG_Rect* clip = NULL, bool force = false);

	static PG_Widget* FindWidgetFromPos(int x, int y);

	/**
	Set the visiblility of a widget with updating the screen contents
	@param visible	true - visible / false - invisible
	*/
	void SetVisible(bool visible);

	/**
	Set the number of steps for fading in/out widgets
	@param steps	number of steps
	*/
	void SetFadeSteps(int steps);

	/**
	Set the transparency of all child widgets
	@param t	transparency 0 - opaque / 255 - full transparent
	*/
	void SetChildTransparency(Uint8 t);

	/**
	Get a list of child widgets

	@return	pointer to childlist
	*/
	PG_RectList* GetChildList();

	/**
	Get the number of childwidgets

	@return	number of childwidgets
	*/
	int GetChildCount();

	/**  */
	void MoveRect(int x, int y);

	/** */
	//static void BulkUpdate();

	/** */
	static void BulkBlit();

	// Navigation

	/** */
	virtual bool Action(KeyAction action);

	/**
	   Get a list of all toplevel widgets
	   @return pointer to a PG_RectList object
	*/
	static PG_RectList* GetWidgetList();
	
	/**
	   Set the name for the widget
	   @param name	Name of the widget - size of the name is defined in PG_NAMESIZE
	*/
	void SetName(const char *name);

	/**
	Get the name for the widget
	@return	name of the widget
	*/
	const char* GetName();

	/**
	Load layout from the XML file to the current widget
	@param name	name of the xml file
	@return returns non-zero on success or 0 if not succes
	*/
	bool LoadLayout(const char *name);

	/**
	Load layout from the XML file to the current widget
	@param name	name of the xml file
	@param WorkCallback	address of function to show progress of loading layout
	@return returns non-zero on success or 0 if not succes
	*/
	bool LoadLayout(const char *name, void (* WorkCallback)(int now, int max));

	/**
	Load layout from the XML file to the current widget
	@param name	name of the xml file
	@param WorkCallback	address of function to show progress of loading layout
	@param UserSpace address of user data witch are passed to Processing Instruction handler etc.
	@return returns non-zero on success or 0 if not succes
	*/
	bool LoadLayout(const char *name, void (* WorkCallback)(int now, int max), void *UserSpace);

	/**
	Removes all childs
	*/
	void RemoveAllChilds();

	/**
	Sets user data to the widget (malloc inside)
	@param userdata	points to data to copy in
	@param size	size of data
	*/
	void SetUserData(void *userdata, int size);

	/**
	Sets user data to the widget (malloc inside)
	@return	size of stored user data (0 = no data stored in)
	*/
	virtual int GetUserDataSize();

	/**
	Gets user data from the widget
	@param userdata where to write data (must be allocated space with size from GetUserDataSize())
	*/
	virtual void GetUserData(void *userdata);

	/**
	Releases user data
	*/
	void ReleaseUserData();

	/**	*/
	bool virtual RemoveChild(PG_Widget* child);

	/**
	Sets text
	@param text	Set the widget text and update widget
	*/
	virtual void SetText(const char* text);

	/**
	Adds text
	@param text	Add text to the widget text
	@param update Do the update
	*/
	void AddText(const char* text, bool update = false);

	/**
	Sets formated text
	@param text	Set the widget text (like printf) and update widget
	*/
	virtual void SetTextFormat(const char* text, ...);

	/** Returns text
	@return	Pointer to the text of the widget (read-only)
	*/
	virtual const char* GetText();

	void GetTextSize(Uint16& w, Uint16& h, const char* text = NULL);

	static void GetTextSize(Uint16& w, Uint16& h, const char* text, PG_Font* font);

	int GetTextWidth();

	int GetTextHeight();

	int GetFontAscender();

	int GetFontHeight();

	/**
	Return the current text color
	@return	PG_Color
	*/
	PG_Color GetFontColor();

	/**
	Set font color
	@param	Color PG_Color class contains color information (RGB)
	*/
	void SetFontColor(const PG_Color& Color, bool bRecursive = false);

	/**
	Set font transparency (!!!)
	@param	Alpha	Value 0 - 255 (0 = invisible, 255 = fully visible)
	@param	bRecursive alter all child widgets
	*/
	void SetFontAlpha(int Alpha, bool bRecursive = false);

	/**
	Set font style
	@param	Style	Binary combination (OR) of PG_Font::NORMAL, PG_Font::BOLD, PG_Font::ITALIC and PG_Font::UNDERLINE
	@param	bRecursive alter all child widgets
	*/
	void SetFontStyle(PG_Font::Style Style, bool bRecursive = false);

	/**
	Set font size
	@param	Size	size of the font
	@param	bRecursive alter all child widgets
	*/
	void SetFontSize(int Size, bool bRecursive = false);

	/**
	Set font index
	@param	Index	Index of the desired font face in the font file (usualy 0)
	@param	bRecursive alter all child widgets
	*/
	void SetFontIndex(int Index, bool bRecursive = false);

	/**
	Set font name
	@param	Name	Filename of the font (this function don`t load the font - or check presention of the file !!!)
	@param	bRecursive alter all child widgets
	*/
	void SetFontName(const char *Name, bool bRecursive = false);

	/**
	Set widget size by size of text (should be used before Show() or AddWidget())
	@param	Width	Value witch is added to text width (default = 0)
	@param	Height	Value witch is added to text height  (default = 0)
	@param	Text	Text to get size from, if NULL my_text is used
	*/
	void SetSizeByText(int Width = 0, int Height = 0, const char *Text = NULL);

	/**
	Get the size of the font
	*/
	int GetFontSize();

	/**
	Get the current font parameters
	@return	pointer to the PG_Font object
	*/
	PG_Font* GetFont();

	/**
	Set the current font parameters
	@param	font	pointer to PG_Font object
	*/
	void SetFont(PG_Font* font);

	/**
	Render text inside the widget
	@param rect rectangle where the text should appear
	@param text pointer to text string
	*/
	void DrawText(const PG_Rect& rect, const char* text);

	/**
	Render text inside the widget
	@param x x-position where the text should appear
	@param y y-position where the text should appear
	@param text pointer to text string
	*/
	void DrawText(int x, int y, const char* text);

	/**
	Render text inside the widget and clip to a given clipping rectangle
	@param x x-position where the text should appear
	@param y y-position where the text should appear
	@param text pointer to text string
	@param cliprect text bounding rectangle
	*/
	void DrawText(int x, int y, const char* text, const PG_Rect& cliprect);

	/**
	Render text inside the widget and set the font color
	@param rect rectangle where the text should appear
	@param text pointer to text string
	@param c color of the rendered text
	*/
	void DrawText(const PG_Rect& rect, const char* text, const PG_Color& c);

	/**
	Render text inside the widget and set the font color
	@param x x-position where the text should appear
	@param y y-position where the text should appear
	@param text pointer to text string
	@param c color of the rendered text
	*/
	void DrawText(int x, int y, const char* text, const PG_Color& c);

	/**  */
	void DrawBorder(const PG_Rect& r, int size, bool up = true);

	/**
	Set the transparency of the drawing object
	@param	t						transparency (0 - opaque / 255 - fully transparent)
	@param	bRecursive	are transparency changes recursive
	*/
	virtual void SetTransparency(Uint8 t, bool bRecursive = false);

	/**
	Get the transparency of the drawing object
	@return							transparency (0 - opaque / 255 - fully transparent)
	*/
	Uint8 GetTransparency();

	/**
	Set the clipping rectangle for the object
	@param r clipping rectangle
	*/
	void SetClipRect(PG_Rect& r);

	/**
	Get the current clipping rectangle
	@return the clipping rectangle
	*/
	PG_Rect* GetClipRect();

	/**
	Check if there is a clipping rectangle assigned to the object
	@return						true / false
	*/
	bool IsClippingEnabled();

	/**  */
	void GetClipRects(PG_Rect& src, PG_Rect& dst);

	/**  */
	void GetClipRects(PG_Rect& src, PG_Rect& dst, const PG_Rect& displayrect);

	/**  */
	void SetPixel(int x, int y, const PG_Color& c);

	/**  */
	void DrawHLine(int x, int y, int w, const PG_Color& c);

	/**  */
	void DrawVLine(int x, int y, int h, const PG_Color& c);

	/**  */
	void DrawRectWH(int x, int y, int w, int h, const PG_Color& c);

	/**  */
	void DrawLine(Uint32 x0, Uint32 y0, Uint32 x1, Uint32 y1, const PG_Color& color, Uint8 width=1);

	/**
	Enter modal mode
	*/
	virtual int RunModal();

	/**
	Quit modal mode
	*/
	void QuitModal();

	bool WillQuitModal();

	void StopQuitModal();
	
	/**
	Set the dirty update mode
	@param bDirtyUpdate true - enable / false - disable
	This function sets the dirty update mode of a widget. This greatly improves the rendering speed
	because the underlying widgets are not redrawn if the widgets transparency is equal to 0.
	It will cause render failures wrong if there is an alpha channel in the widget's drawing surface.
	If you encounter problems with activated dirty updates simple disable it.
	*/
	void SetDirtyUpdate(bool bDirtyUpdate);
	
	/**
	return if the dirty update mode is enabled
	@return true - dirty updates enabled
	*/
	bool GetDirtyUpdate();
	
	/**
		eventhandler for mouse movements.
		This overrideable handler is called everytime the mouse cursor is leaving the widget area.
	*/
	virtual void eventMouseLeave();
	
	/**
		eventhandler for mouse movements.
		This overrideable handler is called everytime the mouse cursor is entering the widget area.
	*/
	virtual void eventMouseEnter();

	void SetHidden(bool hidden);
	
	bool IsHidden();

	/**
		Set the return status of the modal eventloop.
		@param status returnstatus
		The specified status will be returned by the RunModal method
	*/
	void SetModalStatus(int status);
	
	void EnableReceiver(bool enable, bool bRecursive = false);

protected:

	/**
		main eventhandler for messages
		@param msg pointer to a MSG_MESSAGE structure
		@return this eventhandler should return "true" if the message was proccessed.
		This messagehandler can be overridden to perform custom operations.
	*/	
	//bool eventMessage(MSG_MESSAGE* msg);

	/**
	Callback for the MoveWidget event
	@param x new x position
	@param y new y position
	This virtual function can be used to implement custom behavior for
	MoveWidget events.
	*/
	virtual void eventMoveWidget(int x, int y);

	/**
	Callback for the MoveWidget event -- OBSOLETE
	@param x new x position
	@param y new y position
	This virtual function can be used to implement custom behavior for
	MoveWidget events.
	CAUTION: This function will be removed in the final version
	*/
	//virtual void eventMoveWindow(int x, int y);

	/**
	Callback for the SizeWidget event
	@param w new width
	@param h new height
	This virtual function can be used to implement custom behavior for
	SizeWidget events.
	*/
	virtual void eventSizeWidget(Uint16 w, Uint16 h);

	/**
	Callback for the SizeWidget event
	@param w new width
	@param h new height
	This virtual function can be used to implement custom behavior for
	SizeWidget events.
	CAUTION: This function will be removed in the final version
	*/
	//virtual void eventSizeWindow(Uint16 w, Uint16 h);

	/**
	overridable eventhandler to draw the object surface
	@param surface the widgets drawing surface.
	@param rect rectangle to draw within.
	This eventhandler is called whenevener the widget contents should be redrawn.
	@note Only widgets with drawing surfaces (see the constructor) will call this eventhandler.
	*/
	virtual void eventDraw(SDL_Surface* surface, const PG_Rect& rect);

	/**
	overridable eventhandler to blit the widget contents to the screen
	@param surface pointer to SDL_Surface to be blitted
	@param src source rectangle (client coordinates)
	@param dst destination rectangle (screen coordinates)
	Override this eventhandler to perform custom blitting behaviour (without drawing onto the widget surface).
	*/
	virtual void eventBlit(SDL_Surface* surface, const PG_Rect& src, const PG_Rect& dst);

	/**
	overridable eventhandler called whenever the widget gets shown.
	*/
	virtual void eventShow();

	/**
	overridable eventhandler called whenever the widget gets hidden.
	*/
	virtual void eventHide();

	/**
	overridable eventhandler called when leaving a modal eventloop
	@param id	id of the widget that send the quit signal
	@param widget pointer to the widget
	@param data event specific data
	@return true if the message was processed
	*/
	virtual bool eventQuitModal(int id, PG_MessageObject* widget, unsigned long data);

	void SetParent(PG_Widget* parent);

	/**  */
	void FadeOut();

	/**  */
	void FadeIn();

	/**  */
	bool AcceptEvent(const SDL_Event* event);

	/**  */
	void RemoveFromWidgetList();

	/**  */
	void AddToWidgetList();

	/**
	pointer to the widgets drawing surface or NULL
	*/
	SDL_Surface* my_srfObject;

	/**
	pointer to the screen surface
	*/
	//SDL_Surface* my_srfScreen;

	/**
	text attached to the widget
	*/
	PG_String my_text;

	/**
	array of border colors
	*/
	PG_Color my_colorBorder[2][2];

private:

	PG_Widget(const PG_Widget&);
	PG_Widget& operator=(const PG_Widget&);

	//static bool bBulkUpdate;
	static int my_ObjectCounter;
	static PG_RectList widgetList;

	// this is a bit rude but neccessary for future binary compatibility
	// because adding non-static data members would break the ABI.
	// For this we put all private data into a dynamically created struct.
	PG_WidgetDataInternal* _mid;
};

#endif // PG_WIDGET_H