Parcourir la source

cmGrDevCtx.c Added _cmGrDcOffs() macros.

This change is goes with cmGrFltk.cpp calls to cmGrDevCtxResize() which
now set the location as well as the size of the device context.
master
kevin il y a 11 ans
Parent
révision
9a65b1bbaa
1 fichiers modifiés avec 16 ajouts et 14 suppressions
  1. 16
    14
      cmGrDevCtx.c

+ 16
- 14
cmGrDevCtx.c Voir le fichier

@@ -8,6 +8,8 @@
8 8
 #include "cmGr.h"
9 9
 #include "cmGrDevCtx.h"
10 10
 
11
+#define _cmGrDcOffsX(p,xx) (xx) // ((p)->pext.loc.x + (xx))
12
+#define _cmGrDcOffsY(p,yy) (yy) // ((p)->pext.loc.y + (yy))
11 13
 
12 14
 cmGrDcH_t cmGrDcNullHandle = cmSTATIC_NULL_HANDLE;
13 15
 
@@ -212,7 +214,7 @@ cmGrDcRC_t      cmGrDevCtxResize(   cmGrDcH_t h, int x, int y, int  ww, int hh )
212 214
     goto errLabel;
213 215
   }
214 216
 
215
-  cmGrPExtSet(&p->pext,-x,-y,ww,hh);
217
+  cmGrPExtSet(&p->pext,x,y,ww,hh);
216 218
 
217 219
  errLabel:
218 220
   // force the current state to be reapplied to the new drawing context
@@ -346,13 +348,13 @@ void            cmGrDcSetPenStyle(   cmGrDcH_t h, unsigned style )
346 348
 void            cmGrDcDrawLine(  cmGrDcH_t h, int x0, int y0, int x1, int y1 )
347 349
 { 
348 350
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
349
-  p->dd->draw_line( p->ddArg, x0+p->pext.loc.x, y0+p->pext.loc.y, x1+p->pext.loc.x, y1+p->pext.loc.y );
351
+  p->dd->draw_line( p->ddArg, _cmGrDcOffsX(p,x0), _cmGrDcOffsY(p,y0), _cmGrDcOffsX(p,x1), _cmGrDcOffsY(p,y1) );
350 352
 }
351 353
 
352 354
 void            cmGrDcDrawRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
353 355
 {
354 356
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
355
-  p->dd->draw_rect( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
357
+  p->dd->draw_rect( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
356 358
 }
357 359
 
358 360
 void            cmGrDcDrawRectPExt(     cmGrDcH_t h, const cmGrPExt_t* pext )
@@ -361,43 +363,43 @@ void            cmGrDcDrawRectPExt(     cmGrDcH_t h, const cmGrPExt_t* pext )
361 363
 void            cmGrDcFillRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
362 364
 {
363 365
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
364
-  p->dd->fill_rect( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
366
+  p->dd->fill_rect( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
365 367
 }
366 368
 
367 369
 void            cmGrDcDrawEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
368 370
 {
369 371
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
370
-  p->dd->draw_ellipse( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
372
+  p->dd->draw_ellipse( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
371 373
 }
372 374
 
373 375
 void            cmGrDcFillEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
374 376
 {
375 377
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
376
-  p->dd->fill_ellipse( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
378
+  p->dd->fill_ellipse( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
377 379
 }
378 380
 
379 381
 void            cmGrDcDrawDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
380 382
 {
381 383
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
382
-  p->dd->draw_diamond( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
384
+  p->dd->draw_diamond( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
383 385
 }
384 386
 
385 387
 void            cmGrDcFillDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
386 388
 {
387 389
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
388
-  p->dd->fill_diamond( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh );
390
+  p->dd->fill_diamond( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh );
389 391
 }
390 392
 
391 393
 void            cmGrDcDrawTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
392 394
 {
393 395
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
394
-  p->dd->draw_triangle( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh, dirFlag );
396
+  p->dd->draw_triangle( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh, dirFlag );
395 397
 }
396 398
 
397 399
 void            cmGrDcFillTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
398 400
 {
399 401
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
400
-  p->dd->fill_triangle( p->ddArg, x+p->pext.loc.x, y+p->pext.loc.y, ww, hh, dirFlag );
402
+  p->dd->fill_triangle( p->ddArg, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), ww, hh, dirFlag );
401 403
 }
402 404
 
403 405
 
@@ -419,26 +421,26 @@ void            cmGrDcMeasure(     cmGrDcH_t h, const cmChar_t* text, cmGrPSz_t*
419 421
 void            cmGrDcDrawText(    cmGrDcH_t h, const cmChar_t* text, int x, int y )
420 422
 {
421 423
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
422
-  p->dd->draw_text( p->ddArg, text, x+p->pext.loc.x, y+p->pext.loc.y );
424
+  p->dd->draw_text( p->ddArg, text, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y) );
423 425
 }
424 426
 
425 427
 void            cmGrDcDrawTextRot( cmGrDcH_t h, const cmChar_t* text, int x, int y, int angle )
426 428
 {
427 429
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
428
-  p->dd->draw_text_rot( p->ddArg, text, x+p->pext.loc.x, y+p->pext.loc.y, angle );
430
+  p->dd->draw_text_rot( p->ddArg, text, _cmGrDcOffsX(p,x), _cmGrDcOffsY(p,y), angle );
429 431
 }
430 432
 
431 433
 
432 434
 void            cmGrDcReadImage(   cmGrDcH_t h, unsigned char* a, const cmGrPExt_t* pext )
433 435
 {
434 436
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
435
-  p->dd->read_image( p->ddArg, a, pext->loc.x+p->pext.loc.x, pext->loc.y+p->pext.loc.y, pext->sz.w, pext->sz.h );
437
+  p->dd->read_image( p->ddArg, a, _cmGrDcOffsX(p,pext->loc.x), _cmGrDcOffsY(p,pext->loc.y), pext->sz.w, pext->sz.h );
436 438
 }
437 439
 
438 440
 void            cmGrDcDrawImage(  cmGrDcH_t h, const unsigned char* a, const cmGrPExt_t* pext )
439 441
 {
440 442
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
441
-  p->dd->draw_image( p->ddArg, a, pext->loc.x+p->pext.loc.x, pext->loc.y+p->pext.loc.y, pext->sz.w, pext->sz.h );
443
+  p->dd->draw_image( p->ddArg, a, _cmGrDcOffsX(p,pext->loc.x), _cmGrDcOffsY(p,pext->loc.y), pext->sz.w, pext->sz.h );
442 444
 }
443 445
 
444 446
 

Chargement…
Annuler
Enregistrer