bool wxSpinCtrl::Create( wxWindow* pParent, wxWindowID vId, const wxString& WXUNUSED(rsValue), const wxPoint& rPos, const wxSize& rSize, long lStyle, int nMin, int nMax, int nInitial, const wxString& rsName ) { if (vId == wxID_ANY) m_windowId = NewControlId(); else m_windowId = vId; if (pParent) { m_backgroundColour = pParent->GetBackgroundColour(); m_foregroundColour = pParent->GetForegroundColour(); } SetName(rsName); SetParent(pParent); m_windowStyle = lStyle; int lSstyle = 0L; lSstyle = WS_VISIBLE | WS_TABSTOP | SPBS_MASTER | // We use only single field spin buttons SPBS_NUMERICONLY; // We default to numeric data if (m_windowStyle & wxCLIP_SIBLINGS ) lSstyle |= WS_CLIPSIBLINGS; SPBCDATA vCtrlData; vCtrlData.cbSize = sizeof(SPBCDATA); vCtrlData.ulTextLimit = 10L; vCtrlData.lLowerLimit = 0L; vCtrlData.lUpperLimit = 100L; vCtrlData.idMasterSpb = vId; vCtrlData.pHWXCtlData = NULL; m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent) ,WC_SPINBUTTON ,(PSZ)NULL ,lSstyle ,0L, 0L, 0L, 0L ,GetWinHwnd(pParent) ,HWND_TOP ,(HMENU)vId ,(PVOID)&vCtrlData ,NULL ); if (m_hWnd == 0) { return false; } m_hWndBuddy = m_hWnd; // One in the same for OS/2 if(pParent) pParent->AddChild((wxSpinButton *)this); SetFont(*wxSMALL_FONT); SetXComp(0); SetYComp(0); SetSize( rPos.x, rPos.y, rSize.x, rSize.y ); SetRange(nMin, nMax); SetValue(nInitial); // // For OS/2 we'll just set our handle into our long data // wxAssociateWinWithHandle( m_hWnd ,(wxWindowOS2*)this ); ::WinSetWindowULong(GetHwnd(), QWL_USER, (LONG)this); fnWndProcSpinCtrl = (WXFARPROC)::WinSubclassWindow(m_hWnd, (PFNWP)wxSpinCtrlWndProc); m_svAllSpins.Add(this); return true; } // end of wxSpinCtrl::Create
// same as AddPage() but does it at given position bool wxNotebook::InsertPage(size_t nPage, wxNotebookPage *pPage, const wxString& strText, bool bSelect, int imageId) { wxCHECK_MSG( pPage != NULL, false, wxT("NULL page in wxNotebook::InsertPage") ); wxCHECK_MSG( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false, wxT("invalid index in wxNotebook::InsertPage") ); wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") ); // add a new tab to the control // ---------------------------- // init all fields to 0 TC_ITEM tcItem; wxZeroMemory(tcItem); // set the image, if any if ( imageId != -1 ) { tcItem.mask |= TCIF_IMAGE; tcItem.iImage = imageId; } // and the text if ( !strText.empty() ) { tcItem.mask |= TCIF_TEXT; tcItem.pszText = wxMSW_CONV_LPTSTR(strText); } // hide the page: unless it is selected, it shouldn't be shown (and if it // is selected it will be shown later) HWND hwnd = GetWinHwnd(pPage); SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_VISIBLE); // this updates internal flag too -- otherwise it would get out of sync // with the real state pPage->Show(false); // fit the notebook page to the tab control's display area: this should be // done before adding it to the notebook or TabCtrl_InsertItem() will // change the notebooks size itself! AdjustPageSize(pPage); // finally do insert it if ( TabCtrl_InsertItem(GetHwnd(), nPage, &tcItem) == -1 ) { wxLogError(wxT("Can't create the notebook page '%s'."), strText.c_str()); return false; } // need to update the bg brush when the first page is added // so the first panel gets the correct themed background if ( m_pages.empty() ) { #if wxUSE_UXTHEME UpdateBgBrush(); #endif // wxUSE_UXTHEME } // succeeded: save the pointer to the page m_pages.Insert(pPage, nPage); // we may need to adjust the size again if the notebook size changed: // normally this only happens for the first page we add (the tabs which // hadn't been there before are now shown) but for a multiline notebook it // can happen for any page at all as a new row could have been started if ( m_pages.GetCount() == 1 || HasFlag(wxNB_MULTILINE) ) { AdjustPageSize(pPage); // Additionally, force the layout of the notebook itself by posting a // size event to it. If we don't do it, notebooks with pages on the // left or the right side may fail to account for the fact that they // are now big enough to fit all all of their pages on one row and // still reserve space for the second row of tabs, see #1792. const wxSize s = GetSize(); ::PostMessage(GetHwnd(), WM_SIZE, SIZE_RESTORED, MAKELPARAM(s.x, s.y)); } // now deal with the selection // --------------------------- // if the inserted page is before the selected one, we must update the // index of the selected page if ( int(nPage) <= m_selection ) { // one extra page added m_selection++; } DoSetSelectionAfterInsertion(nPage, bSelect); InvalidateBestSize(); return true; }