00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "drawing_area.h"
00025
00026
00027 using namespace std;
00028
00029
00030 drawing_area::drawing_area ()
00031 {
00032 move (0, 0);
00033 resize (0, 0);
00034 draw_to = NULL;
00035 }
00036
00037 drawing_area::drawing_area (s_int16 px, s_int16 py, u_int16 pw, u_int16 ph)
00038 {
00039 move (px, py);
00040 resize (pw, ph);
00041 draw_to = NULL;
00042 }
00043
00044 drawing_area& drawing_area::operator = (SDL_Rect& r)
00045 {
00046 rect = r;
00047 draw_to = NULL;
00048 return (*this);
00049 }
00050
00051 SDL_Rect drawing_area::setup_rects () const
00052 {
00053 if (draw_to)
00054 {
00055 SDL_Rect ret;
00056 SDL_Rect temp = draw_to->setup_rects ();
00057
00058 ret.x = temp.x > x ()? temp.x : x ();
00059 ret.y = temp.y > y ()? temp.y : y ();
00060
00061
00062 s_int32 xpl = x () + length ();
00063 s_int32 txw = temp.x + temp.w;
00064 s_int32 txwmrx = txw - ret.x;
00065 s_int32 xplmrx = xpl - ret.x;
00066 s_int32 yph = y () + height ();
00067 s_int32 tyh = temp.y + temp.h;
00068 s_int32 tyhmry = tyh - ret.y;
00069 s_int32 yphmry = yph - ret.y;
00070
00071
00072 ret.w = txw < xpl ? txwmrx > 0 ? txwmrx : 0 : xplmrx > 0 ? xplmrx : 0;
00073 ret.h = tyh < yph ? tyhmry > 0 ? tyhmry : 0 : yphmry > 0 ? yphmry : 0;
00074
00075 return ret;
00076 }
00077 else return rect;
00078
00079 }