bool nuiLabel::SetRect(const nuiRect& rRect) { bool needRecalcLayout = false; if (mUseEllipsis || mWrapping) needRecalcLayout = (rRect.GetWidth() != mRect.GetWidth()); nuiWidget::SetRect(rRect); nuiRect ideal(mIdealLayoutRect); if (needRecalcLayout || ideal.GetWidth() > mRect.GetWidth()) { if (mUseEllipsis) { CalcLayout(); nuiSize diff = ideal.GetWidth() - mRect.GetWidth(); int NbLetterToRemove = ToNearest(diff / (ideal.GetWidth() / mText.GetLength())) + 3; nglString text = mText; if (NbLetterToRemove > 0) { int len = text.GetLength(); text.DeleteRight(MIN(NbLetterToRemove, len)); text.Append(_T("...")); } delete mpLayout; mpLayout = new nuiTextLayout(mpFont); mpLayout->SetWrapX(0); mpLayout->Layout(text); GetLayoutRect(); } else if (mWrapping) { CalcLayout(); delete mpLayout; mpLayout = new nuiTextLayout(mpFont); delete mpIdealLayout; mpIdealLayout = new nuiTextLayout(mpFont); mpLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight); mpIdealLayout->SetWrapX(mRect.GetWidth() - mBorderLeft - mBorderRight); mpLayout->Layout(mText); mpIdealLayout->Layout(mText); GetLayoutRect(); } SetToolTip(mText); } else { if (GetToolTip() == mText) SetToolTip(nglString::Empty); } return true; }
// Rotate this object about a point void CDrawPower::Rotate(CDPoint p, int ndir) { // Rotate bounding box only if we have a centre point if (p != CDPoint(0, 0)) { // Translate this point so the rotational point is the origin m_point_a = CDPoint(m_point_a.x - p.x, m_point_a.y - p.y); m_point_b = CDPoint(m_point_b.x - p.x, m_point_b.y - p.y); // Perfrom the rotation switch (ndir) { case 2: // Left m_point_a = CDPoint(m_point_a.y, -m_point_a.x); m_point_b = CDPoint(m_point_b.y, -m_point_b.x); break; case 3: // Right m_point_a = CDPoint(-m_point_a.y, m_point_a.x); m_point_b = CDPoint(-m_point_b.y, m_point_b.x); break; case 4: // Mirror m_point_a = CDPoint(-m_point_a.x, m_point_a.y); m_point_b = CDPoint(-m_point_b.x, m_point_b.y); break; } // Re-translate the points back to the original location m_point_a = CDPoint(m_point_a.x + p.x, m_point_a.y + p.y); m_point_b = CDPoint(m_point_b.x + p.x, m_point_b.y + p.y); } dir = (BYTE) DoRotate(dir, ndir); CalcLayout(); }
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxBitmap &bitmap, const wxPoint& pos, const wxSize& size_, long style, const wxValidator& val, const wxString& name) { m_labelString = label; if (bitmap.Ok()) m_bmpLabel = bitmap; wxSize bestSize = DoGetBestSize_(parent); wxSize size(size_.x<0 ? bestSize.x:size_.x, size_.y<0 ? bestSize.y:size_.y); //SetInitialSize(size); if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name)) return false; wxControl::SetBackgroundColour(parent->GetBackgroundColour()); wxControl::SetForegroundColour(parent->GetForegroundColour()); wxControl::SetFont(parent->GetFont()); if (!SetButtonStyle(style)) return false; //SetBestSize(size); CalcLayout(true); return true; }
bool wxCustomButton::SetButtonStyle(long style) { int n_styles = 0; if ((style & wxCUSTBUT_LEFT) != 0) n_styles++; if ((style & wxCUSTBUT_RIGHT) != 0) n_styles++; if ((style & wxCUSTBUT_TOP) != 0) n_styles++; if ((style & wxCUSTBUT_BOTTOM) != 0) n_styles++; wxCHECK_MSG(n_styles < 2, FALSE, wxT("Only one wxCustomButton label position allowed")); n_styles = 0; if ((style & wxCUSTBUT_NOTOGGLE) != 0) n_styles++; if ((style & wxCUSTBUT_BUTTON) != 0) n_styles++; if ((style & wxCUSTBUT_TOGGLE) != 0) n_styles++; if ((style & wxCUSTBUT_BUT_DCLICK_TOG) != 0) n_styles++; if ((style & wxCUSTBUT_TOG_DCLICK_BUT) != 0) n_styles++; wxCHECK_MSG(n_styles < 2, FALSE, wxT("Only one wxCustomButton style allowed")); m_button_style = style; if ((m_button_style & wxCUSTBUT_BUTTON) != 0) m_down = 0; CalcLayout(TRUE); return TRUE; }
void wxCustomButton::SetMargins(const wxSize &margin, bool fit) { m_labelMargin = margin; m_bitmapMargin = margin; CalcLayout(TRUE); if (fit) SetSize(DoGetBestSize()); }
bool wxCustomButton::Create(wxWindow* parent, wxWindowID id, const wxString& label, const wxBitmap &bitmap, const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name) { if (!wxControl::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name)) return FALSE; wxControl::SetLabel(label); wxControl::SetBackgroundColour(parent->GetBackgroundColour()); wxControl::SetForegroundColour(parent->GetForegroundColour()); wxControl::SetFont(parent->GetFont()); if (bitmap.Ok()) m_bmpLabel = bitmap; if (!SetButtonStyle(style)) return FALSE; wxSize bestSize = DoGetBestSize(); SetSize(wxSize(size.x<0 ? bestSize.x:size.x, size.y<0 ? bestSize.y:size.y)); #if (wxMINOR_VERSION<8) SetBestSize(GetSize()); #else SetInitialSize(GetSize()); #endif CalcLayout(TRUE); return TRUE; }
void wxBitmapComboBox::Thaw() { m_frozen = false; CalcLayout(); if (m_labelWin) m_labelWin->Refresh(); }
CSize CGuiToolBarWnd::CalcFixedLayout(BOOL bStretch, BOOL bHorz) { DWORD dwMode = bStretch ? LM_STRETCH : 0; dwMode |= bHorz ? LM_HORZ : 0; return CalcLayout(dwMode); }
void wxBitmapComboBox::SetBitmap(int n, const wxBitmap &bitmap) { wxCHECK_RET((n>=0) && (n < GetCount()), wxT("invalid index")); *((wxBitmap*)m_bitmaps.Item(n)) = bitmap; CalcLayout(); if (n == m_selection) m_labelWin->Refresh(false); }
void wxBitmapComboBox::SetLabel(int n, const wxString &label) { wxCHECK_RET( (n>=0) && (n < GetCount()), wxT("invalid index")); m_labels[n] = label; CalcLayout(); if (n == m_selection) m_labelWin->Refresh(false); }
void wxBitmapComboBox::Insert(int n, const wxString &label, const wxBitmap &bitmap) { wxCHECK_RET((n>=0) && (n<GetCount()), wxT("invalid index")); m_labels.Insert(label, n); m_bitmaps.Insert(new wxBitmap(bitmap), n); CalcLayout(); }
void emPsDocumentPanel::SetDocument(const emPsDocument & document) { if (Document!=document) { DestroyPagePanels(); Document=document; CalcLayout(); if (ArePagePanelsToBeShown()) CreatePagePanels(); } }
void wxBitmapComboBox::Append(const wxString &label, const wxBitmap &bitmap, int count) { for (int n=0; n<count; n++) { m_labels.Add(label); m_bitmaps.Add(new wxBitmap(bitmap)); } CalcLayout(); }
CSize CGuiToolBarWnd::CalcDynamicLayout(int nLength, DWORD dwMode) { if ((nLength == -1) && !(dwMode & LM_MRUWIDTH) && !(dwMode & LM_COMMIT) && ((dwMode & LM_HORZDOCK) || (dwMode & LM_VERTDOCK))) { return CalcFixedLayout(dwMode & LM_STRETCH, dwMode & LM_HORZDOCK); } return CalcLayout(dwMode, nLength); }
bool CPrintFolder::CalcLayout() { if (m_devmode.m_pDevMode) { m_devmode.m_pDevMode->dmOrientation = m_bPrintLandscape ? DMORIENT_LANDSCAPE : DMORIENT_PORTRAIT; } CDC dcPrinter = m_printer.CreatePrinterDC(m_devmode); return CalcLayout(dcPrinter.m_hDC); }
emPsDocumentPanel::emPsDocumentPanel( ParentArg parent, const emString & name, const emPsDocument & document ) : emPanel(parent,name) { BGColor=emColor(0,0,0,0); FGColor=emColor(0,0,0); PagePanels=NULL; CalcLayout(); SetDocument(document); }
CSize CDialBar::CalcDynamicLayout(int length, DWORD mode) { // TRACE2("length = %d \tmode = %x\n", length, (int)mode); if ((length == -1) && !(mode & LM_MRUWIDTH) && !(mode & LM_COMMIT) && ((mode & LM_HORZDOCK) || (mode & LM_VERTDOCK))) { return CalcFixedLayout(mode & LM_STRETCH, mode & LM_HORZDOCK); } return CalcLayout(length,mode); }
void wxBitmapComboBox::Clear() { m_labels.Clear(); while (m_bitmaps.GetCount() > 0u) { wxBitmap *bmp = (wxBitmap*)m_bitmaps.Item(0); m_bitmaps.RemoveAt(0); delete bmp; } CalcLayout(); }
bool CPrintFolder::CalcLayout(CDCHandle dcPrinter) { if(!dcPrinter.IsNull()) { CRect rcPage(0, 0, dcPrinter.GetDeviceCaps(PHYSICALWIDTH) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETX), dcPrinter.GetDeviceCaps(PHYSICALHEIGHT) - 2 * dcPrinter.GetDeviceCaps(PHYSICALOFFSETY)); // Fix for 98...PHYSICALWIDTH seems to fail on 98? if (rcPage.right == 0) { rcPage.right = dcPrinter.GetDeviceCaps(HORZRES); rcPage.bottom = dcPrinter.GetDeviceCaps(VERTRES); } return CalcLayout(dcPrinter, rcPage); } return CalcLayout(dcPrinter, m_rcOutput); }
void wxBitmapComboBox::Delete( int n, int count ) { wxCHECK_RET((n>=0) && (count>0) && (n+count<=GetCount()), wxT("invalid index")); for (int i=0; i<count; i++) { m_labels.RemoveAt(n); wxBitmap *bmp = (wxBitmap*)m_bitmaps.Item(n); m_bitmaps.RemoveAt(n); delete bmp; } CalcLayout(); }
BOOL COXTabViewContainer::Create(CWnd* pParentWnd, CRect rect/*=CRect(0,0,0,0)*/, DWORD dwStyle/*=WS_CHILD|WS_VISIBLE*/, UINT nID/*=AFX_IDW_PANE_FIRST*/) { ASSERT(pParentWnd != NULL); ASSERT(dwStyle & WS_CHILD); ASSERT(nID != 0); // the Windows scroll bar styles bits turn on the smart scrollbars DWORD dwCreateStyle=dwStyle&~(WS_HSCROLL|WS_VSCROLL); dwCreateStyle&=~WS_BORDER; dwCreateStyle|=WS_CHILD; // define our own window class WNDCLASS wndClass; wndClass.style=CS_DBLCLKS; wndClass.lpfnWndProc=AfxWndProc; wndClass.cbClsExtra=0; wndClass.cbWndExtra=0; wndClass.hInstance=AfxGetInstanceHandle(); wndClass.hIcon=0; wndClass.hCursor=::LoadCursor(NULL,IDC_ARROW); wndClass.hbrBackground=(HBRUSH)(COLOR_BTNFACE+1); wndClass.lpszMenuName=NULL; wndClass.lpszClassName=_T("TabViewContainer"); if(!AfxRegisterClass(&wndClass)) return FALSE; if (!CreateEx(WS_EX_CLIENTEDGE,wndClass.lpszClassName,NULL, dwCreateStyle,rect.left,rect.top,rect.Width(),rect.Height(), pParentWnd->m_hWnd,(HMENU)(INT_PTR)nID,NULL)) { return FALSE; // create invisible } // remove WS_EX_CLIENTEDGE style from parent window pParentWnd->ModifyStyleEx(WS_EX_CLIENTEDGE, 0, SWP_DRAWFRAME); // sign ::SetWindowLongPtr(GetSafeHwnd(),GWL_USERDATA,ID_TABVIEWCONTAINER_SIGN); SetScrollStyle(0,TRUE); CalcLayout(); return TRUE; }
BOOL COXTabViewContainer::LoadState(LPCTSTR lpszProfileName) { CWinApp* pApp=AfxGetApp(); if(pApp==NULL) return FALSE; m_nLastTabBtnAreaWidth=pApp->GetProfileInt(lpszProfileName, _T("TabButtonsAreaWidth"),m_nLastTabBtnAreaWidth); CalcLayout(); UpdateScrollSizes(); RedrawContainer(); return TRUE; }
void emPsDocumentPanel::Notice(NoticeFlags flags) { emPanel::Notice(flags); if (flags&(NF_LAYOUT_CHANGED|NF_VIEWING_CHANGED|NF_SOUGHT_NAME_CHANGED)) { if (flags&NF_LAYOUT_CHANGED) { CalcLayout(); InvalidateChildrenLayout(); } if (ArePagePanelsToBeShown()) { if (!PagePanels) CreatePagePanels(); } else { if (PagePanels) DestroyPagePanels(); } } }
void wxTreeLayout::DoLayout(wxDC& dc, long topId) { if (topId != wxID_ANY) SetTopNode(topId); long actualTopId = GetTopNode(); long id = actualTopId; while (id != wxID_ANY) { SetNodeX(id, 0); SetNodeY(id, 0); ActivateNode(id, false); id = GetNextNode(id); } m_lastY = m_topMargin; m_lastX = m_leftMargin; CalcLayout(actualTopId, 0, dc); }
nuiRect nuiLabel::CalcIdealSize() { // NGL_OUT(_T("Calc 0x%x\n"), this); CalcLayout(); if (mpLayout) { mIdealRect = mIdealLayoutRect; // if (GetDebug(1)) // { // printf("New ideal rect: %s\n", mIdealRect.GetValue().GetChars()); // } } mIdealRect.RoundToBiggest(); //NGL_OUT(_T("%s [%s]"), mText.GetChars(), mIdealRect.GetValue().GetChars()); return mIdealRect; }
bool nuiMatrixViewItem::Draw(nuiDrawContext* pContext) { pContext->EnableBlending(true); pContext->SetBlendFunc(nuiBlendTransp); CalcLayout(); nuiRect rect = mIdealLayoutRect; rect.SetPosition(GetPosition(), mRect.Size()); pContext->SetFillColor(mDesc.GetFillColor()); pContext->SetStrokeColor(mDesc.GetStrokeColor()); pContext->DrawRect(mRect.Size(),eStrokeAndFillShape); nuiFormatedLabel::Draw(pContext); return true; }
void COXTabViewContainer::OnSettingChange(UINT uFlags, LPCTSTR lpszSection) { UNREFERENCED_PARAMETER(uFlags); UNREFERENCED_PARAMETER(lpszSection); CalcLayout(); UpdateScrollSizes(); CWnd* pWnd=GetActivePage(); if(pWnd!=NULL) { ASSERT(::IsWindow(pWnd->m_hWnd)); if(::IsWindow(pWnd->m_hWnd)) pWnd->MoveWindow(m_rectPage); } RedrawContainer(); CWnd::OnSettingChange(uFlags, lpszSection); }
bool wxBitmapComboBox::Create( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxValidator& val, const wxString& name) { if (!DropDownBase::Create(parent,id,pos,size,wxNO_BORDER|wxCLIP_CHILDREN,val,name)) return false; m_labelWin = new wxBitmapComboLabel(this); m_win_border = m_labelWin->GetSize().x - m_labelWin->GetClientSize().x; SetBackgroundColour(*wxWHITE); m_frozen = false; CalcLayout(); wxSize bestSize = DoGetBestSize(); SetSize( wxSize(size.x < 0 ? bestSize.x : size.x, size.y < 0 ? bestSize.y : size.y) ); return SetButtonStyle(style); }
void COXTabViewContainer::OnSize(UINT nType, int cx, int cy) { CWnd::OnSize(nType, cx, cy); // TODO: Add your message handler code here if(nType!=SIZE_MINIMIZED && cx>0 && cy>0) { CalcLayout(); UpdateScrollSizes(); CWnd* pWnd=GetActivePage(); if(pWnd!=NULL) { ASSERT(::IsWindow(pWnd->m_hWnd)); if(::IsWindow(pWnd->m_hWnd)) pWnd->MoveWindow(m_rectPage); } RedrawContainer(); } }
void wxCustomButton::OnSize( wxSizeEvent &event ) { CalcLayout(TRUE); event.Skip(); }