libcm is a C development framework with an emphasis on audio signal processing applications.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

cmGrPlot.h 9.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 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'.
  94. typedef bool (*cmGrPlotCbFunc_t)( cmGrPlotCbArg_t* arg );
  95. extern cmGrPlH_t cmGrPlNullHandle;
  96. extern cmGrPlObjH_t cmGrPlObjNullHandle;
  97. // Notes:
  98. // 1) Set kSymbolGrPlFl to create a symbol.
  99. // 2) If kSymbolGrPlFl is set then w and h are taken as the physical size
  100. // of the symbol. Set w and h to 0 to use the default symbols size
  101. // kDefaultSymW, kDefaultSymH
  102. cmGrPlRC_t cmGrPlotObjCreate(
  103. cmGrPlH_t plH, // Owner Plot Object Manager. See cmGrPlotCreate().
  104. cmGrH_t grH, // The canvas this object will be drawn on.
  105. cmGrPlObjH_t* ohp, // Pointer to the new objects handle (optional)
  106. unsigned id, // User defined identifier.
  107. cmGrPlObjH_t parentObjH, // Containing parent object.
  108. cmGrPlObjH_t xAnchorObjH, // x is taken as an offset from this obj's x coord (optional).
  109. cmGrPlObjH_t yAnchorObjH, // y is taken as an offset from this obj's y coord (optional).
  110. cmGrPlObjTypeId_t typeId, // See cmGrPlObjTypeId_t
  111. unsigned cfgFlags, //
  112. cmReal_t x, // Coord's within the parent's world coord system.
  113. cmReal_t y, //
  114. cmReal_t w, //
  115. cmReal_t h, //
  116. const cmChar_t* label, // Object text string (optional)
  117. const cmGrVExt_t* wext ); // This objects internal world extents (optional)
  118. cmGrPlRC_t cmGrPlotObjDestroy( cmGrPlObjH_t* ohp );
  119. bool cmGrPlotObjIsValid( cmGrPlObjH_t oh );
  120. cmGrPlH_t cmGrPlotObjMgrHandle( cmGrPlObjH_t oh );
  121. cmGrObjH_t cmGrPlotObjHandle( cmGrPlObjH_t oh );
  122. void cmGrPlotObjSetId( cmGrPlObjH_t oh, unsigned id );
  123. unsigned cmGrPlotObjId( cmGrPlObjH_t oh );
  124. void cmGrPlotObjSetUserPtr( cmGrPlObjH_t oh, void* userPtr );
  125. void* cmGrPlotObjUserPtr( cmGrPlObjH_t oh );
  126. void cmGrPlotObjSetLabel( cmGrPlObjH_t oh, const cmChar_t* label );
  127. const cmChar_t* cmGrPlotObjLabel( cmGrPlObjH_t oh );
  128. // Set flags to kXXXJsGrFl values. See cmGrDrawTextJustify for their meaning.
  129. // 'color' is optional
  130. void cmGrPlotObjSetLabelAttr( cmGrPlObjH_t oh, unsigned flags, int angle, const cmGrColor_t color );
  131. unsigned cmGrPlotObjLabelFlags( cmGrPlObjH_t oh );
  132. int cmGrPlotObjLabelAngle( cmGrPlObjH_t oh );
  133. const cmGrColor_t cmGrPlotObjLabelColor( cmGrPlObjH_t oh );
  134. void cmGrPlotObjSetStateFlags( cmGrPlObjH_t oh, unsigned flags );
  135. unsigned cmGrPlotObjStateFlags( cmGrPlObjH_t oh );
  136. void cmGrPlotObjSetCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  137. void cmGrPlotObjClrCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  138. void cmGrPlotObjTogCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  139. unsigned cmGrPlotObjCfgFlags( cmGrPlObjH_t oh );
  140. cmGrPlRC_t cmGrPlotObjSetPhysExt( cmGrPlObjH_t oh, int loffs, int toffs, int roffs, int boffs );
  141. void cmGrPlotObjPhysExt( cmGrPlObjH_t oh, int* loffs, int* toffs, int* roffs, int* boffs );
  142. void cmGrPlotObjVExt( cmGrPlObjH_t oh, cmGrVExt_t* vext );
  143. void cmGrPlotObjSetFontFamily( cmGrPlObjH_t h, unsigned id );
  144. unsigned cmGrPlotObjFontFamily( cmGrPlObjH_t h );
  145. void cmGrPlotObjSetFontSize( cmGrPlObjH_t h, unsigned size );
  146. unsigned cmGrPlotObjFontSize( cmGrPlObjH_t h );
  147. void cmGrPlotObjSetFontStyle( cmGrPlObjH_t h, unsigned flags );
  148. unsigned cmGrPlotObjFontStyle( cmGrPlObjH_t h );
  149. void cmGrPlotObjSetFont( cmGrPlObjH_t h, unsigned id, unsigned size, unsigned style );
  150. void cmGrPlotObjSetLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  151. const cmGrColor_t cmGrPlotObjLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  152. const cmGrColor_t cmGrPlotObjCurLineColor( cmGrPlObjH_t h );
  153. void cmGrPlotObjSetFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  154. const cmGrColor_t cmGrPlotObjFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  155. const cmGrColor_t cmGrPlotObjCurFillColor( cmGrPlObjH_t h );
  156. void cmGrPlotObjSetCb( cmGrPlObjH_t h, cmGrPlotCbFunc_t func, void* arg );
  157. cmGrPlotCbFunc_t cmGrPlotObjCbFunc( cmGrPlObjH_t h );
  158. void* cmGrPlotObjCbArg( cmGrPlObjH_t h );
  159. // Draw aH above bH in the z-order.
  160. void cmGrPlotObjDrawAbove( cmGrPlObjH_t bH, cmGrPlObjH_t aH );
  161. //----------------------------------------------------------------------------
  162. // Plot Object Manager Functions
  163. //----------------------------------------------------------------------------
  164. cmGrPlRC_t cmGrPlotCreate( cmCtx_t* ctx, cmGrPlH_t* hp );
  165. cmGrPlRC_t cmGrPlotDestroy( cmGrPlH_t* hp );
  166. bool cmGrPlotIsValid( cmGrPlH_t h );
  167. cmGrPlRC_t cmGrPlotClear( cmGrPlH_t h ); // destroy all objects
  168. cmErr_t* cmGrPlotErr( cmGrPlH_t h );
  169. cmRpt_t* cmGrPlotRpt( cmGrPlH_t h );
  170. unsigned cmGrPlotObjectCount( cmGrPlH_t h );
  171. cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
  172. cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
  173. // Pass a keyboard event to the plot system.
  174. void cmGrPlotKeyEvent( cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
  175. #ifdef __cplusplus
  176. }
  177. #endif
  178. #endif
  179. /*
  180. Plot Object Attributes:
  181. Location: x,y
  182. Size: w,h
  183. Shape:
  184. rectangle:
  185. ellipse:
  186. line:
  187. hline:
  188. vline:
  189. symbol:
  190. Parent: Defines the world coordinate system in which this object is drawn.
  191. Children are always fully contained by their parent and may not be dragged
  192. outside of their parent.
  193. Label:
  194. Border Color: One per state (enabled,selected,focused)
  195. Fill Color: One per state (enabled,selected,focused)
  196. State:
  197. Visible: Draw this object.
  198. Enabled: Disabled objects cannot be selected,focused, or dragged.
  199. Selected: Multiple objects may be selected.
  200. Focused: Only one object may be focused.
  201. Physical Offsets: Physical offsets which expand the size of the object.
  202. Font Family:
  203. Font Style:
  204. Font Size:
  205. Cfg Flags:
  206. No Drag: Do not allow dragging.
  207. No Select: Do not allow selection.
  208. No Focus: Do not allow focusing.
  209. No Draw: Do not draw this object (automatically disabled the object)
  210. No Fill: Do not draw fill color.
  211. No Border: Do not draw border.
  212. No Label: Do not draw label.
  213. */