void wxPlotCurve::SetClientData( void *data ) { wxCHECK_RET(M_PLOTCURVEDATA, wxT("invalid plotcurve")); M_PLOTCURVEDATA->SetClientData(data); }
void wxRadioBox::SetLabel( const wxString& label ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); GTKSetLabelForFrame(GTK_FRAME(m_widget), label); }
void wxTextCtrl::Paste() { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); gtk_editable_paste_clipboard(GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG); }
void ExportSingleDatasetSelect(wxWindow* pWnd, IGxDataset* const pGxDataset) { wxCHECK_RET(pGxDataset, wxT("The input pointer (IGxDataset*) is NULL")); wxGxObject* pGxSrcObj = dynamic_cast<wxGxObject*>(pGxDataset); wxString sName = pGxSrcObj->GetName(); sName = ClearExt(sName); wxGxObjectDialog dlg(pWnd, wxID_ANY, _("Select output")); dlg.SetName(sName); dlg.SetAllowMultiSelect(false); dlg.SetAllFilters(false); wxGISEnumDatasetType eType = pGxDataset->GetType(); int eSubType = pGxDataset->GetSubType(); bool bDefaultSet = false; int eDefaulSubType = 0; if (eType == enumGISFeatureDataset) { for (size_t i = enumVecUnknown + 1; i < enumVecMAX; ++i) { wxGISEnumVectorDatasetType eCurrentSubType = (wxGISEnumVectorDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISFeatureDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumVecPostGIS) { dlg.AddFilter(new wxGxFeatureDatasetFilter(enumVecPostGIS), false); } } else if (eType == enumGISRasterDataset) { //for (size_t i = enumRasterUnknown + 1; i < enumRasterMAX; ++i) //{ // wxGISEnumRasterDatasetType eCurrentSubType = (wxGISEnumRasterDatasetType)i; // if (eCurrentSubType != eSubType && IsFileDataset(enumGISRasterDataset, eCurrentSubType)) // { // if (bDefaultSet) // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), false); // } // else // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), true); // bDefaultSet = true; // eDefaulSubType = eCurrentSubType; // } // } //} //if (eSubType != enumRasterPostGIS) //{ // dlg.AddFilter(new wxGxRasterDatasetFilter(enumRasterPostGIS), false); //} } else if (eType == enumGISTableDataset) { for (size_t i = enumTableUnknown + 1; i < enumTableMAX; ++i) { wxGISEnumTableDatasetType eCurrentSubType = (wxGISEnumTableDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISTableDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumTablePostgres) { dlg.AddFilter(new wxGxTableDatasetFilter(enumTablePostgres), false); } } dlg.SetButtonCaption(_("Export")); dlg.SetOverwritePrompt(true); wxGxObject* pGxParentObj = pGxSrcObj->GetParent(); wxString sStartLoc; if (pGxParentObj) { while (NULL != pGxParentObj) { wxGxObjectContainer* pGxCont = wxDynamicCast(pGxParentObj, wxGxObjectContainer); if (NULL != pGxCont && pGxCont->CanCreate(enumGISFeatureDataset, eDefaulSubType)) { break; } else { pGxParentObj = pGxParentObj->GetParent(); } } if (pGxParentObj) { sStartLoc = pGxParentObj->GetFullName(); } } wxGISAppConfig oConfig = GetConfig(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_vector_ds/path"), sStartLoc); } else if (eType == enumGISRasterDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_raster_ds/path"), sStartLoc); } else if (eType == enumGISTableDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_table_ds/path"), sStartLoc); } } if (!sStartLoc.IsEmpty()) dlg.SetStartingLocation(sStartLoc); if (dlg.ShowModalSave() == wxID_OK) { wxGxObjectFilter* pFilter = dlg.GetCurrentFilter(); if (NULL == pFilter) { wxMessageBox(_("Unexpected error"), _("Error"), wxCENTRE | wxOK | wxICON_ERROR, pWnd); wxLogError(_("Null wxGxObjectFilter returned")); return; } CPLString sPath = dlg.GetPath(); wxString sCatalogPath = dlg.GetLocation()->GetFullName(); wxFileName oFName(dlg.GetName()); wxString sName = oFName.GetName(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_vector_ds/path"), sCatalogPath); } else if (eType == enumGISRasterDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_raster_ds/path"), sCatalogPath); } else if (eType == enumGISTableDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/exp_table_ds/path"), sCatalogPath); } } if (eType == enumGISFeatureDataset) { ExportSingleVectorDataset(pWnd, sPath, sName, pFilter, pGxDataset); } else if (eType == enumGISRasterDataset) { ExportSingleRasterDataset(pWnd, sPath, sName, pFilter, pGxDataset); } else if (eType == enumGISTableDataset) { ExportSingleTableDataset(pWnd, sPath, sName, pFilter, pGxDataset); } } }
void wxClientDCImpl::DoGetSize(int *width, int *height) const { wxCHECK_RET( m_window, wxT("wxClientDCImpl without a window?") ); m_window->GetClientSize(width, height); }
void SCH_EDIT_FRAME::EndSegment( wxDC* DC ) { SCH_SCREEN* screen = GetScreen(); SCH_LINE* segment = (SCH_LINE*) screen->GetCurItem(); if( segment == NULL || segment->Type() != SCH_LINE_T || !segment->IsNew() ) return; // Delete zero length segments and clear item flags. SCH_ITEM* item = s_wires.begin(); while( item ) { item->ClearFlags(); wxCHECK_RET( item->Type() == SCH_LINE_T, wxT( "Unexpected object type in wire list." ) ); segment = (SCH_LINE*) item; item = item->Next(); if( segment->IsNull() ) delete s_wires.Remove( segment ); } if( s_wires.GetCount() == 0 ) return; // Get the last non-null wire (this is the last created segment). SetRepeatItem( segment = (SCH_LINE*) s_wires.GetLast() ); screen->SetCurItem( NULL ); m_canvas->EndMouseCapture( -1, -1, wxEmptyString, false ); // store the terminal point of this last segment: a junction could be needed // (the last wire could be merged/deleted/modified, and lost) wxPoint endpoint = segment->GetEndPoint(); // store the starting point of this first segment: a junction could be needed SCH_LINE* firstsegment = (SCH_LINE*) s_wires.GetFirst(); wxPoint startPoint = firstsegment->GetStartPoint(); screen->Append( s_wires ); // Correct and remove segments that need to be merged. screen->SchematicCleanUp( NULL, DC ); // A junction could be needed to connect the end point of the last created segment. if( screen->IsJunctionNeeded( endpoint ) ) screen->Append( AddJunction( DC, endpoint ) ); // A junction could be needed to connect the start point of the set of new created wires if( screen->IsJunctionNeeded( startPoint ) ) screen->Append( AddJunction( DC, startPoint ) ); m_canvas->Refresh(); // Put the snap shot of the previous wire, buses, and junctions in the undo/redo list. PICKED_ITEMS_LIST oldItems; oldItems.m_Status = UR_WIRE_IMAGE; while( s_oldWires.GetCount() != 0 ) { ITEM_PICKER picker = ITEM_PICKER( s_oldWires.PopFront(), UR_WIRE_IMAGE ); oldItems.PushItem( picker ); } SaveCopyInUndoList( oldItems, UR_WIRE_IMAGE ); OnModify(); }
void wxMenuBase::AddSubMenu(wxMenu *submenu) { wxCHECK_RET( submenu, wxT("can't add a NULL submenu") ); submenu->SetParent((wxMenu *)this); }
// ---------------------------------------------------------------------------- // client data // ---------------------------------------------------------------------------- void wxChoice::DoSetItemClientData(unsigned int n, void* clientData) { wxCHECK_RET( IsValid(n), wxT("wxChoice::DoSetItemClientData: invalid index") ); m_datas[n] = (char*)clientData ; }
wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext *other, const wxGLContextAttrs *ctxAttrs) { const int* contextAttribs = NULL; bool needsARB = false; if ( ctxAttrs ) { contextAttribs = ctxAttrs->GetGLAttrs(); needsARB = ctxAttrs->NeedsARB(); } else if ( win->GetGLCTXAttrs().GetGLAttrs() ) { // If OpenGL context parameters were set at wxGLCanvas ctor, get them now contextAttribs = win->GetGLCTXAttrs().GetGLAttrs(); needsARB = win->GetGLCTXAttrs().NeedsARB(); } // else use GPU driver defaults m_isOk = false; // We need to create a temporary context to get the pointer to // wglCreateContextAttribsARB function HGLRC tempContext = wglCreateContext(win->GetHDC()); wxCHECK_RET( tempContext, "wglCreateContext failed!" ); wglMakeCurrent(win->GetHDC(), tempContext); PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC) wglGetProcAddress("wglCreateContextAttribsARB"); wglMakeCurrent(win->GetHDC(), NULL); wglDeleteContext(tempContext); // The preferred way is using wglCreateContextAttribsARB, even for old context if ( !wglCreateContextAttribsARB && needsARB ) // OpenGL 3 context creation { wxLogMessage(_("OpenGL 3.0 or later is not supported by the OpenGL driver.")); return; } if ( wglCreateContextAttribsARB ) { m_glContext = wglCreateContextAttribsARB(win->GetHDC(), other ? other->m_glContext : 0, contextAttribs); } else { // Create legacy context m_glContext = wglCreateContext(win->GetHDC()); // Set shared context if ( other && !wglShareLists(other->m_glContext, m_glContext) ) wxLogLastError("wglShareLists"); } if ( !m_glContext ) wxLogMessage(_("Couldn't create OpenGL context")); else m_isOk = true; }
void wxWizard::SetPageSize(const wxSize& size) { wxCHECK_RET(!m_started, wxT("wxWizard::SetPageSize after RunWizard")); m_sizePage = size; }
void wxWizard::SetBorder(int border) { wxCHECK_RET(!m_started, wxT("wxWizard::SetBorder after RunWizard")); m_border = border; }
void hoxTable::SetBoard( hoxBoard* pBoard ) { wxCHECK_RET(m_board == NULL, "The Board has already been set."); m_board = pBoard; }
void hoxTable::OnPrivateMessageRequest_FromBoard( const wxString& sPlayerId ) { wxCHECK_RET(m_boardPlayer, "The Board Player cannot be NULL."); m_boardPlayer->CreatePrivateChatWith( sPlayerId ); }
void hoxTable::OnPlayerInviteRequest_FromBoard( const wxString& sPlayerId ) { wxCHECK_RET(m_boardPlayer, "The Board Player cannot be NULL."); m_boardPlayer->InvitePlayer( sPlayerId ); }
void wxMenuBar::Refresh(bool WXUNUSED(eraseBackground), const wxRect *WXUNUSED(rect)) { wxCHECK_RET( IsAttached(), wxT("can't refresh unatteched menubar") ); DrawMenuBar(); }
void wxColourData::SetCustomColour(int i, const wxColour& colour) { wxCHECK_RET( i >= 0 && i < NUM_CUSTOM, wxT("custom colour index out of range") ); m_custColours[i] = colour; }
void SCH_EDIT_FRAME::BeginSegment( wxDC* DC, int type ) { SCH_LINE* segment; SCH_LINE* nextSegment; wxPoint cursorpos = GetCrossHairPosition(); // We should know if a segment is currently in progress segment = (SCH_LINE*) GetScreen()->GetCurItem(); if( segment ) // a current item exists, but not necessary a currently edited item { if( !segment->GetFlags() || ( segment->Type() != SCH_LINE_T ) ) { if( segment->GetFlags() ) { wxLogDebug( wxT( "BeginSegment: item->GetFlags()== %X" ), segment->GetFlags() ); } // no wire, bus or graphic line in progress segment = NULL; } } if( !segment ) /* first point : Create first wire or bus */ { GetScreen()->ExtractWires( s_oldWires, true ); GetScreen()->SchematicCleanUp( m_canvas ); switch( type ) { default: segment = new SCH_LINE( cursorpos, LAYER_NOTES ); break; case LAYER_WIRE: segment = new SCH_LINE( cursorpos, LAYER_WIRE ); /* A junction will be created later, when we'll know the * segment end position, and if the junction is really needed */ break; case LAYER_BUS: segment = new SCH_LINE( cursorpos, LAYER_BUS ); break; } segment->SetFlags( IS_NEW ); s_wires.PushBack( segment ); GetScreen()->SetCurItem( segment ); // We need 2 segments to go from a given start pin to an end point when the horizontal // and vertical lines only switch is on. if( GetForceHVLines() ) { nextSegment = new SCH_LINE( *segment ); nextSegment->SetFlags( IS_NEW ); s_wires.PushBack( nextSegment ); GetScreen()->SetCurItem( nextSegment ); } m_canvas->SetMouseCapture( DrawSegment, AbortCreateNewLine ); SetRepeatItem( NULL ); } else // A segment is in progress: terminates the current segment and add a new segment. { SCH_LINE* prevSegment = (SCH_LINE*) segment->Back(); // Be aware prevSegment can be null when the horizontal and vertical lines only switch is off // when we create the first segment. if( !GetForceHVLines() ) { // If only one segment is needed and it has a zero length, do not create a new one. if( segment->IsNull() ) return; } else { wxCHECK_RET( prevSegment != NULL, wxT( "Failed to create second line segment." ) ); // If two segments are required and they both have zero length, do not // create a new one. if( prevSegment && prevSegment->IsNull() && segment->IsNull() ) return; } m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); // Terminate the command if the end point is on a pin, junction, or another wire or bus. if( GetScreen()->IsTerminalPoint( cursorpos, segment->GetLayer() ) ) { EndSegment( DC ); return; } // Create a new segment, and chain it after the current new segment. nextSegment = new SCH_LINE( *segment ); nextSegment->SetStartPoint( cursorpos ); s_wires.PushBack( nextSegment ); segment->SetEndPoint( cursorpos ); segment->ClearFlags( IS_NEW ); segment->SetFlags( SELECTED ); nextSegment->SetFlags( IS_NEW ); GetScreen()->SetCurItem( nextSegment ); m_canvas->CallMouseCapture( DC, wxDefaultPosition, false ); } }
void wxBitmapComboBoxBase::DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap) { wxCHECK_RET( n < m_bitmaps.size(), "invalid item index" ); *GetBitmapPtr(n) = bitmap; }
void wxRadioButton::SetLabel( const wxString& label ) { wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") ); GTKSetLabelForLabel(GTK_LABEL(BUTTON_CHILD(m_widget)), label); }
void wxWindowDFB::PaintWindow(const wxRect& rect) { wxCHECK_RET( !IsFrozen() && IsShown(), "shouldn't be called" ); wxLogTrace(TRACE_PAINT, "%p ('%s'): painting region [%i,%i,%i,%i]", this, GetName().c_str(), rect.x, rect.y, rect.GetRight(), rect.GetBottom()); m_updateRegion = rect; // FIXME_DFB: don't waste time rendering the area if it's fully covered // by some children, go directly to rendering the children // (unless some child has HasTransparentBackground()=true!) // NB: unconditionally send wxEraseEvent, because our implementation of // wxWindow::Refresh() ignores the eraseBack argument wxWindowDC dc((wxWindow*)this); wxEraseEvent eventEr(m_windowId, &dc); eventEr.SetEventObject(this); HandleWindowEvent(eventEr); wxRect clientRect(GetClientRect()); // only send wxNcPaintEvent if drawing at least part of nonclient area: if ( !clientRect.Contains(rect) ) { wxNcPaintEvent eventNc(GetId()); eventNc.SetEventObject(this); HandleWindowEvent(eventNc); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxNcPaintEvent", this, GetName().c_str()); } // only send wxPaintEvent if drawing at least part of client area: if ( rect.Intersects(clientRect) ) { wxPaintEvent eventPt(GetId()); eventPt.SetEventObject(this); HandleWindowEvent(eventPt); } else { wxLogTrace(TRACE_PAINT, "%p ('%s'): not sending wxPaintEvent", this, GetName().c_str()); } // draw window's overlays on top of the painted window, if we have any: PaintOverlays(rect); m_updateRegion.Clear(); // client area portion of 'rect': wxRect rectClientOnly(rect); rectClientOnly.Intersect(clientRect); // paint the children: wxPoint origin = GetClientAreaOrigin(); wxWindowList& children = GetChildren(); for ( wxWindowList::iterator i = children.begin(); i != children.end(); ++i ) { wxWindow *child = *i; if ( child->IsFrozen() || !child->IsShown() ) continue; // don't paint anything if the window is frozen or hidden // compute child's area to repaint wxRect childrect(child->GetRect()); childrect.Offset(origin); if ( child->CanBeOutsideClientArea() ) childrect.Intersect(rect); else childrect.Intersect(rectClientOnly); if ( childrect.IsEmpty() ) continue; // and repaint it: childrect.Offset(-child->GetPosition()); childrect.Offset(-origin); child->PaintWindow(childrect); } }
void ExportMultipleDatasetsSelect(wxWindow* pWnd, wxVector<IGxDataset*> &paDatasets) { wxCHECK_RET(paDatasets.size() > 1, wxT("The input dataset array is empty")); wxGxContainerDialog dlg(pWnd, wxID_ANY, _("Select output")); dlg.SetAllFilters(false); dlg.ShowExportFormats(true); wxGxObject* pGxSrcObj = dynamic_cast<wxGxObject*>(paDatasets[0]); wxGISEnumDatasetType eType = paDatasets[0]->GetType(); int eSubType = paDatasets[0]->GetSubType(); bool bDefaultSet = false; int eDefaulSubType = 0; if (eType == enumGISFeatureDataset) { for (size_t i = enumVecUnknown + 1; i < enumVecMAX; ++i) { wxGISEnumVectorDatasetType eCurrentSubType = (wxGISEnumVectorDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISFeatureDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxFeatureDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumVecPostGIS) { dlg.AddFilter(new wxGxFeatureDatasetFilter(enumVecPostGIS), false); } } else if (eType == enumGISRasterDataset) { //for (size_t i = enumRasterUnknown + 1; i < enumRasterMAX; ++i) //{ // wxGISEnumRasterDatasetType eCurrentSubType = (wxGISEnumRasterDatasetType)i; // if (eCurrentSubType != eSubType && IsFileDataset(enumGISRasterDataset, eCurrentSubType)) // { // if (bDefaultSet) // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), false); // } // else // { // dlg.AddFilter(new wxGxRasterDatasetFilter(eCurrentSubType), true); // bDefaultSet = true; // eDefaulSubType = eCurrentSubType; // } // } //} //if (eSubType != enumRasterPostGIS) //{ // dlg.AddFilter(new wxGxRasterDatasetFilter(enumRasterPostGIS), false); //} } else if (eType == enumGISTableDataset) { for (size_t i = enumTableUnknown + 1; i < enumTableMAX; ++i) { wxGISEnumTableDatasetType eCurrentSubType = (wxGISEnumTableDatasetType)i; if (eCurrentSubType != eSubType && IsFileDataset(enumGISTableDataset, eCurrentSubType)) { if (bDefaultSet) { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), false); } else { dlg.AddFilter(new wxGxTableDatasetFilter(eCurrentSubType), true); bDefaultSet = true; eDefaulSubType = eCurrentSubType; } } } if (eSubType != enumTablePostgres) { dlg.AddFilter(new wxGxTableDatasetFilter(enumTablePostgres), false); } } dlg.AddShowFilter(new wxGxFolderFilter()); dlg.AddShowFilter(new wxGxRemoteDBSchemaFilter()); dlg.ShowCreateButton(true); wxGxObject* pGxParentObj = pGxSrcObj->GetParent(); wxString sStartLoc; if (pGxParentObj) { while (NULL != pGxParentObj) { wxGxObjectContainer* pGxCont = wxDynamicCast(pGxParentObj, wxGxObjectContainer); if (NULL != pGxCont && pGxCont->CanCreate(enumGISFeatureDataset, eDefaulSubType)) { break; } else { pGxParentObj = pGxParentObj->GetParent(); } } if (pGxParentObj) { sStartLoc = pGxParentObj->GetFullName(); } } wxGISAppConfig oConfig = GetConfig(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_vector_ds/path"), sStartLoc); } else if (eType == enumGISRasterDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_raster_ds/path"), sStartLoc); } else if (eType == enumGISTableDataset) { sStartLoc = oConfig.Read(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_table_ds/path"), sStartLoc); } } if (!sStartLoc.IsEmpty()) dlg.SetStartingLocation(sStartLoc); if (dlg.ShowModal() == wxID_OK) { wxGxObjectFilter* pFilter = dlg.GetCurrentFilter(); if (NULL == pFilter) { wxMessageBox(_("Unexpected error"), _("Error"), wxCENTRE | wxOK | wxICON_ERROR, pWnd); wxLogError(_("Null wxGxObjectFilter returned")); return; } CPLString sPath = dlg.GetPath(); wxString sCatalogPath = dlg.GetLocation()->GetFullName(); if (oConfig.IsOk()) { if (eType == enumGISFeatureDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_vector_ds/path"), sCatalogPath); } else if (eType == enumGISRasterDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_raster_ds/path"), sCatalogPath); } else if (eType == enumGISTableDataset) { oConfig.Write(enumGISHKCU, dlg.GetAppName() + wxT("/lastpath/expm_table_ds/path"), sCatalogPath); } } //TODO: Now we create the copies (new names) instead of overwrite, but should show table with exist names and new names. If user set the same name - overwrite // |----------------|------------------| // | dataset1 | dataset1 (1) | // | dataset2 | dataset2 (1) | // | dataset3 | dataset3 (2) | // |----------------|------------------| wxVector<EXPORTED_DATASET> paExportDatasets; for (size_t i = 0; i < paDatasets.size(); ++i) { wxGxObject* pGxSrcDatasetObj = dynamic_cast<wxGxObject*>(paDatasets[i]); if (NULL == pGxSrcDatasetObj) { continue; } wxString sNewName = CheckUniqName(sPath, pGxSrcDatasetObj->GetBaseName(), pFilter->GetExt()); EXPORTED_DATASET ds = { sNewName, paDatasets[i] }; paExportDatasets.push_back(ds); } if (eType == enumGISFeatureDataset) { ExportMultipleVectorDatasets(pWnd, sPath, pFilter, paExportDatasets); } else if (eType == enumGISRasterDataset) { ExportMultipleRasterDatasets(pWnd, sPath, pFilter, paExportDatasets); } else if (eType == enumGISTableDataset) { ExportMultipleTableDatasets(pWnd, sPath, pFilter, paExportDatasets); } } }
void wxMenuItem::Check( bool bCheck ) { bool bOk; wxCHECK_RET( IsCheckable(), wxT("only checkable items may be checked") ); if (m_isChecked == bCheck) return; HMENU hMenu = GetHmenuOf(m_parentMenu); if (GetKind() == wxITEM_RADIO) { // // It doesn't make sense to uncheck a radio item - what would this do? // if (!bCheck) return; // // Get the index of this item in the menu // const wxMenuItemList& rItems = m_parentMenu->GetMenuItems(); int nPos = rItems.IndexOf(this); wxCHECK_RET( nPos != wxNOT_FOUND ,wxT("menuitem not found in the menu items list?") ); // // Get the radio group range // int nStart; int nEnd; if (m_bIsRadioGroupStart) { // // We already have all information we need // nStart = nPos; nEnd = m_vRadioGroup.m_nEnd; } else // next radio group item { // // Get the radio group end from the start item // nStart = m_vRadioGroup.m_nStart; nEnd = rItems.Item(nStart)->GetData()->m_vRadioGroup.m_nEnd; } // // Also uncheck all the other items in this radio group // wxMenuItemList::compatibility_iterator node = rItems.Item(nStart); for (int n = nStart; n <= nEnd && node; n++) { if (n == nPos) { ::WinSendMsg( hMenu ,MM_SETITEMATTR ,MPFROM2SHORT(n, TRUE) ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED) ); } if (n != nPos) { node->GetData()->m_isChecked = FALSE; ::WinSendMsg( hMenu ,MM_SETITEMATTR ,MPFROM2SHORT(n, TRUE) ,MPFROM2SHORT(MIA_CHECKED, FALSE) ); } node = node->GetNext(); } } else // check item { if (bCheck) bOk = (bool)::WinSendMsg( hMenu ,MM_SETITEMATTR ,MPFROM2SHORT(GetRealId(), TRUE) ,MPFROM2SHORT(MIA_CHECKED, MIA_CHECKED) ); else bOk = (bool)::WinSendMsg( hMenu ,MM_SETITEMATTR ,MPFROM2SHORT(GetRealId(), TRUE) ,MPFROM2SHORT(MIA_CHECKED, FALSE) ); } if (!bOk) { wxLogLastError(wxT("CheckMenuItem")); } wxMenuItemBase::Check(bCheck); } // end of wxMenuItem::Check
void ExportMultipleVectorDatasets(wxWindow* pWnd, const CPLString &sPath, wxGxObjectFilter* const pFilter, wxVector<EXPORTED_DATASET> &paDatasets) { wxCHECK_RET(pWnd && pFilter && paDatasets.size() > 1, wxT("The input pointer is NULL or datasets array is empty")); wxGISProgressDlg ProgressDlg(_("Exporting..."), _("Begin operation..."), 100, pWnd); ProgressDlg.SetAddPercentToMessage(false); ProgressDlg.ShowProgress(true); for (size_t i = 0; i < paDatasets.size(); ++i) { ProgressDlg.SetTitle(wxString::Format(_("Proceed %ld of %ld..."), i + 1, paDatasets.size())); wxGISDataset* pDataset = paDatasets[i].pDSet->GetDataset(false, &ProgressDlg); wxVector<wxGISFeatureDataset*> apFeatureDatasets; if (pDataset->GetSubsetsCount() == 0) { wxGISFeatureDataset* pFeatureDataset = wxDynamicCast(pDataset, wxGISFeatureDataset); if (NULL != pFeatureDataset) { pFeatureDataset->Reference(); apFeatureDatasets.push_back(pFeatureDataset); } } else { for (size_t j = 0; j < pDataset->GetSubsetsCount(); ++j) { wxGISFeatureDataset* pFeatureDataset = wxDynamicCast(pDataset->GetSubset(j), wxGISFeatureDataset); if (NULL != pFeatureDataset) { pFeatureDataset->Reference(); apFeatureDatasets.push_back(pFeatureDataset); } } } if (apFeatureDatasets.size() == 0) { wxMessageBox(_("The dataset is empty"), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(_("wxGISFeatureDataset pointer is null returned")); return; } for (size_t j = 0; j < apFeatureDatasets.size(); ++j) { if(!ProgressDlg.Continue()) break; if (!apFeatureDatasets[j]->IsOpened()) { if (!apFeatureDatasets[j]->Open(0, TRUE, false, &ProgressDlg)) { wxMessageBox(ProgressDlg.GetLastMessage(), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(ProgressDlg.GetLastMessage()); wsDELETE(apFeatureDatasets[j]); continue; } } if (!ExportFormat(apFeatureDatasets[j], sPath, paDatasets[i].sName, pFilter, wxGISNullSpatialFilter, NULL, NULL, true, static_cast<ITrackCancel*>(&ProgressDlg))) { wxMessageBox(ProgressDlg.GetLastMessage(), _("Error"), wxCENTRE | wxICON_ERROR | wxOK, pWnd); wxLogError(ProgressDlg.GetLastMessage()); wsDELETE(apFeatureDatasets[j]); continue; } wsDELETE(apFeatureDatasets[j]); } } if (ProgressDlg.GetWarningCount() > 0 && ProgressDlg.Continue()) { ShowMessageDialog(pWnd, ProgressDlg.GetWarnings()); } }
void wxMenuItem::SetItemLabel( const wxString& rText ) { // // Don't do anything if label didn't change // wxString sText = wxPMTextToLabel(rText); if (m_text == sText) return; // wxMenuItemBase will do stock ID checks wxMenuItemBase::SetItemLabel(sText); HWND hMenu = GetHmenuOf(m_parentMenu); wxCHECK_RET(hMenu, wxT("menuitem without menu")); #if wxUSE_ACCEL m_parentMenu->UpdateAccel(this); #endif // wxUSE_ACCEL USHORT uId = (USHORT)GetRealId(); MENUITEM vItem; USHORT uFlagsOld; if (!::WinSendMsg( hMenu ,MM_QUERYITEM ,MPFROM2SHORT(uId, TRUE) ,(MPARAM)&vItem )) { wxLogLastError(wxT("GetMenuState")); } else { uFlagsOld = vItem.afStyle; if (IsSubMenu()) { uFlagsOld |= MIS_SUBMENU; } char* pData; #if wxUSE_OWNER_DRAWN if (IsOwnerDrawn()) { uFlagsOld |= MIS_OWNERDRAW; pData = (char*)this; } else #endif //owner drawn { uFlagsOld |= MIS_TEXT; pData = (char*) m_text.wx_str(); } // // Set the style // if (!::WinSendMsg( hMenu ,MM_SETITEM ,MPFROM2SHORT(uId, TRUE) ,(MPARAM)&vItem )) { wxLogLastError(wxT("ModifyMenu")); } // // Set the text // if (::WinSendMsg( hMenu ,MM_SETITEMTEXT ,MPFROMSHORT(uId) ,(MPARAM)pData )) { wxLogLastError(wxT("ModifyMenu")); } } } // end of wxMenuItem::SetText
void CClientList::AddToKadList(CUpDownClient* toadd) { wxCHECK_RET(toadd, wxT("NULL pointer in AddToKadList")); m_KadSources.insert(CCLIENTREF(toadd, wxT("CClientList::AddToKadList"))); // This will take care of duplicates. }
void wxListBox::GtkAddItem( const wxString &item, int pos ) { wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); GtkWidget *list_item; wxString label(item); #if wxUSE_CHECKLISTBOX if (m_hasCheckBoxes) { label.Prepend(wxCHECKLBOX_STRING); } #endif // wxUSE_CHECKLISTBOX list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) ); GList *gitem_list = g_list_alloc (); gitem_list->data = list_item; if (pos == -1) gtk_list_append_items( GTK_LIST (m_list), gitem_list ); else gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos ); gtk_signal_connect_after( GTK_OBJECT(list_item), "select", GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED)) gtk_signal_connect_after( GTK_OBJECT(list_item), "deselect", GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(list_item), "button_press_event", (GtkSignalFunc)gtk_listbox_button_press_callback, (gpointer) this ); gtk_signal_connect_after( GTK_OBJECT(list_item), "button_release_event", (GtkSignalFunc)gtk_listbox_button_release_callback, (gpointer) this ); gtk_signal_connect( GTK_OBJECT(list_item), "key_press_event", (GtkSignalFunc)gtk_listbox_key_press_callback, (gpointer)this ); gtk_signal_connect( GTK_OBJECT(list_item), "focus_in_event", GTK_SIGNAL_FUNC(gtk_listitem_focus_in_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(list_item), "focus_out_event", GTK_SIGNAL_FUNC(gtk_listitem_focus_out_callback), (gpointer)this ); ConnectWidget( list_item ); if (GTK_WIDGET_REALIZED(m_widget)) { gtk_widget_show( list_item ); gtk_widget_realize( list_item ); gtk_widget_realize( GTK_BIN(list_item)->child ); #if wxUSE_TOOLTIPS if (m_tooltip) m_tooltip->Apply( this ); #endif } // Apply current widget style to the new list_item GtkRcStyle *style = CreateWidgetStyle(); if (style) { gtk_widget_modify_style( GTK_WIDGET( list_item ), style ); GtkBin *bin = GTK_BIN( list_item ); gtk_widget_modify_style( GTK_WIDGET( bin->child ), style ); gtk_rc_style_unref( style ); } }
void wxTextCtrl::Remove( long from, long to ) { wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); }
void CVPCB_MAINFRAME::SetNewPkg( const wxString& aFootprintName ) { COMPONENT* component; bool hasFootprint = false; int componentIndex; wxString description; if( m_netlist.IsEmpty() ) return; // If no component is selected, select the first one if( m_ListCmp->GetFirstSelected() < 0 ) { componentIndex = 0; m_ListCmp->SetSelection( componentIndex, true ); } // iterate over the selection while( m_ListCmp->GetFirstSelected() != -1 ) { // Get the component for the current iteration componentIndex = m_ListCmp->GetFirstSelected(); component = m_netlist.GetComponent( componentIndex ); if( component == NULL ) return; // Check to see if the component has already a footprint set. hasFootprint = !component->GetFPID().empty(); FPID fpid; if( !aFootprintName.IsEmpty() ) { wxCHECK_RET( fpid.Parse( aFootprintName ) < 0, wxString::Format( wxT( "<%s> is not a valid FPID." ), GetChars( aFootprintName ) ) ); } component->SetFPID( fpid ); // create the new component description description.Printf( CMP_FORMAT, componentIndex + 1, GetChars( component->GetReference() ), GetChars( component->GetValue() ), GetChars( FROM_UTF8( component->GetFPID().Format().c_str() ) ) ); // If the component hasn't had a footprint associated with it // it now has, so we decrement the count of components without // a footprint assigned. if( !hasFootprint ) { hasFootprint = true; m_undefinedComponentCnt -= 1; } // Set the new description and deselect the processed component m_ListCmp->SetString( componentIndex, description ); m_ListCmp->SetSelection( componentIndex, false ); } // Mark this "session" as modified m_modified = true; // select the next component, if there is one if( componentIndex < (m_ListCmp->GetCount() - 1) ) componentIndex++; m_ListCmp->SetSelection( componentIndex, true ); // update the statusbar DisplayStatus(); }
void wxRadioButton::SetValue(bool value) { ::SendMessage(GetHwnd(), BM_SETCHECK, value ? BST_CHECKED : BST_UNCHECKED, 0); m_isChecked = value; if ( !value ) return; // if we set the value of one radio button we also must clear all the other // buttons in the same group: Windows doesn't do it automatically // // moreover, if another radiobutton in the group currently has the focus, // we have to set it to this radiobutton, else the old radiobutton will be // reselected automatically, if a parent window loses the focus and regains // it. wxWindow * const focus = FindFocus(); wxTopLevelWindow * const tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow); wxCHECK_RET( tlw, wxT("radio button outside of TLW?") ); wxWindow * const focusInTLW = tlw->GetLastFocus(); const wxWindowList& siblings = GetParent()->GetChildren(); wxWindowList::compatibility_iterator nodeThis = siblings.Find(this); wxCHECK_RET( nodeThis, wxT("radio button not a child of its parent?") ); // this will be set to true in the code below if the focus is in our TLW // and belongs to one of the other buttons in the same group bool shouldSetFocus = false; // this will be set to true if the focus is outside of our TLW currently // but the remembered focus of this TLW is one of the other buttons in the // same group bool shouldSetTLWFocus = false; // if it's not the first item of the group ... if ( !HasFlag(wxRB_GROUP) ) { // ... turn off all radio buttons before it for ( wxWindowList::compatibility_iterator nodeBefore = nodeThis->GetPrevious(); nodeBefore; nodeBefore = nodeBefore->GetPrevious() ) { wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(), wxRadioButton); if ( !btn ) { // don't stop on non radio buttons, we could have intermixed // buttons and e.g. static labels continue; } if ( btn->HasFlag(wxRB_SINGLE) ) { // A wxRB_SINGLE button isn't part of this group break; } if ( btn == focus ) shouldSetFocus = true; else if ( btn == focusInTLW ) shouldSetTLWFocus = true; btn->SetValue(false); if ( btn->HasFlag(wxRB_GROUP) ) { // even if there are other radio buttons before this one, // they're not in the same group with us break; } } } // ... and also turn off all buttons after this one for ( wxWindowList::compatibility_iterator nodeAfter = nodeThis->GetNext(); nodeAfter; nodeAfter = nodeAfter->GetNext() ) { wxRadioButton *btn = wxDynamicCast(nodeAfter->GetData(), wxRadioButton); if ( !btn ) continue; if ( btn->HasFlag(wxRB_GROUP | wxRB_SINGLE) ) { // no more buttons or the first button of the next group break; } if ( btn == focus ) shouldSetFocus = true; else if ( btn == focusInTLW ) shouldSetTLWFocus = true; btn->SetValue(false); } if ( shouldSetFocus ) SetFocus(); else if ( shouldSetTLWFocus ) tlw->SetLastFocus(this); }
void wxPlotCurve::SetDefaultPen(wxPlotPen_Type colour_type, const wxGenericPen &pen ) { InitPlotCurveDefaultPens(); wxCHECK_RET((colour_type >= 0) && (colour_type < int(wxPlotCurveRefData::sm_defaultPens.GetCount())), wxT("invalid plot colour")); wxPlotCurveRefData::sm_defaultPens[colour_type] = pen; }