libcm is a C development framework with an emphasis on audio signal processing applications.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

cmGrPlot.h 10KB

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