CDSFontColrF.cpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. //---------------------------------------------------------------------------
  2. #pragma hdrstop
  3. #include "CDSFontColrF.h"
  4. #include "AppGlobalF.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. //---------------------------------------------------------------------------
  8. TVmsFontColr::TVmsFontColr(int ACOLR_CD, String ACOLR_NM, String ACOLR_DESC, int ACOLR_VAL, int ACOLR_R, int ACOLR_G, int ACOLR_B)
  9. {
  10. COLR_CD = ACOLR_CD;
  11. COLR_NM = ACOLR_NM;
  12. COLR_DESC = ACOLR_DESC;
  13. COLR_VAL = ACOLR_VAL;
  14. COLR_R = ACOLR_R;
  15. COLR_G = ACOLR_G;
  16. COLR_B = ACOLR_B;
  17. USE_YN = "Y";
  18. }
  19. //---------------------------------------------------------------------------
  20. TFontColrManager *FontColrManager = NULL;
  21. //---------------------------------------------------------------------------
  22. TFontColrManager::TFontColrManager()
  23. {
  24. }
  25. //---------------------------------------------------------------------------
  26. TFontColrManager::~TFontColrManager()
  27. {
  28. FLists.RemoveAll();
  29. }
  30. //---------------------------------------------------------------------------
  31. int TFontColrManager::Load()
  32. {
  33. FLists.RemoveAll();
  34. String apiUri = g_AppCfg.sRestApiUri + "/api/vms/common/vms-form-font-colr";
  35. TMcJsonItem *ObjList = NULL;
  36. try {
  37. ObjList = TRestObjectManager::RequestGet(apiUri);
  38. if (ObjList == NULL) {
  39. return 0;
  40. }
  41. for (int ii = 0; ii < ObjList->Count; ii++) {
  42. String sUseYn = TRestObjectManager::GetValue(ObjList->Items[ii], "use_yn");
  43. if (sUseYn != "Y") {
  44. continue;
  45. }
  46. String sCD = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_font_colr_cd");
  47. String sNM = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_font_colr_nm");
  48. String sDESC = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_font_colr_desc");
  49. String sVal = TRestObjectManager::GetValue(ObjList->Items[ii], "vms_font_colr_val");
  50. String sR = TRestObjectManager::GetValue(ObjList->Items[ii], "color_r");
  51. String sG = TRestObjectManager::GetValue(ObjList->Items[ii], "color_g");
  52. String sB = TRestObjectManager::GetValue(ObjList->Items[ii], "color_b");
  53. TVmsFontColr *pObj = new TVmsFontColr(sCD.ToIntDef(0), sNM, sDESC, sVal.ToIntDef(0), sR.ToIntDef(0), sG.ToIntDef(0), sB.ToIntDef(0));
  54. FLists.Push(pObj->COLR_CD, pObj);
  55. }
  56. } __finally {
  57. if (ObjList) delete ObjList;
  58. }
  59. return 0;
  60. }
  61. //---------------------------------------------------------------------------
  62. TVmsFontColr* TFontColrManager::Find(int ATypeCd)
  63. {
  64. return FLists.Find(ATypeCd);
  65. }
  66. //---------------------------------------------------------------------------
  67. int TFontColrManager::GetColorCode(int AColor)
  68. {
  69. FOR_STL(TVmsFontColr*, pObj, FLists)
  70. {
  71. if (AColor == pObj->COLR_VAL) return pObj->COLR_CD;
  72. }
  73. return 0;
  74. }
  75. //---------------------------------------------------------------------------
  76. int TFontColrManager::GetColorCodeIndex(int ACode)
  77. {
  78. int nIdx = 0;
  79. FOR_STL(TVmsFontColr*, pObj, FLists)
  80. {
  81. if (ACode == pObj->COLR_CD) return nIdx;
  82. nIdx++;
  83. }
  84. return 0;
  85. }
  86. //---------------------------------------------------------------------------