00001
00002
00003
00004
00005
00006 #ifdef USE_TILE
00007 #ifndef TILEREG_H
00008 #define TILEREG_H
00009
00010 #include "tilebuf.h"
00011 #include "tiletex.h"
00012
00013 class ImageManager;
00014 struct MouseEvent;
00015
00016 class Region
00017 {
00018 public:
00019 Region();
00020 virtual ~Region();
00021
00022 void resize(int mx, int my);
00023 void place(int sx, int sy, int margin);
00024 void place(int sx, int sy, int ex, int ey, int margin);
00025 void place(int sx, int sy);
00026 void resize_to_fit(int wx, int wy);
00027
00028
00029
00030 virtual bool mouse_pos(int mouse_x, int mouse_y, int &cx, int &cy);
00031
00032 bool inside(int px, int py);
00033 virtual bool update_tip_text(std::string &tip) { return false; }
00034 virtual bool update_alt_text(std::string &alt) { return false; }
00035 virtual int handle_mouse(MouseEvent &event) = 0;
00036
00037 virtual void render() = 0;
00038 virtual void clear() = 0;
00039
00040
00041
00042
00043
00044
00045
00046 int ox;
00047 int oy;
00048
00049
00050 int dx;
00051 int dy;
00052
00053
00054 int mx;
00055 int my;
00056
00057
00058 int wx;
00059 int wy;
00060
00061
00062 int sx;
00063 int sy;
00064
00065
00066 int ex;
00067 int ey;
00068
00069 static coord_def NO_CURSOR;
00070
00071 protected:
00072 void recalculate();
00073 virtual void on_resize() = 0;
00074 void set_transform(bool no_scaling = false);
00075 };
00076
00077 class FontWrapper;
00078
00079
00080
00081 class TileRegionInit
00082 {
00083 public:
00084 TileRegionInit(ImageManager *_im, FontWrapper *_font, int _tx, int _ty) :
00085 im(_im), tag_font(_font), tile_x(_tx), tile_y(_ty) { }
00086 TileRegionInit() { }
00087
00088 ImageManager *im;
00089 FontWrapper *tag_font;
00090 int tile_x;
00091 int tile_y;
00092 };
00093
00094 class TileRegion : public Region
00095 {
00096 public:
00097 TileRegion(const TileRegionInit &init);
00098 ~TileRegion();
00099
00100 protected:
00101 ImageManager *m_image;
00102 FontWrapper *m_tag_font;
00103 bool m_dirty;
00104 };
00105
00106
00107 class ControlRegion : public Region
00108 {
00109 public:
00110 virtual void run() = 0;
00111 };
00112
00113 #endif
00114 #endif