| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
#include <fontforge-config.h> |
| 29 |
|
| 30 |
#include "gdraw.h" |
| 31 |
#include "gdrawP.h" |
| 32 |
#include "ggadgetP.h" |
| 33 |
#include "gkeysym.h" |
| 34 |
#include "ustring.h" |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
GDisplay *screen_display = NULL; |
| 41 |
|
| 42 |
int GDrawPointsToPixels(GWindow gw,int points) { |
| 43 |
if ( gw==NULL ) { |
| 44 |
if ( screen_display==NULL ) |
| 45 |
return( PointToPixel(points,100)); |
| 46 |
gw = screen_display->groot; |
| 47 |
} |
| 48 |
return( PointToPixel(points,gw->display->res)); |
| 49 |
} |
| 50 |
|
| 51 |
int GDrawPixelsToPoints(GWindow gw,int pixels) { |
| 52 |
if ( gw==NULL ) { |
| 53 |
if ( screen_display==NULL ) |
| 54 |
return( PixelToPoint(pixels,100)); |
| 55 |
gw = screen_display->groot; |
| 56 |
} |
| 57 |
return( PixelToPoint(pixels,gw->display->res)); |
| 58 |
} |
| 59 |
|
| 60 |
void GDrawSetDefaultIcon(GWindow icon) { |
| 61 |
(icon->display->funcs->setDefaultIcon)(icon); |
| 62 |
} |
| 63 |
|
| 64 |
GWindow GDrawCreateTopWindow(GDisplay *gdisp, GRect *pos, |
| 65 |
int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs) { |
| 66 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 67 |
return( (gdisp->funcs->createTopWindow)(gdisp,pos,eh,user_data,wattrs) ); |
| 68 |
} |
| 69 |
|
| 70 |
GWindow GDrawCreateSubWindow(GWindow w, GRect *pos, |
| 71 |
int (*eh)(GWindow,GEvent *), void *user_data, GWindowAttrs *wattrs) { |
| 72 |
return( (w->display->funcs->createSubWindow)(w,pos,eh,user_data,wattrs) ); |
| 73 |
} |
| 74 |
|
| 75 |
GWindow GDrawCreatePixmap(GDisplay *gdisp, GWindow similar, uint16_t width, uint16_t height) { |
| 76 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 77 |
return( (gdisp->funcs->createPixmap)(gdisp,similar,width,height)); |
| 78 |
} |
| 79 |
|
| 80 |
GWindow GDrawCreateBitmap(GDisplay *gdisp, uint16_t width, uint16_t height, uint8_t *data) { |
| 81 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 82 |
return( (gdisp->funcs->createBitmap)(gdisp,width,height,data)); |
| 83 |
} |
| 84 |
|
| 85 |
GCursor GDrawCreateCursor(GWindow src,GWindow mask,Color fg,Color bg, |
| 86 |
int16_t x, int16_t y ) { |
| 87 |
return( (src->display->funcs->createCursor)(src,mask,fg,bg,x,y)); |
| 88 |
} |
| 89 |
|
| 90 |
void GDrawDestroyWindow(GWindow w) { |
| 91 |
(w->display->funcs->destroyWindow)(w); |
| 92 |
} |
| 93 |
|
| 94 |
void GDrawSetZoom(GWindow w,GRect *zoom, enum gzoom_flags flags) { |
| 95 |
(w->display->funcs->setZoom)(w,zoom,flags); |
| 96 |
} |
| 97 |
|
| 98 |
int GDrawNativeWindowExists(GDisplay *gdisp, void *native) { |
| 99 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 100 |
return( (gdisp->funcs->nativeWindowExists)(gdisp,native) ); |
| 101 |
} |
| 102 |
|
| 103 |
void GDrawSetWindowBackground(GWindow w,Color col) { |
| 104 |
(w->display->funcs->setWindowBackground)(w,col); |
| 105 |
} |
| 106 |
|
| 107 |
int GDrawSetDither(GDisplay *gdisp, int dither) { |
| 108 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 109 |
return( (gdisp->funcs->setDither)(gdisp,dither) ); |
| 110 |
} |
| 111 |
|
| 112 |
void GDrawSetVisible(GWindow w, int visible) { |
| 113 |
(w->display->funcs->setVisible)(w,visible); |
| 114 |
} |
| 115 |
|
| 116 |
int GDrawIsVisible(GWindow w) { |
| 117 |
if ( w==NULL ) |
| 118 |
return( false ); |
| 119 |
while ( w!=NULL && ( w->is_visible || w->is_pixmap )) |
| 120 |
w = w->parent; |
| 121 |
return( w==NULL ); |
| 122 |
} |
| 123 |
|
| 124 |
void GDrawMove(GWindow w, int32_t x, int32_t y) { |
| 125 |
(w->display->funcs->move)(w,x,y); |
| 126 |
} |
| 127 |
|
| 128 |
void GDrawTrueMove(GWindow w, int32_t x, int32_t y) { |
| 129 |
(w->display->funcs->trueMove)(w,x,y); |
| 130 |
} |
| 131 |
|
| 132 |
void GDrawResize(GWindow w, int32_t width, int32_t height) { |
| 133 |
(w->display->funcs->resize)(w,width,height); |
| 134 |
} |
| 135 |
|
| 136 |
void GDrawMoveResize(GWindow w, int32_t x, int32_t y, int32_t width, int32_t height) { |
| 137 |
(w->display->funcs->moveResize)(w,x,y,width,height); |
| 138 |
} |
| 139 |
|
| 140 |
GWindow GDrawGetRoot(GDisplay *gdisp) { |
| 141 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 142 |
return(gdisp->groot); |
| 143 |
} |
| 144 |
|
| 145 |
Color GDrawGetDefaultBackground(GDisplay *gdisp) { |
| 146 |
return _GDraw_res_bg; |
| 147 |
} |
| 148 |
|
| 149 |
Color GDrawGetDefaultForeground(GDisplay *gdisp) { |
| 150 |
return _GDraw_res_fg; |
| 151 |
} |
| 152 |
|
| 153 |
Color GDrawGetWarningForeground(GDisplay *gdisp) { |
| 154 |
return _GDraw_res_warnfg; |
| 155 |
} |
| 156 |
|
| 157 |
GRect *GDrawGetSize(GWindow w, GRect *ret) { |
| 158 |
*ret = w->pos; |
| 159 |
return(ret); |
| 160 |
} |
| 161 |
|
| 162 |
GDrawEH GDrawGetEH(GWindow w) { |
| 163 |
return( w->eh ); |
| 164 |
} |
| 165 |
|
| 166 |
void GDrawSetEH(GWindow w,GDrawEH eh) { |
| 167 |
w->eh = eh; |
| 168 |
} |
| 169 |
|
| 170 |
void GDrawGetPointerPosition(GWindow w, GEvent *ret) { |
| 171 |
(w->display->funcs->getPointerPos)(w,ret); |
| 172 |
} |
| 173 |
|
| 174 |
GWindow GDrawGetPointerWindow(GWindow w) { |
| 175 |
return( (w->display->funcs->getPointerWindow)(w)); |
| 176 |
} |
| 177 |
|
| 178 |
void GDrawRaise(GWindow w) { |
| 179 |
(w->display->funcs->raise)(w); |
| 180 |
} |
| 181 |
|
| 182 |
void GDrawSetWindowTitles8(GWindow w, const char *title, const char *icontit) { |
| 183 |
(w->display->funcs->setWindowTitles8)(w,title,icontit); |
| 184 |
} |
| 185 |
|
| 186 |
char *GDrawGetWindowTitle8(GWindow w) { |
| 187 |
return( (w->display->funcs->getWindowTitle8)(w) ); |
| 188 |
} |
| 189 |
|
| 190 |
void GDrawSetTransientFor(GWindow transient, GWindow owner) { |
| 191 |
(transient->display->funcs->setTransientFor)(transient,owner); |
| 192 |
} |
| 193 |
|
| 194 |
void GDrawSetCursor(GWindow w, GCursor ct) { |
| 195 |
(w->display->funcs->setCursor)(w,ct); |
| 196 |
} |
| 197 |
|
| 198 |
GCursor GDrawGetCursor(GWindow w) { |
| 199 |
return( (w->display->funcs->getCursor)(w) ); |
| 200 |
} |
| 201 |
|
| 202 |
void GDrawTranslateCoordinates(GWindow from,GWindow to, GPoint *pt) { |
| 203 |
GDisplay *gd; |
| 204 |
if ( from!=NULL ) |
| 205 |
gd = from->display; |
| 206 |
else if ( to!=NULL ) |
| 207 |
gd = to->display; |
| 208 |
else |
| 209 |
return; |
| 210 |
(gd->funcs->translateCoordinates)(from,to,pt); |
| 211 |
} |
| 212 |
|
| 213 |
int32_t GDrawEventInWindow(GWindow inme,GEvent *event) { |
| 214 |
GPoint pt; |
| 215 |
if ( event->type<et_char || event->type>et_crossing ) |
| 216 |
return( false ); |
| 217 |
pt.x = event->u.mouse.x; pt.y = event->u.mouse.y; |
| 218 |
(inme->display->funcs->translateCoordinates)(event->w,inme,&pt); |
| 219 |
if ( pt.x<0 || pt.y<0 || pt.x >= inme->pos.width || pt.y >= inme->pos.height ) |
| 220 |
return( false ); |
| 221 |
|
| 222 |
return( true ); |
| 223 |
} |
| 224 |
|
| 225 |
GWindow GDrawGetParentWindow(GWindow gw) { |
| 226 |
return( gw->parent ); |
| 227 |
} |
| 228 |
|
| 229 |
int GDrawWindowIsAncestor(GWindow ancester, GWindow descendent) { |
| 230 |
while ( descendent!=NULL && descendent!=ancester ) |
| 231 |
descendent = descendent->parent; |
| 232 |
return( descendent==ancester ); |
| 233 |
} |
| 234 |
|
| 235 |
void GDrawSetUserData(GWindow gw, void *ud) { |
| 236 |
gw->user_data = ud; |
| 237 |
} |
| 238 |
|
| 239 |
void *GDrawGetUserData(GWindow gw) { |
| 240 |
if( !gw ) |
| 241 |
return 0; |
| 242 |
return( gw->user_data ); |
| 243 |
} |
| 244 |
|
| 245 |
void GDrawSetWindowTypeName(GWindow gw, char* name) |
| 246 |
{ |
| 247 |
gw->window_type_name = name; |
| 248 |
} |
| 249 |
|
| 250 |
char* GDrawGetWindowTypeName(GWindow gw) |
| 251 |
{ |
| 252 |
if(!gw) |
| 253 |
return 0; |
| 254 |
|
| 255 |
return(gw->window_type_name); |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
GDisplay *GDrawGetDisplayOfWindow(GWindow gw) { |
| 260 |
if ( gw==NULL ) |
| 261 |
return( screen_display ); |
| 262 |
|
| 263 |
return( gw->display ); |
| 264 |
} |
| 265 |
|
| 266 |
void GDrawBeep(GDisplay *gdisp) { |
| 267 |
if ( gdisp==NULL ) gdisp = screen_display; |
| 268 |
(gdisp->funcs->beep)(gdisp); |
| 269 |
} |
| 270 |
|
| 271 |
bool GDrawClipContains(const GWindow w, const GRect *other, bool rev) { |
| 272 |
const GRect *parent = rev ? other : &w->ggc->clip; |
| 273 |
const GRect *child = rev ? &w->ggc->clip : other; |
| 274 |
return child->x >= parent->x && |
| 275 |
(child->x + child->width) <= (parent->x + parent->width) && |
| 276 |
child->y >= parent->y && |
| 277 |
(child->y + child->height) <= (parent->y + parent->height); |
| 278 |
} |
| 279 |
|
| 280 |
bool GDrawClipOverlaps(const GWindow w, const GRect *other) { |
| 281 |
return w->ggc->clip.x < (other->x + other->width) && |
| 282 |
(w->ggc->clip.x + w->ggc->clip.width) > other->x && |
| 283 |
w->ggc->clip.y < (other->y + other->height) && |
| 284 |
(w->ggc->clip.y + w->ggc->clip.height) > other->y; |
| 285 |
} |
| 286 |
|
| 287 |
void GDrawGetClip(GWindow w, GRect *ret) { |
| 288 |
*ret = w->ggc->clip; |
| 289 |
} |
| 290 |
|
| 291 |
void GDrawPushClip(GWindow w, GRect *rct, GRect *old) { |
| 292 |
(w->display->funcs->pushClip)(w,rct,old); |
| 293 |
} |
| 294 |
|
| 295 |
void GDrawPushClipOnly(GWindow w) |
| 296 |
{ |
| 297 |
if( w->display->funcs->PushClipOnly ) |
| 298 |
(w->display->funcs->PushClipOnly)( w ); |
| 299 |
} |
| 300 |
|
| 301 |
void GDrawClipPreserve(GWindow w) |
| 302 |
{ |
| 303 |
if( w->display->funcs->ClipPreserve ) |
| 304 |
(w->display->funcs->ClipPreserve)( w ); |
| 305 |
} |
| 306 |
|
| 307 |
|
| 308 |
void GDrawPopClip(GWindow w, GRect *old) { |
| 309 |
(w->display->funcs->popClip)(w,old); |
| 310 |
} |
| 311 |
|
| 312 |
void GDrawSetDashedLine(GWindow w,int16_t dash_len, int16_t skip_len, int16_t off) { |
| 313 |
w->ggc->dash_offset = off; |
| 314 |
w->ggc->dash_len = dash_len; |
| 315 |
w->ggc->skip_len = skip_len; |
| 316 |
} |
| 317 |
|
| 318 |
void GDrawSetStippled(GWindow w,int16_t ts, int32_t yoff,int32_t xoff) { |
| 319 |
w->ggc->ts = ts; |
| 320 |
w->ggc->ts_xoff = xoff; w->ggc->ts_yoff = yoff; |
| 321 |
} |
| 322 |
|
| 323 |
void GDrawSetLineWidth(GWindow w,int16_t width) { |
| 324 |
w->ggc->line_width = width; |
| 325 |
} |
| 326 |
|
| 327 |
int16_t GDrawGetLineWidth( GWindow w ) |
| 328 |
{ |
| 329 |
return w->ggc->line_width; |
| 330 |
} |
| 331 |
|
| 332 |
void GDrawSetBackground(GWindow w,Color col) { |
| 333 |
w->ggc->bg = col; |
| 334 |
} |
| 335 |
|
| 336 |
void GDrawDrawLine(GWindow w, int32_t x,int32_t y, int32_t xend,int32_t yend, Color col) { |
| 337 |
if ( col!=COLOR_UNKNOWN ) |
| 338 |
(w->display->funcs->drawLine)(w,x,y,xend,yend,col); |
| 339 |
} |
| 340 |
|
| 341 |
void GDrawDrawArrow(GWindow w, int32_t x,int32_t y, int32_t xend,int32_t yend, int arrows, Color col) { |
| 342 |
if ( col!=COLOR_UNKNOWN ) |
| 343 |
(w->display->funcs->drawArrow)(w,x,y,xend,yend,arrows,col); |
| 344 |
} |
| 345 |
|
| 346 |
void GDrawDrawRect(GWindow w, GRect *rect, Color col) { |
| 347 |
if ( col!=COLOR_UNKNOWN ) |
| 348 |
(w->display->funcs->drawRect)(w,rect,col); |
| 349 |
} |
| 350 |
|
| 351 |
void GDrawFillRect(GWindow w, GRect *rect, Color col) { |
| 352 |
GRect temp; |
| 353 |
if ( rect==NULL ) { |
| 354 |
temp.x = temp.y = 0; temp.width = w->pos.width; temp.height = w->pos.height; |
| 355 |
rect = &temp; |
| 356 |
} |
| 357 |
if ( col!=COLOR_UNKNOWN ) |
| 358 |
(w->display->funcs->fillRect)(w,rect,col); |
| 359 |
} |
| 360 |
|
| 361 |
void GDrawFillRoundRect(GWindow w, GRect *rect, int radius, Color col) { |
| 362 |
GRect temp; |
| 363 |
if ( rect==NULL ) { |
| 364 |
temp.x = temp.y = 0; temp.width = w->pos.width; temp.height = w->pos.height; |
| 365 |
rect = &temp; |
| 366 |
} |
| 367 |
if ( col!=COLOR_UNKNOWN ) |
| 368 |
(w->display->funcs->fillRoundRect)(w,rect,radius,col); |
| 369 |
} |
| 370 |
|
| 371 |
void GDrawDrawElipse(GWindow w, GRect *rect, Color col) { |
| 372 |
if ( col!=COLOR_UNKNOWN ) |
| 373 |
(w->display->funcs->drawElipse)(w,rect,col); |
| 374 |
} |
| 375 |
|
| 376 |
void GDrawFillElipse(GWindow w, GRect *rect, Color col) { |
| 377 |
if ( col!=COLOR_UNKNOWN ) |
| 378 |
(w->display->funcs->fillElipse)(w,rect,col); |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
void GDrawDrawArc(GWindow w, GRect *rect, int32_t sangle, int32_t tangle, Color col) { |
| 385 |
if ( col!=COLOR_UNKNOWN ) |
| 386 |
(w->display->funcs->drawArc)(w,rect,sangle,tangle,col); |
| 387 |
} |
| 388 |
|
| 389 |
void GDrawDrawPoly(GWindow w, GPoint *pts, int16_t cnt, Color col) { |
| 390 |
if ( col!=COLOR_UNKNOWN ) |
| 391 |
(w->display->funcs->drawPoly)(w,pts,cnt,col); |
| 392 |
} |
| 393 |
|
| 394 |
void GDrawFillPoly(GWindow w, GPoint *pts, int16_t cnt, Color col) { |
| 395 |
if ( col!=COLOR_UNKNOWN ) |
| 396 |
(w->display->funcs->fillPoly)(w,pts,cnt,col); |
| 397 |
} |
| 398 |
|
| 399 |
void GDrawScroll(GWindow w, GRect *rect, int32_t hor, int32_t vert) { |
| 400 |
(w->display->funcs->scroll)(w,rect,hor,vert); |
| 401 |
} |
| 402 |
|
| 403 |
|
| 404 |
void GDrawDrawImage(GWindow w, GImage *img, GRect *src, int32_t x, int32_t y) { |
| 405 |
int width = GImageGetWidth(img); |
| 406 |
int height = GImageGetHeight(img); |
| 407 |
GRect r = src ? *src : (GRect){0, 0, width, height}; |
| 408 |
|
| 409 |
if (x < w->ggc->clip.x) { |
| 410 |
r.x += w->ggc->clip.x - x; |
| 411 |
r.width -= w->ggc->clip.x - x; |
| 412 |
x = w->ggc->clip.x; |
| 413 |
} |
| 414 |
if (y < w->ggc->clip.y) { |
| 415 |
r.y += w->ggc->clip.y - y; |
| 416 |
r.height -= w->ggc->clip.y - y; |
| 417 |
y = w->ggc->clip.y; |
| 418 |
} |
| 419 |
if (r.x < 0) { |
| 420 |
r.width += r.x; |
| 421 |
r.x = 0; |
| 422 |
} |
| 423 |
if (r.y < 0) { |
| 424 |
r.height += r.y; |
| 425 |
r.y = 0; |
| 426 |
} |
| 427 |
if (r.width > width) |
| 428 |
r.width = width; |
| 429 |
if (r.height > height) |
| 430 |
r.height = height; |
| 431 |
if (x + r.width > w->ggc->clip.x + w->ggc->clip.width) |
| 432 |
r.width = w->ggc->clip.x + w->ggc->clip.width - x; |
| 433 |
if (y + r.height > w->ggc->clip.y + w->ggc->clip.height) |
| 434 |
r.height = w->ggc->clip.y + w->ggc->clip.height - y; |
| 435 |
if (r.width <= 0 || r.height <= 0) |
| 436 |
return; |
| 437 |
|
| 438 |
(w->display->funcs->drawImage)(w,img,&r,x,y); |
| 439 |
} |
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
void GDrawDrawScaledImage(GWindow w, GImage *img, int32_t x, int32_t y) { |
| 444 |
GRect r; |
| 445 |
|
| 446 |
r.x = r.y = 0; |
| 447 |
r.width = GImageGetScaledWidth(w,img); |
| 448 |
r.height = GImageGetScaledHeight(w,img); |
| 449 |
(w->display->funcs->drawImage)(w,img,&r,x,y); |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
void GDrawDrawGlyph(GWindow w, GImage *img, GRect *src, int32_t x, int32_t y) { |
| 456 |
GRect r; |
| 457 |
if ( src==NULL ) { |
| 458 |
struct _GImage *base = img->list_len==0?img->u.image:img->u.images[0]; |
| 459 |
r.x = r.y = 0; |
| 460 |
r.width = base->width; r.height = base->height; |
| 461 |
src = &r; |
| 462 |
} |
| 463 |
(w->display->funcs->drawGlyph)(w,img,src,x,y); |
| 464 |
} |
| 465 |
|
| 466 |
|
| 467 |
void GDrawDrawPixmap(GWindow w, GWindow pixmap, GRect *src, int32_t x, int32_t y) { |
| 468 |
(w->display->funcs->drawPixmap)(w,pixmap,src,x,y); |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
void GDrawDrawImageMagnified(GWindow w, GImage *img, GRect *dest, int32_t x, int32_t y, |
| 477 |
int32_t width, int32_t height) { |
| 478 |
GRect temp; |
| 479 |
struct _GImage *base = img->list_len==0?img->u.image:img->u.images[0]; |
| 480 |
|
| 481 |
|
| 482 |
if ( base->width==width && base->height==height ) { |
| 483 |
GDrawDrawImage(w, img, dest, x, y); |
| 484 |
return; |
| 485 |
} |
| 486 |
if ( dest==NULL ) { |
| 487 |
temp.x = temp.y = 0; |
| 488 |
temp.width = width; temp.height = height; |
| 489 |
dest = &temp; |
| 490 |
} else if ( dest->x<0 || dest->y<0 || |
| 491 |
dest->x+dest->width > width || dest->y+dest->height > height ) { |
| 492 |
temp = *dest; |
| 493 |
if ( temp.x<0 ) { temp.width += temp.x; temp.x = 0; } |
| 494 |
if ( temp.y<0 ) { temp.height += temp.y; temp.y = 0; } |
| 495 |
if ( temp.x+temp.width>width ) temp.width = width-temp.x; |
| 496 |
if ( temp.y+temp.height>height ) temp.height = height-temp.y; |
| 497 |
dest = &temp; |
| 498 |
} |
| 499 |
(w->display->funcs->drawImageMag)(w,img,dest,x,y, width, height); |
| 500 |
} |
| 501 |
|
| 502 |
void GDrawWindowFontMetrics(GWindow w,FontInstance *fi,int *as, int *ds, int *ld) { |
| 503 |
(w->display->funcs->getFontMetrics)(w,fi,as,ds,ld); |
| 504 |
} |
| 505 |
|
| 506 |
void GDrawDefaultFontMetrics(GWindow w,int *as, int *ds, int *ld) { |
| 507 |
(w->display->funcs->getFontMetrics)(w,_ggadget_default_font.fi,as,ds,ld); |
| 508 |
} |
| 509 |
|
| 510 |
void GDrawPathStartNew(GWindow w) { |
| 511 |
(w->display->funcs->startNewPath)(w); |
| 512 |
} |
| 513 |
|
| 514 |
void GDrawPathStartSubNew(GWindow w) { |
| 515 |
(w->display->funcs->startNewSubPath)(w); |
| 516 |
} |
| 517 |
|
| 518 |
int GDrawFillRuleSetWinding(GWindow w) { |
| 519 |
return (w->display->funcs->fillRuleSetWinding)(w); |
| 520 |
} |
| 521 |
|
| 522 |
void GDrawPathClose(GWindow w) { |
| 523 |
(w->display->funcs->closePath)(w); |
| 524 |
} |
| 525 |
|
| 526 |
void GDrawPathMoveTo(GWindow w,double x, double y) { |
| 527 |
(w->display->funcs->moveto)(w,x,y); |
| 528 |
} |
| 529 |
|
| 530 |
void GDrawPathLineTo(GWindow w,double x, double y) { |
| 531 |
(w->display->funcs->lineto)(w,x,y); |
| 532 |
} |
| 533 |
|
| 534 |
void GDrawPathCurveTo(GWindow w, |
| 535 |
double cx1, double cy1, |
| 536 |
double cx2, double cy2, |
| 537 |
double x, double y) { |
| 538 |
(w->display->funcs->curveto)(w,cx1,cy1,cx2,cy2,x,y); |
| 539 |
} |
| 540 |
|
| 541 |
void GDrawPathStroke(GWindow w,Color col) { |
| 542 |
(w->display->funcs->stroke)(w,col); |
| 543 |
} |
| 544 |
|
| 545 |
void GDrawPathFill(GWindow w,Color col) { |
| 546 |
(w->display->funcs->fill)(w,col); |
| 547 |
} |
| 548 |
|
| 549 |
void GDrawPathFillAndStroke(GWindow w,Color fillcol, Color strokecol) { |
| 550 |
(w->display->funcs->fillAndStroke)(w,fillcol,strokecol); |
| 551 |
} |
| 552 |
|
| 553 |
void GDrawLayoutInit(GWindow w, char *text, int cnt, GFont *fi) { |
| 554 |
(w->display->funcs->layoutInit)(w,text,cnt,fi); |
| 555 |
} |
| 556 |
|
| 557 |
void GDrawLayoutDraw(GWindow w, int32_t x, int32_t y, Color fg) { |
| 558 |
(w->display->funcs->layoutDraw)(w,x,y,fg); |
| 559 |
} |
| 560 |
|
| 561 |
void GDrawLayoutIndexToPos(GWindow w, int index, GRect *pos) { |
| 562 |
(w->display->funcs->layoutIndexToPos)(w,index,pos); |
| 563 |
} |
| 564 |
|
| 565 |
int GDrawLayoutXYToIndex(GWindow w, int x, int y) { |
| 566 |
return( (w->display->funcs->layoutXYToIndex)(w,x,y) ); |
| 567 |
} |
| 568 |
|
| 569 |
void GDrawLayoutExtents(GWindow w, GRect *size) { |
| 570 |
(w->display->funcs->layoutExtents)(w,size); |
| 571 |
} |
| 572 |
|
| 573 |
void GDrawLayoutSetWidth(GWindow w, int width) { |
| 574 |
(w->display->funcs->layoutSetWidth)(w,width); |
| 575 |
} |
| 576 |
|
| 577 |
int GDrawLayoutLineCount(GWindow w) { |
| 578 |
return( (w->display->funcs->layoutLineCount)(w) ); |
| 579 |
} |
| 580 |
|
| 581 |
int GDrawLayoutLineStart(GWindow w,int line) { |
| 582 |
return( (w->display->funcs->layoutLineStart)(w,line) ); |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
GIC *GDrawCreateInputContext(GWindow w,enum gic_style def_style) { |
| 587 |
return(w->display->funcs->createInputContext)(w,def_style); |
| 588 |
} |
| 589 |
|
| 590 |
void GDrawSetGIC(GWindow w, GIC *gic, int x, int y) { |
| 591 |
(w->display->funcs->setGIC)(w,gic,x,y); |
| 592 |
} |
| 593 |
|
| 594 |
int GDrawKeyState(GWindow w, int keysym) { |
| 595 |
return (w->display->funcs->keyState)(w, keysym); |
| 596 |
} |
| 597 |
|
| 598 |
void GDrawGrabSelection(GWindow w,enum selnames sel) { |
| 599 |
(w->display->funcs->grabSelection)(w,sel); |
| 600 |
} |
| 601 |
|
| 602 |
void GDrawAddSelectionType(GWindow w,enum selnames sel,char *type, |
| 603 |
void *data,int32_t cnt,int32_t unitsize,void *(*gendata)(void *,int32_t *len), |
| 604 |
void (*freedata)(void *)) { |
| 605 |
(w->display->funcs->addSelectionType)(w,sel,type,data,cnt,unitsize,gendata,freedata); |
| 606 |
} |
| 607 |
|
| 608 |
void *GDrawRequestSelection(GWindow w,enum selnames sn, char *typename, int32_t *len) { |
| 609 |
return( (w->display->funcs->requestSelection)(w,sn,typename,len)); |
| 610 |
} |
| 611 |
|
| 612 |
int GDrawSelectionHasType(GWindow w,enum selnames sn, char *typename) { |
| 613 |
return( (w->display->funcs->selectionHasType)(w,sn,typename)); |
| 614 |
} |
| 615 |
|
| 616 |
void GDrawBindSelection(GDisplay *disp,enum selnames sel, char *atomname) { |
| 617 |
if ( disp==NULL ) |
| 618 |
disp = screen_display; |
| 619 |
if (disp != NULL) |
| 620 |
(disp->funcs->bindSelection)(disp,sel,atomname); |
| 621 |
} |
| 622 |
|
| 623 |
int GDrawSelectionOwned(GDisplay *disp,enum selnames sel) { |
| 624 |
if ( disp==NULL ) |
| 625 |
disp = screen_display; |
| 626 |
if (disp != NULL) |
| 627 |
return( (disp->funcs->selectionHasOwner)(disp,sel)); |
| 628 |
else |
| 629 |
return -1; |
| 630 |
} |
| 631 |
|
| 632 |
int GDrawEnableExposeRequests(GWindow w,int enabled) { |
| 633 |
int old = w->disable_expose_requests; |
| 634 |
w->disable_expose_requests = enabled; |
| 635 |
return( old ); |
| 636 |
} |
| 637 |
|
| 638 |
void GDrawRequestExpose(GWindow w, GRect *rect, int doclear) { |
| 639 |
if ( !GDrawIsVisible(w) || w->disable_expose_requests ) |
| 640 |
return; |
| 641 |
(w->display->funcs->requestExpose)(w,rect,doclear); |
| 642 |
} |
| 643 |
|
| 644 |
void GDrawForceUpdate(GWindow w) { |
| 645 |
(w->display->funcs->forceUpdate)(w); |
| 646 |
} |
| 647 |
|
| 648 |
void GDrawSync(GDisplay *gdisp) { |
| 649 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 650 |
if (gdisp != NULL) |
| 651 |
(gdisp->funcs->sync)(gdisp); |
| 652 |
} |
| 653 |
|
| 654 |
void GDrawPointerUngrab(GDisplay *gdisp) { |
| 655 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 656 |
if (gdisp != NULL) |
| 657 |
(gdisp->funcs->pointerUngrab)(gdisp); |
| 658 |
} |
| 659 |
|
| 660 |
void GDrawPointerGrab(GWindow w) { |
| 661 |
(w->display->funcs->pointerGrab)(w); |
| 662 |
} |
| 663 |
|
| 664 |
void GDrawProcessOneEvent(GDisplay *gdisp) { |
| 665 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 666 |
if (gdisp != NULL) |
| 667 |
(gdisp->funcs->processOneEvent)(gdisp); |
| 668 |
} |
| 669 |
|
| 670 |
void GDrawSkipMouseMoveEvents(GWindow w,GEvent *last) { |
| 671 |
(w->display->funcs->skipMouseMoveEvents)(w,last); |
| 672 |
} |
| 673 |
|
| 674 |
void GDrawProcessPendingEvents(GDisplay *gdisp) { |
| 675 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 676 |
if (gdisp != NULL) |
| 677 |
(gdisp->funcs->processPendingEvents)(gdisp); |
| 678 |
} |
| 679 |
|
| 680 |
void GDrawEventLoop(GDisplay *gdisp) { |
| 681 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 682 |
if (gdisp != NULL) |
| 683 |
(gdisp->funcs->eventLoop)(gdisp); |
| 684 |
} |
| 685 |
|
| 686 |
void GDrawPostEvent(GEvent *e) { |
| 687 |
GDisplay *gdisp = e->w->display; |
| 688 |
if ( gdisp==NULL ) gdisp=screen_display; |
| 689 |
if (gdisp != NULL) |
| 690 |
(gdisp->funcs->postEvent)(e); |
| 691 |
} |
| 692 |
|
| 693 |
void GDrawPostDragEvent(GWindow w,GEvent *mouse,enum event_type et) { |
| 694 |
GDisplay *gdisp = w->display; |
| 695 |
(gdisp->funcs->postDragEvent)(w,mouse,et); |
| 696 |
} |
| 697 |
|
| 698 |
GTimer *GDrawRequestTimer(GWindow w,int32_t time_from_now,int32_t frequency, |
| 699 |
void *userdata) { |
| 700 |
return( (w->display->funcs->requestTimer)(w,time_from_now,frequency,userdata)); |
| 701 |
} |
| 702 |
|
| 703 |
void GDrawCancelTimer(GTimer *timer) { |
| 704 |
GDisplay *gdisp; |
| 705 |
if ( timer==NULL ) |
| 706 |
return; |
| 707 |
gdisp=timer->owner->display; |
| 708 |
(gdisp->funcs->cancelTimer)(timer); |
| 709 |
} |
| 710 |
|
| 711 |
int GDrawRequestDeviceEvents(GWindow w,int devcnt,struct gdeveventmask *de) { |
| 712 |
return( (w->display->funcs->requestDeviceEvents)(w,devcnt,de) ); |
| 713 |
} |
| 714 |
|
| 715 |
int GDrawShortcutKeyMatches(const GEvent *e, unichar_t ch) { |
| 716 |
return (e->w->display->funcs->shortcutKeyMatches)(e, ch); |
| 717 |
} |
| 718 |
|
| 719 |
void GDrawDestroyDisplays() { |
| 720 |
if (screen_display != NULL) { |
| 721 |
_GGDKDraw_DestroyDisplay(screen_display); |
| 722 |
screen_display = NULL; |
| 723 |
} |
| 724 |
} |
| 725 |
|
| 726 |
void GDrawCreateDisplays(char *displayname,char *programname) { |
| 727 |
screen_display = _GGDKDraw_CreateDisplay(displayname, programname); |
| 728 |
if ( screen_display==NULL ) { |
| 729 |
fprintf( stderr, "Could not open screen.\n" ); |
| 730 |
#if __Mac |
| 731 |
fprintf( stderr, "You must start X11 before you can start %s\n", programname); |
| 732 |
fprintf( stderr, " X11 is optional software found on your install DVD.\n" ); |
| 733 |
#elif __CygWin |
| 734 |
fprintf( stderr, "You must start X11 before you can start %s\n", programname); |
| 735 |
fprintf( stderr, " X11 may be obtained from the cygwin site in a separate package.\n" ); |
| 736 |
#endif |
| 737 |
exit(1); |
| 738 |
} |
| 739 |
} |