2 * This file is part of NumptyPhysics
3 * Copyright (C) 2008 Tim Edmonds
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 3 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
31 virtual void add( Widget
* w
)=0;
32 virtual void remove( Widget
* w
)=0;
39 virtual bool isDirty() {return false;}
40 virtual Rect
dirtyArea() {return Rect();};
41 virtual void onTick( int tick
) {}
42 virtual void draw( Canvas
& screen
, const Rect
& area
) {};
43 virtual bool handleEvent( SDL_Event
& ev
) {return false;}
44 void setParent(WidgetParent
* p
) {m_parent
= p
;}
45 WidgetParent
* parent() { return m_parent
; }
47 WidgetParent
* m_parent
;
51 class Label
: public Widget
55 void text( std::string
& s
);
61 class Button
: public Widget
67 class Container
: public Widget
, public WidgetParent
72 virtual bool isDirty();
73 virtual Rect
dirtyArea();
74 virtual void onTick( int tick
);
75 virtual void draw( Canvas
& screen
, const Rect
& area
);
76 virtual bool handleEvent( SDL_Event
& ev
);
78 void add( Widget
* w
);
79 virtual void remove( Widget
* w
);
83 class Layer
: public Widget
86 virtual void onShow() {}
87 virtual void onHide() {}