bool MyComboBoxValidator::TransferFromWindow() { wxASSERT(GetWindow()->IsKindOf(CLASSINFO(wxComboBox))); if ( m_var ) { wxComboBox* cb = (wxComboBox*)GetWindow(); if ( !cb ) return false; *m_var = cb->GetValue(); } return true; }
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, long style, const wxValidator& validator, const wxString& name) { m_macIsUserPane = false ; if ( !wxControl::Create(parent, id, pos, size, style, validator, name) ) return false; m_label = label ; Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; m_peer = new wxMacControl(this) ; verify_noerr ( CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") , 0 , false /* no autotoggle */ , m_peer->GetControlRefAddr() ) ); MacPostControlCreate(pos,size) ; m_cycle = this ; if (HasFlag(wxRB_GROUP)) { AddInCycle( NULL ) ; } else { /* search backward for last group start */ wxRadioButton *chief = (wxRadioButton*) NULL; wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast(); while (node) { wxWindow *child = node->GetData(); if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) ) { chief = (wxRadioButton*) child; if (child->HasFlag(wxRB_GROUP)) break; } node = node->GetPrevious(); } AddInCycle( chief ) ; } return true; }
void wxSFMultiSelRect::OnBottomHandle(wxSFShapeHandle& handle) { if(GetParentCanvas() && !AnyHeightExceeded(handle.GetDelta())) { wxXS::RealPointList::compatibility_iterator ptnode; wxSFLineShape* pLine; wxRealPoint* pt; double dy, sy = (GetRectSize().y - 2*sfDEFAULT_ME_OFFSET + handle.GetDelta().y)/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET); ShapeList m_lstSelection; GetParentCanvas()->GetSelectedShapes(m_lstSelection); ShapeList::compatibility_iterator node = m_lstSelection.GetFirst(); while(node) { wxSFShapeBase* pShape = node->GetData(); if(!pShape->IsKindOf(CLASSINFO(wxSFLineShape))) { dy = (pShape->GetAbsolutePosition().y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y; if(pShape->ContainsStyle(sfsSIZE_CHANGE)) pShape->Scale(1, sy, sfWITHCHILDREN); if(pShape->ContainsStyle(sfsPOSITION_CHANGE)) pShape->MoveBy(0, dy); if( ! pShape->ContainsStyle( sfsNO_FIT_TO_CHILDREN ) ) pShape->FitToChildren(); } else { if(pShape->ContainsStyle(sfsPOSITION_CHANGE)) { pLine = (wxSFLineShape*)pShape; ptnode = pLine->GetControlPoints().GetFirst(); while(ptnode) { pt = ptnode->GetData(); dy = ( pt->y - (GetAbsolutePosition().y + sfDEFAULT_ME_OFFSET))/(GetRectSize().y - 2*sfDEFAULT_ME_OFFSET)*handle.GetDelta().y; pt->y += dy; pt->y = floor(pt->y); ptnode = ptnode->GetNext(); } } } node = node->GetNext(); } } }
bool wxGenericImageList::Draw( int index, wxDC &dc, int x, int y, int flags, bool WXUNUSED(solidBackground) ) { wxObjectList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, false, wxT("wrong index in image list") ); wxBitmap *bm = (wxBitmap*)node->GetData(); if (bm->IsKindOf(CLASSINFO(wxIcon))) dc.DrawIcon( * ((wxIcon*) bm), x, y); else dc.DrawBitmap( *bm, x, y, (flags & wxIMAGELIST_DRAW_TRANSPARENT) > 0 ); return true; }
int CFrame::GetNotebookAffiliation(wxWindowID Id) { for (u32 i = 0, j = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for(u32 k = 0; k < NB->GetPageCount(); k++) { if (NB->GetPage(k)->GetId() == Id) return j; } j++; } return -1; }
void CFrame::ResetToolbarStyle() { wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i) { wxAuiPaneInfo& Pane = AllPanes[i]; if (Pane.window->IsKindOf(CLASSINFO(wxAuiToolBar))) { Pane.Show(); // Show all of it if (Pane.rect.GetLeft() > GetClientSize().GetX() - 50) Pane.Position(GetClientSize().GetX() - Pane.window->GetClientSize().GetX()); } } m_Mgr->Update(); }
pascal SInt32 wxMacControlDefinition(SInt16 varCode, ControlRef theControl, ControlDefProcMessage message, SInt32 param) { wxControl* wx = (wxControl*) wxFindControlFromMacControl( theControl ) ; if ( wx != NULL && wx->IsKindOf( CLASSINFO( wxControl ) ) ) { if( message == drawCntl ) { wxMacWindowClipper clip( wx ) ; return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; } else return InvokeControlDefUPP( varCode , theControl , message , param , (ControlDefUPP) wx->MacGetControlAction() ) ; } return NULL ; }
void CFrame::AddRemoveBlankPage() { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for(u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPageText(j).IsSameAs(wxT("<>")) && NB->GetPageCount() > 1) NB->DeletePage(j); } if (NB->GetPageCount() == 0) NB->AddPage(new wxPanel(this, wxID_ANY), wxT("<>"), true); } }
void BdayFrame::onClose( wxCloseEvent& event ) { if ( event.CanVeto() ) { wxWindowList & wnds = GetChildren(); for ( wxWindowList::iterator it = wnds.begin(); it != wnds.end(); ++it ) if ( ( *it )->IsKindOf(CLASSINFO(wxFrame)) ) if ( ! ((wxFrame *)( *it ))->Close() ) { event.Veto(true); return; } } event.Skip(); }
void MyEvtHandler::OnEndDragRight(double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment)) { GetShape()->GetCanvas()->ReleaseMouse(); MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas(); // Check if we're on an object int new_attachment; wxShape *otherShape = canvas->FindFirstSensitiveShape(x, y, &new_attachment, OP_DRAG_RIGHT); if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape))) { canvas->view->GetDocument()->GetCommandProcessor()->Submit( new DiagramCommand(_T("wxLineShape"), OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape), 0.0, 0.0, false, NULL, GetShape(), otherShape)); } }
wxLuaBindClass* wxLuaGetClassList_wxmedia(size_t &count) { static wxLuaBindClass classList[] = { #if wxLUA_USE_wxMediaCtrl && wxUSE_MEDIACTRL { wxluaclassname_wxMediaCtrl, wxMediaCtrl_methods, wxMediaCtrl_methodCount, CLASSINFO(wxMediaCtrl), &wxluatype_wxMediaCtrl, wxluabaseclassnames_wxMediaCtrl, wxluabaseclassbinds_wxMediaCtrl, NULL, NULL, NULL, 0, &wxLua_wxMediaCtrl_delete_function, }, { wxluaclassname_wxMediaEvent, wxMediaEvent_methods, wxMediaEvent_methodCount, CLASSINFO(wxMediaEvent), &wxluatype_wxMediaEvent, wxluabaseclassnames_wxMediaEvent, wxluabaseclassbinds_wxMediaEvent, NULL, NULL, NULL, 0, &wxLua_wxMediaEvent_delete_function, }, #endif // wxLUA_USE_wxMediaCtrl && wxUSE_MEDIACTRL { 0, 0, 0, 0, 0, 0, 0 }, }; count = sizeof(classList)/sizeof(wxLuaBindClass) - 1; return classList; }
wxWindow * CFrame::GetNotebookPageFromId(wxWindowID Id) { for (u32 i = 0; i < m_Mgr->GetAllPanes().GetCount(); i++) { if (!m_Mgr->GetAllPanes()[i].window->IsKindOf(CLASSINFO(wxAuiNotebook))) continue; wxAuiNotebook * NB = (wxAuiNotebook*)m_Mgr->GetAllPanes()[i].window; for (u32 j = 0; j < NB->GetPageCount(); j++) { if (NB->GetPage(j)->GetId() == Id) return NB->GetPage(j); } } return nullptr; }
// Adjust the containing wxScrolledWindow's scrollbars appropriately void wxRemotelyScrolledTreeCtrl::AdjustRemoteScrollbars() { if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) { // This is for the generic tree control. // It calls SetScrollbars which has been overridden // to adjust the parent scrolled window vertical // scrollbar. ((wxGenericTreeCtrl*) this)->AdjustMyScrollbars(); return; } else { // This is for the wxMSW tree control ecScrolledWindow* scrolledWindow = GetScrolledWindow(); if (scrolledWindow) { wxRect itemRect; if (GetBoundingRect(GetRootItem(), itemRect)) { // Actually, the real height seems to be 1 less than reported // (e.g. 16 instead of 16) int itemHeight = itemRect.GetHeight() - 1; int w, h; GetClientSize(&w, &h); wxRect rect(0, 0, 0, 0); CalcTreeSize(rect); double f = ((double) (rect.GetHeight()) / (double) itemHeight) ; int treeViewHeight = (int) ceil(f); int scrollPixelsPerLine = itemHeight; int scrollPos = - (itemRect.y / itemHeight); scrolledWindow->SetScrollbars(0, scrollPixelsPerLine, 0, treeViewHeight, 0, scrollPos); // Ensure that when a scrollbar becomes hidden or visible, // the contained window sizes are right. // Problem: this is called too early (?) wxSizeEvent event(scrolledWindow->GetSize(), scrolledWindow->GetId()); scrolledWindow->GetEventHandler()->ProcessEvent(event); } } } }
int CScrolledTreeCtrl::GetScrollPos(int orient) const { #if !defined(__WXMSW__) wxScrolledWindow *scrolledWindow = GetScrolledWindow(); if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) { wxGenericTreeCtrl *win = (wxGenericTreeCtrl *) this; if (orient == wxHORIZONTAL) { return win->wxGenericTreeCtrl::GetScrollPos(orient); } else { return scrolledWindow->GetScrollPos(orient); } } #endif return 0; }
void CRenderWnd::ReflectDoubleBufferingInChildren(wxWindow * pWindow) { #if defined(__WXGTK__) // Process this one if (pWindow->IsKindOf(CLASSINFO(CRenderWnd))) ::SetDoubleBuffer(pWindow, m_DoubleBuffer); #endif // Now process children if any wxWindowList::Node * pNode = pWindow->GetChildren().GetFirst(); while (pNode) { ReflectDoubleBufferingInChildren(pNode->GetData()); pNode = pNode->GetNext(); } return; }
// Get the icon wxIcon wxImageList::GetIcon(int index) const { wxList::compatibility_iterator node = m_images.Item( index ); wxCHECK_MSG( node, wxNullIcon , wxT("wrong index in image list") ); wxObject* obj = (wxObject*) node->GetData(); if ( obj == NULL ) return wxNullIcon ; else if ( obj->IsKindOf(CLASSINFO(wxBitmap)) ) { wxFAIL_MSG( wxT("cannot convert from bitmap to icon") ) ; return wxNullIcon ; } else return *(static_cast<wxIcon*>(obj)) ; }
bool wxRealFormValidator::OnRetrieveValue(wxProperty *property, wxPropertyFormView *WXUNUSED(view), wxWindow *WXUNUSED(parentWindow) ) { // The item used for viewing the real number: should be a text item. wxWindow *m_propertyWindow = property->GetWindow(); if (!m_propertyWindow || !m_propertyWindow->IsKindOf(CLASSINFO(wxTextCtrl))) return false; wxString value(((wxTextCtrl *)m_propertyWindow)->GetValue()); if (value.Length() == 0) return false; float f = (float)wxAtof((const wxChar *)value); property->GetValue() = f; return true; }
void ClassListDialog::InitControls() { // create a wxArrayString with the names of all classes: const wxClassInfo *ci = wxClassInfo::GetFirst(); wxArrayString arr; while (ci) { arr.Add(ci->GetClassName()); ci = ci->GetNext(); } arr.Sort(); // sort alphabetically // now add it to the raw-mode listbox for (unsigned int i=0; i<arr.GetCount(); i++) if (!IsToDiscard(arr[i])) m_pRawListBox->Append(arr[i]); m_nCount = m_pRawListBox->GetCount(); // sort again using size as sortkey arr.Sort((wxArrayString::CompareFunction)CompareClassSizes); // now add it to the size-mode listbox for (unsigned int i=0; i<arr.GetCount(); i++) if (!IsToDiscard(arr[i])) m_pSizeListBox->Append(arr[i]); // add root item to parent-mode treectrl wxTreeItemId id = m_pParentTreeCtrl->AddRoot(wxT("wxObject")); // recursively add all leaves to the treectrl int count = AddClassesWithParent(CLASSINFO(wxObject), id); m_pParentTreeCtrl->SetItemText(id, m_pParentTreeCtrl->GetItemText(id) + wxString::Format(wxT(" [%d]"), count)); // initially expand the root item m_pParentTreeCtrl->Expand(id); m_nTotalCount = arr.GetCount(); UpdateFilterText(); // don't leave blank the XTI info display m_pChoiceBook->ChangeSelection(0); m_pRawListBox->Select(0); UpdateClassInfo(m_pRawListBox->GetStringSelection()); }
void wxRemotelyScrolledTreeCtrl::HideVScrollbar() { #if defined(__WXMSW__) #if USE_GENERIC_TREECTRL if (!IsKindOf(CLASSINFO(wxGenericTreeCtrl))) #endif { ::ShowScrollBar((HWND) GetHWND(), SB_VERT, false); } #if USE_GENERIC_TREECTRL else { // Implicit in overriding SetScrollbars } #endif #endif }
// Begin drag. hotspot is the location of the drag position relative to the upper-left // corner of the image. This is full screen only. fullScreenRect gives the // position of the window on the screen, to restrict the drag to. bool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window, wxWindow* fullScreenRect) { wxRect rect; int x = fullScreenRect->GetPosition().x; int y = fullScreenRect->GetPosition().y; wxSize sz = fullScreenRect->GetSize(); if (fullScreenRect->GetParent() && !fullScreenRect->IsKindOf(CLASSINFO(wxFrame))) fullScreenRect->GetParent()->ClientToScreen(& x, & y); rect.x = x; rect.y = y; rect.width = sz.x; rect.height = sz.y; return BeginDrag(hotspot, window, true, & rect); }
// In case we're using the generic tree control. int wxRemotelyScrolledTreeCtrl::GetScrollPos(int orient) const { ecScrolledWindow* scrolledWindow = GetScrolledWindow(); if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) { wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; if (orient == wxHORIZONTAL) return win->wxGenericTreeCtrl::GetScrollPos(orient); else { return scrolledWindow->GetScrollPos(orient); } } return 0; }
// Try to find the deepest child that contains 'pt'. // We go backwards, to try to allow for controls that are spacially // within other controls, but are still siblings (e.g. buttons within // static boxes). Static boxes are likely to be created _before_ controls // that sit inside them. wxWindow* wxFindWindowAtPoint(wxWindow* win, const wxPoint& pt) { if (!win->IsShown()) return NULL; // Hack for wxNotebook case: at least in wxGTK, all pages // claim to be shown, so we must only deal with the selected one. #if wxUSE_NOTEBOOK if (win->IsKindOf(CLASSINFO(wxNotebook))) { wxNotebook* nb = (wxNotebook*) win; int sel = nb->GetSelection(); if (sel >= 0) { wxWindow* child = nb->GetPage(sel); wxWindow* foundWin = wxFindWindowAtPoint(child, pt); if (foundWin) return foundWin; } } #endif wxWindowList::compatibility_iterator node = win->GetChildren().GetLast(); while (node) { wxWindow* child = node->GetData(); wxWindow* foundWin = wxFindWindowAtPoint(child, pt); if (foundWin) return foundWin; node = node->GetPrevious(); } wxPoint pos = win->GetPosition(); wxSize sz = win->GetSize(); if ( !win->IsTopLevel() && win->GetParent() ) { pos = win->GetParent()->ClientToScreen(pos); } wxRect rect(pos, sz); if (rect.Contains(pt)) return win; return NULL; }
void ecConflictListCtrl::OnLeftDClick(wxMouseEvent& event) { if (!GetParent ()->IsKindOf (CLASSINFO(wxDialog))) // handle double click for conflicts view only { long sel = wxListCtrlGetSelection(* this); if (sel >= 0) { // Find which column we're on int col = wxListCtrlFindColumn(*this, 3, event.GetX()); ecConfigItem * pItem = AssociatedItem (sel, col); // get the referenced item if (pItem) { // if a referenced item was found wxGetApp().GetTreeCtrl()->SelectItem (pItem->GetTreeItem()); // select the refreenced item } } } }
// Collect up all module-derived classes, create an instance of each, // and register them. void wxModule::RegisterModules() { for (wxClassInfo::const_iterator it = wxClassInfo::begin_classinfo(), end = wxClassInfo::end_classinfo(); it != end; ++it) { const wxClassInfo* classInfo = *it; if ( classInfo->IsKindOf(CLASSINFO(wxModule)) && (classInfo != (& (wxModule::ms_classInfo))) ) { wxLogTrace(TRACE_MODULE, wxT("Registering module %s"), classInfo->GetClassName()); wxModule* module = (wxModule *)classInfo->CreateObject(); wxModule::RegisterModule(module); } } }
int wxXmlSerializer::GetIDCount(long id) { int nCount = 0; SerializableList items; GetItems(CLASSINFO(xsSerializable), items); SerializableList::compatibility_iterator node = items.GetFirst(); while(node) { if( node->GetData()->GetId() == id ) nCount++; node = node->GetNext(); } if( m_pRoot->GetId() == id ) nCount++; return nCount; }
// Returns TRUE if division is a descendant of this container bool wxCompositeShape::ContainsDivision(wxDivisionShape *division) { if (m_divisions.Member(division)) return TRUE; wxNode *node = m_children.GetFirst(); while (node) { wxShape *child = (wxShape *)node->GetData(); if (child->IsKindOf(CLASSINFO(wxCompositeShape))) { bool ans = ((wxCompositeShape *)child)->ContainsDivision(division); if (ans) return TRUE; } node = node->GetNext(); } return FALSE; }
void CScrolledTreeCtrl::PrepareDC(wxDC & dc) { #if !defined(__WXMSW__) if (IsKindOf(CLASSINFO(wxTreeCtrl))) { wxScrolledWindow *scrolledWindow = GetScrolledWindow(); wxGenericTreeCtrl *win = (wxGenericTreeCtrl *) this; int startX, startY; GetViewStart(&startX, &startY); int xppu1, yppu1, xppu2, yppu2; win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(&xppu1, &yppu1); scrolledWindow->GetScrollPixelsPerUnit(&xppu2, &yppu2); dc.SetDeviceOrigin(-startX * xppu1, -startY * yppu2); } #endif }
// Collect up all module-derived classes, create an instance of each, // and register them. void wxModule::RegisterModules() { wxHashTable::compatibility_iterator node; wxClassInfo* classInfo; wxClassInfo::sm_classTable->BeginFind(); node = wxClassInfo::sm_classTable->Next(); while (node) { classInfo = (wxClassInfo *)node->GetData(); if ( classInfo->IsKindOf(CLASSINFO(wxModule)) && (classInfo != (& (wxModule::ms_classInfo))) ) { wxModule* module = (wxModule *)classInfo->CreateObject(); RegisterModule(module); } node = wxClassInfo::sm_classTable->Next(); } }
// In case we're using the generic tree control. void wxRemotelyScrolledTreeCtrl::PrepareDC(wxDC& dc) { if (IsKindOf(CLASSINFO(wxGenericTreeCtrl))) { ecScrolledWindow* scrolledWindow = GetScrolledWindow(); wxGenericTreeCtrl* win = (wxGenericTreeCtrl*) this; int startX, startY; GetViewStart(& startX, & startY); int xppu1, yppu1, xppu2, yppu2; win->wxGenericTreeCtrl::GetScrollPixelsPerUnit(& xppu1, & yppu1); scrolledWindow->GetScrollPixelsPerUnit(& xppu2, & yppu2); dc.SetDeviceOrigin( -startX * xppu1, -startY * yppu2 ); // dc.SetUserScale( win->GetScaleX(), win->GetScaleY() ); } }
void CFrame::ToggleNotebookStyle(bool On, long Style) { wxAuiPaneInfoArray& AllPanes = m_Mgr->GetAllPanes(); for (int i = 0, Count = (int)AllPanes.GetCount(); i < Count; ++i) { wxAuiPaneInfo& Pane = AllPanes[i]; if (Pane.window->IsKindOf(CLASSINFO(wxAuiNotebook))) { wxAuiNotebook* NB = (wxAuiNotebook*)Pane.window; if (On) NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() | Style); else NB->SetWindowStyleFlag(NB->GetWindowStyleFlag() &~ Style); NB->Refresh(); } } }