original 1.0.1 release
[xwelltris.git] / src / wellsimpledraw.cxx
blob8496ce57fd474d8382bdf377540a3733cb9e67c9
1 // docm_prefix(///)
2 /****************************************************************************
3 * Copyright (C) 2002 by Leo Khramov
4 * email: leo@xnc.dubna.su
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 ****************************************************************************/
16 // $Id: wellsimpledraw.cxx,v 1.2 2003/02/19 09:51:39 leo Exp $
18 /// module description
19 /// WellSimpleDrawing - class that implements simple drawing algorithm
20 /// with dirty rectangles
22 #include "wellsimpledraw.h"
24 //===========================================================================
25 /// global WellSimpleDraw()
26 /// constructor of the class - init's variables.
27 /// tags WellSimpleDraw
28 WellSimpleDraw::WellSimpleDraw()
30 max_dirties=0;
33 //===========================================================================
34 /// global ~WellSimpleDraw()
35 /// destructor of the class.
36 /// tags WellSimpleDraw
37 WellSimpleDraw::~WellSimpleDraw()
39 clear_dirty_list();
42 //===========================================================================
43 /// global new_dirty_rec(int dx, int dy)
44 /// create new dirty rec and remember delta position for main screen
45 /// tags WellSimpleDraw
46 void WellSimpleDraw::new_dirty_rec(int dx, int dy)
48 current_dirty.delta_x=dx;
49 current_dirty.delta_y=dy;
50 max_x=max_y=-1;
51 min_x=min_y=99999; //Hope we will never have screen bigger :)
54 //===========================================================================
55 /// global dirty_add_xy(int x, int y)
56 /// we add dot to current dirty rec - need detect max and min corners
57 /// tags WellSimpleDraw
58 void WellSimpleDraw::dirty_add_xy(int x, int y)
60 if(x<min_x)
61 min_x=x;
62 if(x>max_x)
63 max_x=x;
64 if(y<min_y)
65 min_y=y;
66 if(y>max_y)
67 max_y=y;
70 //===========================================================================
71 /// global finish_dirty_rec()
72 /// finish dots definition of current dirty rec - add it to the dirty queue
73 /// tags WellSimpleDraw
74 void WellSimpleDraw::finish_dirty_rec()
76 current_dirty.x=min_x;
77 current_dirty.y=min_y;
78 current_dirty.l=max_x-min_x+1;
79 current_dirty.h=max_y-min_y+1;
80 DirtyList *plist=new DirtyList(current_dirty);
81 dirty_list.add(plist);
82 max_dirties++;
85 //===========================================================================
86 /// global clear_dirty_list()
87 /// clear all the list and free allocated memory
88 /// tags WellSimpleDraw
89 void WellSimpleDraw::clear_dirty_list()
91 DirtyList *plist;
92 do
94 plist=dirty_list.get_next();
95 if(plist)
97 plist->del_self();
98 delete plist;
100 } while(plist);
101 max_dirties=0;
104 //===========================================================================
105 /// global dirty_add_rec(DirtyRect r)
106 /// directly add the whole rec to the dirty queue
107 /// tags WellSimpleDraw
108 void WellSimpleDraw::dirty_add_rec(DirtyRect r)
110 DirtyList *plist=new DirtyList(r);
111 dirty_list.add(plist);
112 max_dirties++;