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

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