这篇教程C++ wxASSERT_MSG函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wxASSERT_MSG函数的典型用法代码示例。如果您正苦于以下问题:C++ wxASSERT_MSG函数的具体用法?C++ wxASSERT_MSG怎么用?C++ wxASSERT_MSG使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wxASSERT_MSG函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: WXUNUSEDwxDragResult wxDropSource::DoDragDrop(int WXUNUSED(flags)){ wxASSERT_MSG( m_data, wxT("Drop source: no data") ); if (!m_data) return (wxDragResult) wxDragNone; if (m_data->GetFormatCount() == 0) return (wxDragResult) wxDragNone; OSErr result; DragReference theDrag; RgnHandle dragRegion; if ((result = NewDrag(&theDrag))) { return wxDragNone ; } // add data to drag size_t formatCount = m_data->GetFormatCount() ; wxDataFormat *formats = new wxDataFormat[formatCount] ; m_data->GetAllFormats( formats ) ; ItemReference theItem = 1 ; for ( size_t i = 0 ; i < formatCount ; ++i ) { size_t dataSize = m_data->GetDataSize( formats[i] ) ; Ptr dataPtr = new char[dataSize] ; m_data->GetDataHere( formats[i] , dataPtr ) ; OSType type = formats[i].GetFormatId() ; if ( type == 'TEXT' ) { dataSize-- ; dataPtr[ dataSize ] = 0 ; wxString st( (wxChar*) dataPtr ) ; wxCharBuffer buf = st.mb_str( wxConvLocal) ; AddDragItemFlavor(theDrag, theItem, type , buf.data(), strlen(buf), 0); } else if (type == kDragFlavorTypeHFS ) { HFSFlavor theFlavor ; OSErr err = noErr; CInfoPBRec cat; wxMacFilename2FSSpec( dataPtr , &theFlavor.fileSpec ) ; cat.hFileInfo.ioNamePtr = theFlavor.fileSpec.name; cat.hFileInfo.ioVRefNum = theFlavor.fileSpec.vRefNum; cat.hFileInfo.ioDirID = theFlavor.fileSpec.parID; cat.hFileInfo.ioFDirIndex = 0; err = PBGetCatInfoSync(&cat); if (err == noErr ) { theFlavor.fdFlags = cat.hFileInfo.ioFlFndrInfo.fdFlags; if (theFlavor.fileSpec.parID == fsRtParID) { theFlavor.fileCreator = 'MACS'; theFlavor.fileType = 'disk'; } else if ((cat.hFileInfo.ioFlAttrib & ioDirMask) != 0) { theFlavor.fileCreator = 'MACS'; theFlavor.fileType = 'fold'; } else { theFlavor.fileCreator = cat.hFileInfo.ioFlFndrInfo.fdCreator; theFlavor.fileType = cat.hFileInfo.ioFlFndrInfo.fdType; } AddDragItemFlavor(theDrag, theItem, type , &theFlavor, sizeof(theFlavor), 0); } } else { AddDragItemFlavor(theDrag, theItem, type , dataPtr, dataSize, 0); } delete[] dataPtr ; } delete[] formats ; dragRegion = NewRgn(); RgnHandle tempRgn = NewRgn() ; EventRecord* ev = NULL ;#if !TARGET_CARBON // TODO ev = (EventRecord*) wxTheApp->MacGetCurrentEvent() ;#else EventRecord rec ; ev = &rec ; wxMacConvertEventToRecord( (EventRef) wxTheApp->MacGetCurrentEvent() , &rec ) ;#endif const short dragRegionOuterBoundary = 10 ; const short dragRegionInnerBoundary = 9 ; SetRectRgn( dragRegion , ev->where.h - dragRegionOuterBoundary , ev->where.v - dragRegionOuterBoundary , ev->where.h + dragRegionOuterBoundary , ev->where.v + dragRegionOuterBoundary ) ; SetRectRgn( tempRgn , ev->where.h - dragRegionInnerBoundary , ev->where.v - dragRegionInnerBoundary , ev->where.h + dragRegionInnerBoundary , ev->where.v + dragRegionInnerBoundary ) ; DiffRgn( dragRegion , tempRgn , dragRegion ) ; DisposeRgn( tempRgn ) ; //.........这里部分代码省略.........
开发者ID:Duion,项目名称:Torsion,代码行数:101,
示例2: wxUnusedVar// ----------------------------------------------------------------------------void clKeyboardManager::Initialize(bool isRefreshRequest)// ----------------------------------------------------------------------------{ wxUnusedVar(isRefreshRequest); m_menuTable.clear(); // First, try to load accelerators from %appdata% keybindings.conf // containing merged default + user defined accerators // Second, try loading from default accerators in %appdata% + accerators.conf clKeyboardBindingConfig config; if( not config.Exists()) //does keybindings.conf exist? { #if defined(LOGGING) LOGIT( _T("[%s]"), _("Keyboard manager: No configuration found - importing old settings")); #endif //CL_DEBUG("Keyboard manager: No configuration found - importing old settings"); // Decide which file we want to load, take the user settings file first // GetUserDataDir() == "c:/Users/<username>/AppData/Roaming/<appname>/config/keybindings.conf" // GetDataDir() == executable directory // Old accererator setting are in %appdata% wxFileName fnOldSettings(wxStandardPaths::Get().GetTempDir(), _T("keyMnuAccels.conf")); wxString personality = Manager::Get()->GetPersonalityManager()->GetPersonality(); fnOldSettings.SetName(personality + _T(".") + fnOldSettings.GetName()); wxFileName fnFileToLoad; bool canDeleteOldSettings(false); // If %appdata% accerators.conf exist, use it if(fnOldSettings.FileExists()) { fnFileToLoad = fnOldSettings; //-canDeleteOldSettings = true; } else // else use executable dir accerators.conf.default accerators { //-fnFileToLoad = fnDefaultOldSettings; wxASSERT_MSG(0, _("clKeyboardManager::Initialize() missing accerators.conf file")); } if(fnFileToLoad.FileExists()) { #if defined(LOGGING) LOGIT( _T("KeyboardManager:Importing settings from:/n/t[%s]"), fnFileToLoad.GetFullPath().wx_str()); #endif // Apply the old settings to the menus wxString content; if(not ReadFileContent(fnFileToLoad, content)) return; wxArrayString lines = ::wxStringTokenize(content, _T("/r/n"), wxTOKEN_STRTOK); for(size_t i = 0; i < lines.GetCount(); ++i) { #if defined(LOGGING) #if wxVERSION_NUMBER > 3000 LOGIT( _T("AccelFile[%u:%s]"), (unsigned)i, lines.Item(i).wx_str() ); #else LOGIT( _T("AccelFile[%u:%s]"), i, lines.Item(i).wx_str() ); #endif #endif wxArrayString parts = ::wxStringTokenize(lines.Item(i), _T("|"), wxTOKEN_RET_EMPTY); if(parts.GetCount() < 3) continue; MenuItemData binding; binding.resourceID = parts.Item(0); binding.parentMenu = parts.Item(1); binding.action = parts.Item(2); if(parts.GetCount() == 4) { binding.accel = parts.Item(3); } m_menuTable.insert(std::make_pair(binding.resourceID, binding)); } if(canDeleteOldSettings) { if (fnFileToLoad.FileExists()) ::wxRemoveFile(fnFileToLoad.GetFullPath()); } } } else //config exists: "keybindings.conf" { config.Load(); m_menuTable = config.GetBindings(); } // Load the default settings and add any new entries from accerators.conf MenuItemDataMap_t defaultEntries = DoLoadDefaultAccelerators(); // Remove any map items nolonger matching the menu structure for (MenuItemDataMap_t::iterator mapIter = m_menuTable.begin(); mapIter != m_menuTable.end(); ++mapIter) { mnuContinue: if (mapIter == m_menuTable.end()) break; //search menu structure map for map menuId if ( defaultEntries.count(mapIter->first) == 0) { // menuID nolonger exists #if defined(LOGGING) wxString mapAccel = mapIter->second.accel; wxString mapParent = mapIter->second.parentMenu; wxString mapMnuID = mapIter->first; LOGIT( _T("Removing ID mismatch[%s][%s][%s]"), mapMnuID.wx_str(), mapParent.wx_str(), mapAccel.wx_str()); #endif//.........这里部分代码省略.........
开发者ID:obfuscated,项目名称:codeblocks_sf,代码行数:101,
示例3: wxASSERT_MSGvoid wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ){ wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") ); wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") ); if (m_resizing) return; /* I don't like recursions */ m_resizing = true; int old_x = m_x; int old_y = m_y; int old_width = m_width; int old_height = m_height; if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) { if (x != -1) m_x = x; if (y != -1) m_y = y; if (width != -1) m_width = width; if (height != -1) m_height = height; } else { m_x = x; m_y = y; m_width = width; m_height = height; }/* if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) { if (width == -1) m_width = 80; } if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) { if (height == -1) m_height = 26; }*/ int minWidth = GetMinWidth(), minHeight = GetMinHeight(), maxWidth = GetMaxWidth(), maxHeight = GetMaxHeight(); if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; if ((m_x != -1) || (m_y != -1)) { if ((m_x != old_x) || (m_y != old_y)) { /* we set the position here and when showing the dialog for the first time in idle time */ gtk_widget_set_uposition( m_widget, m_x, m_y ); } } if ((m_width != old_width) || (m_height != old_height)) { gtk_widget_set_usize( m_widget, m_width, m_height ); /* actual resizing is deferred to GtkOnSize in idle time and when showing the dialog */ m_sizeSet = false; } m_resizing = false;}
开发者ID:beanhome,项目名称:dev,代码行数:73,
示例4: wxLogApiErrorvoid wxTaskBarJumpListImpl::LoadKnownCategory(const wxString& title){ IApplicationDocumentLists *docList = 0; HRESULT hr = CoCreateInstance ( wxCLSID_ApplicationDocumentLists, NULL, CLSCTX_INPROC_SERVER, wxIID_IApplicationDocumentLists, reinterpret_cast<void **>(&docList) ); if ( FAILED(hr) ) { wxLogApiError("CoCreateInstance(wxCLSID_ApplicationDocumentLists)", hr); return; } if ( !m_appID.empty() ) docList->SetAppID(m_appID.wc_str()); IObjectArray *array = NULL; wxASSERT_MSG( title == "Recent" || title == "Frequent", "Invalid title." ); hr = docList->GetList ( title == "Recent" ? ADLT_RECENT : ADLT_FREQUENT, 0, wxIID_IObjectArray, reinterpret_cast<void **>(&array) ); if ( FAILED(hr) ) { wxLogApiError("IApplicationDocumentLists::GetList", hr); return; } UINT count = 0; array->GetCount(&count); for (UINT i = 0; i < count; ++i) { IUnknown *collectionItem = NULL; hr = array->GetAt(i, wxIID_IUnknown, reinterpret_cast<void **>(&collectionItem)); if ( FAILED(hr) ) { wxLogApiError("IObjectArray::GetAt", hr); continue; } IShellLink *shellLink = NULL; IShellItem *shellItem = NULL; wxTaskBarJumpListItem* item = NULL; if ( SUCCEEDED(collectionItem->QueryInterface( wxIID_IShellLink, reinterpret_cast<void**>(&shellLink))) ) { item = GetItemFromIShellLink(shellLink); shellLink->Release(); } else if ( SUCCEEDED(collectionItem->QueryInterface( wxIID_IShellItem, reinterpret_cast<void**>(&shellItem))) ) { item = GetItemFromIShellItem(shellItem); shellItem->Release(); } else { wxLogError("Can not query interfaces: IShellLink or IShellItem."); } if ( item ) { if ( title == wxT("Frequent") ) m_frequent->Append(item); else m_recent->Append(item); } collectionItem->Release(); } array->Release(); docList->Release();}
开发者ID:EEmmanuel7,项目名称:wxWidgets,代码行数:81,
示例5: wxASSERT_MSG// Begin dragbool wxDragImage::BeginDrag(const wxPoint& hotspot, wxWindow* window, bool fullScreen, wxRect* rect){ wxASSERT_MSG( (m_hImageList != 0), wxT("Image list must not be null in BeginDrag.")); wxASSERT_MSG( (window != 0), wxT("Window must not be null in BeginDrag.")); m_fullScreen = fullScreen; if (rect) m_boundingRect = * rect; bool ret = (ImageList_BeginDrag(GetHimageList(), 0, hotspot.x, hotspot.y) != 0); if (!ret) { wxFAIL_MSG( wxT("BeginDrag failed.") ); return false; } if (m_cursor.IsOk()) {#if wxUSE_SIMPLER_DRAGIMAGE m_oldCursor = window->GetCursor(); window->SetCursor(m_cursor);#else if (!m_hCursorImageList) {#ifndef SM_CXCURSOR // Smartphone may not have these metric symbol int cxCursor = 16; int cyCursor = 16;#else int cxCursor = ::GetSystemMetrics(SM_CXCURSOR); int cyCursor = ::GetSystemMetrics(SM_CYCURSOR);#endif m_hCursorImageList = (WXHIMAGELIST) ImageList_Create(cxCursor, cyCursor, ILC_MASK, 1, 1); } // See if we can find the cursor hotspot wxPoint curHotSpot(hotspot); // Although it seems to produce the right position, when the hotspot goeos // negative it has strange effects on the image. // How do we stop the cursor jumping right and below of where it should be?#if 0 ICONINFO iconInfo; if (::GetIconInfo((HICON) (HCURSOR) m_cursor.GetHCURSOR(), & iconInfo) != 0) { curHotSpot.x -= iconInfo.xHotspot; curHotSpot.y -= iconInfo.yHotspot; }#endif //wxString msg; //msg.Printf("Hotspot = %d, %d", curHotSpot.x, curHotSpot.y); //wxLogDebug(msg); // First add the cursor to the image list HCURSOR hCursor = (HCURSOR) m_cursor.GetHCURSOR(); int cursorIndex = ImageList_AddIcon((HIMAGELIST) m_hCursorImageList, (HICON) hCursor); wxASSERT_MSG( (cursorIndex != -1), wxT("ImageList_AddIcon failed in BeginDrag.")); if (cursorIndex != -1) { ImageList_SetDragCursorImage((HIMAGELIST) m_hCursorImageList, cursorIndex, curHotSpot.x, curHotSpot.y); }#endif }#if !wxUSE_SIMPLER_DRAGIMAGE if (m_cursor.IsOk()) ::ShowCursor(FALSE);#endif m_window = window; ::SetCapture(GetHwndOf(window)); return true;}
开发者ID:Richard-Ni,项目名称:wxWidgets,代码行数:80,
示例6: wxASSERT_MSGwxTaskBarJumpListItem*wxTaskBarJumpListCategory::FindItemByPosition(size_t pos) const{ wxASSERT_MSG( pos < m_items.size(), "invalid pos." ); return m_items[pos];}
开发者ID:EEmmanuel7,项目名称:wxWidgets,代码行数:6,
示例7: wxCHECK_MSGboolwxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n){ wxCHECK_MSG( n >= 16, false, _T("GL attributes buffer too small") ); /* Different versions of GLX API use rather different attributes lists, see the following URLs: - <= 1.2: http://www.opengl.org/sdk/docs/man/xhtml/glXChooseVisual.xml - >= 1.3: http://www.opengl.org/sdk/docs/man/xhtml/glXChooseFBConfig.xml Notice in particular that - GLX_RGBA is boolean attribute in the old version of the API but a value of GLX_RENDER_TYPE in the new one - Boolean attributes such as GLX_DOUBLEBUFFER don't take values in the old version but must be followed by True or False in the new one. */ if ( !wxattrs ) { size_t i = 0; // use double-buffered true colour by default glattrs[i++] = GLX_DOUBLEBUFFER; if ( GetGLXVersion() < 13 ) { // default settings if attriblist = 0 glattrs[i++] = GLX_RGBA; glattrs[i++] = GLX_DEPTH_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_RED_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_GREEN_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_BLUE_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_ALPHA_SIZE; glattrs[i++] = 0; } else // recent GLX can choose the defaults on its own just fine { // we just need to have a value after GLX_DOUBLEBUFFER glattrs[i++] = True; } glattrs[i] = None; wxASSERT_MSG( i < n, _T("GL attributes buffer too small") ); } else // have non-default attributes { size_t p = 0; for ( int arg = 0; wxattrs[arg] != 0; ) { // check if we have any space left, knowing that we may insert 2 // more elements during this loop iteration and we always need to // terminate the list with None (hence -3) if ( p > n - 3 ) return false; // indicates whether we have a boolean attribute bool isBoolAttr = false; switch ( wxattrs[arg++] ) { case WX_GL_BUFFER_SIZE: glattrs[p++] = GLX_BUFFER_SIZE; break; case WX_GL_LEVEL: glattrs[p++] = GLX_LEVEL; break; case WX_GL_RGBA: if ( GetGLXVersion() >= 13 ) { // this is the default GLX_RENDER_TYPE anyhow continue; } glattrs[p++] = GLX_RGBA; isBoolAttr = true; break; case WX_GL_DOUBLEBUFFER: glattrs[p++] = GLX_DOUBLEBUFFER; isBoolAttr = true; break; case WX_GL_STEREO: glattrs[p++] = GLX_STEREO; isBoolAttr = true; break; case WX_GL_AUX_BUFFERS: glattrs[p++] = GLX_AUX_BUFFERS; break; case WX_GL_MIN_RED: glattrs[p++] = GLX_RED_SIZE; break; case WX_GL_MIN_GREEN://.........这里部分代码省略.........
开发者ID:jonntd,项目名称:dynamica,代码行数:101,
示例8: wxDialogPrefsDialog::PrefsDialog(wxWindow * parent): wxDialog(parent, wxID_ANY, wxString(_("Audacity Preferences")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER){ ShuttleGui S(this, eIsCreating); S.StartVerticalLay(true); { S.StartHorizontalLay(wxALIGN_LEFT | wxEXPAND, true); { mCategories = new wxTreebook(this, wxID_ANY); S.Prop(1); S.AddWindow(mCategories, wxEXPAND); wxWindow *w; // Parameters are: AppPage( page, name, IsSelected, imageId) w = new DevicePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new PlaybackPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new RecordingPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);#ifdef EXPERIMENTAL_MIDI_OUT w = new MidiIOPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);#endif w = new QualityPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new GUIPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new TracksPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new ImportExportPrefs(mCategories);mCategories->AddPage(w, w->GetName(), false, 0); w = new ProjectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new LibraryPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new SpectrumPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new DirectoriesPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new WarningsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new EffectsPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);#ifdef EXPERIMENTAL_THEME_PREFS w = new ThemePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0);#endif// w = new BatchPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new KeyConfigPrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); w = new MousePrefs(mCategories); mCategories->AddPage(w, w->GetName(), false, 0); } S.EndHorizontalLay(); } S.EndVerticalLay(); S.AddStandardButtons(eOkButton | eCancelButton); size_t selected = gPrefs->Read(wxT("/Prefs/PrefsCategory"), 0L); if (selected < 0 || selected >= mCategories->GetPageCount()) { selected = 0; } mCategories->SetSelection(selected);#if defined(__WXGTK__) mCategories->GetTreeCtrl()->EnsureVisible(mCategories->GetTreeCtrl()->GetRootItem());#endif// mCategories->SetSizeHints(-1, -1, 790, 600); // 790 = 800 - (border * 2) Layout(); Fit(); wxSize sz = GetSize(); wxASSERT_MSG(sz.x <= 800 && sz.y <= 600, wxT("Preferences dialog exceeds max size")); if (sz.x > 800) { sz.x = 800; } if (sz.y > 600) { sz.y = 600; } SetSizeHints(sz.x, sz.y, 800, 600); // Center after all that resizing, but make sure it doesn't end up // off-screen CentreOnParent();}
开发者ID:tuanmasterit,项目名称:audacity,代码行数:80,
示例9: PostEventvoid ClangWorkerThread::ProcessRequest(ThreadRequest* request){ // Send start event PostEvent(wxEVT_CLANG_PCH_CACHE_STARTED, ""); ClangThreadRequest* task = dynamic_cast<ClangThreadRequest*>(request); wxASSERT_MSG(task, "ClangWorkerThread: NULL task"); { // A bit of optimization wxCriticalSectionLocker locker(m_criticalSection); if(task->GetContext() == CTX_CachePCH && m_cache.Contains(task->GetFileName())) { // Nothing to be done here PostEvent(wxEVT_CLANG_PCH_CACHE_ENDED, task->GetFileName()); return; } } CL_DEBUG(wxT("==========> [ ClangPchMakerThread ] ProcessRequest started: %s"), task->GetFileName().c_str()); CL_DEBUG(wxT("ClangWorkerThread:: processing request %d"), (int)task->GetContext()); ClangCacheEntry cacheEntry = findEntry(task->GetFileName()); CXTranslationUnit TU = cacheEntry.TU; CL_DEBUG(wxT("ClangWorkerThread:: found cached TU: %p"), (void*)TU); bool reparseRequired = true; if(!TU) { // First time creating the TU TU = DoCreateTU(task->GetIndex(), task, true); reparseRequired = false; cacheEntry.lastReparse = time(NULL); cacheEntry.TU = TU; cacheEntry.sourceFile = task->GetFileName(); } if(!TU) { CL_DEBUG(wxT("Failed to parse Translation UNIT...")); PostEvent(wxEVT_CLANG_TU_CREATE_ERROR, task->GetFileName()); return; } if(reparseRequired && task->GetContext() == ::CTX_ReparseTU) { DoSetStatusMsg(wxString::Format(wxT("clang: re-parsing file %s..."), task->GetFileName().c_str())); // We need to reparse the TU CL_DEBUG(wxT("Calling clang_reparseTranslationUnit... [CTX_ReparseTU]")); if(clang_reparseTranslationUnit(TU, 0, NULL, clang_defaultReparseOptions(TU)) == 0) { CL_DEBUG(wxT("Calling clang_reparseTranslationUnit... done [CTX_ReparseTU]")); cacheEntry.lastReparse = time(NULL); } else { CL_DEBUG(wxT("An error occurred during reparsing of the TU for file %s. TU: %p"), task->GetFileName().c_str(), (void*)TU); // The only thing that left to be done here, is to dispose the TU clang_disposeTranslationUnit(TU); PostEvent(wxEVT_CLANG_TU_CREATE_ERROR, task->GetFileName()); return; } } // Construct a cache-returner class // which makes sure that the TU is cached // when we leave the current scope CacheReturner cr(this, cacheEntry); // Prepare the 'End' event wxCommandEvent eEnd(wxEVT_CLANG_PCH_CACHE_ENDED); ClangThreadReply* reply = new ClangThreadReply; reply->context = task->GetContext(); reply->filterWord = task->GetFilterWord(); reply->filename = task->GetFileName().c_str(); reply->results = NULL; wxFileName realFileName(reply->filename); if(realFileName.GetFullName().StartsWith(CODELITE_CLANG_FILE_PREFIX)) { realFileName.SetFullName(realFileName.GetFullName().Mid(strlen(CODELITE_CLANG_FILE_PREFIX))); } reply->filename = realFileName.GetFullPath(); if(task->GetContext() == CTX_CodeCompletion || task->GetContext() == CTX_WordCompletion || task->GetContext() == CTX_Calltip) { CL_DEBUG(wxT("Calling clang_codeCompleteAt...")); ClangThreadRequest::List_t usList = task->GetModifiedBuffers(); usList.push_back(std::make_pair(task->GetFileName(), task->GetDirtyBuffer())); ClangUnsavedFiles usf(usList); CL_DEBUG(wxT("Location: %s:%u:%u"), task->GetFileName().c_str(), task->GetLine(), task->GetColumn()); reply->results = clang_codeCompleteAt(TU, cstr(task->GetFileName()), task->GetLine(), task->GetColumn(), usf.GetUnsavedFiles(), usf.GetCount(), clang_defaultCodeCompleteOptions()#if HAS_LIBCLANG_BRIEFCOMMENTS | CXCodeComplete_IncludeBriefComments#endif );//.........这里部分代码省略.........
开发者ID:jiapei100,项目名称:codelite,代码行数:101,
示例10: WXUNUSEDvoid wxOverlayImpl::Clear(wxDC* WXUNUSED(dc)){ wxASSERT_MSG( IsOk() , _("You cannot Clear an overlay that is not inited") ); CGRect box = CGRectMake( m_x - 1, m_y - 1 , m_width + 2 , m_height + 2 ); CGContextClearRect( m_overlayContext, box );}
开发者ID:chromylei,项目名称:third_party,代码行数:6,
示例11: MakeUserDataRecvoid MakeUserDataRec(OpenUserDataRec *myData , const wxString& filter ){ myData->menuitems = NULL ; myData->currentfilter = 0 ; myData->saveMode = false ; if ( filter && filter[0] ) { wxString filter2(filter) ; int filterIndex = 0; bool isName = true ; wxString current ; for( unsigned int i = 0; i < filter2.Len() ; i++ ) { if( filter2.GetChar(i) == wxT('|') ) { if( isName ) { myData->name.Add( current ) ; } else { myData->extensions.Add( current.MakeUpper() ) ; ++filterIndex ; } isName = !isName ; current = wxEmptyString ; } else { current += filter2.GetChar(i) ; } } // we allow for compatibility reason to have a single filter expression (like *.*) without // an explanatory text, in that case the first part is name and extension at the same time wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ; if ( current.IsEmpty() ) myData->extensions.Add( myData->name[filterIndex] ) ; else myData->extensions.Add( current.MakeUpper() ) ; if ( filterIndex == 0 || isName ) myData->name.Add( current.MakeUpper() ) ; ++filterIndex ; const size_t extCount = myData->extensions.GetCount(); for ( size_t i = 0 ; i < extCount; i++ ) { wxUint32 fileType; wxUint32 creator; wxString extension = myData->extensions[i]; if (extension.GetChar(0) == '*') extension = extension.Mid(1); // Remove leading * if (extension.GetChar(0) == '.') { extension = extension.Mid(1); // Remove leading . } if (wxFileName::MacFindDefaultTypeAndCreator( extension, &fileType, &creator )) { myData->filtermactypes.Add( (OSType)fileType ); } else { myData->filtermactypes.Add( '****' ) ; // We'll fail safe if it's not recognized } } }}
开发者ID:Duion,项目名称:Torsion,代码行数:70,
示例12: StrPrintfbool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, int aCtl ){ // This is for python: if( aFileSet.size() != 1 ) { UTF8 msg = StrPrintf( "Pcbnew:%s() takes only a single filename", __func__ ); DisplayError( this, msg ); return false; } wxString fullFileName( aFileSet[0] ); // We insist on caller sending us an absolute path, if it does not, we say it's a bug. wxASSERT_MSG( wxFileName( fullFileName ).IsAbsolute(), wxT( "bug in single_top.cpp or project manager." ) ); if( !LockFile( fullFileName ) ) { wxString msg = wxString::Format( _( "PCB file '%s' is already open." ), GetChars( fullFileName ) ); DisplayError( this, msg ); return false; } if( GetScreen()->IsModify() ) { int response = YesNoCancelDialog( this, _( "The current board has been modified. Do you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) return false; else if( response == wxID_YES ) SavePcbFile( GetBoard()->GetFileName(), CREATE_BACKUP_FILE ); else { // response == wxID_NO, fall thru } } wxFileName pro = fullFileName; pro.SetExt( ProjectFileExtension ); bool is_new = !wxFileName::IsFileReadable( fullFileName ); // If its a non-existent schematic and caller thinks it exists if( is_new && !( aCtl & KICTL_CREATE ) ) { // notify user that fullFileName does not exist, ask if user wants to create it. wxString ask = wxString::Format( _( "Board '%s' does not exist. Do you wish to create it?" ), GetChars( fullFileName ) ); if( !IsOK( this, ask ) ) return false; } Clear_Pcb( false ); // pass false since we prompted above for a modified board IO_MGR::PCB_FILE_T pluginType = plugin_type( fullFileName, aCtl ); bool converted = pluginType != IO_MGR::LEGACY && pluginType != IO_MGR::KICAD; if( !converted ) { // PROJECT::SetProjectFullName() is an impactful function. It should only be // called under carefully considered circumstances. // The calling code should know not to ask me here to change projects unless // it knows what consequences that will have on other KIFACEs running and using // this same PROJECT. It can be very harmful if that calling code is stupid. Prj().SetProjectFullName( pro.GetFullPath() ); // load project settings before BOARD LoadProjectSettings(); } if( is_new ) { OnModify(); } else { BOARD* loadedBoard = 0; // it will be set to non-NULL if loaded OK PLUGIN::RELEASER pi( IO_MGR::PluginFind( pluginType ) ); try { PROPERTIES props; char xbuf[30]; char ybuf[30]; // EAGLE_PLUGIN can use this info to center the BOARD, but it does not yet. sprintf( xbuf, "%d", GetPageSizeIU().x );//.........这里部分代码省略.........
开发者ID:chgans,项目名称:kicad,代码行数:101,
示例13: wxASSERT_MSGwxUnixTimerImpl::~wxUnixTimerImpl(){ wxASSERT_MSG( !m_isRunning, wxT("must have been stopped before") );}
开发者ID:NullNoname,项目名称:dolphin,代码行数:4,
示例14: wxASSERT_MSGvoid wxMenuItem::SetItemLabel( const wxString& string ){ wxString str = string; if ( str.empty() && !IsSeparator() ) { wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?")); str = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR | wxSTOCK_WITH_MNEMONIC); } // Some optimization to avoid flicker wxString oldLabel = m_text; oldLabel = wxStripMenuCodes(oldLabel); oldLabel.Replace(wxT("_"), wxEmptyString); wxString label1 = wxStripMenuCodes(str); wxString oldhotkey = GetHotKey(); // Store the old hotkey in Ctrl-foo format wxCharBuffer oldbuf = wxGTK_CONV( GetGtkHotKey(*this) ); // and as <control>foo DoSetText(str); if (oldLabel == label1 && oldhotkey == GetHotKey()) // Make sure we can change a hotkey even if the label is unaltered return; if (m_menuItem) { GtkLabel *label; if (m_labelWidget) label = (GtkLabel*) m_labelWidget; else label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); // set new text gtk_label_set( label, wxGTK_CONV( m_text ) ); // reparse key accel (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); } guint accel_key; GdkModifierType accel_mods; gtk_accelerator_parse( (const char*) oldbuf, &accel_key, &accel_mods); if (accel_key != 0) { gtk_widget_remove_accelerator( GTK_WIDGET(m_menuItem), m_parentMenu->m_accel, accel_key, accel_mods ); } wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*this) ); gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods); if (accel_key != 0) { gtk_widget_add_accelerator( GTK_WIDGET(m_menuItem), "activate", m_parentMenu->m_accel, accel_key, accel_mods, GTK_ACCEL_VISIBLE); }}
开发者ID:esrrhs,项目名称:fuck-music-player,代码行数:63,
示例15: Top//.........这里部分代码省略......... Push(ReportIdentifiedWorldsState); } else if(el=="unidentifiedWorlds") { Push(ReportUnidentifiedWorldsState); } else if(el=="uninhabitedWorlds") { Push(ReportUninhabitedWorldsState); } else { Push(ReportUnknownState); } } else if (t == ReportMapState) { if (el == "ulx") { Push(ReportMapULXState); } if (el == "lrx") { Push(ReportMapLRXState); } if (el == "uly") { Push(ReportMapULYState); } if (el == "lry") { Push(ReportMapLRYState); } } else if(t==ReportStatusState) { if(el=="tech") { Push(ReportStatusTechState); } else if(el=="numPlanets") { Push(ReportStatusNumPlanetsState); } else if(el=="population") { Push(ReportStatusPopulationState); } else if(el=="industry") { Push(ReportStatusIndustryState); } else if(el=="stockpiles") { Push(ReportStatusStockpilesState); } else { wxASSERT_MSG(false, "This should never happen."); } } else if(t==ReportStatusTechState) { if(el=="drive") { Push(ReportStatusDriveState); } else if(el=="weapons") { Push(ReportStatusWeaponsState); } else if(el=="shields") { Push(ReportStatusShieldsState); } else if(el=="cargo") { Push(ReportStatusCargoState); } else { wxASSERT_MSG(false, "This should never happen."); } } else if(t==ReportStatusStockpilesState) { if(el=="capital") { Push(ReportStatusCapitalState); } else if(el=="material") { Push(ReportStatusMaterialState); } else if(el=="colonists") { Push(ReportStatusColonistsState); } else { wxASSERT_MSG(false, "This should never happen."); } } else if(t==ReportAlienRacesState) { if(el=="alienRace") { m_aliens.AddNew(attr[1], attr[3]); Push(ReportAlienRaceState); } else { wxASSERT_MSG(false, "This should never happen."); } } else if(t==ReportAlienRaceState) { if(el=="tech") {
开发者ID:scumola,项目名称:galaxyview,代码行数:67,
示例16: gtk_menu_item_new//.........这里部分代码省略......... // start of a new radio group m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); // set new text gtk_label_set_text( label, wxGTK_CONV( text ) ); } else // continue the radio group { group = gtk_radio_menu_item_group (GTK_RADIO_MENU_ITEM (m_prevRadio)); m_prevRadio = menuItem = gtk_radio_menu_item_new_with_label( group, wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); } break; } default: wxFAIL_MSG( wxT("unexpected menu item kind") ); // fall through case wxITEM_NORMAL: { menuItem = gtk_menu_item_new_with_label( wxGTK_CONV( text ) ); label = GTK_LABEL( GTK_BIN(menuItem)->child ); m_prevRadio = NULL; break; } } } guint accel_key; GdkModifierType accel_mods; wxCharBuffer buf = wxGTK_CONV( GetGtkHotKey(*mitem) ); // wxPrintf( wxT("item: %s hotkey %s/n"), mitem->GetItemLabel().c_str(), GetGtkHotKey(*mitem).c_str() ); gtk_accelerator_parse( (const char*) buf, &accel_key, &accel_mods); if (accel_key != 0) { gtk_widget_add_accelerator (GTK_WIDGET(menuItem), "activate", m_accel, accel_key, accel_mods, GTK_ACCEL_VISIBLE); } if (pos == -1) gtk_menu_shell_append(GTK_MENU_SHELL(m_menu), menuItem); else gtk_menu_shell_insert(GTK_MENU_SHELL(m_menu), menuItem, pos); gtk_widget_show( menuItem ); if ( !mitem->IsSeparator() ) { wxASSERT_MSG( menuItem, wxT("invalid menuitem") ); gtk_signal_connect( GTK_OBJECT(menuItem), "select", GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), (gpointer)this ); gtk_signal_connect( GTK_OBJECT(menuItem), "deselect", GTK_SIGNAL_FUNC(gtk_menu_nolight_callback), (gpointer)this ); if ( mitem->IsSubMenu() && mitem->GetKind() != wxITEM_RADIO && mitem->GetKind() != wxITEM_CHECK ) { gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); gtk_widget_show( mitem->GetSubMenu()->m_menu ); } else { gtk_signal_connect( GTK_OBJECT(menuItem), "activate", GTK_SIGNAL_FUNC(gtk_menu_clicked_callback), (gpointer)this ); } guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) ); if (accel_key != GDK_VoidSymbol) { gtk_widget_add_accelerator (menuItem, "activate_item", gtk_menu_ensure_uline_accel_group(GTK_MENU(m_menu)), accel_key, GDK_MOD1_MASK, GTK_ACCEL_LOCKED); } } mitem->SetMenuItem(menuItem); if (ms_locked) { // This doesn't even exist! // gtk_widget_lock_accelerators(mitem->GetMenuItem()); } return true;}
开发者ID:esrrhs,项目名称:fuck-music-player,代码行数:101,
示例17: switch//.........这里部分代码省略......... g_object_get( gtk_settings_get_for_screen(gdk_drawable_get_screen(window)), "gtk-dnd-drag-threshold", &drag_threshold, NULL); } else#endif { g_object_get(gtk_settings_get_default(), "gtk-dnd-drag-threshold", &drag_threshold, NULL); } // The correct thing here would be to double the value // since that is what the API wants. But the values // are much bigger under GNOME than under Windows and // just seem to much in many cases to be useful. // drag_threshold *= 2; return drag_threshold; // MBN: ditto for icons case wxSYS_ICON_X: return 32; case wxSYS_ICON_Y: return 32; case wxSYS_SCREEN_X:#if GTK_CHECK_VERSION(2,2,0) if (window && !gtk_check_version(2,2,0)) return gdk_screen_get_width(gdk_drawable_get_screen(window)); else#endif return gdk_screen_width(); case wxSYS_SCREEN_Y:#if GTK_CHECK_VERSION(2,2,0) if (window && !gtk_check_version(2,2,0)) return gdk_screen_get_height(gdk_drawable_get_screen(window)); else#endif return gdk_screen_height(); case wxSYS_HSCROLL_Y: return 15; case wxSYS_VSCROLL_X: return 15; case wxSYS_CAPTION_Y: if (!window) // No realized window specified, and no implementation for that case yet. return -1; // Check if wm supports frame extents - we can't know the caption height if it does not.#if GTK_CHECK_VERSION(2,2,0) if (!gtk_check_version(2,2,0)) { if (!gdk_x11_screen_supports_net_wm_hint( gdk_drawable_get_screen(window), gdk_atom_intern("_NET_FRAME_EXTENTS", false) ) ) return -1; } else#endif { if (!gdk_net_wm_supports(gdk_atom_intern("_NET_FRAME_EXTENTS", false))) return -1; } wxASSERT_MSG( wxDynamicCast(win, wxTopLevelWindow), wxT("Asking for caption height of a non toplevel window") ); // Get the height of the top windowmanager border. // This is the titlebar in most cases. The titlebar might be elsewhere, and // we could check which is the thickest wm border to decide on which side the // titlebar is, but this might lead to interesting behaviours in used code. // Reconsider when we have a way to report to the user on which side it is. if (wxXGetWindowProperty(window, type, format, nitems, data)) { int caption_height = -1; if ((type == XA_CARDINAL) && (format == 32) && (nitems >= 3) && (data)) { caption_height = ((long*)data)[2]; // top frame extent } if (data) XFree(data); return caption_height; } // Try a default approach without a window pointer, if possible // ... return -1; case wxSYS_PENWINDOWS_PRESENT: // No MS Windows for Pen computing extension available in X11 based gtk+. return 0; default: return -1; // metric is unknown }}
开发者ID:SCP-682,项目名称:Cities3D,代码行数:101,
示例18: Gestaltbool wxDisplay::ChangeMode(const wxVideoMode& mode){ unsigned long dwDMVer; Gestalt(gestaltDisplayMgrVers, (long*)&dwDMVer); if (GetCount() == 1 || dwDMVer >= 0x020000) { if (mode == wxDefaultVideoMode) {//#ifndef __DARWIN__// Handle hDisplayState;// if (DMBeginConfigureDisplays(&hDisplayState) != noErr)// {// wxLogSysError(wxT("Could not lock display for display mode changing!"));// return false;// }// wxASSERT( DMUseScreenPrefs(true, hDisplayState) == noErr);// DMEndConfigureDisplays(hDisplayState);// return true;//#else //hmmmmm.... return true;//#endif } //0 & NULL for params 2 & 3 of DMSetVideoMode signal it to use defaults (current mode) //DM 2.0+ doesn't use params 2 & 3 of DMSetDisplayMode //so we have to use this icky structure VDSwitchInfoRec sMode; memset(&sMode, 0, sizeof(VDSwitchInfoRec) ); DMListIndexType nNumModes; DMListType pModes; DMDisplayModeListIteratorUPP uppMLI; DisplayIDType nDisplayID; wxASSERT(DMGetDisplayIDByGDevice(m_priv->m_hndl, &nDisplayID, false) == noErr); //Create a new list... wxASSERT_MSG(DMNewDisplayModeList(nDisplayID, NULL, NULL, &nNumModes, &pModes) == noErr, wxT("Could not create a new display mode list") ); uppMLI = NewDMDisplayModeListIteratorUPP(DMModeInfoProc); wxASSERT(uppMLI); DMModeInfoRec sModeInfo; sModeInfo.bMatched = false; sModeInfo.pMode = &mode; unsigned int i; for(i = 0; i < nNumModes; ++i) { wxASSERT(DMGetIndexedDisplayModeFromList(pModes, i, NULL, uppMLI, &sModeInfo) == noErr); if (sModeInfo.bMatched == true) { sMode = sModeInfo.sMode; break; } } if(i == nNumModes) return false; DisposeDMDisplayModeListIteratorUPP(uppMLI); wxASSERT(DMDisposeList(pModes) == noErr); // For the really paranoid - // unsigned long flags; // Boolean bok; // wxASSERT(noErr == DMCheckDisplayMode(m_priv->m_hndl, sMode.csData, // sMode.csMode, &flags, NULL, &bok)); // wxASSERT(bok); Handle hDisplayState; if (DMBeginConfigureDisplays(&hDisplayState) != noErr) { wxLogSysError(wxT("Could not lock display for display mode changing!")); return false; } unsigned long dwBPP = (unsigned long) mode.bpp; if (DMSetDisplayMode(m_priv->m_hndl, sMode.csData, (unsigned long*) &(dwBPP), NULL //(unsigned long) &sMode , hDisplayState ) != noErr) { DMEndConfigureDisplays(hDisplayState); wxMessageBox(wxString::Format(wxT("Could not set the display mode"))); return false; } DMEndConfigureDisplays(hDisplayState); } else //DM 1.0, 1.2, 1.x { wxLogSysError(wxString::Format(wxT("Monitor gravitation not supported yet. dwDMVer:%u"), (unsigned int) dwDMVer)); return false; } return true;}
开发者ID:HackLinux,项目名称:chandler-1,代码行数:99,
示例19: wxASSERT_MSGvoid wxCursor::CreateFromImage(const wxImage & image){ m_refData = new wxCursorRefData; int w = 16; int h = 16; int hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X); int hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y); int image_w = image.GetWidth(); int image_h = image.GetHeight(); wxASSERT_MSG( hotSpotX >= 0 && hotSpotX < image_w && hotSpotY >= 0 && hotSpotY < image_h, _T("invalid cursor hot spot coordinates") ); wxImage image16(image); // final image of correct size // if image is too small then place it in the center, resize it if too big if ((w > image_w) && (h > image_h)) { wxPoint offset((w - image_w)/2, (h - image_h)/2); hotSpotX = hotSpotX + offset.x; hotSpotY = hotSpotY + offset.y; image16 = image.Size(wxSize(w, h), offset); } else if ((w != image_w) || (h != image_h)) { hotSpotX = int(hotSpotX * double(w) / double(image_w)); hotSpotY = int(hotSpotY * double(h) / double(image_h)); image16 = image.Scale(w, h); } unsigned char * rgbBits = image16.GetData(); bool bHasMask = image16.HasMask() ;#if 0 // monochrome implementation M_CURSORDATA->m_hCursor = NewHandle( sizeof( Cursor ) ) ; M_CURSORDATA->m_disposeHandle = true ; HLock( (Handle) M_CURSORDATA->m_hCursor ) ; CursPtr cp = *(CursHandle)M_CURSORDATA->m_hCursor ; memset( cp->data , 0 , sizeof( Bits16 ) ) ; memset( cp->mask , 0 , sizeof( Bits16 ) ) ; unsigned char mr = image16.GetMaskRed() ; unsigned char mg = image16.GetMaskGreen() ; unsigned char mb = image16.GetMaskBlue() ; for ( int y = 0 ; y < h ; ++y ) { short rowbits = 0 ; short maskbits = 0 ; for ( int x = 0 ; x < w ; ++x ) { long pos = (y * w + x) * 3; unsigned char r = rgbBits[pos] ; unsigned char g = rgbBits[pos+1] ; unsigned char b = rgbBits[pos+2] ; if ( bHasMask && r==mr && g==mg && b==mb ) { // masked area, does not appear anywhere } else { if ( (int)r + (int)g + (int)b < 0x0200 ) { rowbits |= ( 1 << (15-x) ) ; } maskbits |= ( 1 << (15-x) ) ; } } cp->data[y] = rowbits ; cp->mask[y] = maskbits ; } if ( !bHasMask ) { memcpy( cp->mask , cp->data , sizeof( Bits16) ) ; } cp->hotSpot.h = hotSpotX ; cp->hotSpot.v = hotSpotY ; HUnlock( (Handle) M_CURSORDATA->m_hCursor ) ;#else PixMapHandle pm = (PixMapHandle) NewHandleClear( sizeof (PixMap)) ; short extent = 16 ; short bytesPerPixel = 1 ; short depth = 8 ; Rect bounds = { 0 , 0 , extent , extent } ; CCrsrHandle ch = (CCrsrHandle) NewHandleClear ( sizeof( CCrsr ) ) ; CTabHandle newColors = GetCTable( 8 ) ; HandToHand((Handle *) &newColors); // set the values to the indices for ( int i = 0 ; i < (**newColors).ctSize ; ++i ) { (**newColors).ctTable[i].value = i ; } HLock( (Handle) ch) ;//.........这里部分代码省略.........
开发者ID:Bluehorn,项目名称:wxPython,代码行数:101,
示例20: wxIOCHECKbool wxHIDDevice::Create (int nClass, int nType, int nDev){ //Create the mach port wxIOCHECK(IOMasterPort(bootstrap_port, &m_pPort), "Could not create mach port"); //Dictionary that will hold first //the matching dictionary for determining which kind of devices we want, //then later some registry properties from an iterator (see below) // //The call to IOServiceMatching filters down the //the services we want to hid services (and also eats the //dictionary up for us (consumes one reference)) CFMutableDictionaryRef pDictionary = IOServiceMatching(kIOHIDDeviceKey); wxCHECK_MSG( pDictionary, false, _T("IOServiceMatching(kIOHIDDeviceKey) failed") ); wxASSERT( pDictionary ); //Here we'll filter down the services to what we want if (nType != -1) { CFNumberRef pType = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &nType); CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsageKey), pType); CFRelease(pType); } if (nClass != -1) { CFNumberRef pClass = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &nClass); CFDictionarySetValue(pDictionary, CFSTR(kIOHIDPrimaryUsagePageKey), pClass); CFRelease(pClass); } //Now get the maching services io_iterator_t pIterator; wxIOCHECK(IOServiceGetMatchingServices(m_pPort, pDictionary, &pIterator), "No Matching HID Services"); wxASSERT_MSG(pIterator != 0, wxT("No devices found!")); //Now we iterate through them io_object_t pObject; while ( (pObject = IOIteratorNext(pIterator)) != 0) { if(--nDev != 0) continue; if ( IORegistryEntryCreateCFProperties ( pObject, &pDictionary, kCFAllocatorDefault, kNilOptions ) != KERN_SUCCESS ) { wxLogDebug(_T("IORegistryEntryCreateCFProperties failed")); } //Just for sanity :) wxASSERT(CFGetTypeID(CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey))) == CFStringGetTypeID());/* kIOHIDTransportKey; kIOHIDVendorIDKey; kIOHIDProductIDKey; kIOHIDVersionNumberKey; kIOHIDManufacturerKey; kIOHIDSerialNumberKey; if !kIOHIDLocationIDKey kUSBDevicePropertyLocationID kIOHIDPrimaryUsageKeykIOHIDPrimaryUsagePageKeyidProductidVendorUSB Product Name*/ //Get [product] name m_szProductName = wxMacCFStringHolder( (CFStringRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductKey)), false ).AsString(); CFNumberRef nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDProductIDKey)); if (nref) CFNumberGetValue( nref, kCFNumberIntType, &m_nProductId ); nref = (CFNumberRef) CFDictionaryGetValue(pDictionary, CFSTR(kIOHIDVendorIDKey)); if (nref) CFNumberGetValue( nref, kCFNumberIntType, &m_nManufacturerId ); //Create the interface (good grief - long function names!) SInt32 nScore; IOCFPlugInInterface** ppPlugin; wxIOCHECK(IOCreatePlugInInterfaceForService(pObject, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &ppPlugin, &nScore), "");//.........这里部分代码省略.........
开发者ID:HackLinux,项目名称:chandler-1,代码行数:101,
示例21: if//.........这里部分代码省略......... for ( size_t n = (size_t)posTab; n < label.length(); n++ ) { if ( (label[n] == '+') || (label[n] == '-') ) { if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) accelFlags |= wxACCEL_CTRL; else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) accelFlags |= wxACCEL_ALT; else if ( CompareAccelString(current, wxTRANSLATE("shift")) ) accelFlags |= wxACCEL_SHIFT; else if ( CompareAccelString(current, wxTRANSLATE("rawctrl")) ) accelFlags |= wxACCEL_RAW_CTRL; else // not a recognized modifier name { // we may have "Ctrl-+", for example, but we still want to // catch typos like "Crtl-A" so only give the warning if we // have something before the current '+' or '-', else take // it as a literal symbol if ( current.empty() ) { current += label[n]; // skip clearing it below continue; } else { wxLogDebug(wxT("Unknown accel modifier: '%s'"), current.c_str()); } } current.clear(); } else // not special character { current += (wxChar) wxTolower(label[n]); } } int keyCode; const size_t len = current.length(); switch ( len ) { case 0: wxLogDebug(wxT("No accel key found, accel string ignored.")); return false; case 1: // it's just a letter keyCode = current[0U]; // if the key is used with any modifiers, make it an uppercase one // because Ctrl-A and Ctrl-a are the same; but keep it as is if it's // used alone as 'a' and 'A' are different if ( accelFlags != wxACCEL_NORMAL ) keyCode = wxToupper(keyCode); break; default: keyCode = IsNumberedAccelKey(current, wxTRANSLATE("F"), WXK_F1, 1, 12); if ( !keyCode ) { for ( size_t n = 0; n < WXSIZEOF(wxKeyNames); n++ ) { const wxKeyName& kn = wxKeyNames[n]; if ( CompareAccelString(current, kn.name) ) { keyCode = kn.code; break; } } } if ( !keyCode ) keyCode = IsNumberedAccelKey(current, wxTRANSLATE("KP_"), WXK_NUMPAD0, 0, 9); if ( !keyCode ) keyCode = IsNumberedAccelKey(current, wxTRANSLATE("SPECIAL"), WXK_SPECIAL1, 1, 20); if ( !keyCode ) { wxLogDebug(wxT("Unrecognized accel key '%s', accel string ignored."), current.c_str()); return false; } } wxASSERT_MSG( keyCode, wxT("logic error: should have key code here") ); if ( flagsOut ) *flagsOut = accelFlags; if ( keyOut ) *keyOut = keyCode; return true;}
开发者ID:BauerBox,项目名称:wxWidgets,代码行数:101,
示例22: dlg//.........这里部分代码省略......... // fall through case _T('//'): while ( i < len - 1 ) { wxChar chNext = m_dir[i + 1]; if ( chNext != _T('//') && chNext != _T('/') ) break; // ignore the next one, unless it is at the start of a UNC path if (i > 0) i++; else break; } // fall through default: // normal char dir += ch; } } of.lpstrInitialDir = dir.c_str(); of.Flags = msw_flags; of.lpfnHook = FileDialogHookFunction; wxArrayString wildDescriptions; size_t items = wxParseCommonDialogsFilter(m_wildCard, wildDescriptions, m_FilterGroups); wxASSERT_MSG( items > 0 , _T("empty wildcard list") ); wxString filterBuffer; for (i = 0; i < items ; i++) { filterBuffer += wildDescriptions[i]; filterBuffer += wxT("|"); filterBuffer += wxT("*.*"); filterBuffer += wxT("|"); } // Replace | with /0 for (i = 0; i < filterBuffer.Len(); i++ ) { if ( filterBuffer.GetChar(i) == wxT('|') ) { filterBuffer[i] = wxT('/0'); } } of.lpstrFilter = (LPTSTR)filterBuffer.c_str(); of.nFilterIndex = m_filterIndex + 1; ParseFilter(of.nFilterIndex); //=== Setting defaultFileName >>========================================= wxStrncpy( fileNameBuffer, (const wxChar *)m_fileName, wxMAXPATH-1 ); fileNameBuffer[ wxMAXPATH-1 ] = wxT('/0'); of.lpstrFile = fileNameBuffer; // holds returned filename of.nMaxFile = wxMAXPATH;
开发者ID:ruthmagnus,项目名称:audacity,代码行数:67,
示例23: wxCHECK_MSG//.........这里部分代码省略......... { wxString dirname; for ( bool cont = GetFirst(&dirname, wxEmptyString, (flags & ~(wxDIR_FILES | wxDIR_DOTDOT)) | wxDIR_DIRS); cont; cont = cont && GetNext(&dirname) ) { const wxString fulldirname = prefix + dirname; switch ( sink.OnDir(fulldirname) ) { default: wxFAIL_MSG(wxT("unexpected OnDir() return value") ); wxFALLTHROUGH; case wxDIR_STOP: cont = false; break; case wxDIR_CONTINUE: { wxDir subdir; // don't give the error messages for the directories // which we can't open: there can be all sorts of good // reason for this (e.g. insufficient privileges) and // this shouldn't be treated as an error -- instead // let the user code decide what to do bool ok; do { wxLogNull noLog; ok = subdir.Open(fulldirname); if ( !ok ) { // ask the user code what to do bool tryagain; switch ( sink.OnOpenError(fulldirname) ) { default: wxFAIL_MSG(wxT("unexpected OnOpenError() return value") ); wxFALLTHROUGH; case wxDIR_STOP: cont = false; wxFALLTHROUGH; case wxDIR_IGNORE: tryagain = false; break; case wxDIR_CONTINUE: tryagain = true; } if ( !tryagain ) break; } } while ( !ok ); if ( ok ) { nFiles += subdir.Traverse(sink, filespec, flags); } } break; case wxDIR_IGNORE: // nothing to do ; } } } // now enum our own files if ( flags & wxDIR_FILES ) { flags &= ~wxDIR_DIRS; wxString filename; bool cont = GetFirst(&filename, filespec, flags); while ( cont ) { wxDirTraverseResult res = sink.OnFile(prefix + filename); if ( res == wxDIR_STOP ) break; wxASSERT_MSG( res == wxDIR_CONTINUE, wxT("unexpected OnFile() return value") ); nFiles++; cont = GetNext(&filename); } } return nFiles;}
开发者ID:3v1n0,项目名称:wxWidgets,代码行数:101,
示例24: wxGetKeyStatebool wxGetKeyState (wxKeyCode key){ wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key != WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons")); if (wxHIDModule::sm_keyboards.GetCount() == 0) { int nKeyboards = wxHIDKeyboard::GetCount(); for(int i = 1; i <= nKeyboards; ++i) { wxHIDKeyboard* keyboard = new wxHIDKeyboard(); if(keyboard->Create(i)) { wxHIDModule::sm_keyboards.Add(keyboard); } else { delete keyboard; break; } } wxASSERT_MSG(wxHIDModule::sm_keyboards.GetCount() != 0, wxT("No keyboards found!")); } for(size_t i = 0; i < wxHIDModule::sm_keyboards.GetCount(); ++i) { wxHIDKeyboard* keyboard = (wxHIDKeyboard*) wxHIDModule::sm_keyboards[i]; switch(key) { case WXK_SHIFT: if( keyboard->IsActive(WXK_SHIFT) || keyboard->IsActive(WXK_RSHIFT) ) { return true; } break; case WXK_ALT: if( keyboard->IsActive(WXK_ALT) || keyboard->IsActive(WXK_RALT) ) { return true; } break; case WXK_CONTROL: if( keyboard->IsActive(WXK_CONTROL) || keyboard->IsActive(WXK_RCONTROL) ) { return true; } break; case WXK_MENU: if( keyboard->IsActive(WXK_MENU) || keyboard->IsActive(WXK_RMENU) ) { return true; } break; default: if( keyboard->IsActive(key) ) { return true; } break; } } return false; //not down/error}
开发者ID:mark711,项目名称:Cafu,代码行数:73,
示例25: wxExecute// wxExecute: the real worker functionlong wxExecute(char **argv, int flags, wxProcess *process, const wxExecuteEnv *env){ // for the sync execution, we return -1 to indicate failure, but for async // case we return 0 which is never a valid PID // // we define this as a macro, not a variable, to avoid compiler warnings // about "ERROR_RETURN_CODE value may be clobbered by fork()" #define ERROR_RETURN_CODE ((flags & wxEXEC_SYNC) ? -1 : 0) wxCHECK_MSG( *argv, ERROR_RETURN_CODE, wxT("can't exec empty command") );#if wxUSE_THREADS // fork() doesn't mix well with POSIX threads: on many systems the program // deadlocks or crashes for some reason. Probably our code is buggy and // doesn't do something which must be done to allow this to work, but I // don't know what yet, so for now just warn the user (this is the least we // can do) about it wxASSERT_MSG( wxThread::IsMain(), wxT("wxExecute() can be called only from the main thread") );#endif // wxUSE_THREADS#if defined(__WXCOCOA__) || ( defined(__WXOSX_MAC__) && wxOSX_USE_COCOA_OR_CARBON ) // wxMacLaunch() only executes app bundles and only does it asynchronously. // It returns false if the target is not an app bundle, thus falling // through to the regular code for non app bundles. if ( !(flags & wxEXEC_SYNC) && wxMacLaunch(argv) ) { // we don't have any PID to return so just make up something non null return -1; }#endif // __DARWIN__ // this struct contains all information which we use for housekeeping wxExecuteData execData; execData.flags = flags; execData.process = process; // create pipes if ( !execData.pipeEndProcDetect.Create() ) { wxLogError( _("Failed to execute '%s'/n"), *argv ); return ERROR_RETURN_CODE; } // pipes for inter process communication wxPipe pipeIn, // stdin pipeOut, // stdout pipeErr; // stderr if ( process && process->IsRedirected() ) { if ( !pipeIn.Create() || !pipeOut.Create() || !pipeErr.Create() ) { wxLogError( _("Failed to execute '%s'/n"), *argv ); return ERROR_RETURN_CODE; } } // fork the process // // NB: do *not* use vfork() here, it completely breaks this code for some // reason under Solaris (and maybe others, although not under Linux) // But on OpenVMS we do not have fork so we have to use vfork and // cross our fingers that it works.#ifdef __VMS pid_t pid = vfork();#else pid_t pid = fork();#endif if ( pid == -1 ) // error? { wxLogSysError( _("Fork failed") ); return ERROR_RETURN_CODE; } else if ( pid == 0 ) // we're in child { // NB: we used to close all the unused descriptors of the child here // but this broke some programs which relied on e.g. FD 1 being // always opened so don't do it any more, after all there doesn't // seem to be any real problem with keeping them opened#if !defined(__VMS) && !defined(__EMX__) if ( flags & wxEXEC_MAKE_GROUP_LEADER ) { // Set process group to child process' pid. Then killing -pid // of the parent will kill the process and all of its children. setsid(); }#endif // !__VMS // redirect stdin, stdout and stderr if ( pipeIn.IsOk() ) { if ( dup2(pipeIn[wxPipe::Read], STDIN_FILENO) == -1 ||//.........这里部分代码省略.........
开发者ID:iokto,项目名称:newton-dynamics,代码行数:101,
示例26: gtk_menu_clicked_callbackstatic void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ){ if (g_isIdle) wxapp_install_idle_handler(); int id = menu->FindMenuIdByMenuItem(widget); /* should find it for normal (not popup) menu */ wxASSERT_MSG( (id != -1) || (menu->GetWindow() != NULL), wxT("menu item not found in gtk_menu_clicked_callback") ); if (!menu->IsEnabled(id)) return; wxMenuItem* item = menu->FindChildItem( id ); wxCHECK_RET( item, wxT("error in menu item callback") ); if ( item->GetId() == wxGTK_TITLE_ID ) { // ignore events from the menu title return; } if (item->IsCheckable()) { bool isReallyChecked = item->IsChecked(), isInternallyChecked = item->wxMenuItemBase::IsChecked(); // ensure that the internal state is always consistent with what is // shown on the screen item->wxMenuItemBase::Check(isReallyChecked); // we must not report the events for the radio button going up nor the // events resulting from the calls to wxMenuItem::Check() if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) || (isInternallyChecked == isReallyChecked) ) { return; } } // Is this menu on a menubar? (possibly nested) wxFrame* frame = NULL; if(menu->IsAttached()) frame = menu->GetMenuBar()->GetFrame(); // FIXME: why do we have to call wxFrame::GetEventHandler() directly here? // normally wxMenu::SendEvent() should be enough, if it doesn't work // in wxGTK then we have a bug in wxMenu::GetWindow() which // should be fixed instead of working around it here... if (frame) { // If it is attached then let the frame send the event. // Don't call frame->ProcessCommand(id) because it toggles // checkable items and we've already done that above. wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); commandEvent.SetEventObject(frame); if (item->IsCheckable()) commandEvent.SetInt(item->IsChecked()); commandEvent.SetEventObject(menu); frame->HandleWindowEvent(commandEvent); } else { // otherwise let the menu have it menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1); }}
开发者ID:esrrhs,项目名称:fuck-music-player,代码行数:70,
示例27: ReadHotkeyConfigvoid SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ){ EDA_DRAW_FRAME::LoadSettings( aCfg ); long tmp; ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Schematic_Hotkeys_Descr ); wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); SetDefaultBusThickness( (int) aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SCH_JUNCTION::SetSymbolSize( (int) aCfg->Read( DefaultJctSizeEntry, SCH_JUNCTION::GetSymbolSize() ) ); aCfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false ); aCfg->Read( HorzVertLinesOnlyEntry, &m_forceHVLines, true ); aCfg->Read( AutoplaceFieldsEntry, &m_autoplaceFields, true ); aCfg->Read( AutoplaceJustifyEntry, &m_autoplaceJustify, true ); aCfg->Read( AutoplaceAlignEntry, &m_autoplaceAlign, false ); aCfg->Read( FootprintPreviewEntry, &m_footprintPreview, false ); // Load netlists options: aCfg->Read( SimulatorCommandEntry, &m_simulatorCommand ); wxASSERT_MSG( m_findReplaceData, wxT( "Find dialog data settings object not created. Bad programmer!" ) ); aCfg->Read( FindReplaceFlagsEntry, &tmp, (long) wxFR_DOWN ); m_findReplaceData->SetFlags( (wxUint32) tmp & ~FR_REPLACE_ITEM_FOUND ); m_findReplaceData->SetFindString( aCfg->Read( FindStringEntry, wxEmptyString ) ); m_findReplaceData->SetReplaceString( aCfg->Read( ReplaceStringEntry, wxEmptyString ) ); // Load the find and replace string history list. for( int i = 0; i < FR_HISTORY_LIST_CNT; ++i ) { wxString tmpHistory; wxString entry; entry.Printf( FindStringHistoryEntry, i ); tmpHistory = aCfg->Read( entry, wxEmptyString ); if( !tmpHistory.IsEmpty() ) m_findStringHistoryList.Add( tmpHistory ); entry.Printf( ReplaceStringHistoryEntry, i ); tmpHistory = aCfg->Read( entry, wxEmptyString ); if( !tmpHistory.IsEmpty() ) m_replaceStringHistoryList.Add( tmpHistory ); } wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString ); if( !templateFieldNames.IsEmpty() ) { TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) ); try { m_templateFieldNames.Parse( &lexer ); } catch( const IO_ERROR& DBG( e ) ) { // @todo show error msg DBG( printf( "templatefieldnames parsing error: '%s'/n", TO_UTF8( e.What() ) ); ) } }
开发者ID:johnbeard,项目名称:kicad,代码行数:64,
注:本文中的wxASSERT_MSG函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ wxArrayString函数代码示例 C++ wuow函数代码示例 |