home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 March / CMCD0304.ISO / Software / Freeware / Programare / nullsoft / nsis20.exe / Source / DialogTemplate.h < prev    next >
C/C++ Source or Header  |  2004-01-30  |  4KB  |  139 lines

  1. /*
  2.   Copyright (C) 2002 Amir Szekely <kichik@netvision.net.il>
  3.  
  4.   This software is provided 'as-is', without any express or implied
  5.   warranty.  In no event will the authors be held liable for any damages
  6.   arising from the use of this software.
  7.  
  8.   Permission is granted to anyone to use this software for any purpose,
  9.   including commercial applications, and to alter it and redistribute it
  10.   freely, subject to the following restrictions:
  11.  
  12.   1. The origin of this software must not be misrepresented; you must not
  13.   claim that you wrote the original software. If you use this software
  14.   in a product, an acknowledgment in the product documentation would be
  15.   appreciated but is not required.
  16.  
  17.   2. Altered source versions must be plainly marked as such, and must not be
  18.   misrepresented as being the original software.
  19.  
  20.   3. This notice may not be removed or altered from any source distribution.
  21. */
  22.  
  23. #if !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
  24. #define AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_
  25.  
  26. #if _MSC_VER > 1000
  27. #pragma once
  28. #endif // _MSC_VER > 1000
  29.  
  30. #include "Platform.h"
  31. #include <Vector>
  32.  
  33. #include <StdExcept>
  34. using namespace std;
  35.  
  36. struct DialogItemTemplate {
  37.   DWORD  dwHelpId; // Extended only
  38.  
  39.   short  sX;
  40.   short  sY;
  41.   short  sWidth;
  42.   short  sHeight;
  43.   DWORD  dwExtStyle;
  44.   DWORD  dwStyle;
  45.   WORD   wId;
  46.  
  47.   char  *szClass;
  48.   char  *szTitle;
  49.   char  *szCreationData;
  50.  
  51.   WORD  wCreateDataSize;
  52. };
  53.  
  54. #pragma pack(push, 1)
  55.  
  56. typedef struct {
  57.   WORD   dlgVer;
  58.   WORD   signature;
  59.   DWORD  helpID;
  60.   DWORD  exStyle;
  61.   DWORD  style;
  62.   WORD   cDlgItems;
  63.   short  x;
  64.   short  y;
  65.   short  cx;
  66.   short  cy;
  67. } DLGTEMPLATEEX;
  68.  
  69. typedef struct {
  70.   DWORD  helpID;
  71.   DWORD  exStyle;
  72.   DWORD  style;
  73.   short  x;
  74.   short  y;
  75.   short  cx;
  76.   short  cy;
  77.   WORD   id;
  78.   WORD   _miscrosoft_docs_are_wrong;
  79. } DLGITEMTEMPLATEEX;
  80.  
  81. #pragma pack(pop)
  82.  
  83. class CDialogTemplate {
  84. public:
  85.   CDialogTemplate(BYTE* pbData, unsigned int uCodePage=CP_ACP);
  86.   virtual ~CDialogTemplate();
  87.  
  88.   short GetWidth();
  89.   short GetHeight();
  90.   DialogItemTemplate* GetItem(WORD wId);
  91.   DialogItemTemplate* GetItemByIdx(DWORD i);
  92.   int   RemoveItem(WORD wId);
  93.   void  SetFont(char* szFaceName, WORD wFontSize);
  94.   void  AddItem(DialogItemTemplate item);
  95.   HWND  CreateDummyDialog();
  96.   void  MoveAll(short x, short y);
  97.   void  Resize(short x, short y);
  98.   void  PixelsToDlgUnits(short& x, short& y);
  99.   void  DlgUnitsToPixels(short& x, short& y);
  100.   SIZE  GetStringSize(WORD id, char *str);
  101.   void  RTrimToString(WORD id, char *str, int margins);
  102.   void  LTrimToString(WORD id, char *str, int margins);
  103.   void  CTrimToString(WORD id, char *str, int margins);
  104.   void  ConvertToRTL();
  105.   BYTE* Save(DWORD& dwSize);
  106.   DWORD GetSize();
  107.  
  108. private:
  109.   bool  m_bExtended;
  110.  
  111.   DWORD m_dwHelpId; // Extended only
  112.  
  113.   short m_sX;
  114.   short m_sY;
  115.   short m_sWidth;
  116.   short m_sHeight;
  117.   DWORD m_dwExtStyle;
  118.   DWORD m_dwStyle;
  119.  
  120.   char* m_szMenu;
  121.   char* m_szClass;
  122.   char* m_szTitle;
  123.  
  124.    // Only if DS_FONT style is set
  125.   short m_sFontSize;
  126.   short m_sFontWeight; // Extended only
  127.   BYTE  m_bItalic; // Extended only
  128.   BYTE  m_bCharset; // Extended only
  129.   char* m_szFont;
  130.  
  131.   // For (en/de)coding Unicode
  132.   unsigned int m_uCodePage;
  133.  
  134.   // Items vector
  135.   vector<DialogItemTemplate*> m_vItems;
  136. };
  137.  
  138. #endif // !defined(AFX_DIALOGTEMPLATE_H__C5A973AF_0F56_4BEC_814A_79318E2EB4AC__INCLUDED_)
  139.