Browse 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 11 years ago
parent
commit
9a65b1bbaa
1 changed files with 16 additions and 14 deletions
  1. 16
    14
      cmGrDevCtx.c

+ 16
- 14
cmGrDevCtx.c View File

8
 #include "cmGr.h"
8
 #include "cmGr.h"
9
 #include "cmGrDevCtx.h"
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
 cmGrDcH_t cmGrDcNullHandle = cmSTATIC_NULL_HANDLE;
14
 cmGrDcH_t cmGrDcNullHandle = cmSTATIC_NULL_HANDLE;
13
 
15
 
212
     goto errLabel;
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
  errLabel:
219
  errLabel:
218
   // force the current state to be reapplied to the new drawing context
220
   // force the current state to be reapplied to the new drawing context
346
 void            cmGrDcDrawLine(  cmGrDcH_t h, int x0, int y0, int x1, int y1 )
348
 void            cmGrDcDrawLine(  cmGrDcH_t h, int x0, int y0, int x1, int y1 )
347
 { 
349
 { 
348
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
354
 void            cmGrDcDrawRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
353
 {
355
 {
354
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawRectPExt(     cmGrDcH_t h, const cmGrPExt_t* pext )
360
 void            cmGrDcDrawRectPExt(     cmGrDcH_t h, const cmGrPExt_t* pext )
361
 void            cmGrDcFillRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
363
 void            cmGrDcFillRect(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
362
 {
364
 {
363
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
369
 void            cmGrDcDrawEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
368
 {
370
 {
369
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcFillEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
375
 void            cmGrDcFillEllipse(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
374
 {
376
 {
375
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
381
 void            cmGrDcDrawDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
380
 {
382
 {
381
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcFillDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
387
 void            cmGrDcFillDiamond(  cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh )
386
 {
388
 {
387
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
393
 void            cmGrDcDrawTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
392
 {
394
 {
393
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcFillTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
399
 void            cmGrDcFillTriangle( cmGrDcH_t h, int x,  int y,  unsigned ww, unsigned hh, unsigned dirFlag )
398
 {
400
 {
399
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawText(    cmGrDcH_t h, const cmChar_t* text, int x, int y )
421
 void            cmGrDcDrawText(    cmGrDcH_t h, const cmChar_t* text, int x, int y )
420
 {
422
 {
421
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawTextRot( cmGrDcH_t h, const cmChar_t* text, int x, int y, int angle )
427
 void            cmGrDcDrawTextRot( cmGrDcH_t h, const cmChar_t* text, int x, int y, int angle )
426
 {
428
 {
427
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcReadImage(   cmGrDcH_t h, unsigned char* a, const cmGrPExt_t* pext )
434
 void            cmGrDcReadImage(   cmGrDcH_t h, unsigned char* a, const cmGrPExt_t* pext )
433
 {
435
 {
434
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 void            cmGrDcDrawImage(  cmGrDcH_t h, const unsigned char* a, const cmGrPExt_t* pext )
440
 void            cmGrDcDrawImage(  cmGrDcH_t h, const unsigned char* a, const cmGrPExt_t* pext )
439
 {
441
 {
440
   cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
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
 

Loading…
Cancel
Save