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

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