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.

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