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 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. cmGrPlObjH_t cmGrPlotObjParent( cmGrPlObjH_t oh );
  124. cmGrPlObjH_t cmGrPlotObjXAnchor( cmGrPlObjH_t oh );
  125. cmGrPlObjH_t cmGrPlotObjYAnchor( cmGrPlObjH_t oh );
  126. void cmGrPlotObjSetId( cmGrPlObjH_t oh, unsigned id );
  127. unsigned cmGrPlotObjId( cmGrPlObjH_t oh );
  128. void cmGrPlotObjSetUserPtr( cmGrPlObjH_t oh, void* userPtr );
  129. void* cmGrPlotObjUserPtr( cmGrPlObjH_t oh );
  130. void cmGrPlotObjSetLabel( cmGrPlObjH_t oh, const cmChar_t* label );
  131. const cmChar_t* cmGrPlotObjLabel( cmGrPlObjH_t oh );
  132. // Set flags to kXXXJsGrFl values. See cmGrDrawTextJustify for their meaning.
  133. // 'color' is optional
  134. void cmGrPlotObjSetLabelAttr( cmGrPlObjH_t oh, unsigned flags, int angle, const cmGrColor_t color );
  135. unsigned cmGrPlotObjLabelFlags( cmGrPlObjH_t oh );
  136. int cmGrPlotObjLabelAngle( cmGrPlObjH_t oh );
  137. const cmGrColor_t cmGrPlotObjLabelColor( cmGrPlObjH_t oh );
  138. void cmGrPlotObjSetStateFlags( cmGrPlObjH_t oh, unsigned flags );
  139. unsigned cmGrPlotObjStateFlags( cmGrPlObjH_t oh );
  140. void cmGrPlotObjSetCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  141. void cmGrPlotObjClrCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  142. void cmGrPlotObjTogCfgFlags( cmGrPlObjH_t oh, unsigned flags );
  143. unsigned cmGrPlotObjCfgFlags( cmGrPlObjH_t oh );
  144. cmGrPlRC_t cmGrPlotObjSetPhysExt( cmGrPlObjH_t oh, int loffs, int toffs, int roffs, int boffs );
  145. void cmGrPlotObjPhysExt( cmGrPlObjH_t oh, int* loffs, int* toffs, int* roffs, int* boffs );
  146. void cmGrPlotObjVExt( cmGrPlObjH_t oh, cmGrVExt_t* vext );
  147. void cmGrPlotObjSetFontFamily( cmGrPlObjH_t h, unsigned id );
  148. unsigned cmGrPlotObjFontFamily( cmGrPlObjH_t h );
  149. void cmGrPlotObjSetFontSize( cmGrPlObjH_t h, unsigned size );
  150. unsigned cmGrPlotObjFontSize( cmGrPlObjH_t h );
  151. void cmGrPlotObjSetFontStyle( cmGrPlObjH_t h, unsigned flags );
  152. unsigned cmGrPlotObjFontStyle( cmGrPlObjH_t h );
  153. void cmGrPlotObjSetFont( cmGrPlObjH_t h, unsigned id, unsigned size, unsigned style );
  154. void cmGrPlotObjSetLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  155. const cmGrColor_t cmGrPlotObjLineColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  156. const cmGrColor_t cmGrPlotObjCurLineColor( cmGrPlObjH_t h );
  157. void cmGrPlotObjSetFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id, const cmGrColor_t c );
  158. const cmGrColor_t cmGrPlotObjFillColor( cmGrPlObjH_t h, cmGrPlStateId_t id );
  159. const cmGrColor_t cmGrPlotObjCurFillColor( cmGrPlObjH_t h );
  160. void cmGrPlotObjSetCb( cmGrPlObjH_t h, cmGrPlotCbFunc_t func, void* arg );
  161. cmGrPlotCbFunc_t cmGrPlotObjCbFunc( cmGrPlObjH_t h );
  162. void* cmGrPlotObjCbArg( cmGrPlObjH_t h );
  163. // Draw aH above bH in the z-order.
  164. void cmGrPlotObjDrawAbove( cmGrPlObjH_t bH, cmGrPlObjH_t aH );
  165. //----------------------------------------------------------------------------
  166. // Plot Object Manager Functions
  167. //----------------------------------------------------------------------------
  168. cmGrPlRC_t cmGrPlotCreate( cmCtx_t* ctx, cmGrPlH_t* hp );
  169. cmGrPlRC_t cmGrPlotDestroy( cmGrPlH_t* hp );
  170. bool cmGrPlotIsValid( cmGrPlH_t h );
  171. cmGrPlRC_t cmGrPlotClear( cmGrPlH_t h ); // destroy all objects
  172. cmErr_t* cmGrPlotErr( cmGrPlH_t h );
  173. cmRpt_t* cmGrPlotRpt( cmGrPlH_t h );
  174. // Return the count of plot objects.
  175. unsigned cmGrPlotObjectCount( cmGrPlH_t h );
  176. // Return the handle of the ith object (0<=index<cmGrPlotObjectCount())
  177. cmGrPlObjH_t cmGrPlotObjectIndexToHandle( cmGrPlH_t h, unsigned index );
  178. // Given a plot object id return the associated object handle.
  179. cmGrPlObjH_t cmGrPlotObjectIdToHandle( cmGrPlH_t h, unsigned id );
  180. // Pass a keyboard event to the plot system.
  181. void cmGrPlotKeyEvent( cmGrPlH_t h, cmGrH_t grH, unsigned eventFlags, cmGrKeyCodeId_t keycode );
  182. // Set the default object callback and arg.
  183. void cmGrPlotSetCb( cmGrPlH_t h, cmGrPlotCbFunc_t func, void* arg );
  184. #ifdef __cplusplus
  185. }
  186. #endif
  187. #endif
  188. /*
  189. Plot Object Attributes:
  190. Location: x,y
  191. Size: w,h
  192. Shape:
  193. rectangle:
  194. ellipse:
  195. line:
  196. hline:
  197. vline:
  198. symbol:
  199. Parent: Defines the world coordinate system in which this object is drawn.
  200. Children are always fully contained by their parent and may not be dragged
  201. outside of their parent.
  202. Label:
  203. Border Color: One per state (enabled,selected,focused)
  204. Fill Color: One per state (enabled,selected,focused)
  205. State:
  206. Visible: Draw this object.
  207. Enabled: Disabled objects cannot be selected,focused, or dragged.
  208. Selected: Multiple objects may be selected.
  209. Focused: Only one object may be focused.
  210. Physical Offsets: Physical offsets which expand the size of the object.
  211. Font Family:
  212. Font Style:
  213. Font Size:
  214. Cfg Flags:
  215. No Drag: Do not allow dragging.
  216. No Select: Do not allow selection.
  217. No Focus: Do not allow focusing.
  218. No Draw: Do not draw this object (automatically disabled the object)
  219. No Fill: Do not draw fill color.
  220. No Border: Do not draw border.
  221. No Label: Do not draw label.
  222. */