NSFlexDialog.cpp

Go to the documentation of this file.
00001 #ifndef NSFLEXDIALOG_IMPLEMENTATION_FILE
00002 #define NSFLEXDIALOG_IMPLEMENTATION_FILE
00003 
00004 // This code is a part of the NanoSoft NSViews C++ Library.
00005 // Copyright (C) 1996 NanoSoft Corporation. All rights reserved.
00006 
00007 #include "stdafx.h"
00008 #include "NSFlexDialog.h"
00009 #include "NSFlexConstraintList.h"
00010 
00011 IMPLEMENT_DYNAMIC(CNSFlexDialog, CDialog)
00012 
00013 BEGIN_MESSAGE_MAP(CNSFlexDialog, CDialog)
00014     //{{AFX_MSG_MAP(CNSFlexDialog)
00015     ON_WM_SIZE()
00016     ON_WM_GETMINMAXINFO()
00017     //}}AFX_MSG_MAP
00018     ON_COMMAND(ID_APPLY_NOW, OnApply)
00019 END_MESSAGE_MAP()
00020 
00021 CNSFlexDialog::CNSFlexDialog(UINT nIDTemplate, CWnd* pParentWnd /*=NULL*/, 
00022     void* pSubject /*=NULL*/) : CDialog(nIDTemplate,pParentWnd),
00023     m_nMinTrackingWidth(0), m_nMinTrackingHeight(0), m_bModified(FALSE),
00024     m_pSubject(pSubject)
00025 {
00026     m_pFlexConstraintList = new CNSFlexConstraintList(this);
00027 }
00028 
00029 CNSFlexDialog::CNSFlexDialog(LPCTSTR lpszTemplateName, 
00030     CWnd* pParentWnd /*=NULL*/, void* pSubject /*=NULL*/) : 
00031     CDialog(lpszTemplateName,pParentWnd),
00032     m_nMinTrackingWidth(0), m_nMinTrackingHeight(0), m_bModified(FALSE),
00033     m_pSubject(pSubject)
00034 {
00035     m_pFlexConstraintList = new CNSFlexConstraintList(this);
00036 }
00037 
00038 CNSFlexDialog::~CNSFlexDialog()
00039 {
00040     delete m_pFlexConstraintList;
00041 }
00042 
00043 void CNSFlexDialog::AddFlexConstraint(UINT nControlID, 
00044     const CNSFlexHorizontalConstraint& HorizontalConstraint,
00045     const CNSFlexVerticalConstraint& VerticalConstraint)
00046 {
00047     m_pFlexConstraintList->AddConstraint(nControlID,
00048         HorizontalConstraint, VerticalConstraint);
00049 }
00050 
00051 void* CNSFlexDialog::GetSubject() const
00052 {
00053     return m_pSubject;
00054 }
00055 
00056 void CNSFlexDialog::OnApply()
00057 {
00058     if (!UpdateData(TRUE))
00059         return;
00060 
00061     if (!OnApplyChanges(m_pSubject))
00062         return;
00063 
00064     SetModified(FALSE);
00065 }
00066 
00067 BOOL CNSFlexDialog::OnApplyChanges(void*pSubject)
00068 {
00069     return TRUE;
00070 }
00071 
00072 void CNSFlexDialog::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI) 
00073 {
00074     CDialog::OnGetMinMaxInfo(lpMMI);
00075 
00076     lpMMI->ptMinTrackSize.x = m_nMinTrackingWidth;
00077     lpMMI->ptMinTrackSize.y = m_nMinTrackingHeight;
00078 }
00079 
00080 BOOL CNSFlexDialog::OnInitDialog() 
00081 {
00082     CDialog::OnInitDialog();
00083     
00084     CRect rect;
00085 
00086     GetWindowRect(rect);
00087     m_nMinTrackingWidth = rect.Width();
00088     m_nMinTrackingHeight = rect.Height();
00089 
00090     GetClientRect(rect);
00091     m_pFlexConstraintList->
00092         SetClientBaseSize(rect.Width(),rect.Height());
00093 
00094     SetModified(FALSE);
00095 
00096     ASSERT(m_pFlexConstraintList->AssertAllFlexControlsExist());
00097 
00098     return TRUE; 
00099 }
00100 
00101 void CNSFlexDialog::OnOK()
00102 {
00103     if (!UpdateData(TRUE))
00104         return;
00105 
00106     if (!OnApplyChanges(m_pSubject))
00107         return;
00108 
00109     EndDialog(IDOK);
00110 }
00111 
00112 void CNSFlexDialog::OnSize(UINT nType, int cx, int cy) 
00113 {
00114     CDialog::OnSize(nType, cx, cy);
00115 
00116     if (nType != SIZE_MINIMIZED)
00117     {
00118         m_pFlexConstraintList->PositionControls(cx,cy);
00119 
00120     // REVISION 4/10/97 TO WORK WITH ACTIVEX CONTROLS (Ed Smetak)
00121         // To get rid of screen garbage left on Windows NT before version 4.0
00122         // and under Win32s
00123         // DWORD dwVersion = GetVersion(); 
00124         // if (LOBYTE(LOWORD(dwVersion)) < 4)
00125     //     Invalidate();
00126         Invalidate();
00127     // END REVISION (Ver 1.04)
00128     }
00129 }
00130 
00131 void CNSFlexDialog::SetModified(BOOL bChanged)
00132 {
00133     m_bModified = bChanged;
00134 
00135     CWnd* pWnd = GetDlgItem(ID_APPLY_NOW);
00136         
00137     if (pWnd)
00138         pWnd->EnableWindow(m_bModified);
00139 }
00140 
00141 void CNSFlexDialog::SetSubject(void* pSubject)
00142 {
00143     m_pSubject = pSubject;
00144 }
00145 
00146 #endif //NSFLEXDIALOG_IMPLEMENTATION_FILE
00147 

Generated on Thu Nov 20 04:28:49 2008 for HOOPLE Libraries by  doxygen 1.5.1