BOOL CGuiControlBar::IsLegal(UINT uAlin) { m_First=GetFirstPos(); // if (IsFloating()) return FALSE; switch(uAlin) { case HTLEFT: if (IsHorz() && m_pos >0 && (m_pos != m_Last && m_pos != m_First)) return TRUE; if (IsVert() && m_pos <= m_Last && IsRight() ) return TRUE; return FALSE; break; case HTTOP: if (m_pos != m_First && IsVert()) return TRUE; if (IsHorz() && m_pos <= m_Last && IsBottom() ) return TRUE; return FALSE; break; case HTRIGHT: if (m_pos <= m_Last && IsVert() && IsLeft() ) return TRUE; if (IsHorz() && m_pos >0 && m_pos != m_Last) return TRUE; return FALSE; case HTBOTTOM: if ((m_pos != m_Last && m_pos != m_First) && IsHorz() && IsBottom()) return TRUE; if (m_pos <= m_Last && IsHorz() && IsTop()) return TRUE; //if (IsVert() && m_pos >0 ) return TRUE; return FALSE; break; } return FALSE; }
void CXTPSkinObjectTab::DrawTabIcon(CDC* pDC, CRect& rcItem, int iItem) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; TC_ITEM tci; tci.mask = TCIF_IMAGE; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); #ifdef _UNICODE if (!bResult) { TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_IMAGE; bResult = (BOOL)::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); tci.iImage = tcia.iImage; } #endif if (!bResult) return; CImageList* pImageList = pTabCtrl->GetImageList(); if (!pImageList || tci.iImage < 0) return; CPoint point = rcItem.TopLeft(); DWORD dwStyle = GetStyle(); if (IsHorz(dwStyle)) { point.Offset(GetMetrics()->m_cxEdge * 2, IsTop(dwStyle) ? GetMetrics()->m_cyEdge : 1); } else { point.Offset(IsLeft(dwStyle) ? GetMetrics()->m_cxEdge : 1, GetMetrics()->m_cyEdge * 2); } // Draw any associated icons. pImageList->Draw(pDC, tci.iImage, point, ILD_TRANSPARENT); IMAGEINFO info; ::ZeroMemory(&info, sizeof(info)); pImageList->GetImageInfo(tci.iImage, &info); CRect rcImage(info.rcImage); if (IsHorz(dwStyle)) { rcItem.left += rcImage.Width() + GetMetrics()->m_cxEdge; } else { rcItem.top += rcImage.Height() + GetMetrics()->m_cyEdge; } }
void ScrollBar::Layout() { Size sz = GetSize(); if(IsHorz()) { prev.SetStyle(style->left); next.SetStyle(style->right); prev2.SetStyle(style->left2); next2.SetStyle(style->right2); int cc = sz.cx > (3 + style->isleft2 + style->isright2) * style->arrowsize ? style->arrowsize : 0; prev.SetRect(0, 0, cc, sz.cy); next.SetRect(sz.cx - cc, 0, cc, sz.cy); prev2.Show(style->isleft2); prev2.SetRect(sz.cx - 2 * cc, 0, cc, sz.cy); next2.Show(style->isright2); next2.SetRect(cc, 0, cc, sz.cy); } else { prev.SetStyle(style->up); next.SetStyle(style->down); prev2.SetStyle(style->up2); next2.SetStyle(style->down2); int cc = sz.cy > (3 + style->isup2 + style->isdown2) * style->arrowsize ? style->arrowsize : 0; prev.SetRect(0, 0, sz.cx, cc); next.SetRect(0, sz.cy - cc, sz.cx, cc); prev2.Show(style->isup2); prev2.SetRect(0, sz.cy - 2 * cc, sz.cx, cc); next2.Show(style->isdown2); next2.SetRect(0, cc, sz.cx, cc); } Set(pagepos); Refresh(); }
void CCoolDialogBar::OnMouseMove(UINT nFlags, CPoint point) { if (IsFloating() || !m_bTracking) { CControlBar::OnMouseMove(nFlags, point); return; } CPoint cpt = m_rectTracker.CenterPoint(); ClientToWnd(point); if (IsHorz()) { if (cpt.y != point.y) { OnInvertTracker(m_rectTracker); m_rectTracker.OffsetRect(0, point.y - cpt.y); OnInvertTracker(m_rectTracker); } } else { if (cpt.x != point.x) { OnInvertTracker(m_rectTracker); m_rectTracker.OffsetRect(point.x - cpt.x, 0); OnInvertTracker(m_rectTracker); } } }
BOOL CCoolDialogBar::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) { if ((nHitTest != HTSIZE) || m_bTracking) return CControlBar::OnSetCursor(pWnd, nHitTest, message); if (IsHorz()) SetCursor(LoadCursor(NULL, IDC_SIZENS)); else SetCursor(LoadCursor(NULL, IDC_SIZEWE)); return TRUE; }
void ScrollBar::Paint(Draw& w) { w.DrawRect(GetSize(), SColorPaper()); int cc; Size sz = style->through ? GetSize() : Slider(cc).GetSize(); light = GetMousePart(); int p = push; if(!HasCapture()) p = -1; const Value *hl[] = { style->hlower, style->hupper, style->hthumb }; const Value *vl[] = { style->vupper, style->vlower, style->vthumb }; const Value **l = IsHorz() ? hl : vl; if(prev.IsShowEnabled()) { for(int i = 0; i < 3; i++) { Rect pr = GetPartRect(i); if(i != 2) { w.Clip(pr); pr = style->through ? GetSize() : Slider(); } if(i != 2 || thumbsize >= style->thumbmin) ChPaint(w, pr, l[i][p == i ? CTRL_PRESSED : light == i ? CTRL_HOT : CTRL_NORMAL]); if(i != 2) w.End(); } } else if(style->through) ChPaint(w, sz, l[0][CTRL_DISABLED]); else if(IsHorz()) { ChPaint(w, cc, 0, sz.cx / 2, sz.cy, l[0][CTRL_DISABLED]); ChPaint(w, cc + sz.cx / 2, 0, sz.cx - sz.cx / 2, sz.cy, l[1][CTRL_DISABLED]); } else { ChPaint(w, 0, cc, sz.cx, sz.cy / 2, l[0][CTRL_DISABLED]); ChPaint(w, 0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, l[1][CTRL_DISABLED]); // w.DrawRect(0, cc, sz.cx, sz.cy / 2, Red()); _DBG_ // w.DrawRect(0, cc + sz.cy / 2, sz.cx, sz.cy - sz.cy / 2, Green()); _DBG_ } }
void CCoolDialogBar::StopTracking(BOOL bAccept) { OnInvertTracker(m_rectTracker); m_pDockSite->UnlockWindowUpdate(); m_bTracking = FALSE; ReleaseCapture(); if (!bAccept) return; int maxsize, minsize, newsize; CRect rcc; m_pDockSite->GetWindowRect(rcc); newsize = IsHorz() ? m_sizeHorz.cy : m_sizeVert.cx; maxsize = newsize + (IsHorz() ? rcc.Height() : rcc.Width()); minsize = IsHorz() ? m_sizeMin.cy : m_sizeMin.cx; CPoint point = m_rectTracker.CenterPoint(); switch (m_nDockBarID) { case AFX_IDW_DOCKBAR_TOP: newsize += point.y - m_ptOld.y; break; case AFX_IDW_DOCKBAR_BOTTOM: newsize += -point.y + m_ptOld.y; break; case AFX_IDW_DOCKBAR_LEFT: newsize += point.x - m_ptOld.x; break; case AFX_IDW_DOCKBAR_RIGHT: newsize += -point.x + m_ptOld.x; break; } newsize = max(minsize, min(maxsize, newsize)); if (IsHorz()) m_sizeHorz.cy = newsize; else m_sizeVert.cx = newsize; m_pDockSite->RecalcLayout(); }
//depende de la posicion se hace igual el tamanio del ancho o alto void CGuiControlBar::SetEqualWidth() { int nFirstPos=GetFirstPos(); for (int nPos = nFirstPos; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos); if (pBar== NULL) continue; if (IsHorz()) pBar->m_sizeHorz.cy=m_sizeHorz.cy;//rcDockBar.Height(); else pBar->m_sizeVert.cx=m_sizeVert.cx; } }
void CCoolDialogBar::StartTracking() { SetCapture(); // make sure no updates are pending RedrawWindow(NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW); m_pDockSite->LockWindowUpdate(); m_ptOld = m_rectBorder.CenterPoint(); m_bTracking = TRUE; m_rectTracker = m_rectBorder; if (!IsHorz()) m_rectTracker.bottom -= 4; OnInvertTracker(m_rectTracker); }
void CSizingTabCtrlBar::OnSize(UINT nType, int cx, int cy) { CSizingControlBar::OnSize(nType, cx, cy); int bottom = (IsHorz() || IsFloating()) ? cy - 14 : cy - 18; m_tabctrl.MoveWindow(-1, cy -24, cx+20, 24); CRect rc; GetWindowRect (&rc); TRACE(_T("%d %d\n"),rc.top, rc.left); CWnd *pWnd; for (POSITION pos=m_views.GetHeadPosition(); pos; m_views.GetNext(pos)) { pWnd=m_views.GetAt(pos)->pWnd; pWnd->MoveWindow(2, 2, cx - 5, bottom-10); } Invalidate (); }
Rect ScrollBar::Slider(int& cc) const { Size sz = GetSize(); Rect r; if(IsHorz()) { cc = sz.cx > (3 + style->isleft2 + style->isright2) * style->arrowsize ? style->arrowsize : 0; r = RectC(cc, 0, sz.cx - 2 * cc, sz.cy); if(style->isleft2) r.right -= cc; if(style->isright2) r.left += cc; } else { cc = sz.cy > (3 + style->isup2 + style->isdown2) * style->arrowsize ? style->arrowsize : 0; r = RectC(0, cc, sz.cx, sz.cy - 2 * cc); if(style->isup2) r.bottom -= cc; if(style->isdown2) r.top += cc; } return r; }
void ScrollBar::Drag(Point p) { if(SetThumb(max(0, IsHorz() ? p.x - delta : p.y - delta), thumbsize) && track) Position(); }
void ScrollBar::FrameLayout(Rect& r) { (IsHorz() ? LayoutFrameBottom : LayoutFrameRight)(r, this, ScrollBarSize()); }
void CGuiControlBar::AjustHorz(BOOL bGrow,int nDif) { int nFirstPos=GetFirstPos(); int nLastPos=GetLastPos(); int m_ThisPos=m_pDockBar->FindBar(this); if(m_SideMove==HTRIGHT) { //Esta ventana crece las anteriores reducen su tamaño if (bGrow) { for (int i=m_ThisPos+1; i <= nLastPos; i++) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsHorz()) { if (pBar->m_sizeHorz.cx-abs(nDif) < pBar->m_sizeMinH.cx) { pBar->m_sizeHorz.cx=pBar->m_sizeMinH.cx; continue; } else { pBar->m_sizeHorz.cx-=abs(nDif); break; } } }//for }//bGrow else //este disminuye la anterior crece { if (m_ThisPos+1 <= m_Last) { CGuiControlBar* pBar = GetGuiControlBar(m_ThisPos+1); if (pBar== NULL) return; pBar->m_sizeHorz.cx+=abs(nDif); if(m_sizeHorz.cx > m_sizeMinH.cx) return; else pBar->m_sizeHorz.cx+=abs(nDif); } for (int i=m_ThisPos-1; i >0; i--) { CGuiControlBar* pBar = GetGuiControlBar(i); if (pBar== NULL) return; if(IsHorz()) { if (pBar->m_sizeHorz.cx-abs(nDif) < pBar->m_sizeMinH.cx) continue; else { pBar->m_sizeHorz.cx-=abs(nDif); return; } } }//for } } }
void ScrollBar::FrameAddSize(Size& sz) { (IsHorz() ? sz.cy : sz.cx) += ScrollBarSize(); }
//esta funcion calcula el tamaño horizontal de la ventana,no importa si esta //docking a izquierda o derecha o arriba o abajo.Debemos disponer de un espacio equitativo entre todas //ventanas que se encuentren docking ya sea en una fila o columna. CSize CGuiControlBar::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { //la funcion original toma el ancho o alto dependiendo del sentido que nos //indica bHorz. ASSERT_VALID(this); if (IsFloating()) return m_sizeMinFloating; else { //si bStrerch es TRUE significa que esta ventana no se puede hacer //Docking if (bStretch) { if (bHorz) return CSize(32767, m_sizeHorz.cy); else return CSize(m_sizeVert.cx, 32767); } } int Len=GetHiWid(); int nWidth = GetWidthMax(); int nMinSpace=0;//minimo espacio requerido con lo tamaños normales int nMinimo=0; //minimo espacio de los tamaños minimos int nRealBars=0; int m_First=GetFirstPos(); for (int nPos = m_First; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos,TRUE); if (pBar== NULL) continue; if (!pBar->IsVisible()) continue; if (!pBar->IsKindOf(RUNTIME_CLASS(CGuiControlBar))) { CPoint pt(GetMessagePos()); m_pDockSite->FloatControlBar(pBar,pt); continue; } if(IsVert()) pBar->m_sizeVert.cx=nWidth; else pBar->m_sizeHorz.cy=nWidth; //todas se hacen con el mismo ancho nMinSpace+=IsVert() ? pBar->m_sizeVert.cy:pBar->m_sizeHorz.cx; //minimo espacio para alinear las barras nRealBars++; //cuantas barras realmente existen } //si el tamaño de las barras en la fila es mayor que //el espacio disponible, luego la solucion salomonica es //repartir el espacio entre todas. if (nRealBars == 1 ) { if (bHorz) return m_sizeHorz= CSize(Len,m_sizeHorz.cy); else return m_sizeVert=CSize(m_sizeVert.cx,Len); } int nDif=Len-nMinSpace; if (abs(nDif) !=0) { BOOL bGrow=FALSE; if (nDif > 0) bGrow=TRUE; nDif=abs(nDif); while(nDif > 0) { for (int nPos = m_First; nPos <= m_Last; nPos++) { CGuiControlBar* pBar = GetGuiControlBar(nPos); if (pBar== NULL) continue; if(IsVert()) { if(bGrow) pBar->m_sizeVert.cy+=1; else { if (pBar->m_sizeVert.cy-1 < pBar->m_sizeMinV.cy) continue; pBar->m_sizeVert.cy-=1; } } else { if(bGrow) pBar->m_sizeHorz.cx+=1; else { if (pBar->m_sizeHorz.cx-1 < pBar->m_sizeMinH.cx) continue; pBar->m_sizeHorz.cx-=1; } } nDif--; if(nDif==0) break; } } } //--reubicar las ventanas, sin esta rutina nada funciona RecalWindowPos(); if (IsHorz()) return m_sizeHorz; else return m_sizeVert; }
int ScrollBar::GetHV(int h, int v) const { return IsHorz() ? h : v; }
void CXTPSkinObjectTab::DrawTabText(CDC* pDC, CRect& rcItem, int iItem, int iCount, BOOL bSelected) { CTabCtrl* pTabCtrl = (CTabCtrl*)this; CString strCaption; LPTSTR pszText = strCaption.GetBuffer(256); pszText[0] = 0; TC_ITEM tci; tci.mask = TCIF_TEXT; tci.pszText = pszText; tci.cchTextMax = 255; BOOL bResult = pTabCtrl->GetItem(iItem, &tci); strCaption.ReleaseBuffer(); #ifdef _UNICODE if (!bResult) { char tText[256]; tText[0] = 0; TC_ITEMA tcia; ::ZeroMemory(&tcia, sizeof(TC_ITEMA)); tcia.mask = TCIF_TEXT; // Get the header item text and format tcia.pszText = tText; tcia.cchTextMax = 255; ::SendMessage(pTabCtrl->m_hWnd, TCM_GETITEMA, iItem, (LPARAM)&tcia); strCaption = tText; } #else if (!bResult) return; #endif if (strCaption.GetLength() == 0) return; pDC->SetTextColor(GetColor(COLOR_BTNTEXT)); // Set the font for the tab label. DWORD dwStyle = GetStyle(); CXTPSkinManagerClass* pClass = GetSkinClass(); int nStateId = bSelected ? TIS_SELECTED: m_nHotItem == iItem ? TIS_HOT : TIS_NORMAL; int nPartId = iItem == 0 ? TABP_TOPTABITEMLEFTEDGE : iItem == iCount - 1 && !bSelected ? TABP_TOPTABITEMRIGHTEDGE : TABP_TOPTABITEM; // Draw the tab label. if (IsHorz(dwStyle)) { UINT dsFlags = DT_SINGLELINE | DT_VCENTER | DT_CENTER | DT_END_ELLIPSIS; if (SendMessage(WM_QUERYUISTATE) & UISF_HIDEACCEL) { dsFlags |= DT_HIDEPREFIX; } if (!(GetStyle() & TCS_BUTTONS)) { rcItem.top += bSelected ? -2 : 1; rcItem.right -= iItem == 0 ? 3 : 0; } else { rcItem.top += bSelected ? 0 : -1; } pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, dsFlags, &rcItem); } else { CSize sz = pDC->GetTextExtent(strCaption); rcItem.left = rcItem.right-(rcItem.Width()-sz.cy + 1)/ 2; rcItem.top = rcItem.top+(rcItem.Height()-sz.cx + 1)/ 2; pClass->DrawThemeText(pDC, nPartId, nStateId, strCaption, DT_SINGLELINE | DT_NOCLIP, &rcItem); } }
int& ScrollBar::HV(int& h, int& v) const { return IsHorz() ? h : v; }