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.

cmUiDrvr.h 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 cmUiDrvr_h
  4. #define cmUiDrvr_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( {file_desc:"UI independent driver used by an rtSys application to communicate with the UI." kw:[rtsys]}
  9. typedef unsigned cmUiRC_t;
  10. // cmUi result codes
  11. enum
  12. {
  13. kOkUiRC = cmOkRC,
  14. kAppNotFoundUiRC,
  15. kCtlNotFoundUiRC,
  16. kPanelNotFoundUiRC,
  17. kInvalidAppIdUiRC,
  18. kPanelFullUiRC,
  19. kDrvrErrUiRC,
  20. kInvalidCtlOpUiRC,
  21. kInvalidColRowUiRC,
  22. kInvalidIdUiRC,
  23. kSubSysFailUiRC,
  24. kBufTooSmallUiRC,
  25. kBufCorruptUiRC,
  26. kNotImplementedUiRC
  27. };
  28. // Built-in control types.
  29. typedef enum
  30. {
  31. kInvalidUiCId,
  32. kPanelUiCId,
  33. kBtnUiCId,
  34. kCheckUiCId,
  35. kMenuBtnUiCId,
  36. kListUiCId,
  37. kLabelUiCId,
  38. kStringUiCId,
  39. kConsoleUiCId,
  40. kNumberUiCId,
  41. kSliderUiCId,
  42. kProgressUiCId,
  43. kMeterUiCId,
  44. kFilenameUiCId,
  45. kDirUiCId,
  46. kMaxUiCId
  47. } cmUiCId_t;
  48. // Control selector id's
  49. typedef enum
  50. {
  51. kInvalidDId,
  52. kCreateCtlDId,
  53. kDestroyCtlDId,
  54. kSetValDId,
  55. kEnableDId, // ival holds new enable state
  56. kMaxDId
  57. } cmUiDId_t;
  58. // Control flags.
  59. enum
  60. {
  61. // All controls recognize kValUiFl and kLblUiFl
  62. kValUiFl = 0x00000001,
  63. kLblUiFl = 0x00000002,
  64. // Flags for Number,Progress,Meter
  65. kMinUiFl = 0x00000004,
  66. kMaxUiFl = 0x00000010,
  67. kIncUiFl = 0x00000020,
  68. kNumMask = kValUiFl | kMinUiFl | kMaxUiFl | kIncUiFl,
  69. kHorzUiFl = 0x00000040,
  70. kVertUiFl = 0x00000080,
  71. // Flags for Filename and Dir
  72. kFnPatUiFl = 0x00000100, // file pattern string
  73. kFnDirUiFl = 0x00000200, // toggle file btn type
  74. kFnMask = kFnPatUiFl | kFnDirUiFl,
  75. // Append list or menu element.
  76. kAppendUiFl = 0x00000400,
  77. kPrependUiFl = 0x00000800,
  78. kClearUiFl = 0x00001000, // clear all ele' from a list or menu
  79. // Alignment flags
  80. kLeftUiFl = 0x00002000,
  81. kTopUiFl = 0x00004000,
  82. kRightUiFl = 0x00008000,
  83. kBottomUiFl = 0x00010000,
  84. kHCtrUiFl = 0x00020000,
  85. kVCtrUiFl = 0x00040000,
  86. kInsideUiFl = 0x00080000,
  87. // Value flags indicate which value fields are valid
  88. kIvalUiFl = 0x00100000,
  89. kFvalUiFl = 0x00200000,
  90. kSvalUiFl = 0x00400000,
  91. kNoReflectUiFl = 0x01000000, // do not reflect event to the client
  92. // When to send text fields
  93. kSendChangeFl = 0x10000000, // whenever text changes
  94. kSendEnterFl = 0x20000000, // when enter key is pressed (and changed or not-changed)
  95. kSendFocusFl = 0x40000000, // when ctl loses focus
  96. kSendNoChangeFl= 0x80000000 // on enter even if no-change
  97. };
  98. // A control can be uniquely idenfied by
  99. // appId and usrId (appId's are unique among app's)
  100. // (usrId's are unique among ctl's on an app)
  101. // appId's and usrId's should be zero based low numbers
  102. // because they are used internally as indexes.
  103. typedef struct
  104. {
  105. cmRtSysMsgHdr_t hdr;
  106. cmUiDId_t dId; // function selector id
  107. unsigned appId; // app id (plug-in instance id)
  108. unsigned usrId; // ctl id
  109. unsigned panelId; // parent panel id
  110. cmUiCId_t cId; // UI control type
  111. unsigned flags; // See kXXXUiFl above.
  112. int ival; // Valid if kIvalUiFl is set.
  113. double fval; // Valid if kFvalUiFl is set.
  114. const cmChar_t* sval; // Valid if kSvalUiFl is set.
  115. int x;
  116. int y;
  117. int w;
  118. int h;
  119. } cmUiDriverArg_t;
  120. typedef cmUiRC_t (*cmUiDriverFunc_t)( void* arg, const cmUiDriverArg_t* a );
  121. void cmUiDriverArgSetup( cmUiDriverArg_t* a,
  122. unsigned rtSubIdx,
  123. unsigned selId,
  124. cmUiDId_t dId,
  125. unsigned appId,
  126. unsigned usrId,
  127. unsigned panelId,
  128. cmUiCId_t cId,
  129. unsigned flags,
  130. int ival,
  131. double fval,
  132. const cmChar_t* sval,
  133. int x,
  134. int y,
  135. int w,
  136. int h
  137. );
  138. unsigned cmUiDriverArgSerializeBufByteCount( const cmUiDriverArg_t* a );
  139. // Returns kBufTooSmallUiRC if the buffer is too small otherwise returns kOkUiRC.
  140. // This function does not call cmErrMsg() on error
  141. // the caller is therefore responsible for generating errors.
  142. cmUiRC_t cmUiDriverArgSerialize( const cmUiDriverArg_t* a, void* buf, unsigned bufByteCnt );
  143. // Return kBufTooSmallUiRC or kBufCorruptUiRC if buffer corruption is detected
  144. // otherwise returns kOkUiRC. This function does not call cmErrMsg() on error
  145. // the caller is therefore responsible for generating errors.
  146. cmUiRC_t cmUiDriverArgDeserialize( cmUiDriverArg_t* a, const void* buf, unsigned bufByteCnt );
  147. // Return an arg. value converted to the requiested type.
  148. // Note that numeric values will be automatically converted but
  149. // values will not be converted between string and numeric values.
  150. int cmUiDriverArgGetInt( const cmUiDriverArg_t* a );
  151. double cmUiDriverArgGetDouble( const cmUiDriverArg_t* a );
  152. const cmChar_t* cmUiDriverArgGetString( const cmUiDriverArg_t* a );
  153. //)
  154. #ifdef __cplusplus
  155. }
  156. #endif
  157. #endif