home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / dateedit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  2.7 KB  |  98 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. #ifndef _DateEdit_h
  20. #define _DateEdit_h
  21.  
  22. // Requires
  23. #include "widgetry.h"
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CNSDateEdit window
  27.  
  28. class CNSDateSubedit : public CEdit
  29. {
  30. public:
  31.     CNSDateSubedit();
  32.     virtual ~CNSDateSubedit();
  33.     int SetValue( int nNewValue );
  34.     int GetValue( void );
  35.  
  36. protected:
  37.     BOOL PreTranslateMessage( MSG* pMsg ); 
  38.  
  39.     afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  40.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  41.     DECLARE_MESSAGE_MAP()
  42. };
  43.  
  44. #define NSDE_RELAYEVENT    (WM_USER+1)
  45.  
  46. class CNSDateEdit: public CStatic
  47. {
  48.     friend CNSDateSubedit;
  49.  
  50. public:
  51.     CNSDateEdit();
  52.     virtual ~CNSDateEdit();
  53.  
  54.     BOOL SetDate( CTime &d );
  55.     BOOL SetDate( int nYear, int nMonth, int nDay );
  56.     // These two methods return FALSE if the current date is invalid
  57.     BOOL GetDate( CTime &d );
  58.     BOOL GetDate( int &nYear, int &nMonth, int &nDay );
  59.  
  60. protected:
  61.  
  62.     void            CreateSubWindows( );
  63.     void            LayoutSubWindows( RECT *pRect );
  64.     BOOL            OnKeyPress( UINT nKey, UINT nRepCnt, UINT nFlags );
  65.  
  66.     BOOL            Validate();
  67.  
  68.     int                m_nDay, m_nMonth, m_nYear;
  69.     BOOL            m_bNeedControls;
  70.     CNSDateSubedit    m_DayField;
  71.     CNSDateSubedit    m_MonthField;
  72.     CNSDateSubedit    m_YearField;
  73.     CNSDateSubedit *m_pFields[3];
  74.     CSpinButtonCtrl    m_wndSpin;
  75.  
  76.     int                m_iCurrentField;
  77.     CRect            m_Sep1;
  78.     CRect            m_Sep2;
  79.  
  80.     afx_msg void OnPaint();
  81.     afx_msg void OnSetFocus(CWnd* pOldWnd);
  82.     afx_msg void OnSize( UINT nType, int cx, int cy );
  83.     afx_msg void OnEnable( BOOL bEnable );
  84.     afx_msg void OnMaxText();
  85.     afx_msg void OnFocusDay();
  86.     afx_msg void OnFocusMonth();
  87.     afx_msg void OnFocusYear();
  88.     afx_msg void OnKillFocusDay();
  89.     afx_msg void OnKillFocusMonth();
  90.     afx_msg void OnKillFocusYear();
  91.     afx_msg LRESULT OnRelayEvent(WPARAM wParam, LPARAM lParam);
  92.     DECLARE_MESSAGE_MAP()
  93. };
  94.  
  95. /////////////////////////////////////////////////////////////////////////////
  96.  
  97. #endif
  98.