libcm is a C development framework with an emphasis on audio signal processing applications.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

cmGrDevCtx.h 7.9KB

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