瀏覽代碼

cmGrDevCtx.h/c Added cmGrDcPoint/RectIsVisible()

master
kevin 11 年之前
父節點
當前提交
390cedeac6
共有 2 個檔案被更改,包括 46 行新增1 行删除
  1. 40
    1
      cmGrDevCtx.c
  2. 6
    0
      cmGrDevCtx.h

+ 40
- 1
cmGrDevCtx.c 查看文件

497
     else
497
     else
498
       y = yy + sz.h/2;
498
       y = yy + sz.h/2;
499
 
499
 
500
-  cmGrDcDrawText(h, text, x+.5, y+.5 );  
501
 
500
 
501
+
502
+  cmGrPExt_t r;
503
+  cmGrPExtSet(&r,x,y,sz.w,sz.h);
504
+
505
+  // Note: Checking for visibility should not be necessary however
506
+  // there appears to be a problem with the FLTK text output whereby
507
+  // text coordinates over 0xffff wrap around and may appear in the
508
+  // visible region.
509
+  if( cmGrDcRectIsVisible(h,&r) )
510
+  {
511
+    /*
512
+    if( text!=NULL && (strncmp(text,"loc:138",7)==0 || strcmp(text,"loc:8 ")==0))
513
+    {
514
+      printf("%s %i %i %i %i\n",text,x,y,sz.w,xx);
515
+      cmGrPExtPrint(text,&r);
516
+      cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
517
+      cmGrPExt_t res;
518
+      cmGrPExtIntersect(&res,&p->pext,&r );
519
+      cmGrPExtPrint(text,&p->pext);
520
+      cmGrPExtPrint("isect:",&res);
521
+      printf("%i\n",cmGrPExtIsNotNullOrEmpty(&res));
522
+    }
523
+    */
524
+
525
+    cmGrDcDrawText(h, text, x+.5, y+.5 );  
526
+  }
502
   //cmGrPExt_t pext;
527
   //cmGrPExt_t pext;
503
   //cmGrDcDrawTextJustifyRect(h, fontId, size, style, text, flags, xx, yy, &pext );
528
   //cmGrDcDrawTextJustifyRect(h, fontId, size, style, text, flags, xx, yy, &pext );
504
   //cmGrDcDrawRectPExt(h,&pext);
529
   //cmGrDcDrawRectPExt(h,&pext);
528
 
553
 
529
   cmGrPExtSet( pext, x, y-sz.h, sz.w+1, sz.h );
554
   cmGrPExtSet( pext, x, y-sz.h, sz.w+1, sz.h );
530
 }
555
 }
556
+
557
+bool            cmGrDcPointIsVisible( cmGrDcH_t h, int x, int y )
558
+{
559
+  cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
560
+  return cmGrVExtIsXyInside(&p->pext,x,y);
561
+}
562
+
563
+bool            cmGrDcRectIsVisible(  cmGrDcH_t h, const cmGrPExt_t* r )
564
+{
565
+  cmGrPExt_t res;
566
+  cmGrDc_t* p = _cmGrDcHandleToPtr(h);  
567
+  cmGrPExtIntersect(&res,&p->pext,r );
568
+  return cmGrPExtIsNotNullOrEmpty(&res);
569
+}

+ 6
- 0
cmGrDevCtx.h 查看文件

189
   // Return the rectangle around the text but do not display the text.
189
   // Return the rectangle around the text but do not display the text.
190
   void            cmGrDcDrawTextJustifyRect( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, unsigned flags, int x, int y, cmGrPExt_t* pext );
190
   void            cmGrDcDrawTextJustifyRect( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, unsigned flags, int x, int y, cmGrPExt_t* pext );
191
 
191
 
192
+  // Is the point x,y visible in this drawing context.
193
+  bool            cmGrDcPointIsVisible( cmGrDcH_t h, int x, int y );
194
+
195
+  // Is any of the rectangle visible in this drawing context.
196
+  bool            cmGrDcRectIsVisible(  cmGrDcH_t h, const cmGrPExt_t* r );
197
+
192
 #ifdef __cplusplus
198
 #ifdef __cplusplus
193
 }
199
 }
194
 #endif
200
 #endif

Loading…
取消
儲存