void ATimeControl::DoLayout() { ARect r = GetAbsPosition(); int nSpinWidth = m_pSpin->GetWidth(); int h=r.GetHeight()-m_iBorderWidth*2-m_iPadding*2; int w=r.GetWidth()-nSpinWidth-m_iBorderWidth*2-m_iPadding*2; double dw = (double)(w) / (double)4.0; m_pEditHour->SetLeft(0); m_pEditHour->SetTop(0); m_pEditHour->SetWidth(dw); m_pEditHour->SetHeight(h); m_pLabel1->SetLeft(dw); m_pLabel1->SetTop(0); m_pLabel1->SetWidth(dw/2); m_pLabel1->SetHeight(h); m_pEditMinute->SetLeft(dw+dw/2); m_pEditMinute->SetTop(0); m_pEditMinute->SetWidth(dw); m_pEditMinute->SetHeight(h); m_pLabel2->SetLeft(dw*2+dw/2); m_pLabel2->SetTop(0); m_pLabel2->SetWidth(dw/2); m_pLabel2->SetHeight(h); m_pEditSecond->SetLeft(dw*3); m_pEditSecond->SetTop(0); m_pEditSecond->SetWidth(dw); m_pEditSecond->SetHeight(h); base_class::DoLayout(); }
// on left mouse button down void CSplitterFrame::OnLButtonDown(UINT nFlags, CPoint point) { INDEX ctParentLevels = 0; if(sp_bDockingEnabled) { ctParentLevels = 1; } CRect rc; ASSERT(GetParent()!=NULL); pDockedParent = GetParent(); pFloatingParent = pDockedParent->GetParent(); ASSERT(pFloatingParent!=NULL); for(INDEX ipar=0; ipar<ctParentLevels; ipar++) { pFloatingParent = pFloatingParent->GetParent(); ASSERT(pFloatingParent!=NULL); } /* CPoint pt = GetAbsPosition(); pt.x += point.x; SetAbsPosition(pt); */ SetCapture(); sp_ptStartPoint = GetAbsPosition(); ChangeParent(pFloatingParent); CWnd::OnLButtonDown(nFlags, point); }
AControl* AScrollBar::_HitTest(int X,int Y) { ARect r = GetAbsPosition(); if( r.PtInRect(APoint(X,Y)) ) { return this; } else return NULL; }
void AScrollBar::SetPosition(int v) { if( v > m_iRange) v = m_iRange; if( v < 0 ) v = 0; int delta = v - m_iPosition; m_iPosition = v; AMouseEvent evt; evt.m_Delta = delta; OnScroll.Call(this,&evt); m_pUICore->Refresh(GetAbsPosition()); }
// on mouse move void CSplitterFrame::OnMouseMove(UINT nFlags, CPoint point) { if(GetCapture()==this) { CPoint ptCursor; GetCursorPos(&ptCursor); CPoint pt = GetAbsPosition(); if(sp_uiDockSide==AFX_IDW_DOCKBAR_LEFT || sp_uiDockSide==AFX_IDW_DOCKBAR_RIGHT) { pt.x = ptCursor.x; } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_TOP || sp_uiDockSide==AFX_IDW_DOCKBAR_BOTTOM) { pt.y = ptCursor.y; } SetAbsPosition(pt); } CWnd::OnMouseMove(nFlags, point); }
void ARadioButton::SetChecked(bool v) { m_bChecked = v; if( v ) { AContainer* pContainer = dynamic_cast<AContainer *>(GetParent()); for(int i=0;i<pContainer->GetChildControls()->GetCount();i++) { AControl* pControl = (AControl *)(pContainer->GetChildControls()->operator [](i)); ARadioButton* pr = dynamic_cast<ARadioButton *>(pControl); if( pr == NULL || pr == this || pr->GetGroup() != (int)m_iGroup ) continue; pr->SetChecked(false); } } m_pUICore->Refresh(GetAbsPosition()); }
ARect AScrollBar::GetTopButton2Pos() { ARect ret(0,0,0,0); if( !m_bShowTop ) return ret; ARect r = GetAbsPosition(); int sw = AApplication::Get()->GetCurSkin()->m_ScrollBarWidth; if( m_Kind == sbVert ) { ret = ARect(r.left,r.bottom-sw,r.right,r.bottom); } else { ret = ARect(r.right-sw,r.top,r.right,r.bottom); } return ret; }
ARect AScrollBar::GetRailPos() { ARect r = GetAbsPosition(); int sw = AApplication::Get()->GetCurSkin()->m_ScrollBarWidth; if( m_Kind == sbVert ) { if( m_bShowTop ) r.Deflate(0,sw,0,sw); if( m_bShowButton ) r.Deflate(0,sw,0,sw); r.Deflate(0,1,0,1); } else { if( m_bShowTop ) r.Deflate(sw,0,sw,0); if( m_bShowButton ) r.Deflate(sw,0,sw,0); r.Deflate(1,0,1,0); } return r; }
// Change parent of splitter void CSplitterFrame::ChangeParent(CWnd *pNewParent) { CPoint &ptCurrent = GetAbsPosition(); SetParent(pNewParent); SetAbsPosition(ptCurrent); }
// Resize parent void CSplitterFrame::UpdateParent() { CRect rcParent; CRect rcMainFrame; CRect rcMainClientFrame; CPoint pt = GetAbsPosition(); CMainFrame* pMainFrame = STATIC_DOWNCAST(CMainFrame, AfxGetMainWnd()); CDlgTemplate &wndParent = *(CDlgTemplate*)GetParent(); pMainFrame->GetClientRect(&rcMainClientFrame); pMainFrame->GetWindowRect(&rcMainFrame); pt.x -=rcMainFrame.left; pt.y -=rcMainFrame.top; wndParent.GetWindowRect(&rcParent); wndParent.ShowWindow(SW_HIDE); INDEX iWidth = rcParent.right - rcParent.left; INDEX iHeight = rcParent.bottom - rcParent.top; if(sp_bDockingEnabled) { pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top)); // is splitter attached on left side if(sp_uiDockSide == AFX_IDW_DOCKBAR_LEFT) { SET_BAR_SIZE(wndParent,rcMainClientFrame.right - pt.x,iHeight); // is splitter attached on right side } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_RIGHT) { SET_BAR_SIZE(wndParent,pt.x,iHeight); // is splitter attached on top side } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_TOP) { SET_BAR_SIZE(wndParent,iWidth,iHeight + sp_ptStartPoint.y - pt.y); // is splitter attached on bottom side } else if(sp_uiDockSide == AFX_IDW_DOCKBAR_BOTTOM) { ASSERT(FALSE); } // Chose docking side INDEX iDockSide = 0; // is splitter attached on left side if(sp_uiDockSide==AFX_IDW_DOCKBAR_LEFT) { iDockSide = AFX_IDW_DOCKBAR_RIGHT; // is splitter attached on right side } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_RIGHT) { iDockSide = AFX_IDW_DOCKBAR_LEFT; // is splitter attached on top side } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_TOP) { iDockSide = AFX_IDW_DOCKBAR_BOTTOM; // is splitter attached on bottom side } else if(sp_uiDockSide==AFX_IDW_DOCKBAR_BOTTOM) { iDockSide = AFX_IDW_DOCKBAR_TOP; } pMainFrame->DockControlBar(&wndParent,iDockSide); } else { SET_BAR_SIZE(wndParent,300,300); // wndParent.SetWindowPos(&wndBottom,0,0,100,300,SWP_NOZORDER); //pMainFrame->FloatControlBar(&wndParent,CPoint(rcParent.left,rcParent.top)); //pMainFrame->DockControlBar(&wndParent,AFX_IDW_DOCKBAR_BOTTOM); } wndParent.ShowWindow(SW_SHOW); wndParent.UpdateWindow(); }
void ACloseButton::DoMouseDown(AEvent* pEvent) { GetUICore()->Refresh(GetAbsPosition()); AControl::DoMouseDown(pEvent); }
void ARadioButton::OnFontChange() { CalcPos(); m_pUICore->Refresh(GetAbsPosition()); }