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.

cmGr.h 34KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879
  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 cmGr_h
  4. #define cmGr_h
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. //( { file_desc:"Low level device independent API for descibing interactive graphics objects." kw:[plot] }
  9. enum
  10. {
  11. kAliceBlueGrId = 0xf0f8ff,
  12. kAntiqueWhiteGrId = 0xfaebd7,
  13. kAquaGrId = 0x00ffff,
  14. kAquamarineGrId = 0x7fffd4,
  15. kAzureGrId = 0xf0ffff,
  16. kBeigeGrId = 0xf5f5dc,
  17. kBisqueGrId = 0xffe4c4,
  18. kBlackGrId = 0x000000,
  19. kBlanchedAlmondGrId = 0xffebcd,
  20. kBlueGrId = 0x0000ff,
  21. kBlueVioletGrId = 0x8a2be2,
  22. kBrownGrId = 0xa52a2a,
  23. kBurlyWoodGrId = 0xdeb887,
  24. kCadetBlueGrId = 0x5f9ea0,
  25. kChartreuseGrId = 0x7fff00,
  26. kChocolateGrId = 0xd2691e,
  27. kCoralGrId = 0xff7f50,
  28. kCornflowerBlueGrId = 0x6495ed,
  29. kCornsilkGrId = 0xfff8dc,
  30. kCrimsonGrId = 0xdc143c,
  31. kCyanGrId = 0x00ffff,
  32. kDarkBlueGrId = 0x00008b,
  33. kDarkCyanGrId = 0x008b8b,
  34. kDarkGoldenRodGrId = 0xb8860b,
  35. kDarkGrayGrId = 0xa9a9a9,
  36. kDarkGreyGrId = 0xa9a9a9,
  37. kDarkGreenGrId = 0x006400,
  38. kDarkKhakiGrId = 0xbdb76b,
  39. kDarkMagentaGrId = 0x8b008b,
  40. kDarkOliveGreenGrId = 0x556b2f,
  41. kDarkorangeGrId = 0xff8c00,
  42. kDarkOrchidGrId = 0x9932cc,
  43. kDarkRedGrId = 0x8b0000,
  44. kDarkSalmonGrId = 0xe9967a,
  45. kDarkSeaGreenGrId = 0x8fbc8f,
  46. kDarkSlateBlueGrId = 0x483d8b,
  47. kDarkSlateGrayGrId = 0x2f4f4f,
  48. kDarkSlateGreyGrId = 0x2f4f4f,
  49. kDarkTurquoiseGrId = 0x00ced1,
  50. kDarkVioletGrId = 0x9400d3,
  51. kDeepPinkGrId = 0xff1493,
  52. kDeepSkyBlueGrId = 0x00bfff,
  53. kDimGrayGrId = 0x696969,
  54. kDimGreyGrId = 0x696969,
  55. kDodgerBlueGrId = 0x1e90ff,
  56. kFireBrickGrId = 0xb22222,
  57. kFloralWhiteGrId = 0xfffaf0,
  58. kForestGreenGrId = 0x228b22,
  59. kFuchsiaGrId = 0xff00ff,
  60. kGainsboroGrId = 0xdcdcdc,
  61. kGhostWhiteGrId = 0xf8f8ff,
  62. kGoldGrId = 0xffd700,
  63. kGoldenRodGrId = 0xdaa520,
  64. kGrayGrId = 0x808080,
  65. kGreyGrId = 0x808080,
  66. kGreenGrId = 0x008000,
  67. kGreenYellowGrId = 0xadff2f,
  68. kHoneyDewGrId = 0xf0fff0,
  69. kHotPinkGrId = 0xff69b4,
  70. kIndianRedGrId = 0xcd5c5c,
  71. kIndigoGrId = 0x4b0082,
  72. kIvoryGrId = 0xfffff0,
  73. kKhakiGrId = 0xf0e68c,
  74. kLavenderGrId = 0xe6e6fa,
  75. kLavenderBlushGrId = 0xfff0f5,
  76. kLawnGreenGrId = 0x7cfc00,
  77. kLemonChiffonGrId = 0xfffacd,
  78. kLightBlueGrId = 0xadd8e6,
  79. kLightCoralGrId = 0xf08080,
  80. kLightCyanGrId = 0xe0ffff,
  81. kLightGoldenRodYellowGrId = 0xfafad2,
  82. kLightGrayGrId = 0xd3d3d3,
  83. kLightGreyGrId = 0xd3d3d3,
  84. kLightGreenGrId = 0x90ee90,
  85. kLightPinkGrId = 0xffb6c1,
  86. kLightSalmonGrId = 0xffa07a,
  87. kLightSeaGreenGrId = 0x20b2aa,
  88. kLightSkyBlueGrId = 0x87cefa,
  89. kLightSlateGrayGrId = 0x778899,
  90. kLightSlateGreyGrId = 0x778899,
  91. kLightSteelBlueGrId = 0xb0c4de,
  92. kLightYellowGrId = 0xffffe0,
  93. kLimeGrId = 0x00ff00,
  94. kLimeGreenGrId = 0x32cd32,
  95. kLinenGrId = 0xfaf0e6,
  96. kMagentaGrId = 0xff00ff,
  97. kMaroonGrId = 0x800000,
  98. kMediumAquaMarineGrId = 0x66cdaa,
  99. kMediumBlueGrId = 0x0000cd,
  100. kMediumOrchidGrId = 0xba55d3,
  101. kMediumPurpleGrId = 0x9370d8,
  102. kMediumSeaGreenGrId = 0x3cb371,
  103. kMediumSlateBlueGrId = 0x7b68ee,
  104. kMediumSpringGreenGrId = 0x00fa9a,
  105. kMediumTurquoiseGrId = 0x48d1cc,
  106. kMediumVioletRedGrId = 0xc71585,
  107. kMidnightBlueGrId = 0x191970,
  108. kMintCreamGrId = 0xf5fffa,
  109. kMistyRoseGrId = 0xffe4e1,
  110. kMoccasinGrId = 0xffe4b5,
  111. kNavajoWhiteGrId = 0xffdead,
  112. kNavyGrId = 0x000080,
  113. kOldLaceGrId = 0xfdf5e6,
  114. kOliveGrId = 0x808000,
  115. kOliveDrabGrId = 0x6b8e23,
  116. kOrangeGrId = 0xffa500,
  117. kOrangeRedGrId = 0xff4500,
  118. kOrchidGrId = 0xda70d6,
  119. kPaleGoldenRodGrId = 0xeee8aa,
  120. kPaleGreenGrId = 0x98fb98,
  121. kPaleTurquoiseGrId = 0xafeeee,
  122. kPaleVioletRedGrId = 0xd87093,
  123. kPapayaWhipGrId = 0xffefd5,
  124. kPeachPuffGrId = 0xffdab9,
  125. kPeruGrId = 0xcd853f,
  126. kPinkGrId = 0xffc0cb,
  127. kPlumGrId = 0xdda0dd,
  128. kPowderBlueGrId = 0xb0e0e6,
  129. kPurpleGrId = 0x800080,
  130. kRedGrId = 0xff0000,
  131. kRosyBrownGrId = 0xbc8f8f,
  132. kRoyalBlueGrId = 0x4169e1,
  133. kSaddleBrownGrId = 0x8b4513,
  134. kSalmonGrId = 0xfa8072,
  135. kSandyBrownGrId = 0xf4a460,
  136. kSeaGreenGrId = 0x2e8b57,
  137. kSeaShellGrId = 0xfff5ee,
  138. kSiennaGrId = 0xa0522d,
  139. kSilverGrId = 0xc0c0c0,
  140. kSkyBlueGrId = 0x87ceeb,
  141. kSlateBlueGrId = 0x6a5acd,
  142. kSlateGrayGrId = 0x708090,
  143. kSlateGreyGrId = 0x708090,
  144. kSnowGrId = 0xfffafa,
  145. kSpringGreenGrId = 0x00ff7f,
  146. kSteelBlueGrId = 0x4682b4,
  147. kTanGrId = 0xd2b48c,
  148. kTealGrId = 0x008080,
  149. kThistleGrId = 0xd8bfd8,
  150. kTomatoGrId = 0xff6347,
  151. kTurquoiseGrId = 0x40e0d0,
  152. kVioletGrId = 0xee82ee,
  153. kWheatGrId = 0xf5deb3,
  154. kWhiteGrId = 0xffffff,
  155. kWhiteSmokeGrId = 0xf5f5f5,
  156. kYellowGrId = 0xffff00,
  157. kYellowGreenGrId = 0x9acd32
  158. };
  159. typedef enum
  160. {
  161. kHomeGrId = 5, // 5
  162. kPageUpGrId, // 6
  163. kEndGrId, // 7
  164. kBackSpaceGrId = 8, // 8
  165. kTabGrId = 9, // 9
  166. kPageDownGrId, // 10
  167. kLeftGrId, // 11
  168. kUpGrId, // 12
  169. kEnterGrId = 13, // 13
  170. kRightGrId, // 14
  171. kDownGrId, // 15
  172. kInsertGrId, // 16
  173. kPrintGrId, // 17
  174. kScrollLockGrId, // 18
  175. kPauseGrId, // 19
  176. kMenuGrId, // 20
  177. kLShiftGrId, // 21
  178. kRShiftGrId, // 22
  179. kLCtrlGrId, // 23
  180. kRCtrlGrId, // 24
  181. kLAltGrId, // 25
  182. kRAltGrId, // 26
  183. kEscapeGrId = 27, // 27
  184. kLSuperGrId, // 28
  185. kRSuperGrId, // 29
  186. kNumLockGrId, // 30
  187. kCapsLockGrId, // 31
  188. kSpaceGrId = 32, // 32 Min. printable ASCII
  189. kExclMarkGrId, // 33
  190. kDQuoteGrId, // 34
  191. kPoundGrId, // 35
  192. kDollarGrId, // 36
  193. kPercentGrId, // 37
  194. kAmpersandGrId, // 38
  195. kApostropheGrId, // 39
  196. kLParenGrId, // 40
  197. kRParenGrId, // 41
  198. kAsteriskGrId, // 42
  199. kPlusGrId, // 43
  200. kCommaGrId, // 44
  201. kHyphenGrId, // 45
  202. kPeriodGrId, // 46
  203. kForwardSlashGrId, // 47
  204. k0GrId, // 48
  205. k1GrId, // 49
  206. k2GrId, // 50
  207. k3GrId, // 51
  208. k4GrId, // 52
  209. k5GrId, // 53
  210. k6GrId, // 54
  211. k7GrId, // 55
  212. k8GrId, // 56
  213. k9GrId, // 57
  214. kColonGrId, // 58
  215. kSemiColonGrId, // 59
  216. kLesserGrId, // 60
  217. kEqualGrId, // 61
  218. kGreaterGrId, // 62
  219. kQMarkGrId, // 63
  220. kAtGrId, // 64
  221. kA_GrId, // 65
  222. kB_GrId, // 66
  223. kC_GrId, // 67
  224. kD_GrId, // 68
  225. kE_GrId, // 69
  226. kF_GrId, // 70
  227. kG_GrId, // 71
  228. kH_GrId, // 72
  229. kI_GrId, // 73
  230. kJ_GrId, // 74
  231. kK_GrId, // 75
  232. kL_GrId, // 76
  233. kM_GrId, // 77
  234. kN_GrId, // 78
  235. kO_GrId, // 79
  236. kP_GrId, // 80
  237. kQ_GrId, // 81
  238. kR_GrId, // 82
  239. kS_GrId, // 83
  240. kT_GrId, // 84
  241. kU_GrId, // 85
  242. kV_GrId, // 86
  243. kW_GrId, // 87
  244. kX_GrId, // 88
  245. kY_GrId, // 89
  246. kZ_GrId, // 90
  247. kLBracketGrId, // 91
  248. kBackSlashGrId, // 92
  249. kRBracketGrId, // 93
  250. kCaretGrId, // 94
  251. kUnderScoreGrId, // 95
  252. kAccentGrId, // 96
  253. ka_GrId, // 97
  254. kb_GrId, // 98
  255. kc_GrId, // 99
  256. kd_GrId, // 100
  257. ke_GrId, // 101
  258. kf_GrId, // 102
  259. kg_GrId, // 103
  260. kh_GrId, // 104
  261. ki_GrId, // 105
  262. kj_GrId, // 106
  263. kk_GrId, // 107
  264. kl_GrId, // 108
  265. km_GrId, // 109
  266. kn_GrId, // 110
  267. ko_GrId, // 111
  268. kp_GrId, // 112
  269. kq_GrId, // 113
  270. kr_GrId, // 114
  271. ks_GrId, // 115
  272. kt_GrId, // 116
  273. ku_GrId, // 117
  274. kv_GrId, // 118
  275. kw_GrId, // 119
  276. kx_GrId, // 120
  277. ky_GrId, // 121
  278. kz_GrId, // 122
  279. kLBraceGrId, // 123
  280. kPipeGrId, // 124
  281. kRBraceGrId, // 125
  282. kTildeGrId, // 126
  283. kDeleteGrId, // 127
  284. kNP_MultGrId, // 128
  285. kNP_PlusGrId, // 129
  286. kNP_MinusGrId, // 130
  287. kNP_DecPtGrId, // 131
  288. kNP_DivGrId, // 132
  289. kNP_0GrId, // 133
  290. kNP_1GrId, // 134
  291. kNP_2GrId, // 135
  292. kNP_3GrId, // 136
  293. kNP_4GrId, // 137
  294. kNP_5GrId, // 138
  295. kNP_6GrId, // 139
  296. kNP_7GrId, // 140
  297. kNP_8GrId, // 141
  298. kNP_9GrId, // 142
  299. kNP_EqualGrId, // 143
  300. kNP_EnterGrId, // 144
  301. kFunc_1GrId, // 145
  302. kFunc_2GrId, // 146
  303. kFunc_3GrId, // 147
  304. kFunc_4GrId, // 148
  305. kFunc_5GrId, // 149
  306. kFunc_6GrId, // 150
  307. kFunc_7GrId, // 151
  308. kFunc_8GrId, // 152
  309. kFunc_9GrId, // 153
  310. kFunc_10GrId, // 154
  311. kFunc_11GrId, // 155
  312. kFunc_12GrId, // 156
  313. kBrightUpGrId, // 157
  314. kBrightDnGrId, // 158
  315. kAudio_PrevGrId, // 159
  316. kAudio_PlayGrId, // 160
  317. kAudio_NextGrId, // 161
  318. kAudio_MuteGrId, // 162
  319. kAudio_UpGrId, // 163
  320. kAudio_DnGrId, // 164
  321. kEjectGrId, // 165
  322. kInvalidKeyCodeGrId
  323. } cmGrKeyCodeId_t;
  324. enum
  325. {
  326. kMinAsciiGrId = kSpaceGrId,
  327. kMaxAsciiGrId = kDeleteGrId
  328. };
  329. enum
  330. {
  331. kOkGrRC,
  332. kLHeapFailGrRC,
  333. kAppErrGrRC,
  334. kRootObjCreateFailGrRC,
  335. kInvalidCoordsGrRC,
  336. kExtsErrGrRC
  337. };
  338. enum
  339. {
  340. kLeftGrFl = 0x01,
  341. kTopGrFl = 0x02,
  342. kRightGrFl = 0x04,
  343. kBottomGrFl = 0x08,
  344. };
  345. typedef enum
  346. {
  347. kLeftGrIdx = 0, // min-x
  348. kTopGrIdx = 1, // max-y
  349. kRightGrIdx = 2, // max-x
  350. kBottomGrIdx = 3, // min-y
  351. kAxisGrCnt = 4
  352. } cmGrAxisIdx_t;
  353. typedef cmHandle_t cmGrH_t;
  354. typedef cmHandle_t cmGrObjH_t;
  355. typedef cmHandle_t cmGrDcH_t;
  356. typedef unsigned cmGrRC_t;
  357. extern cmGrH_t cmGrNullHandle;
  358. extern cmGrObjH_t cmGrObjNullHandle;
  359. typedef cmReal_t cmGrV_t;
  360. //====================================================================================================
  361. // Calculate the width and height between two pixels.
  362. // This implies that the first and last pixel are inside the valid range.
  363. #define cmGrXtoW(x0,x1) (abs((x1)-(x0))+1)
  364. #define cmGrWtoX(x0,w) (((x0)+(w))-1)
  365. #define cmGrYtoH(y0,y1) (abs((y1)-(y0))+1)
  366. #define cmGrHtoY(y0,h) (((y0)+(h))-1)
  367. #define cmGrPIsXInRange(x,x0,w) ((x0)<=(x)&&(x)<=cmGrWtoX((x0),(w)))
  368. #define cmGrPIsYInRange(y,y0,h) ((y0)<=(y)&&(y)<=cmGrHtoY((y0),(h)))
  369. #define cmGrVIsXInRange(x,x0,w) ((x0)<=(x)&&(x)<=((x0)+(w)))
  370. #define cmGrVIsYInRange(y,y0,h) ((y0)<=(y)&&(y)<=((y0)+(h)))
  371. typedef struct
  372. {
  373. int x;
  374. int y;
  375. } cmGrPPt_t;
  376. #define cmGrPPtSet( p, xx, yy ) do{ (p)->x=(xx); (p)->y=(yy); }while(0)
  377. #define cmGrPPtIsEqual(p0,p1) ((p0)->x==(p1)->x && (p0)->y==(p1)->y)
  378. #define cmGrPPtPrint(lbl,p) printf("%s x=%i y=%i\n",(lbl),(p)->x,(p)->y)
  379. //====================================================================================================
  380. typedef struct
  381. {
  382. int w;
  383. int h;
  384. } cmGrPSz_t;
  385. #define cmGrPSzSet( s, ww, hh ) do{ (s)->w=(ww); (s)->h=(hh);}while(0)
  386. #define cmGrPSzSetD( s, x0, y0, x1, y1 ) cmGrPSzSet(cmGrXtoW(x0,x1),cmGrYtoH(y0,y1))
  387. #define cmGrPSzSetEmpty( s ) ((s)->w = (s)->h = 0)
  388. #define cmGrPSzSetNull( s ) ((s)->w = (s)->h = -1)
  389. #define cmGrPSzIsEmpty( s ) ((s)->w== 0 && (s)->h== 0)
  390. #define cmGrPSzIsNull( s ) ((s)->w==-1 && (s)->h==-1)
  391. #define cmGrPSzIsEqual(s0,s1) ((s0)->w==(s1)->w && (s0)->h==(s1)->h)
  392. #define cmGrPSzPrint(lbl,s) printf("%s w=%i h=%i\n",(lbl),(s)->w,(s)->h)
  393. //====================================================================================================
  394. typedef struct
  395. {
  396. cmGrPPt_t loc;
  397. cmGrPSz_t sz;
  398. } cmGrPExt_t;
  399. #define cmGrPExtSet( e, x, y, w, h ) do{ cmGrPPtSet(&(e)->loc,(x),(y)); cmGrPSzSet(&(e)->sz,(w),(h)); }while(0)
  400. #define cmGrPExtSetD(e, x0, y0, x1, y1) cmGrPExtSet(e,cmMin(x0,x1),cmMin(y0,y1),cmGrXtoW(x0,x1),cmGrYtoH(y0,y1))
  401. #define cmGrPExtL(e) ((e)->loc.x)
  402. #define cmGrPExtT(e) ((e)->loc.y)
  403. #define cmGrPExtR(e) (cmGrWtoX((e)->loc.x,(e)->sz.w))
  404. #define cmGrPExtB(e) (cmGrHtoY((e)->loc.y,(e)->sz.h))
  405. #define cmGrPExtW(e) ((e)->sz.w)
  406. #define cmGrPExtH(e) ((e)->sz.h)
  407. #define cmGrPExtSetL(e,v) ((e)->loc.x = (v))
  408. #define cmGrPExtSetT(e,v) ((e)->loc.y = (v))
  409. #define cmGrPExtSetR(e,v) cmGrPExtSetW(e,cmGrXtoW((e)->loc.x,(v)))
  410. #define cmGrPExtSetB(e,v) cmGrPExtSetH(e,cmGrYtoH((e)->loc.y,(v)))
  411. #define cmGrPExtSetW(e,v) ((e)->sz.w = (v))
  412. #define cmGrPExtSetH(e,v) ((e)->sz.h = (v))
  413. #define cmGrPExtCtrX(e) ((e)->loc.x + (e)->sz.w / 2)
  414. #define cmGrPExtCtrY(e) ((e)->loc.y + (e)->sz.h / 2)
  415. #define cmGrPExtCtr(e,pt) do{ (pt)->x=cmGrPExtCtrX(e); (pt)->y=cmGrPExtCtrY(e); }while(0)
  416. #define cmGrPExtSetEmpty( e ) do{ cmGrPSzSetEmpty(&(e)->sz); cmGrPPtSet(&(e)->loc,0,0); }while(0)
  417. #define cmGrPExtSetNull( e ) do{ cmGrPSzSetNull( &(e)->sz); cmGrPPtSet(&(e)->loc,0,0); }while(0)
  418. #define cmGrPExtIsEmpty( e ) cmGrPSzIsEmpty( &(e)->sz )
  419. #define cmGrPExtIsNull( e ) cmGrPSzIsNull( &(e)->sz )
  420. #define cmGrPExtIsNullOrEmpty(e) (cmGrPExtIsNull(e)||cmGrPExtIsEmpty(e))
  421. #define cmGrPExtIsNotEmpty(e) (!cmGrPExtIsEmpty(e))
  422. #define cmGrPExtIsNotNull(e) (!cmGrPExtIsNull(e))
  423. #define cmGrPExtIsNotNullOrEmpty(e) (cmGrPExtIsNotNull(e)&&cmGrPExtIsNotEmpty(e))
  424. #define cmGrPExtIsEqual( e0, e1 ) (cmGrPPtIsEqual(&(e0)->loc,&(e1)->loc) && cmGrPSzIsEqual(&(e0)->sz, &(e1)->sz))
  425. #define cmGrPExtIsXyInside( e, xx, yy) (cmGrPIsXInRange((xx),(e)->loc.x,(e)->sz.w) && cmGrPIsYInRange((yy), (e)->loc.y, (e)->sz.h) )
  426. #define cmGrPExtIsPtInside( e, pt ) (cmGrPExtIsXyInside((e),(pt)->x,(pt)->y))
  427. #define cmGrPExtIsExtInside(e0, e1) (cmGrPExtIsPtInside((e0),&((e1)->loc)) && cmGrPExtIsXyInside((e0), cmGrWtoX((e1)->loc.x,(e1)->sz.w), cmGrHtoY((e1)->loc.y,(e1)->sz.h)))
  428. #define cmGrPExtExpand(e,l,t,r,b) do{(e)->loc.x+=(l); (e)->loc.y+=(t); (e)->sz.w+=(abs(l)+abs(r)); (e)->sz.h+=(abs(t)+abs(b));}while(0)
  429. #define cmGrPExtRpt(e,rpt) cmRptPrintf(rpt,"x:%i y:%i w:%i h:%i",(e)->loc.x,(e)->loc.y,(e)->sz.w,(e)->sz.h)
  430. #define cmGrPExtPrint(lbl,e) printf("%s %i %i %i %i\n",lbl,(e)->loc.x,(e)->loc.y,(e)->sz.w,(e)->sz.h)
  431. void cmGrPExtIntersect( cmGrPExt_t* r, const cmGrPExt_t* e0, const cmGrPExt_t* e1 );
  432. //====================================================================================================
  433. typedef struct
  434. {
  435. cmGrV_t x;
  436. cmGrV_t y;
  437. } cmGrVPt_t;
  438. #define cmGrVPtSet( p, xx, yy ) do{ (p)->x=(xx); (p)->y=(yy); }while(0)
  439. #define cmGrVPtIsEqual(p0,p1) ((p0)->x==(p1)->x && (p0)->y==(p1)->y)
  440. #define cmGrVPtIsNotEqual(p0,p1) (!cmGrVPtIsEqual(p0,p1))
  441. //====================================================================================================
  442. typedef struct
  443. {
  444. cmGrV_t w;
  445. cmGrV_t h;
  446. } cmGrVSz_t;
  447. #define cmGrVSzSet( s, ww, hh ) do{ (s)->w=(ww); (s)->h=(hh);}while(0)
  448. #define cmGrVSzSetD( s, x0, y0, x1, y1 ) cmGrVSzSet((x1)-(x0),(y1)-(y0))
  449. #define cmGrVSzSetEmpty( s ) ((s)->w = (s)->h = 0)
  450. #define cmGrVSzSetNull( s ) ((s)->w = (s)->h = -1)
  451. #define cmGrVSzIsEmpty( s ) ((s)->w== 0 && (s)->h== 0)
  452. #define cmGrVSzIsNull( s ) ((s)->w==-1 || (s)->h==-1)
  453. #define cmGrVSzIsEqual(s0,s1) ((s0)->w==(s1)->w && (s0)->h==(s1)->h)
  454. //====================================================================================================
  455. typedef struct
  456. {
  457. cmGrVPt_t loc;
  458. cmGrVSz_t sz;
  459. } cmGrVExt_t;
  460. #define cmGrVExtIsNorm( e ) ((e)->sz.w>=0 && (e)->sz.h>=0)
  461. #define cmGrVExtNorm( e ) do{ if( cmGrVExtIsNotNull(e) ){ if((e)->sz.w<0){(e)->loc.x += (e)->sz.w; (e)->sz.w*=-1;} if((e)->sz.h<0){(e)->loc.y += (e)->sz.h; (e)->sz.h*=-1;}} }while(0)
  462. #define cmGrVExtSet( e, x, y, w, h ) do{ cmGrVPtSet(&(e)->loc,(x),(y)); cmGrVSzSet(&(e)->sz,(w),(h)); cmGrVExtNorm(e); }while(0)
  463. #define cmGrVExtSetD(e, x0, y0, x1, y1) cmGrVExtSet((e),(x0),(y0),(x1)-(x0),(y1)-(y0))
  464. //
  465. // l,t minx,maxy
  466. // r,b maxx,miny
  467. //
  468. #define cmGrVExtMinX(e) ((e)->loc.x)
  469. #define cmGrVExtMinY(e) ((e)->loc.y)
  470. #define cmGrVExtMaxX(e) ((e)->loc.x + (e)->sz.w)
  471. #define cmGrVExtMaxY(e) ((e)->loc.y + (e)->sz.h)
  472. #define cmGrVExtW(e) ((e)->sz.w)
  473. #define cmGrVExtH(e) ((e)->sz.h)
  474. #define cmGrVExtSetMinX(e,v) ((e)->loc.x = (v))
  475. #define cmGrVExtSetMinY(e,v) ((e)->loc.y = (v))
  476. // Beware: setting maxx and maxy depends on the current value of minx and miny.
  477. // If both minx and maxx are being changed then be sure to set minx first.
  478. // If both miny and maxy are being changed then be sure to set miny first.
  479. #define cmGrVExtSetMaxX(e,v) ((e)->sz.w = (v) - cmGrVExtMinX(e))
  480. #define cmGrVExtSetMaxY(e,v) ((e)->sz.h = (v) - cmGrVExtMinY(e))
  481. #define cmGrVExtSetW(e,v) ((e)->sz.w = (v))
  482. #define cmGrVExtSetH(e,v) ((e)->sz.h = (v))
  483. #define cmGrVExtSetEmpty( e ) do{ cmGrVSzSetEmpty(&(e)->sz); cmGrVPtSet(&(e)->loc,0,0); }while(0)
  484. #define cmGrVExtSetNull( e ) do{ cmGrVSzSetNull(&(e)->sz); cmGrVPtSet(&(e)->loc,0,0); }while(0)
  485. #define cmGrVExtIsEmpty( e ) cmGrVSzIsEmpty(&(e)->sz)
  486. #define cmGrVExtIsNull( e ) cmGrVSzIsNull( &(e)->sz)
  487. #define cmGrVExtIsNullOrEmpty(e) (cmGrVExtIsNull(e)||cmGrVExtIsEmpty(e))
  488. #define cmGrVExtIsNotEmpty(e) (!cmGrVExtIsEmpty(e))
  489. #define cmGrVExtIsNotNull(e) (!cmGrVExtIsNull(e))
  490. #define cmGrVExtIsNotNullOrEmpty(e) (cmGrVExtIsNotNull(e)&&cmGrVExtIsNotEmpty(e))
  491. #define cmGrVExtIsEqual( e0, e1 ) (cmGrVPtIsEqual(&(e0)->loc,&(e1)->loc) && cmGrVSzIsEqual(&(e0)->sz, &(e1)->sz))
  492. #define cmGrVExtIsXyInside( e, xx, yy) (cmGrVIsXInRange((xx),(e)->loc.x,(e)->sz.w) && cmGrVIsYInRange((yy),(e)->loc.y,(e)->sz.h))
  493. #define cmGrVExtIsPtInside( e, pt ) (cmGrVExtIsXyInside((e),(pt)->x,(pt)->y))
  494. // e1 is inside e0
  495. #define cmGrVExtIsExtInside(e0, e1) (cmGrVExtIsXyInside((e0),cmGrVExtMinX(e1),cmGrVExtMinY(e1)) && cmGrVExtIsXyInside((e0), cmGrVExtMaxX(e1), cmGrVExtMaxY(e1)))
  496. #define cmGrVExtRpt(e,rpt) cmRptPrintf(rpt,"x:%f y:%f w:%f h:%f",(e)->loc.x,(e)->loc.y,(e)->sz.w,(e)->sz.h)
  497. #define cmGrVExtPrint(lbl,e) printf("%s %f %f %f %f\n",lbl,(e)->loc.x,(e)->loc.y,(e)->sz.w,(e)->sz.h)
  498. // Shift and expand e0 to contain e1. Return true if e0 actually changes.
  499. bool cmGrVExtExpandToContain( cmGrVExt_t* e0, const cmGrVExt_t* e1 );
  500. // Force e1 to be contained by e0 by shifting e1's location. This function
  501. // will never change the width or height of e1. Return true if e1 is changed.
  502. bool cmGrVExtContain( const cmGrVExt_t* e0, cmGrVExt_t* e1 );
  503. // Return the intersection of 'e0' with 'e1' in 'r'.
  504. void cmGrVExtIntersect( cmGrVExt_t* r, const cmGrVExt_t* e0, const cmGrVExt_t* e1 );
  505. //====================================================================================================
  506. #define cmGrRgbToColor( r, g, b ) (((r) << 16) + ((g) << 8) + (b))
  507. #define cmGrColorToR( c ) (((c) >> 16) & 0x000000ff)
  508. #define cmGrColorToG( c ) (((c) >> 8) & 0x000000ff)
  509. #define cmGrColorToB( c ) (((c) ) & 0x000000ff)
  510. typedef unsigned cmGrColor_t;
  511. enum { kGrDefaultColorMapIdx = 0, kGrDefaultColorMapId=0 };
  512. unsigned cmGrColorMapCount( cmGrH_t grH );
  513. unsigned cmGrColorMapId( cmGrH_t grH, unsigned mapIdx );
  514. const cmChar_t* cmGrColorMapLabel( cmGrH_t grH, unsigned id );
  515. unsigned cmGrColorMapRegister( cmGrH_t grH, cmChar_t* label, const cmGrColor_t* array, unsigned cnt );
  516. cmGrColor_t* cmGrColorMap( cmGrH_t grH, unsigned mapId );
  517. unsigned cmGrColorMapEleCount( cmGrH_t grH, unsigned mapId );
  518. //====================================================================================================
  519. typedef struct
  520. {
  521. cmCtx_t* ctx; // application context
  522. cmGrH_t grH; // graphics system handle to which this graphic object belongs
  523. cmGrObjH_t objH; // this graphics object handle
  524. void* cbArg; // user callback arg
  525. cmGrPPt_t msDnPPt; // mouse down phys point
  526. cmGrVPt_t msDnVPt; // mouse down virt point inside op->parent->wext
  527. cmGrVSz_t msDnVOffs; // virtual offset from mouse down point to msDnObj->vext
  528. cmGrObjH_t msDnObjH; // handle of object which recv'd mouse down
  529. cmGrVPt_t msVPt; // cur ms virtual point
  530. } cmGrObjFuncArgs_t;
  531. typedef cmGrRC_t (*cmGrCreateObjCb_t)( cmGrObjFuncArgs_t* args );
  532. typedef void (*cmGrDestroyObjCb_t)( cmGrObjFuncArgs_t* args );
  533. typedef bool (*cmGrRenderObjCb_t)( cmGrObjFuncArgs_t* args, cmGrDcH_t dcH );
  534. typedef int (*cmGrDistanceObjCb_t)( cmGrObjFuncArgs_t* args, int x, int y );
  535. typedef bool (*cmGrEventObjCb_t)( cmGrObjFuncArgs_t* args, unsigned flags, unsigned key, int px, int py );
  536. typedef void (*cmGrVExtObjCb_t)( cmGrObjFuncArgs_t* args, cmGrVExt_t* vext );
  537. typedef bool (*cmGrIsInsideObjCb_t)( cmGrObjFuncArgs_t* args, unsigned evtFlags, int px, int py, cmGrV_t vx, cmGrV_t vy );
  538. typedef struct cmGrObjFunc_str
  539. {
  540. // User defined constructor.
  541. cmGrCreateObjCb_t createCbFunc;
  542. void* createCbArg;
  543. // User defined destructor.
  544. cmGrDestroyObjCb_t destroyCbFunc;
  545. void* destroyCbArg;
  546. // Draw the object by calling back to the cmGrDrawXXX() functions
  547. cmGrRenderObjCb_t renderCbFunc;
  548. void* renderCbArg;
  549. // Return the physical distance from a physical view location to the object.
  550. // (NOT USED)
  551. cmGrDistanceObjCb_t distanceCbFunc;
  552. void* distanceCbArg;
  553. // Handle an event. gx,gy are in the same coord's as args.objH.vext (they are inside args.objH.parent.wext).
  554. // Return true if the event objects dirty flag should be set.
  555. cmGrEventObjCb_t eventCbFunc;
  556. void* eventCbArg;
  557. // Return the objects location and size inside op->parent->wext
  558. cmGrVExtObjCb_t vextCbFunc;
  559. void* vextCbArg;
  560. // Called to determine which object is under the mouse and whether the event can
  561. // handle the event as described by the 'evtFlags' args.
  562. // Return true if the point is inside this obj. vx,vy is in the the same coord's
  563. // as op->vext (i.e. vx,vy is inside op->parent->wext) and the object will accept
  564. // the event implied by the 'evtFlags' argument.
  565. // The simple answer to this call is cmGrVExtIsXyInside( *vext, vx, vy ).
  566. cmGrIsInsideObjCb_t isInsideCbFunc;
  567. void* isInsideCbArg;
  568. } cmGrObjFunc_t;
  569. // Create a graphic object. This function calls the user defined (*create)() function.
  570. // ('flags' is not used)
  571. cmGrRC_t cmGrObjCreate( cmGrH_t h, cmGrObjH_t* hp, cmGrObjH_t parentH, cmGrObjFunc_t* f, unsigned id, unsigned flags, const cmGrVExt_t* wext );
  572. // Destroy a graphic object and all of it's children.
  573. // This function calls the user defined (*destroy)() function.
  574. cmGrRC_t cmGrObjDestroy( cmGrH_t h, cmGrObjH_t* hp );
  575. // Return true if 'oh' is a valid handle.
  576. cmGrRC_t cmGrObjIsValid( cmGrH_t h, cmGrObjH_t oh );
  577. // Return the user id associated with this object.
  578. unsigned cmGrObjId( cmGrObjH_t oh );
  579. void cmGrObjSetId( cmGrObjH_t oh, unsigned id );
  580. // Return the handle to the parent object.
  581. cmGrObjH_t cmGrObjParent( cmGrObjH_t oh );
  582. // An object world coord's are used to place child objects.
  583. cmGrRC_t cmGrObjSetWorldExt( cmGrH_t h, cmGrObjH_t oh, const cmGrVExt_t* vext );
  584. void cmGrObjWorldExt( cmGrObjH_t oh, cmGrVExt_t* vext );
  585. cmGrRC_t cmGrObjSetWorldLimitExt( cmGrH_t h, cmGrObjH_t oh, const cmGrVExt_t* vext, unsigned limitFlags );
  586. void cmGrObjWorldLimitExt( cmGrObjH_t oh, cmGrVExt_t* vext, unsigned* limitFlags );
  587. void cmGrObjSetCreateCb( cmGrObjH_t oh, cmGrCreateObjCb_t cbFunc, void* cbArg );
  588. void cmGrObjSetDestroyCb( cmGrObjH_t oh, cmGrDestroyObjCb_t cbFunc, void* cbArg );
  589. void cmGrObjSetRenderCb( cmGrObjH_t oh, cmGrRenderObjCb_t cbFunc, void* cbArg );
  590. void cmGrObjSetDistanceCb( cmGrObjH_t oh, cmGrDistanceObjCb_t cbFunc, void* cbArg );
  591. void cmGrObjSetEventCb( cmGrObjH_t oh, cmGrEventObjCb_t cbFunc, void* cbArg );
  592. void cmGrObjSetVExtCb( cmGrObjH_t oh, cmGrVExtObjCb_t cbFunc, void* cbArg );
  593. void cmGrObjSetIsInsideCb( cmGrObjH_t oh, cmGrIsInsideObjCb_t cbFunc, void* cbArg );
  594. cmGrCreateObjCb_t cmGrObjCreateCbFunc( cmGrObjH_t oh );
  595. cmGrDestroyObjCb_t cmGrObjDestroyCbFunc( cmGrObjH_t oh );
  596. cmGrRenderObjCb_t cmGrObjRenderCbFunc( cmGrObjH_t oh );
  597. cmGrDistanceObjCb_t cmGrObjDistanceCbFunc( cmGrObjH_t oh );
  598. cmGrEventObjCb_t cmGrObjEventCbFunc( cmGrObjH_t oh );
  599. cmGrVExtObjCb_t cmGrObjVExtCbFunc( cmGrObjH_t oh );
  600. cmGrIsInsideObjCb_t cmGrObjIsInsideCbFunc( cmGrObjH_t oh );
  601. void* cmGrObjCreateCbArg( cmGrObjH_t oh );
  602. void* cmGrObjDestroyCbArg( cmGrObjH_t oh );
  603. void* cmGrObjRenderCbArg( cmGrObjH_t oh );
  604. void* cmGrObjDistanceCbArg( cmGrObjH_t oh );
  605. void* cmGrObjEventCbArg( cmGrObjH_t oh );
  606. void* cmGrObjVExtCbArg( cmGrObjH_t oh );
  607. void* cmGrObjIsInsideCbArg( cmGrObjH_t oh );
  608. // Same as call to user defined (*vect)().
  609. void cmGrObjLocalVExt( cmGrH_t h, cmGrObjH_t oh, cmGrVExt_t* vext );
  610. // Given an objects id return it's handle.
  611. cmGrObjH_t cmGrObjIdToHandle( cmGrH_t h, unsigned id );
  612. // Move 'aoH' such that it is drawn above 'boH' in the z-order.
  613. // This means that 'boH' will be drawn before 'aoH'.
  614. void cmGrObjDrawAbove( cmGrObjH_t boH, cmGrObjH_t aoH );
  615. void cmGrObjReport( cmGrH_t h, cmGrObjH_t oh, cmRpt_t* rpt );
  616. void cmGrObjReportR( cmGrH_t h, cmGrObjH_t oh, cmRpt_t* rpt ); // print children
  617. //====================================================================================================
  618. // Drawing Functions - called by objects to draw themselves
  619. int cmGrX_VtoP( cmGrH_t hh, cmGrObjH_t oh, cmGrV_t y );
  620. int cmGrY_VtoP( cmGrH_t hh, cmGrObjH_t oh, cmGrV_t x );
  621. void cmGrXY_VtoP( cmGrH_t hh, cmGrObjH_t oh, cmGrV_t x, cmGrV_t y, cmGrPPt_t* rp );
  622. void cmGrXYWH_VtoP( cmGrH_t hh, cmGrObjH_t oh, cmGrV_t x, cmGrV_t y, cmGrV_t w, cmGrV_t h, cmGrPExt_t* pext );
  623. void cmGrVExt_VtoP( cmGrH_t hh, cmGrObjH_t oh, const cmGrVExt_t* vext, cmGrPExt_t* pext );
  624. void cmGrXY_PtoV( cmGrH_t hh, cmGrObjH_t oh, int x, int y, cmGrVPt_t* rp );
  625. void cmGrXYWH_PtoV( cmGrH_t hh, cmGrObjH_t oh, int x, int y, int w, int h, cmGrVExt_t* vext );
  626. void cmGrPExt_PtoV( cmGrH_t hh, cmGrObjH_t oh, const cmGrPExt_t* pext, cmGrVExt_t* vext );
  627. void cmGrDrawVLine( cmGrH_t hh, cmGrDcH_t dcH, cmGrObjH_t oh, cmGrV_t x0, cmGrV_t y0, cmGrV_t x1, cmGrV_t y1 );
  628. void cmGrDrawVRect( cmGrH_t hh, cmGrDcH_t dcH, cmGrObjH_t oh, cmGrV_t x, cmGrV_t y, cmGrV_t w, cmGrV_t h );
  629. //====================================================================================================
  630. // Callback identifiers
  631. typedef enum
  632. {
  633. kCreateCbGrId,
  634. kDestroyCbGrId,
  635. kLocalPtCbGrId,
  636. kGlobalPtCbGrId,
  637. kPhysExtCbGrId,
  638. kViewExtCbGrId,
  639. kSelectExtCbGrId,
  640. kFocusCbGrId,
  641. kKeyUpCbGrId,
  642. kKeyDnCbGrId
  643. } cmGrCbId_t;
  644. // Callback function associated with this canvas.
  645. typedef void (*cmGrCbFunc_t)( void* arg, cmGrH_t grH, cmGrCbId_t id, unsigned evtFlags, cmGrKeyCodeId_t keycode );
  646. // Configuration Flags
  647. enum
  648. {
  649. kExpandViewGrFl = 0x01, // expand the view to show new objects
  650. kSelectHorzGrFl = 0x02, // select along x-axis only
  651. kSelectVertGrFl = 0x04 // select along y-axis only
  652. };
  653. // 'wext' is optional.
  654. // 'id' is an arbitrary user definable identifier - although it is used
  655. // as the view index by cmGrPage().
  656. cmGrRC_t cmGrCreate(
  657. cmCtx_t* ctx,
  658. cmGrH_t* hp,
  659. unsigned id,
  660. unsigned cfgFlags,
  661. cmGrCbFunc_t cbFunc,
  662. void* cbArg,
  663. const cmGrVExt_t* wext ); // Optional internal world extents for this object
  664. // Destroy this canvas.
  665. cmGrRC_t cmGrDestroy( cmGrH_t* hp );
  666. // Remove all objects from the root object and restore the canvas to it's default state.
  667. cmGrRC_t cmGrClear( cmGrH_t h );
  668. // Get the root object handle
  669. cmGrObjH_t cmGrRootObjH( cmGrH_t h );
  670. // Get and set the configuration flags (e.g. kExpandViewGrFl | kSelectHorzGrFl | kSelectVertHorzGrFl )
  671. unsigned cmGrCfgFlags( cmGrH_t h );
  672. void cmGrSetCfgFlags( cmGrH_t h, unsigned cfgFlags );
  673. // Draw the objects on the canvas.
  674. cmGrRC_t cmGrDraw( cmGrH_t h, cmGrDcH_t dcH );
  675. // event flags
  676. enum
  677. {
  678. kMsDownGrFl = 0x0001,
  679. kMsUpGrFl = 0x0002,
  680. kMsMoveGrFl = 0x0004,
  681. kMsWheelGrFl= 0x0008,
  682. kMsDragGrFl = 0x0010,
  683. kMsClickGrFl= 0x0020,
  684. kKeyDnGrFl = 0x0040,
  685. kKeyUpGrFl = 0x0080,
  686. kMsEvtMask = 0x02f,
  687. kEvtMask = 0x00ff,
  688. kMsLBtnGrFl = 0x0100,
  689. kMsCBtnGrFl = 0x0200,
  690. kMsRBtnGrFl = 0x0400,
  691. kShiftKeyGrFl = 0x0800,
  692. kAltKeyGrFl = 0x1000,
  693. kCtlKeyGrFl = 0x2000,
  694. };
  695. // Receive a UI event.
  696. bool cmGrEvent( cmGrH_t h, unsigned flags, cmGrKeyCodeId_t key, int x, int y );
  697. // Return true if 'h' is valid.
  698. bool cmGrIsValid( cmGrH_t h );
  699. // Return the user defined 'id' set in cmGrCreate()
  700. unsigned cmGrId( cmGrH_t h );
  701. // Return the last mouse location in root object coordinates.
  702. const cmGrVPt_t* cmGrGlobalPt( cmGrH_t h );
  703. // Return the last mouse location in coordinates of the object the mouse was over.
  704. const cmGrVPt_t* cmGrLocalPt( cmGrH_t h );
  705. // The new view extents must fit inside the world extents.
  706. // Return true if the view extents actually changed.
  707. bool cmGrSetViewExtents( cmGrH_t hh, cmGrV_t minx, cmGrV_t miny, cmGrV_t maxx, cmGrV_t maxy );
  708. bool cmGrSetViewExtentsE(cmGrH_t h, const cmGrVExt_t* ext );
  709. void cmGrViewExtents( cmGrH_t h, cmGrVExt_t* exts );
  710. // View Location
  711. // Return true if the phys extents actually changed.
  712. bool cmGrSetPhysExtents( cmGrH_t hh, int x, int y, int w, int h );
  713. bool cmGrSetPhysExtentsE(cmGrH_t h, const cmGrPExt_t* ext );
  714. void cmGrPhysExtents( cmGrH_t h, cmGrPExt_t* exts );
  715. // Return some scroll bar values for this canvas.
  716. // tot=world pixels, vis=vis pixels, max=max scroll pos pos=cur scroll pos
  717. // All return values are optional.
  718. void cmGrScrollExtents( cmGrH_t h, cmGrPSz_t* tot, cmGrPSz_t* vis, cmGrPSz_t* max, cmGrPPt_t* pos );
  719. // Return true if the view location actually changed.
  720. bool cmGrSetScrollH( cmGrH_t h, int x );
  721. int cmGrScrollH( cmGrH_t h );
  722. bool cmGrSetScrollV( cmGrH_t h, int y );
  723. int cmGrScrollV( cmGrH_t h );
  724. // Get the current selection extents.
  725. // If the selection extents are not valid then the function returns false
  726. // and sets the return extents to their null state.
  727. bool cmGrSelectExtents( cmGrH_t h, cmGrVExt_t* vext, cmGrPExt_t* pext );
  728. // Both pts are optional
  729. void cmGrSetSelectPoints(cmGrH_t h, const cmGrVPt_t* pt0, const cmGrVPt_t* pt1 );
  730. void cmGrSelectPoints( cmGrH_t h, cmGrVPt_t* pt0, cmGrVPt_t* pt1 );
  731. enum { kZoomInGrFl=0x01, kXAxisGrFl=0x02, kYAxisGrFl=0x04, kSelectGrFl=0x08, kShowAllGrFl=0x10 };
  732. // 1) If kSelectGrFl is not set then the center 1/3 of the current view
  733. // becomes the new view.
  734. // 2) If kSelectGrFl is set then the selection area becomes the view.
  735. // 3) If kSelectGrFl is set but no selection area exists then
  736. // option 1) is selected used and using the selection point as center.
  737. void cmGrZoom( cmGrH_t h, unsigned flags );
  738. // Synchronize the 'syncGrH' horz. and/or verical, world,view,select extents to
  739. // this gr's extents. Changes to this gr's extents will be automatically
  740. // applied to 'syncGrH'.
  741. // If 'syncGrH' was used in a previous call to this function then flags will
  742. // modify the previously set flags value.
  743. // Clear the kHorzSyncFl and kVertSyncFl to disable the synchronization.
  744. // Set flags to 0 to prevent future sync calls.
  745. enum { kWorldSyncGrFl=0x01, kViewSyncGrFl=0x02, kSelectSyncGrFl=0x04, kHorzSyncGrFl=0x08, kVertSyncGrFl=0x10 };
  746. void cmGrSetSync( cmGrH_t h, cmGrH_t syncGrH, unsigned flags );
  747. void cmGrReport( cmGrH_t h, cmRpt_t* rpt );
  748. //)
  749. #ifdef __cplusplus
  750. }
  751. #endif
  752. #endif