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.

cmGrPage.h 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. //| Copyright: (C) 2009-2020 Kevin Larke <contact AT larke DOT org>
  2. //| License: GNU GPL version 3.0 or above. See the accompanying LICENSE file.
  3. #ifndef cmGrPage_h
  4. #define cmGrPage_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Device independent plotting window with one or more plot views." kw:[plot]}
  9. enum
  10. {
  11. kHashMarkGrFl = 0x10,
  12. kHashLabelGrFl= 0x20
  13. };
  14. typedef cmHandle_t cmGrPgH_t;
  15. typedef cmHandle_t cmGrVwH_t;
  16. typedef cmHandle_t cmGrAxH_t;
  17. extern cmGrPgH_t cmGrPgNullHandle;
  18. extern cmGrVwH_t cmGrVwNullHandle;
  19. extern cmGrAxH_t cmGrAxNullHandle;
  20. // Create a cmGrPage object.
  21. cmGrRC_t cmGrPageCreate( cmCtx_t* ctx, cmGrPgH_t* hp, cmGrCbFunc_t cbFunc, void* cbArg );
  22. // Destroy and release the resources assoc'd with a cmGrPage object;
  23. cmGrRC_t cmGrPageDestroy( cmGrPgH_t* hp );
  24. // Return true if the cmGrPage object handle is valid
  25. bool cmGrPageIsValid( cmGrPgH_t h );
  26. // Remove all objects from the page.
  27. cmGrRC_t cmGrPageClear( cmGrPgH_t h );
  28. // Intialize the count of rows and columns and setup the default layout.
  29. cmGrRC_t cmGrPageInit( cmGrPgH_t h, const cmGrPExt_t* r, unsigned rn, unsigned cn, cmGrDcH_t dcH );
  30. // Update the position of the views on the page.
  31. cmGrRC_t cmGrPageResize( cmGrPgH_t h, const cmGrPExt_t* r, cmGrDcH_t dcH );
  32. // Return the current page size and loc'n as set by cmGrPageInit() or cmGrPageResize().
  33. void cmGrPageRect( cmGrPgH_t h, cmGrPExt_t* r );
  34. // Return the count of plot views contained by this page. (rn*cn)
  35. unsigned cmGrPageViewCount( cmGrPgH_t h );
  36. // Enable or disable the focus for a given view.
  37. // Note that the focused view is the view which is the target of controller
  38. // buttons and scrollbars. This does not refer to the focused object.
  39. // Set 'enableFl' if the view is receiving the focus.
  40. // Clear 'enableFl' if the view is losing focus.
  41. void cmGrPageViewFocus( cmGrPgH_t h, unsigned vwIdx, bool enableFl );
  42. // Return the view which currently has the focus or cmGrVwNullHandle if
  43. // no view has the focus.
  44. cmGrVwH_t cmGrPageFocusedView( cmGrPgH_t h );
  45. //
  46. bool cmGrPageLayout( cmGrPgH_t h, cmGrDcH_t dcH );
  47. // Draw the page.
  48. void cmGrPageDraw( cmGrPgH_t h, cmGrDcH_t dcH );
  49. // Label callback functions are used to translate numeric axis values to
  50. // text strings. Multiple label callback functions can be registered with
  51. // a page and then assigned to a given view axis via cmGrViewSetLabelFunc().
  52. typedef void (*cmGrLabelFunc_t)( void* arg, cmChar_t* label, unsigned labelCharCnt, cmGrV_t value );
  53. // Returns id of the new page label function.
  54. unsigned cmGrPageLabelFuncRegister( cmGrPgH_t h, cmGrLabelFunc_t func, void* arg, const cmChar_t* label );
  55. unsigned cmGrPageLabelFuncCount( cmGrPgH_t h );
  56. unsigned cmGrPageLabelFuncIndexToId( cmGrPgH_t h, unsigned index );
  57. unsigned cmGrPageLabelFuncLabelToId( cmGrPgH_t h, const cmChar_t* label );
  58. cmGrLabelFunc_t cmGrPageLabelFunc( cmGrPgH_t h, unsigned id );
  59. const cmChar_t* cmGrPageLabelFuncLabel( cmGrPgH_t h, unsigned id );
  60. void* cmGrPageLabelFuncArg( cmGrPgH_t h, unsigned id );
  61. //----------------------------------------------------------------------------
  62. //)
  63. //( { label:cmGrView file_desc:"Device independent plotting view." kw:[plot]}
  64. //
  65. // Get a view handle from the view index.
  66. cmGrVwH_t cmGrPageViewHandle( cmGrPgH_t h, unsigned vwIdx );
  67. // Get a view handle from to cmGrH_t.
  68. cmGrVwH_t cmGrPageGrHandleToView( cmGrPgH_t h, cmGrH_t grH );
  69. bool cmGrViewIsValid( cmGrVwH_t h );
  70. // Initialize a plot view. title,xLabel, and yLabel are optional.
  71. cmGrRC_t cmGrViewInit( cmGrVwH_t h, cmGrH_t grH, const cmChar_t* vwTitle, const cmChar_t* xLabel, const cmChar_t* yLabel );
  72. // Remove all objects from the view.
  73. cmGrRC_t cmGrViewClear( cmGrVwH_t h );
  74. // Get the plot views physical extents. This function will return the
  75. // current view location/size only after a call to cmGrPageDraw().
  76. // See the implementation note at the top of this file.
  77. cmGrRC_t cmGrViewPExt( cmGrVwH_t h, cmGrPExt_t* pext );
  78. bool cmGrViewHasFocus( cmGrVwH_t h );
  79. // Get the cmGrH_t associated with a view.
  80. cmGrH_t cmGrViewGrHandle( cmGrVwH_t h );
  81. // kExpandViewGrFl | kSelectHorzGrFl | kSelectVertGrFl
  82. void cmGrViewSetCfg( cmGrVwH_t h, unsigned cfgFlags );
  83. unsigned cmGrViewCfg( cmGrVwH_t h );
  84. void cmGrViewSetTitle( cmGrVwH_t h, const cmChar_t* title );
  85. const cmChar_t* cmGrViewTitle( cmGrVwH_t h );
  86. void cmGrViewSetFontFamily( cmGrVwH_t h, unsigned id );
  87. unsigned cmGrViewFontFamily( cmGrVwH_t h );
  88. void cmGrViewSetFontStyle( cmGrVwH_t h, unsigned flags );
  89. unsigned cmGrViewFontStyle( cmGrVwH_t h );
  90. void cmGrViewSetFontSize( cmGrVwH_t h, unsigned size );
  91. unsigned cmGrViewFontSize( cmGrVwH_t h );
  92. // Assign a translation function to be used with cmGrViewValue().
  93. // cmLeftGrIdx or cmGrRightGrIdx is used to assign y axis translation functions.
  94. // cmTopGrIdx or cmGrBottomGrIdx is used to assign x axis translation functions.
  95. // 'pgLabelFuncId' must be a valid page label function id as returned from cmGrPageLabelFuncRegister().
  96. // or cmGrPageLabelFuncIndexToId().
  97. void cmGrViewSetLabelFunc( cmGrVwH_t h, cmGrAxisIdx_t axisId, unsigned pgLabelFuncId );
  98. typedef enum
  99. {
  100. kLocalX_VwId,
  101. kLocalY_VwId,
  102. kGlobalX_VwId,
  103. kGlobalY_VwId,
  104. kSelX0_VwId,
  105. kSelY0_VwId,
  106. kSelX1_VwId,
  107. kSelY1_VwId,
  108. kSelW_VwId,
  109. kSelH_VwId
  110. } cmGrViewValueId_t;
  111. const cmChar_t* cmGrViewValue( cmGrVwH_t h, cmGrViewValueId_t id, cmChar_t* buf, unsigned bufCharCnt );
  112. // Get an axis handle.
  113. cmGrAxH_t cmGrViewAxisHandle( cmGrVwH_t h, cmGrAxisIdx_t axisIdx );
  114. //----------------------------------------------------------------------------
  115. //)
  116. //( { label:cmGrAxis file_desc:"Device independent plotting axis." kw:[plot]}
  117. //
  118. bool cmGrAxisIsValid( cmGrAxH_t h );
  119. // kHashMarkGrFl | kHashLabelGrFl
  120. void cmGrAxisSetCfg( cmGrAxH_t h, unsigned cfgFlags );
  121. unsigned cmGrAxisCfg( cmGrAxH_t h );
  122. void cmGrAxisSetTitle( cmGrAxH_t h, const cmChar_t* title );
  123. const cmChar_t* cmGrAxisTitle( cmGrAxH_t h );
  124. void cmGrAxisTitleSetFontFamily( cmGrAxH_t h, unsigned id );
  125. unsigned cmGrAxisTitleFontFamily( cmGrAxH_t h );
  126. void cmGrAxisTitleSetFontStyle( cmGrAxH_t h, unsigned flags );
  127. unsigned cmGrAxisTitleFontStyle( cmGrAxH_t h );
  128. void cmGrAxisTitleSetFontSize( cmGrAxH_t h, unsigned size );
  129. unsigned cmGrAxisTitleFontSize( cmGrAxH_t h );
  130. void cmGrAxisLabelSetFontFamily( cmGrAxH_t h, unsigned id );
  131. unsigned cmGrAxisLabelFontFamily( cmGrAxH_t h );
  132. void cmGrAxisLabelSetFontStyle( cmGrAxH_t h, unsigned flags );
  133. unsigned cmGrAxisLabelFontStyle( cmGrAxH_t h );
  134. void cmGrAxisLabelSetFontSize( cmGrAxH_t h, unsigned size );
  135. unsigned cmGrAxisLabelFontSize( cmGrAxH_t h );
  136. // Assign a translation function for the value on this axis.
  137. // 'pgLabelFuncId' must be a valid page label function id as returned from cmGrPageLabelFuncRegister().
  138. // or cmGrPageLabelFuncIndexToId().
  139. void cmGrAxisSetLabelFunc( cmGrAxH_t h, unsigned pgLabelFuncId );
  140. //)
  141. #ifdef __cplusplus
  142. }
  143. #endif
  144. #endif