libcm is a C development framework with an emphasis on audio signal processing applications.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

cmGrPlot.h 10.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. #ifndef cmGrTimeLine_h
  2. #define cmGrTimeLine_h
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. enum
  7. {
  8. kOkGrPlRC,
  9. kObjNotFoundGrPlRC,
  10. kGrFailGrPlRC,
  11. kRsrcFailGrPlRC
  12. };
  13. typedef enum
  14. {
  15. kInvalidPlId,
  16. kRectGrPlId,
  17. kHLineGrPlId,
  18. kVLineGrPlId,
  19. kLineGrPlId,
  20. kEllipseGrPlId,
  21. kDiamondGrPlId,
  22. kUTriGrPlId,
  23. kDTriGrPlId,
  24. kLTriGrPlId,
  25. kRTriGrPlId,
  26. kStarGrPlId,
  27. kCrossGrPlId,
  28. kPlusGrPlId,
  29. } cmGrPlObjTypeId_t;
  30. // object cfg flags
  31. enum
  32. {
  33. kSymbolGrPlFl = 0x0001, // This object is a symbol
  34. kNoSelectGrPlFl = 0x0002, // The clicking with the mouse will not select this object
  35. kNoDragGrPlFl = 0x0004, // Dragging with the mouse will not move this object
  36. kNoFocusGrPlFl = 0x0008, // This object cannot receive focus.
  37. kNoDrawGrPlFl = 0x0010, // Do not draw this object (is is invisible and disabled)
  38. kNoFillGrPlFl = 0x0020, // Do not draw the fill area of this object
  39. kNoBorderGrPlFl = 0x0040, // Do not draw the border of this object
  40. kNoLabelGrPlFl = 0x0080, // Do not draw the label for this object
  41. };
  42. // object state flags
  43. enum
  44. {
  45. kVisibleGrPlFl = 0x0001,
  46. kEnabledGrPlFl = 0x0002, // Enabled obj's must be visible.
  47. kSelectGrPlFl = 0x0004, //
  48. kFocusGrPlFl = 0x0008 // Focused obj's are also selected.
  49. };
  50. typedef enum
  51. {
  52. kFocusPlGrId,
  53. kSelectPlGrId,
  54. kEnablePlGrId,
  55. kDisablePlGrId,
  56. kMaxPlGrId
  57. } cmGrPlStateId_t;
  58. enum // TODO: change these into cmGrPlotH_t user settable variables
  59. {
  60. kDefaultSymW = 9,
  61. kDefaultSymH = 9
  62. };
  63. typedef cmHandle_t cmGrPlH_t;
  64. typedef cmHandle_t cmGrPlObjH_t;
  65. typedef cmRC_t cmGrPlRC_t;
  66. // Plot object callback id's
  67. typedef enum
  68. {
  69. kCreatedCbSelGrPlId,
  70. kDestroyedCbSelGrPlId,
  71. kPreEventCbSelGrPlId,
  72. kEventCbSelGrPlId,
  73. kStateChangeGrPlId, // See Note with cmGrPlotCbFunc_t below.
  74. } cmGrPlCbSelId_t;
  75. typedef struct
  76. {
  77. cmCtx_t* ctx; // Global program context.
  78. void* cbArg; // User pointer set in cmGrPlotObjSetCb().
  79. cmGrPlCbSelId_t selId; // Callback selector id. See cmGrPlCbSeId_t.
  80. cmGrPlObjH_t objH; // The plot object handle.
  81. unsigned eventFlags; // Event flags from canvas callback (See cmGrEvent() flags)
  82. cmGrKeyCodeId_t eventKey; // Event keys (See the cmGrEvent() keys)
  83. int eventX; // Mouse X,Y location when event was generated (Same as cmGrEvent())
  84. int eventY; //
  85. unsigned deltaFlags; // Event which caused an object state change (See kXXXGrPlFl flags)
  86. } cmGrPlotCbArg_t;
  87. // Return 'false' from kPreEventCbGrPlSelId events to prevent default processing.
  88. // Note:
  89. // When this callback is made with the 'kStateChangeGrPlId' the state of
  90. // the object has not yet been changed. This may be confusing because if
  91. // the state of the object is queried inside the callback it will have the
  92. // pre-change state - but this state will be automatically toggled when the
  93. // callback returns 'true'. Examine the arg->deltaFlags to determine the
  94. // state attribute which is changing.
  95. typedef bool (*cmGrPlotCbFunc_t)( cmGrPlotCbArg_t* arg );
  96. extern cmGrPlH_t cmGrPlNullHandle;
  97. extern cmGrPlObjH_t cmGrPlObjNullHandle;
  98. // Notes:
  99. // 1) Set kSymbolGrPlFl to create a symbol.
  100. // 2) If kSymbolGrPlFl is set then w and h are taken as the physical size
  101. // of the symbol. Set w and h to 0 to use the default symbols size
  102. // kDefaultSymW, kDefaultSymH
  103. cmGrPlRC_t cmGrPlotObjCreate(
  104. cmGrPlH_t plH, // Owner Plot Object Manager. See cmGrPlotCreate().
  105. cmGrH_t grH, // The canvas this object will be drawn on.
  106. cmGrPlObjH_t* ohp, // Pointer to the new objects handle (optional)
  107. unsigned id, // User defined identifier.
  108. cmGrPlObjH_t parentObjH, // Containing parent object.
  109. cmGrPlObjH_t xAnchorObjH, // x is taken as an offset from this obj's x coord (optional).
  110. cmGrPlObjH_t yAnchorObjH, // y is taken as an offset from this obj's y coord (optional).
  111. cmGrPlObjTypeId_t typeId, // See cmGrPlObjTypeId_t
  112. unsigned cfgFlags, //
  113. cmReal_t x, // Coord's within the parent's world coord system.
  114. cmReal_t y, //
  115. cmReal_t w, //
  116. cmReal_t h, //
  117. const cmChar_t* label, // Object text string (optional)
  118. const cmGrVExt_t* wext ); // This objects internal world extents (optional)
  119. cmGrPlRC_t cmGrPlotObjDestroy( cmGrPlObjH_t* ohp );
  120. bool cmGrPlotObjIsValid( cmGrPlObjH_t oh );
  121. cmGrPlH_t cmGrPlotObjMgrHandle( cmGrPlObjH_t oh );
  122. cmGrObjH_t cmGrPlotObjHandle( cmGrPlObjH_t oh );
  123. void cmGrPlotObjSetId( cmGrPlObjH_t oh, unsigned id );
  124. unsigned cmGrPlotObjId( cmGrPlObjH_t oh );
  125. void cmGrPlotObjSetUserPtr( cmGrPlObjH_t oh, void* userPtr );
  126. void* cmGrPlotObjUserPtr( cmGrPlObjH_t oh );
  127. void cmGrPlotObjSetLabel( cmGrPlObjH_t oh, const cmChar_t* label );
  128. const cmChar_t* cmGrPlotObjLabel( cmGrPlObjH_t oh );
  129. // Set flags to kXXXJsGrFl values. See cmGrDrawTextJustify for their meaning.
  130. // 'color' is optional
  131. void cmGrPlotObjSetLabelAttr( cmGrPlObjH_t oh, unsigned flags, int angle, const cmGrColor_t color );
  132. unsigned cmGrPlotObjLabelFlags( cmGrPlObjH_t oh );
  133. int cmGrPlotObjLabelAngle( cmGrPlObjH_t oh );
  134. const cmGrColor_t cmGrPlotObjLabelColor( cmGrPlObjH_t oh );
  135. void cmGrPlotObjSetStateFlags( cmGrPlObjH_t oh, unsigned flags );
  136. unsigned cmGrPlotObjStateFlags( cmGrPlObjH_t oh );
  137. void cmGrPlotObjSetCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  138. void cmGrPlotObjClrCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  139. void cmGrPlotObjTogCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  140. unsigned cmGrPlotObjCfgFlags( cmGrPlObjH_t oh );
  141. cmGrPlRC_t cmGrPlotObjSetPhysExt( cmGrPlObjH_t oh, int loffs, int toffs, int roffs, int boffs );
  142. void cmGrPlotObjPhysExt( cmGrPlObjH_t oh, int* loffs, int* toffs, int* roffs, int* boffs );
  143. void cmGrPlotObjVExt( cmGrPlObjH_t oh, cmGrVExt_t* vext );
  144. void cmGrPlotObjSetFontFamily( cmGrPlObjH_t h, unsigned id );
  145. unsigned cmGrPlotObjFontFamily( cmGrPlObjH_t h );
  146. void cmGrPlotObjSetFontSize( cmGrPlObjH_t h, unsigned size );
  147. unsigned cmGrPlotObjFontSize( cmGrPlObjH_t h );
  148. void cmGrPlotObjSetFontStyle( cmGrPlObjH_t h, unsigned flags );
  149. unsigned cmGrPlotObjFontStyle( cmGrPlObjH_t h );
  150. void cmGrPlotObjSetFont( cmGrPlObjH_t h, unsigned id, unsigned size, unsigned style );
  151. void cmGrPlotObjSetLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  152. const cmGrColor_t cmGrPlotObjLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  153. const cmGrColor_t cmGrPlotObjCurLineColor( cmGrPlObjH_t h );
  154. void cmGrPlotObjSetFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  155. const cmGrColor_t cmGrPlotObjFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  156. const cmGrColor_t cmGrPlotObjCurFillColor( cmGrPlObjH_t h );
  157. void cmGrPlotObjSetCb( cmGrPlObjH_t h, cmGrPlotCbFunc_t func, void* arg );
  158. cmGrPlotCbFunc_t cmGrPlotObjCbFunc( cmGrPlObjH_t h );
  159. void* cmGrPlotObjCbArg( cmGrPlObjH_t h );
  160. // Draw aH above bH in the z-order.
  161. void cmGrPlotObjDrawAbove( cmGrPlObjH_t bH, cmGrPlObjH_t aH );
  162. //----------------------------------------------------------------------------
  163. // Plot Object Manager Functions
  164. //----------------------------------------------------------------------------
  165. cmGrPlRC_t cmGrPlotCreate( cmCtx_t* ctx, cmGrPlH_t* hp );
  166. cmGrPlRC_t cmGrPlotDestroy( cmGrPlH_t* hp );
  167. bool cmGrPlotIsValid( cmGrPlH_t h );
  168. cmGrPlRC_t cmGrPlotClear( cmGrPlH_t h ); // destroy all objects
  169. cmErr_t* cmGrPlotErr( cmGrPlH_t h );
  170. cmRpt_t* cmGrPlotRpt( cmGrPlH_t h );
  171. // Return the count of plot objects.
  172. unsigned cmGrPlotObjectCount( cmGrPlH_t h );
  173. // Return the handle of the ith object (0<=index<cmGrPlotObjectCount())
  174. cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
  175. // Given a plot object id return the associated object handle.
  176. cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
  177. // Pass a keyboard event to the plot system.
  178. void cmGrPlotKeyEvent( cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
  179. // Set the default object callback and arg.
  180. void cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg );
  181. #ifdef __cplusplus
  182. }
  183. #endif
  184. #endif
  185. /*
  186. Plot Object Attributes:
  187. Location: x,y
  188. Size: w,h
  189. Shape:
  190. rectangle:
  191. ellipse:
  192. line:
  193. hline:
  194. vline:
  195. symbol:
  196. Parent: Defines the world coordinate system in which this object is drawn.
  197. Children are always fully contained by their parent and may not be dragged
  198. outside of their parent.
  199. Label:
  200. Border Color: One per state (enabled,selected,focused)
  201. Fill Color: One per state (enabled,selected,focused)
  202. State:
  203. Visible: Draw this object.
  204. Enabled: Disabled objects cannot be selected,focused, or dragged.
  205. Selected: Multiple objects may be selected.
  206. Focused: Only one object may be focused.
  207. Physical Offsets: Physical offsets which expand the size of the object.
  208. Font Family:
  209. Font Style:
  210. Font Size:
  211. Cfg Flags:
  212. No Drag: Do not allow dragging.
  213. No Select: Do not allow selection.
  214. No Focus: Do not allow focusing.
  215. No Draw: Do not draw this object (automatically disabled the object)
  216. No Fill: Do not draw fill color.
  217. No Border: Do not draw border.
  218. No Label: Do not draw label.
  219. */