WndImagePart.cpp
上传用户:dzyhzl
上传日期:2019-04-29
资源大小:56270k
文件大小:3k
源码类别:

模拟服务器

开发平台:

C/C++

  1. /*****************************************************************************************
  2. // 界面窗口体系结构--显示图形局部的窗口
  3. // Copyright : Kingsoft 2002
  4. // Author :   Wooy(Wu yue)
  5. // CreateTime: 2002-7-25
  6. *****************************************************************************************/
  7. #include "KWin32.h"
  8. #include "KIniFile.h"
  9. #include "WndImagePart.h"
  10. #include "KSprite.h"
  11. #include "../../../Represent/iRepresent/iRepresentShell.h"
  12. extern iRepresentShell* g_pRepresentShell;
  13. //--------------------------------------------------------------------------
  14. // 功能:构造函数
  15. //--------------------------------------------------------------------------
  16. KWndImagePart::KWndImagePart()
  17. {
  18. IR_InitUiImagePartRef(m_Image);
  19. }
  20. void KWndImagePart::Clone(KWndImagePart* pCopy)
  21. {
  22. if (pCopy)
  23. {
  24. KWndWindow::Clone(pCopy);
  25. pCopy->m_Image = m_Image;
  26. pCopy->SetPart(0, 100);
  27. }
  28. }
  29. //--------------------------------------------------------------------------
  30. // 功能:初始化窗口
  31. //--------------------------------------------------------------------------
  32. int KWndImagePart::Init(KIniFile* pIniFile, const char* pSection)
  33. {
  34. if (KWndWindow::Init(pIniFile, pSection))
  35. {
  36. pIniFile->GetInteger(pSection, "PartType", 0, &m_Image.nDivideFashion);
  37. if (m_Image.nDivideFashion < IDF_LEFT_TO_RIGHT || m_Image.nDivideFashion > IDF_BOTTOM_TO_TOP)
  38. m_Image.nDivideFashion = IDF_LEFT_TO_RIGHT;
  39. m_Image.uImage = 0;
  40. m_Image.nISPosition = 0;
  41. int nValue;
  42. pIniFile->GetInteger(pSection, "ImgType", 0, &nValue);
  43. if (nValue == 1)
  44. {
  45. m_Image.nType = ISI_T_BITMAP16;
  46. m_Image.bRenderStyle = IMAGE_RENDER_STYLE_OPACITY;
  47. }
  48. else
  49. {
  50. m_Image.nType = ISI_T_SPR;
  51. m_Image.bRenderStyle = IMAGE_RENDER_STYLE_ALPHA;
  52. }
  53. pIniFile->GetString(pSection, "Image", "" , m_Image.szImage, sizeof(m_Image.szImage));
  54. return true;
  55. }
  56. return false;
  57. }
  58. //--------------------------------------------------------------------------
  59. // 功能:窗体绘制
  60. //--------------------------------------------------------------------------
  61. void KWndImagePart::PaintWindow()
  62. {
  63. KWndWindow::PaintWindow();
  64. if (g_pRepresentShell)
  65. {
  66. #ifdef _DEBUG
  67. if (m_Image.szImage[0] == 0 && WND_SHOW_DEBUG_FRAME_TEXT)
  68. {
  69. g_pRepresentShell->OutputText(16, m_Caption, -1, m_nAbsoluteLeft + 1, m_nAbsoluteTop + 1, 0xFF000000);
  70. g_pRepresentShell->OutputText(16, m_Caption, -1, m_nAbsoluteLeft, m_nAbsoluteTop, 0xFFFFFFFF);
  71. }
  72. else
  73. #endif
  74. {
  75. m_Image.oPosition.nX = m_nAbsoluteLeft;
  76. m_Image.oPosition.nY = m_nAbsoluteTop;
  77. g_pRepresentShell->DrawPrimitives(1, &m_Image, RU_T_IMAGE_PART, true);
  78. }
  79. }
  80. }
  81. //--------------------------------------------------------------------------
  82. // 功能:根据部分值与全值的比例关系设置绘制图的哪部分区域
  83. //--------------------------------------------------------------------------
  84. void KWndImagePart::SetPart(int nPartValue, int nFullValue)
  85. {
  86. if (nFullValue)
  87. IR_UpdateImagePart(m_Image, nPartValue, nFullValue);
  88. }