home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Source / vctl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  12.6 KB  |  327 lines

  1. // -------------------------------------------------------------------------
  2. // Copyright @ 1997 TCK Software, Incorporated
  3. // All Rights Reserved
  4. // -------------------------------------------------------------------------
  5. #ifndef __VCTL_H__
  6. #define __VCTL_H__
  7.  
  8. #include "VCtlBase.h"
  9.  
  10. // -------------------------------------------------------------------------
  11. //    VForm Button
  12. // -------------------------------------------------------------------------
  13. class AFX_EXT_CLASS VButton : public VCtl
  14. {
  15. protected:
  16.     BOOL    m_bDown;            // Is the button pushed down?
  17.     // int    m_nPictureId;        // picture on button
  18.     
  19. public:
  20.     VButton();
  21.     VButton(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  22.     VButton(VButton &x) { *this = x; }                // Copy Constructor
  23.     VButton&    operator =(VButton &x);                // Assignment Operator
  24.  
  25.     // --------- Get Member Functions --------------
  26.     BOOL        Down()                { return m_bDown; }
  27.     
  28.     // --------- Set Member Functions --------------
  29.     void    Init(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  30.     void    Down(BOOL x)            { m_bDown = x; }
  31.     
  32.     // --------- Implementation Functions --------------
  33.     virtual int  IsA()                { return VCTL_BUTTON; }
  34.     // virtual void OnDraw(CDC *pDC);                // Draw itself
  35.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  36.     virtual BOOL OnLButtonDown(UINT nFlags, CPoint pt);
  37.     virtual BOOL OnLButtonUp(UINT nFlags, CPoint pt, BOOL bSameCtl);
  38.     virtual BOOL OnEnterDown();
  39.     virtual BOOL OnEnterUp();
  40.     virtual BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  41.     virtual BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  42.     virtual BOOL OnKillFocus(VCtl *pNewCtl)    { m_bDown = FALSE; return TRUE; }
  43. };
  44.  
  45. // -------------------------------------------------------------------------
  46. //    VForm Check Box
  47. // -------------------------------------------------------------------------
  48. class AFX_EXT_CLASS VCheckBox : public VCtl 
  49. {
  50. protected:
  51.     BOOL    m_bChecked;                        // State of checkbox
  52.     BOOL    m_bPushed;                        // Is button pushed
  53.     BOOL    m_bRadioLook;                    // Draw as a Radio Button
  54.     int        m_nBoxSize;                        // Size of Box
  55.     
  56. public:
  57.     VCheckBox();
  58.     VCheckBox(VRow *pRow, int nId, LPCTSTR szText, 
  59.                 int x, int y, int cx, int cy);
  60.     VCheckBox(VCheckBox &x) { *this = x; }            // Copy Constructor
  61.     VCheckBox&    operator =(VCheckBox &x);            // Assignment Operator
  62.  
  63.     // --------- Get Member Functions --------------
  64.     BOOL    Checked()        { return m_bChecked; }
  65.     BOOL    RadioLook()        { return m_bRadioLook; }
  66.     int        BoxSize()        { return m_nBoxSize; }
  67.  
  68.     // --------- Set Member Functions --------------
  69.     void    Init(VRow *pRow, int nId, LPCTSTR szText, 
  70.                 int x, int y, int cx, int cy);
  71.     void    Checked(BOOL bFlag)        { m_bChecked = bFlag; }
  72.     void    Toggle()                { m_bChecked = !m_bChecked; }
  73.     void    RadioLook(BOOL bFlag)    { m_bRadioLook = bFlag; }
  74.     void    BoxSize(int nBoxSize)    { m_nBoxSize = nBoxSize; }
  75.  
  76.     // --------- Implementation Functions --------------
  77.     virtual int  IsA()                { return VCTL_CHECKBOX; }
  78.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  79.     virtual BOOL OnLButtonDown(UINT nFlags, CPoint pt);        // Toggle Box
  80.     virtual BOOL OnLButtonUp(UINT nFlags, CPoint pt, BOOL bSameCtl);
  81.     virtual BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  82.     virtual BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  83.     virtual BOOL OnKillFocus(VCtl *pNewCtl)    { m_bPushed = FALSE; return TRUE; }
  84. };
  85.  
  86. // -------------------------------------------------------------------------
  87. //    VForm RadioList
  88. // -------------------------------------------------------------------------
  89. class AFX_EXT_CLASS VRadioList : public VCtl 
  90. {
  91. protected:
  92.     CStringArray m_data;                // Array of strings
  93.     int        m_nItem;                    // Index of current item
  94.     int        m_nSelItem;                    // Index of selected item
  95.     BOOL    m_bPushed;                    // Is button pushed
  96.     BOOL    m_bVertical;                // Vertical or Horizontal
  97.     int        m_nBoxSize;                    // Size of Box
  98.     int        m_nTextHeight;
  99.     
  100. public:
  101.     VRadioList();
  102.     VRadioList(VRow *pRow, int nId, LPCTSTR szText, 
  103.                 int x, int y, int cx, int cy);
  104.     VRadioList(VRadioList &x) { *this = x; }            // Copy Constructor
  105.     VRadioList&    operator =(VRadioList &x);                // Assignment Operator
  106.  
  107.     // --------- Get Member Functions --------------
  108.     int        SelItem()        { return m_nSelItem; }
  109.     int        BoxSize()        { return m_nBoxSize; }
  110.     BOOL    Vertical()        { return m_bVertical; }
  111.  
  112.     // --------- Set Member Functions --------------
  113.     void    Init(VRow *pRow, int nId, LPCTSTR szText, 
  114.                 int x, int y, int cx, int cy);
  115.     void    SelItem(int nSelItem)    { m_nSelItem = nSelItem; }
  116.     void    BoxSize(int nBoxSize)    { m_nBoxSize = nBoxSize; }
  117.     void    Vertical(BOOL bFlag)    { m_bVertical = bFlag; }
  118.  
  119.     int        AddString(LPCTSTR szText)    { return m_data.Add(szText); }
  120.     void    ResetContent()                { m_data.RemoveAll(); }
  121.     long    GetCount()                    { return m_data.GetSize(); }
  122.     CString    GetSelString()                { return GetString(m_nSelItem); }
  123.     CString    GetString(int nItem);
  124.     int        GetItemByPoint(CPoint pt);
  125.  
  126.  
  127.     // --------- Implementation Functions --------------
  128.     virtual int  IsA()                { return VCTL_RADIOLIST; }
  129.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  130.     virtual BOOL OnLButtonDown(UINT nFlags, CPoint pt);        // Toggle Box
  131.     virtual BOOL OnLButtonUp(UINT nFlags, CPoint pt, BOOL bSameCtl);
  132.     virtual BOOL OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
  133.     virtual BOOL OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
  134.     virtual BOOL OnKillFocus(VCtl *pNewCtl)    { m_bPushed = FALSE; return TRUE; }
  135. };
  136.  
  137.  
  138.  
  139. // -------------------------------------------------------------------------
  140. //    VForm Static Text Control
  141. // -------------------------------------------------------------------------
  142. class AFX_EXT_CLASS VStatic : public VCtl
  143. {
  144. protected:
  145.  
  146. public:
  147.     VStatic();
  148.     VStatic(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  149.     VStatic(VStatic &x) { *this = x; }                // Copy Constructor
  150.     VStatic&    operator =(VStatic &x);                // Assignment Operator
  151.  
  152.     // --------- Get Member Functions --------------
  153.  
  154.     // --------- Set Member Functions --------------
  155.     void    Init(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  156.     
  157.     // --------- Implementation Functions --------------
  158.     virtual int  IsA()                { return VCTL_STATIC; }
  159.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  160. };
  161.  
  162. // -------------------------------------------------------------------------
  163. //    VForm Edit Control
  164. // -------------------------------------------------------------------------
  165. class AFX_EXT_CLASS VSmallEdit : public VCtl 
  166. {
  167. protected:
  168.     UINT    m_nFlags;            // VSmallEdit Flags
  169.     UINT    m_nLimitText;        // Maximum Chars
  170.     BYTE    m_nLeftMargin;        // Left Margin
  171.  
  172. public:
  173.     VSmallEdit();
  174.     VSmallEdit(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  175.     VSmallEdit(VSmallEdit &x) { *this = x; }                // Copy Constructor
  176.     VSmallEdit&    operator =(VSmallEdit &x);                // Assignment Operator
  177.  
  178.     // --------- Get Member Functions --------------
  179.     BOOL    MultiLine()                { return (m_nFlags & VEDIT_MULTILINE); }
  180.     BOOL    ReadOnly()                { return (m_nFlags & VEDIT_READONLY); }
  181.     BOOL    Password()                { return (m_nFlags & VEDIT_PASSWORD); }
  182.     BOOL    Numeric()                { return (m_nFlags & VEDIT_NUMERIC); }
  183.     BOOL    LowerCase()                { return (m_nFlags & VEDIT_LOWERCASE); }
  184.     BOOL    UpperCase()                { return (m_nFlags & VEDIT_UPPERCASE); }
  185.     UINT    LimitText()                { return m_nLimitText; }
  186.     UINT    LeftMargin()            { return m_nLeftMargin; }
  187.  
  188.     // --------- Set Member Functions --------------
  189.     void    Init(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  190.     void    MultiLine(BOOL bFlag)            { SetBitFlag(m_nFlags, VEDIT_MULTILINE, bFlag); }
  191.     void    ReadOnly(BOOL bFlag)            { SetBitFlag(m_nFlags, VEDIT_READONLY, bFlag); }
  192.     void    Password(BOOL bFlag)            { SetBitFlag(m_nFlags, VEDIT_PASSWORD, bFlag); }
  193.     void    Numeric(BOOL bFlag)                { SetBitFlag(m_nFlags, VEDIT_NUMERIC, bFlag); }
  194.     void    LowerCase(BOOL bFlag)            { SetBitFlag(m_nFlags, VEDIT_LOWERCASE, bFlag); }
  195.     void    UpperCase(BOOL bFlag)            { SetBitFlag(m_nFlags, VEDIT_UPPERCASE, bFlag); }
  196.     void    LimitText(UINT nLimit)            { m_nLimitText = nLimit; }
  197.     void    LeftMargin(UINT nPixels)        { m_nLeftMargin = nPixels; }
  198.  
  199.     // --------- Implementation Functions --------------
  200.     void    DrawTextEx(CDC *pDC, CRect rect, BOOL bNoBkgrnd, BOOL bGridMode);
  201.     virtual int        IsA()                { return VCTL_EDIT; }
  202.     virtual void    OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  203.  
  204.     // --------- Virtual Helper Functions --------------
  205.     virtual VCtlHelper*    CreateHelper(CWnd *pParent);
  206.     virtual int        HelperId();
  207.     virtual CRect    HelperRect(LPRECT pRect=0, BOOL bGridMode=FALSE);
  208.     virtual BOOL    IsHelperDirty(VCtlHelper* pHelper);
  209.     virtual BOOL    OnBeginHelper(VCtlHelper* pHelper);    
  210.     virtual BOOL    OnEndHelper(VCtlHelper* pHelper);
  211. };
  212.  
  213. // -------------------------------------------------------------------------
  214. //    VDropDown Control
  215. // -------------------------------------------------------------------------
  216. class AFX_EXT_CLASS VDropDown : public VCtl 
  217. {
  218. protected:
  219.     CStringArray m_data;                // Array of strings
  220.     BOOL         m_bButtonDown;            // Is the button pushed down?
  221.  
  222. public:
  223.     VDropDown();
  224.     VDropDown(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  225.     VDropDown(VDropDown &x) { *this = x; }            // Copy Constructor
  226.     VDropDown&    operator =(VDropDown &x);            // Assignment Operator
  227.  
  228.     // --------- Get Member Functions --------------
  229.     BOOL    ButtonDown()        { return m_bButtonDown; }
  230.     CStringArray* GetStringArray()    { return &m_data; }
  231.     
  232.     // --------- Set Member Functions --------------
  233.     void    Init(VRow *pRow, int nId, LPCTSTR szText, int x, int y, int cx, int cy);
  234.     void    ButtonDown(BOOL bFlag)        { m_bButtonDown = bFlag; }
  235.  
  236.     // --------- Implementation Functions --------------
  237.     int        AddString(LPCTSTR szText)    { return m_data.Add(szText); }
  238.     void    ResetContent()                { m_data.RemoveAll(); }
  239.     long    GetCount()                    { return m_data.GetSize(); }
  240.     CString    GetString(int nItem);
  241.  
  242.     virtual int  IsA()            { return VCTL_DROPDOWN; }
  243.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  244.     virtual BOOL OnLButtonDown(UINT nFlags, CPoint pt);
  245.     virtual BOOL OnLButtonUp(UINT nFlags, CPoint pt, BOOL bSameCtl);
  246.     virtual BOOL OnEnterDown();
  247.     virtual BOOL OnEnterUp();
  248.     virtual BOOL OnBeginList(CListBox *pListBox);
  249.     virtual BOOL OnEndList(CListBox *pListBox);
  250. };
  251.  
  252.  
  253. // -------------------------------------------------------------------------
  254. //    VRectangle Control
  255. // -------------------------------------------------------------------------
  256. class AFX_EXT_CLASS VRectangle : public VCtl
  257. {
  258. protected:
  259.     
  260. public:
  261.     VRectangle();
  262.     VRectangle(VRow *pRow, int nId, int x, int y, int cx, int cy);
  263.     VRectangle(VRectangle &x) { *this = x; }        // Copy Constructor
  264.     VRectangle&    operator =(VRectangle &x);            // Assignment Operator
  265.  
  266.     // --------- Get Member Functions --------------
  267.     
  268.     // --------- Set Member Functions --------------
  269.     void    Init(VRow *pRow, int nId, int x, int y, int cx, int cy);
  270.     
  271.     // --------- Implementation Functions ------------
  272.     virtual int  IsA()                { return VCTL_RECTANGLE; }
  273.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  274. };
  275.  
  276.  
  277. // -------------------------------------------------------------------------
  278. //    VLine Control
  279. // -------------------------------------------------------------------------
  280. class AFX_EXT_CLASS VLine : public VCtl
  281. {
  282. protected:
  283.     BOOL    m_bVertical;            // Draw a Vertical Line
  284.     
  285. public:
  286.     VLine();
  287.     VLine(VRow *pRow, int nId, int x, int y, int cx, int cy);
  288.     VLine(VLine &x) { *this = x; }                // Copy Constructor
  289.     VLine&    operator =(VLine &x);                // Assignment Operator
  290.  
  291.     // --------- Get Member Functions --------------
  292.     BOOL    Vertical()            { return m_bVertical; }
  293.     
  294.     // --------- Set Member Functions --------------
  295.     void    Init(VRow *pRow, int nId, int x, int y, int cx, int cy);
  296.     void    Vertical(BOOL bFlag)        { m_bVertical = bFlag; }
  297.     
  298.     // --------- Implementation Functions ------------
  299.     virtual int  IsA()                { return VCTL_LINE; }
  300.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  301. };
  302.  
  303. // -------------------------------------------------------------------------
  304. //    VEllipse Control
  305. // -------------------------------------------------------------------------
  306. class AFX_EXT_CLASS VEllipse : public VCtl
  307. {
  308. protected:
  309.     
  310. public:
  311.     VEllipse();
  312.     VEllipse(VRow *pRow, int nId, int x, int y, int cx, int cy);
  313.     VEllipse(VEllipse &x) { *this = x; }            // Copy Constructor
  314.     VEllipse&    operator =(VEllipse &x);            // Assignment Operator
  315.  
  316.     // --------- Set Member Functions --------------
  317.     void    Init(VRow *pRow, int nId, int x, int y, int cx, int cy);
  318.     
  319.     // --------- Implementation Functions ------------
  320.     virtual int  IsA()                { return VCTL_ELLIPSE;}
  321.     virtual void OnDraw(CDC *pDC, LPRECT pRect=0, BOOL bGridMode=0);
  322.     void    DrawEtchedEllipse(CDC *pDC, CRect rect, BOOL bBumped=0);
  323. };
  324.  
  325.  
  326. #endif
  327.