00001 #ifndef NSFLEXFORMVIEW_IMPLEMENTATION_FILE
00002 #define NSFLEXFORMVIEW_IMPLEMENTATION_FILE
00003
00004
00005
00006
00007 #include "stdafx.h"
00008 #include "NSFlexFormView.h"
00009 #include "NSFlexConstraintList.h"
00010 #include "NSFlexMDIChildWnd.h"
00011 #include "NSViewsMessages.h"
00012
00013 #include <basis/convert_utf.h>
00014
00015 IMPLEMENT_DYNAMIC(CNSFlexFormView, CFormView)
00016
00017 BEGIN_MESSAGE_MAP(CNSFlexFormView, CFormView)
00018
00019 ON_WM_CREATE()
00020 ON_WM_SIZE()
00021
00022 END_MESSAGE_MAP()
00023
00024 CNSFlexFormView::CNSFlexFormView(UINT nIDTemplate) :
00025 CFormView(nIDTemplate)
00026 {
00027 m_pFlexConstraintList = new CNSFlexConstraintList(this);
00028
00029
00030 m_bNeedInitialUpdate = TRUE;
00031
00032 }
00033
00034 CNSFlexFormView::CNSFlexFormView(LPCTSTR lpszTemplateName) :
00035 CFormView(lpszTemplateName)
00036 {
00037 m_pFlexConstraintList = new CNSFlexConstraintList(this);
00038
00039
00040 m_bNeedInitialUpdate = TRUE;
00041
00042 }
00043
00044 CNSFlexFormView::~CNSFlexFormView()
00045 {
00046 delete m_pFlexConstraintList;
00047 }
00048
00049 void CNSFlexFormView::AddFlexConstraint(UINT nControlID,
00050 const CNSFlexHorizontalConstraint& HorizontalConstraint,
00051 const CNSFlexVerticalConstraint& VerticalConstraint)
00052 {
00053 m_pFlexConstraintList->AddConstraint(nControlID,
00054 HorizontalConstraint, VerticalConstraint);
00055 }
00056
00057 int CNSFlexFormView::OnCreate(LPCREATESTRUCT lpCreateStruct)
00058 {
00059 if (CFormView::OnCreate(lpCreateStruct) == -1)
00060 return -1;
00061
00062 m_pFlexConstraintList->
00063 SetClientBaseSize(lpCreateStruct->cx,lpCreateStruct->cy);
00064
00065 return 0;
00066 }
00067
00068 void CNSFlexFormView::OnInitialUpdate()
00069 {
00070
00071 if (m_bNeedInitialUpdate)
00072 {
00073 m_bNeedInitialUpdate = FALSE;
00074
00075
00076
00077 ResizeParentToFit(FALSE);
00078
00079 CWnd *pParentFrame = GetParentFrame();
00080 ASSERT(pParentFrame);
00081
00082 if (pParentFrame->IsKindOf(RUNTIME_CLASS(CNSFlexMDIChildWnd)))
00083 pParentFrame->SendMessage(WM_SETMINTRACKSIZE);
00084 #ifdef _DEBUG
00085 else
00086 TRACE_PRINT("Warning! "
00087 "CNSFlexFormView used without CNSFlexMDIChildWnd frame.\n");
00088 #endif
00089
00090 CFormView::OnInitialUpdate();
00091
00092 ASSERT(m_pFlexConstraintList->AssertAllFlexControlsExist());
00093
00094
00095 }
00096 else
00097 CFormView::OnInitialUpdate();
00098
00099 }
00100
00101 void CNSFlexFormView::OnSize(UINT nType, int cx, int cy)
00102 {
00103 CFormView::OnSize(nType, cx, cy);
00104
00105 if (nType != SIZE_MINIMIZED)
00106 m_pFlexConstraintList->PositionControls(cx,cy);
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 }
00126
00127 #endif //NSFLEXFORMVIEW_IMPLEMENTATION_FILE
00128