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>
37 fill, fillRegion, clear,
48 setBackgroundColorRGB,
49 setForegroundColorRGB,
53 setClip, addClip, popClip,
61 enableSpinner, disableSpinner, incrementSpinner,
145 /* gRC is the singleton which controls the fifo and dispatches commands */
146 class gRC: public iObject, public Object
149 friend class gPainter;
150 static gRC *instance;
153 static void *thread_wrapper(void *ptr);
154 pthread_t the_thread;
155 pthread_mutex_t mutex;
160 gOpcode queue[MAXSIZE];
163 eFixedMessagePump<int> m_notify_pump;
164 void recv_notify(const int &i);
166 ePtr<gDC> m_spinner_dc;
167 int m_spinner_enabled;
169 void enableSpinner();
170 void disableSpinner();
176 void submit(const gOpcode &o);
178 Signal0<void> notify;
180 void setSpinnerDC(gDC *dc) { m_spinner_dc = dc; }
182 static gRC *getInstance();
185 /* gPainter is the user frontend, which in turn sends commands through gRC */
193 void begin(const eRect &rect);
196 gPainter(gDC *dc, eRect rect=eRect());
199 void setBackgroundColor(const gColor &color);
200 void setForegroundColor(const gColor &color);
202 void setBackgroundColor(const gRGB &color);
203 void setForegroundColor(const gRGB &color);
205 void setFont(gFont *font);
206 /* flags only THESE: */
209 // todo, make mask. you cannot align both right AND center AND block ;)
210 RT_HALIGN_LEFT = 0, /* default */
212 RT_HALIGN_CENTER = 2,
215 RT_VALIGN_TOP = 0, /* default */
216 RT_VALIGN_CENTER = 8,
217 RT_VALIGN_BOTTOM = 16,
221 void renderText(const eRect &position, const std::string &string, int flags=0);
223 void renderPara(eTextPara *para, ePoint offset=ePoint(0, 0));
225 void fill(const eRect &area);
226 void fill(const gRegion &area);
236 void blit(gPixmap *pixmap, ePoint pos, const eRect &what=eRect(), int flags=0);
238 void setPalette(gRGB *colors, int start=0, int len=256);
239 void setPalette(gPixmap *source);
240 void mergePalette(gPixmap *target);
242 void line(ePoint start, ePoint end);
244 void setOffset(ePoint abs);
245 void moveOffset(ePoint rel);
248 void resetClip(const gRegion &clip);
249 void clip(const gRegion &clip);
257 class gDC: public iObject
261 ePtr<gPixmap> m_pixmap;
263 gColor m_foreground_color, m_background_color;
264 gRGB m_foreground_color_rgb, m_background_color_rgb;
265 ePtr<gFont> m_current_font;
266 ePoint m_current_offset;
268 std::stack<gRegion> m_clip_stack;
269 gRegion m_current_clip;
271 ePtr<gPixmap> m_spinner_saved, m_spinner_temp;
272 ePtr<gPixmap> *m_spinner_pic;
274 int m_spinner_num, m_spinner_i;
276 virtual void exec(gOpcode *opcode);
277 gDC(gPixmap *pixmap);
280 gRegion &getClip() { return m_current_clip; }
281 int getPixmap(ePtr<gPixmap> &pm) { pm = m_pixmap; return 0; }
282 gRGB getRGB(gColor col);
283 virtual eSize size() { return m_pixmap->size(); }
284 virtual int islocked() { return 0; }
286 void enableSpinner();
287 void disableSpinner();
288 void incrementSpinner();
289 void setSpinner(eRect pos, ePtr<gPixmap> *pic, int len);