libcm is a C development framework with an emphasis on audio signal processing applications.
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

cmGrDevCtx.h 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. #ifndef cmGrDevCtx_h
  2. #define cmGrDevCtx_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. //( { file_desc:"Device independent graphics context object used by cmGr." kw:[plot]}
  7. enum
  8. {
  9. kOkGrDcRC = cmOkRC,
  10. kStackFaultGrDcRC,
  11. kDevDrvFailGrDcRC
  12. };
  13. typedef cmRC_t cmGrDcRC_t;
  14. extern cmGrDcH_t cmGrDcNullHandle;
  15. enum
  16. {
  17. kSolidLsGrFl = 0x01,
  18. kDashLsGrFl = 0x02,
  19. kDotLsGrFl = 0x04
  20. };
  21. enum
  22. {
  23. kHelveticaFfGrId,
  24. kTimesFfGrId,
  25. kCourierFfGrId,
  26. kFontFfCnt
  27. };
  28. enum
  29. {
  30. kNormalFsGrFl = 0x00,
  31. kBoldFsGrFl = 0x01,
  32. kItalicFsGrFl = 0x02
  33. };
  34. typedef struct cmGrDev_str
  35. {
  36. // return true on success
  37. bool (*create)( void* arg, unsigned w, unsigned h );
  38. void (*destroy)( void* arg );
  39. void (*begin_draw)( void* arg );
  40. void (*end_draw)( void* arg );
  41. void (*draw)( void* arg, int x, int y );
  42. void (*set_color)( void* arg, const cmGrColor_t c );
  43. void (*get_color)( void* arg, cmGrColor_t* c );
  44. // Return false if the 'font' label is not recognized.
  45. void (*set_font_family)(void* arg, unsigned fontId );
  46. unsigned (*get_font_family)(void* arg );
  47. void (*set_font_style)( void* arg, unsigned styleFLags );
  48. unsigned (*get_font_style)( void* arg );
  49. void (*set_font_size)( void* arg, unsigned size );
  50. unsigned (*get_font_size)( void* arg );
  51. void (*set_pen_style)( void* arg, unsigned styleFlags );
  52. unsigned (*get_pen_style)( void* arg );
  53. void (*set_pen_width)( void* arg, unsigned w );
  54. unsigned (*get_pen_width)( void* arg );
  55. void (*draw_line)( void* arg, int x, int y, int x1, int y1 );
  56. void (*draw_rect)( void* arg, int x, int y, unsigned w, unsigned h );
  57. void (*fill_rect)( void* arg, int x, int y, unsigned w, unsigned h );
  58. // Draw an ellipse, diamond or triangle inside the rectangle formed by l,t,w,h.
  59. void (*draw_ellipse)( void* arg, int x, int y, unsigned w, unsigned h );
  60. void (*fill_ellipse)( void* arg, int x, int y, unsigned w, unsigned h );
  61. void (*draw_diamond)( void* arg, int x, int y, unsigned w, unsigned h );
  62. void (*fill_diamond)( void* arg, int x, int y, unsigned w, unsigned h );
  63. void (*draw_triangle)( void* arg, int x, int y, unsigned w, unsigned h, unsigned dirFlag );
  64. void (*fill_triangle)( void* arg, int x, int y, unsigned w, unsigned h, unsigned dirFlag );
  65. // x,y identifies the left,lower text edge
  66. void (*draw_text)( void* arg, const char* text, int x, int y );
  67. void (*draw_text_rot)(void* arg, const char* text, int x, int y, int angle );
  68. void (*measure_text)( void* arg, const char* text, unsigned* w, unsigned* h );
  69. // Fill p[w*h*3] with RGB data.
  70. void (*read_image)( void* arg, unsigned char* p, int x, int y, unsigned w, unsigned h );
  71. void (*draw_image)( void* arg, const unsigned char* p, int x, int y, unsigned w, unsigned h );
  72. } cmGrDev_t;
  73. cmGrDcRC_t cmGrDevCtxCreate( cmCtx_t* ctx, cmGrDcH_t* hp, cmGrDev_t* dd, void* ddArg, int x, int y, int w, int h );
  74. cmGrDcRC_t cmGrDevCtxDestroy( cmGrDcH_t* hp );
  75. bool cmGrDevCtxIsValid( cmGrDcH_t h );
  76. cmGrDcRC_t cmGrDevCtxResize( cmGrDcH_t h, int x, int y, int ww, int hh );
  77. void cmGrDevCtxSize( cmGrDcH_t h, cmGrPExt_t* pext );
  78. void cmGrDevCtxBeginDraw( cmGrDcH_t h );
  79. void cmGrDevCtxEndDraw( cmGrDcH_t h );
  80. void cmGrDevCtxDraw( cmGrDcH_t h );
  81. void cmGrDcPushCtx( cmGrDcH_t h );
  82. void cmGrDcPopCtx( cmGrDcH_t h );
  83. unsigned cmGrDcColor( cmGrDcH_t h );
  84. void cmGrDcSetColorRgb( cmGrDcH_t h, unsigned char r, unsigned char g, unsigned char b );
  85. void cmGrDcSetColor( cmGrDcH_t h, cmGrColor_t color );
  86. unsigned cmGrDcFontFamily( cmGrDcH_t h );
  87. void cmGrDcSetFontFamily( cmGrDcH_t h, unsigned fontId );
  88. unsigned cmGrDcFontStyle( cmGrDcH_t h );
  89. void cmGrDcSetFontStyle( cmGrDcH_t h, unsigned style );
  90. unsigned cmGrDcFontSize( cmGrDcH_t h );
  91. void cmGrDcSetFontSize( cmGrDcH_t h, unsigned size );
  92. unsigned cmGrDcPenWidth( cmGrDcH_t h );
  93. void cmGrDcSetPenWidth( cmGrDcH_t h, unsigned width );
  94. unsigned cmGrDcPenStyle( cmGrDcH_t h );
  95. void cmGrDcSetPenStyle( cmGrDcH_t h, unsigned style );
  96. void cmGrDcDrawLine( cmGrDcH_t h, int x, int y, int x1, int y1 );
  97. // x,y is the upper,left.
  98. void cmGrDcDrawRect( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  99. void cmGrDcDrawRectPExt( cmGrDcH_t h, const cmGrPExt_t* pext );
  100. void cmGrDcFillRect( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  101. void cmGrDcDrawEllipse( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  102. void cmGrDcFillEllipse( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  103. void cmGrDcDrawDiamond( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  104. void cmGrDcFillDiamond( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh );
  105. // Set 'dirFlag' to kTopGrFl,kBottomGrFl,kRightGrFl,kLeftGrFl to indicate
  106. // the direction the triangle is pointeed.
  107. void cmGrDcDrawTriangle( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh, unsigned dirFlag );
  108. void cmGrDcFillTriangle( cmGrDcH_t h, int x, int y, unsigned ww, unsigned hh, unsigned dirFlag );
  109. void cmGrDcMeasure( cmGrDcH_t h, const cmChar_t* text, cmGrPSz_t* sz );
  110. void cmGrDcDrawText( cmGrDcH_t h, const cmChar_t* text, int x, int y );
  111. void cmGrDcDrawTextRot( cmGrDcH_t h, const cmChar_t* text, int x, int y, int angle );
  112. void cmGrDcReadImage( cmGrDcH_t h, unsigned char* p, const cmGrPExt_t* pext );
  113. void cmGrDcDrawImage( cmGrDcH_t h, const unsigned char* p, const cmGrPExt_t* pext );
  114. //
  115. // Composite Functions
  116. //
  117. void cmGrDcSetFont( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style );
  118. void cmGrDcFontSetAndMeasure(cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, cmGrPSz_t* sz );
  119. enum
  120. {
  121. kLeftJsGrFl = 0x001,
  122. kRightJsGrFl = 0x002,
  123. kTopJsGrFl = 0x004,
  124. kBottomJsGrFl = 0x008,
  125. kHorzCtrJsGrFl = 0x010,
  126. kVertCtrJsGrFl = 0x020,
  127. kNorthJsGrFl = 0x040,
  128. kEastJsGrFl = 0x080,
  129. kSouthJsGrFl = 0x100,
  130. kWestJsGrFl = 0x200
  131. };
  132. // Use compass (NSEW) flags to select the draw point. Defaults to center for both dir's.
  133. // Use TBLF flags to select the text justification relative to the point.
  134. // In effect the TBLF flags select the corner of the text to place at the location of
  135. // the point selected by the NSEW flags.
  136. // If neither NS flag is set then the vertical point is set to the vertical center.
  137. // If neither EW flags is set then the horizontal point is set to the horzontal center.
  138. void cmGrDcDrawTextJustify( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, const cmGrPExt_t* pext, unsigned flags );
  139. // Use LBLF to set the justification - the text corner to match to the given point.
  140. // If neither TL flag is given then the point is matched to the vertical center of the text.
  141. // If neither RL flag is given then the point is matched to the horizontal center of the text.
  142. void cmGrDcDrawTextJustifyPt( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, unsigned flags, int x, int y );
  143. // Return the rectangle around the text but do not display the text.
  144. void cmGrDcDrawTextJustifyRect( cmGrDcH_t h, unsigned fontId, unsigned size, unsigned style, const cmChar_t* text, unsigned flags, int x, int y, cmGrPExt_t* pext );
  145. // Is the point x,y visible in this drawing context.
  146. bool cmGrDcPointIsVisible( cmGrDcH_t h, int x, int y );
  147. // Is any of the rectangle visible in this drawing context.
  148. bool cmGrDcRectIsVisible( cmGrDcH_t h, const cmGrPExt_t* r );
  149. //)
  150. #ifdef __cplusplus
  151. }
  152. #endif
  153. #endif