5 gPainter ist die high-level version. die highlevel daten werden zu low level opcodes ueber
6 die gRC-queue geschickt und landen beim gDC der hardwarespezifisch ist, meist aber auf einen
7 gPixmap aufsetzt (und damit unbeschleunigt ist).
19 #include <lib/base/elock.h>
20 #include <lib/base/message.h>
21 #include <lib/gdi/erect.h>
22 #include <lib/gdi/gpixmap.h>
23 #include <lib/gdi/region.h>
24 #include <lib/gdi/gfont.h>
38 fill, fillRegion, clear,
49 setBackgroundColorRGB,
50 setForegroundColorRGB,
54 setClip, addClip, popClip,
62 enableSpinner, disableSpinner, incrementSpinner,
146 /* gRC is the singleton which controls the fifo and dispatches commands */
147 class gRC: public iObject, public Object
151 friend class gPainter;
152 static gRC *instance;
155 static void *thread_wrapper(void *ptr);
156 pthread_t the_thread;
157 pthread_mutex_t mutex;
162 gOpcode queue[MAXSIZE];
165 eFixedMessagePump<int> m_notify_pump;
166 void recv_notify(const int &i);
168 ePtr<gDC> m_spinner_dc;
169 int m_spinner_enabled;
171 void enableSpinner();
172 void disableSpinner();
178 void submit(const gOpcode &o);
180 Signal0<void> notify;
182 void setSpinnerDC(gDC *dc) { m_spinner_dc = dc; }
184 static gRC *getInstance();
187 /* gPainter is the user frontend, which in turn sends commands through gRC */
195 void begin(const eRect &rect);
198 gPainter(gDC *dc, eRect rect=eRect());
201 void setBackgroundColor(const gColor &color);
202 void setForegroundColor(const gColor &color);
204 void setBackgroundColor(const gRGB &color);
205 void setForegroundColor(const gRGB &color);
207 void setFont(gFont *font);
208 /* flags only THESE: */
211 // todo, make mask. you cannot align both right AND center AND block ;)
212 RT_HALIGN_LEFT = 0, /* default */
214 RT_HALIGN_CENTER = 2,
217 RT_VALIGN_TOP = 0, /* default */
218 RT_VALIGN_CENTER = 8,
219 RT_VALIGN_BOTTOM = 16,
223 void renderText(const eRect &position, const std::string &string, int flags=0);
225 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
227 void fill(const eRect &area);
228 void fill(const gRegion &area);
237 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
239 void setPalette(gRGB *colors, int start=0, int len=256);
240 void setPalette(gPixmap *source);
241 void mergePalette(gPixmap *target);
243 void line(ePoint start, ePoint end);
245 void setOffset(ePoint abs);
246 void moveOffset(ePoint rel);
249 void resetClip(const gRegion &clip);
250 void clip(const gRegion &clip);
261 class gDC: public iObject
266 ePtr<gPixmap> m_pixmap;
268 gColor m_foreground_color, m_background_color;
269 gRGB m_foreground_color_rgb, m_background_color_rgb;
270 ePtr<gFont> m_current_font;
271 ePoint m_current_offset;
273 std::stack<gRegion> m_clip_stack;
274 gRegion m_current_clip;
276 ePtr<gPixmap> m_spinner_saved, m_spinner_temp;
277 ePtr<gPixmap> *m_spinner_pic;
279 int m_spinner_num, m_spinner_i;
281 virtual void exec(gOpcode *opcode);
285 gDC(gPixmap *pixmap);
288 gRegion &getClip() { return m_current_clip; }
289 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
290 gRGB getRGB(gColor col);
291 virtual eSize size() { return m_pixmap->size(); }
292 virtual int islocked() { return 0; }
294 void enableSpinner();
295 void disableSpinner();
296 void incrementSpinner();
297 void setSpinner(eRect pos, ePtr<gPixmap> *pic, int len);