void ScrollableGamePanel::_onTimer(wxTimerEvent& evt) { const int KEY_SENSITIVITY = 20; int x = m_pMapScrollX->GetThumbPosition(); int y = m_pMapScrollY->GetThumbPosition(); bool bChanges = false; if(wxGetKeyState(WXK_LEFT)) { m_pMapScrollX->SetThumbPosition(std::max(0, x - KEY_SENSITIVITY)); bChanges = true; } if(wxGetKeyState(WXK_RIGHT)) { m_pMapScrollX->SetThumbPosition(std::min(m_pMapScrollX->GetRange(), x + KEY_SENSITIVITY)); bChanges = true; } if(wxGetKeyState(WXK_UP)) { m_pMapScrollY->SetThumbPosition(std::max(0, y - KEY_SENSITIVITY)); bChanges = true; } if(wxGetKeyState(WXK_DOWN)) { m_pMapScrollY->SetThumbPosition(std::min(m_pMapScrollY->GetRange(), y + KEY_SENSITIVITY)); bChanges = true; } if (bChanges) { _positionMap(); } }
void PlatformKeyboardEvent::getCurrentModifierState(bool& shiftKey, bool& ctrlKey, bool& altKey, bool& metaKey) { shiftKey = wxGetKeyState(WXK_SHIFT); ctrlKey = wxGetKeyState(WXK_CONTROL); altKey = wxGetKeyState(WXK_ALT); metaKey = false; }
bool FOOTPRINT_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { bool eventHandled = true; // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; wxPoint oldpos = GetCrossHairPosition(); wxPoint pos = aPosition; GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); SetCrossHairPosition( pos, snapToGrid ); RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { eventHandled = OnHotKey( aDC, aHotKey, aPosition ); } UpdateStatusBar(); return eventHandled; }
void IncrementalSelectListDlg::OnKeyDown(wxKeyEvent& event) { //Manager::Get()->GetLogManager()->Log(mltDevDebug, "OnKeyDown"); size_t sel = 0; switch (event.GetKeyCode()) { case WXK_RETURN: case WXK_NUMPAD_ENTER: EndModal(wxID_OK); break; case WXK_ESCAPE: EndModal(wxID_CANCEL); break; case WXK_UP: case WXK_NUMPAD_UP: sel = m_List->GetSelection() - 1; m_List->SetSelection(sel == (size_t) -1 ? 0 : sel); break; case WXK_DOWN: case WXK_NUMPAD_DOWN: m_List->SetSelection(m_List->GetSelection() + 1); break; case WXK_PAGEUP: case WXK_NUMPAD_PAGEUP: sel = m_List->GetSelection() - 10; m_List->SetSelection(sel > m_List->GetCount() ? 0 : sel); break; case WXK_PAGEDOWN: case WXK_NUMPAD_PAGEDOWN: sel = m_List->GetSelection() + 10; m_List->SetSelection(sel >= m_List->GetCount() ? m_List->GetCount() - 1 : sel); break; case WXK_HOME: if (wxGetKeyState(WXK_CONTROL)) m_List->SetSelection(0); else event.Skip(); break; case WXK_END: if (wxGetKeyState(WXK_CONTROL)) m_List->SetSelection(m_List->GetCount() - 1); else event.Skip(); break; default: event.Skip(); break; } }
void MyStatusBar::OnIdle(wxIdleEvent& event) { SetStatusText(numlockIndicators[wxGetKeyState(WXK_NUMLOCK)], Field_NumLockIndicator); SetStatusText(capslockIndicators[wxGetKeyState(WXK_CAPITAL)], Field_CapsLockIndicator); event.Skip(); }
void SelectionTool::OnCanvasLeftMouseButtonClick(const wxMouseEvent &event) { auto positionOnMap = m_canvas.GetMousePositionOnMap(event.GetPosition()); if (wxGetKeyState(MOVE_SELECTED_KEY)) return; if (wxGetKeyState(REMOVE_SELECTION_KEY)) { m_selectionManager.PunctualUnselect(positionOnMap); } else m_selectionManager.PunctualSelect(positionOnMap, wxGetKeyState(ADD_SELECTION_KEY)); m_mousePositionOnMap = m_canvas.GetMousePositionOnMap(event.GetPosition()); }
void MyFrame::OnCharHook(wxKeyEvent& evt) { bool handled = false; // This never gets called on OSX (since we moved to wxWidgets-3.0.0), so we // rely on the menu accelerators on the MyFrame to provide the keyboard // responses. For Windows and Linux, we keep this here so the keystrokes // work when other windows like the Drift Tool window have focus. if (evt.GetKeyCode() == 'B') { if (!evt.GetEventObject()->IsKindOf(wxCLASSINFO(wxTextCtrl))) { int modifiers; #ifdef __WXOSX__ modifiers = 0; if (wxGetKeyState(WXK_ALT)) modifiers |= wxMOD_ALT; if (wxGetKeyState(WXK_CONTROL)) modifiers |= wxMOD_CONTROL; if (wxGetKeyState(WXK_SHIFT)) modifiers |= wxMOD_SHIFT; if (wxGetKeyState(WXK_RAW_CONTROL)) modifiers |= wxMOD_RAW_CONTROL; #else modifiers = evt.GetModifiers(); #endif if (!modifiers) { pGuider->ToggleShowBookmarks(); bookmarks_menu->Check(MENU_BOOKMARKS_SHOW, pGuider->GetBookmarksShown()); handled = true; } else if (modifiers == wxMOD_CONTROL) { pGuider->DeleteAllBookmarks(); handled = true; } else if (modifiers == wxMOD_SHIFT) { pGuider->BookmarkLockPosition(); handled = true; } } } if (!handled) { evt.Skip(); } }
bool SelectShapesOP::onMouseLeftDown(int x, int y) { m_bDraggable = true; Vector pos = m_editPanel->transPosScreenToProject(x, y); IShape* selected = m_shapeImpl->queryShapeByPos(pos); if (selected) { if (wxGetKeyState(WXK_CONTROL)) { if (m_selection->isExist(selected)) m_selection->erase(selected); else { m_selection->insert(selected); if (m_selection->size() == 1) m_propertyPanel->setPropertySetting(createPropertySetting(selected)); else m_propertyPanel->setPropertySetting(createPropertySetting(NULL)); } } else { if (!m_selection->isExist(selected)) { m_selection->clear(); m_selection->insert(selected); if (m_propertyPanel) m_propertyPanel->setPropertySetting(createPropertySetting(selected)); } } m_firstPos.setInvalid(); if (m_callback) m_callback->updateControlValue(); } else { DrawRectangleOP::onMouseLeftDown(x, y); m_firstPos = pos; if (wxGetKeyState(WXK_CONTROL)) m_bDraggable = false; else m_selection->clear(); m_editPanel->Refresh(); } return false; }
bool wxGxTreeView::OnDropObjects(wxCoord x, wxCoord y, const wxArrayString& GxObjects) { bool bMove = !wxGetKeyState(WXK_CONTROL); wxPoint pt(x, y); int flag = wxTREE_HITTEST_ONITEMINDENT; wxTreeItemId ItemId = wxTreeCtrl::HitTest(pt, flag); if(ItemId.IsOk()) { SetItemDropHighlight(ItemId, false); wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(ItemId); if(pData == NULL) return wxDragNone; wxGxObject* pGxObject = m_pCatalog->GetRegisterObject(pData->m_nObjectID); IGxDropTarget* pTarget = dynamic_cast<IGxDropTarget*>(pGxObject); if(pTarget) { wxDragResult res(bMove == true ? wxDragMove : wxDragCopy); if(wxIsDragResultOk(pTarget->CanDrop(res))) return pTarget->Drop(GxObjects, bMove); } } return false; }
void ExtImportPrefs::OnPluginKeyDown(wxListEvent& event) { for (int i = 0; i < 1; i++) { #ifdef __WXMAC__ if (!mFakeKeyEvent && !wxGetKeyState(WXK_COMMAND)) break; #else if (!mFakeKeyEvent && !wxGetKeyState(WXK_CONTROL)) break; #endif if (DoOnPluginKeyDown (event.GetKeyCode())) event.Skip(); } }
// // Watch for shift key changes // void ToolManager::OnTimer( wxTimerEvent & event ) { // Go ahead and set the event to propagate event.Skip(); // Can't do anything if we're not dragging. This also prevents // us from intercepting events that don't belong to us from the // parent since we're Connect()ed to a couple. if( !mDragWindow ) { return; } bool state = wxGetKeyState( WXK_SHIFT ); if( mLastState != state ) { mLastState = state; #if defined(__WXMAC__) // Disable window animation wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 ); #endif mIndicator->Show( !state ); #if defined(__WXMAC__) // Disable window animation wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition ); #endif } return; }
/************************************************************** *** ** ContextMenuProvider --- getNewViewMenu *** ***************************************************************/ wxMenu *ContextMenuProvider::getNewViewMenu() { const int vedicitems[] = { 0, CMD_CHILD_NEW_DASA, CMD_CHILD_NEW_GRAPHICALDASA, CMD_CHILD_NEW_TRANSIT, 0, CMD_CHILD_NEW_YOGA, CMD_CHILD_NEW_ASHTAKAVARGA, CMD_CHILD_NEW_SOLAR, -1 }; const int westernitems[5] = { 0, CMD_CHILD_NEW_URANIAN, CMD_CHILD_NEW_TRANSIT, CMD_CHILD_NEW_SOLAR, -1 }; const int appitems[5] = { APP_SHOWEPHEM, APP_SHOWECLIPSE, APP_SHOWHORA, APP_NEW_PARTNER, -1 }; MyMenu *menu = new MyMenu( _( "New View" ), view ); bool vedicmode = view->isVedic(); if ( wxGetKeyState( WXK_SHIFT )) vedicmode = ! vedicmode; if ( view->getDoc()) { // Varga submenu or western chart if ( vedicmode ) menu->addVargaMenu(); else menu->addItem( CMD_CHILD_NEW_WCHART ); if ( vedicmode ) { menu->addItem( CMD_CHILD_NEW_VARGA ); menu->addItem( CMD_CHILD_NEW_SBC ); } menu->addItem( CMD_CHILD_NEW_TEXT ); menu->addArray( vedicmode ? vedicitems : westernitems ); } else { menu->addArray( appitems ); } return menu; }
/* FindReplacePanel::onTextFindEnter * Called when the enter key is pressed within the 'Find' text box *******************************************************************/ void FindReplacePanel::onTextFindEnter(wxCommandEvent& e) { if (wxGetKeyState(WXK_SHIFT)) text_editor->findPrev(getFindText(), getFindFlags()); else text_editor->findNext(getFindText(), getFindFlags()); }
//--------------------------------------------------------- void CWKSP_Map_Control::On_Drag_End(wxTreeEvent &event) { if( event.GetItem().IsOk() && (((CWKSP_Base_Item *)GetItemData(m_draggedItem))->Get_Type() == WKSP_ITEM_Map_Layer || ((CWKSP_Base_Item *)GetItemData(m_draggedItem))->Get_Type() == WKSP_ITEM_Map_Graticule || ((CWKSP_Base_Item *)GetItemData(m_draggedItem))->Get_Type() == WKSP_ITEM_Map_BaseMap ) ) { CWKSP_Map *pDst_Map, *pSrc_Map; CWKSP_Base_Item *pSrc, *pDst, *pCpy; pDst = (CWKSP_Base_Item *)GetItemData(event.GetItem()); pSrc = (CWKSP_Base_Item *)GetItemData(m_draggedItem); pSrc_Map = (CWKSP_Map *)pSrc->Get_Manager(); switch( pDst->Get_Type() ) { default: pDst_Map = NULL; break; case WKSP_ITEM_Map: pDst_Map = (CWKSP_Map *)pDst; pDst = NULL; break; case WKSP_ITEM_Map_Layer: case WKSP_ITEM_Map_Graticule: case WKSP_ITEM_Map_BaseMap: pDst_Map = (CWKSP_Map *)pDst->Get_Manager(); break; } if( pDst_Map ) { Freeze(); if( pDst_Map == pSrc_Map ) { pDst_Map->Move_To(pSrc, pDst); pDst_Map->View_Refresh(false); } else if( (pCpy = pDst_Map->Add_Copy(pSrc)) != NULL ) { pDst_Map->Move_To(pCpy, pDst); if( pCpy && !wxGetKeyState(WXK_CONTROL) ) { Del_Item(pSrc_Map, pSrc); } pDst_Map->View_Refresh(false); } Thaw(); } } m_draggedItem = (wxTreeItemId)0l; }
void MyFrame::OnSelectGear(wxCommandEvent& evt) { try { if (CaptureActive) { throw ERROR_INFO("OnSelectGear called while CaptureActive"); } if (pConfig->NumProfiles() == 1 && pGearDialog->IsEmptyProfile()) { if (ConfirmDialog::Confirm( _("It looks like this is a first-time connection to your camera and mount. The Setup Wizard can help\n" "you with that and will also establish baseline guiding parameters for your new configuration.\n" "Would you like to use the Setup Wizard now?"), "/use_new_profile_wizard", _("Yes"), _("No"), _("Setup Wizard Recommendation"))) { pGearDialog->ShowProfileWizard(evt); return; } } pGearDialog->ShowGearDialog(wxGetKeyState(WXK_SHIFT)); } catch (wxString Msg) { POSSIBLY_UNUSED(Msg); } }
void MyFrame::GuideButtonClick(bool interactive) { try { if (pMount == NULL) { // no mount selected -- should never happen throw ERROR_INFO("pMount == NULL"); } if (!pMount->IsConnected()) { throw ERROR_INFO("Unable to guide with no scope Connected"); } if (!pCamera || !pCamera->Connected) { throw ERROR_INFO("Unable to guide with no camera Connected"); } if (pGuider->GetState() < STATE_SELECTED) { wxMessageBox(_T("Please select a guide star before attempting to guide")); throw ERROR_INFO("Unable to guide with state < STATE_SELECTED"); } ValidateDarksLoaded(); if (wxGetKeyState(WXK_SHIFT)) { bool recalibrate = true; if (pMount->IsCalibrated() || (pSecondaryMount && pSecondaryMount->IsCalibrated())) { recalibrate = ConfirmDialog::Confirm(_("Are you sure you want force recalibration?"), "/force_recalibration_ok", _("Force Recalibration")); } if (recalibrate) { pMount->ClearCalibration(); if (pSecondaryMount) pSecondaryMount->ClearCalibration(); } } if (interactive && pPointingSource && pPointingSource->IsConnected()) { bool error = pPointingSource->PreparePositionInteractive(); if (error) return; } StartGuiding(); } catch (const wxString& Msg) { POSSIBLY_UNUSED(Msg); pGuider->Reset(false); } }
void AButton::Listener::OnTimer(wxTimerEvent & event) { event.Skip(); // bug 307 fix: // Shift key-up events get swallowed if a command with a Shift in its keyboard // shortcut opens a dialog, and OnKeyUp() doesn't get called. // With CTRL now causing the button to change appearance, presumably similar // can happen with that key. if (!wxGetKeyState(WXK_SHIFT) || !wxGetKeyState(WXK_CONTROL)) { wxKeyEvent dummy; this->OnKeyUp(dummy); mShiftKeyTimer.Stop(); } }
bool SCH_EDIT_FRAME::GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey ) { bool eventHandled = true; // Filter out the 'fake' mouse motion after a keyboard movement if( !aHotKey && m_movingCursorWithKeyboard ) { m_movingCursorWithKeyboard = false; return false; } // when moving mouse, use the "magnetic" grid, unless the shift+ctrl keys is pressed // for next cursor position // ( shift or ctrl key down are PAN command with mouse wheel) bool snapToGrid = true; if( !aHotKey && wxGetKeyState( WXK_SHIFT ) && wxGetKeyState( WXK_CONTROL ) ) snapToGrid = false; // Cursor is left off grid only if no block in progress if( GetScreen()->m_BlockLocate.GetState() != STATE_NO_BLOCK ) snapToGrid = true; wxPoint pos = aPosition; wxPoint oldpos = GetCrossHairPosition(); GeneralControlKeyMovement( aHotKey, &pos, snapToGrid ); // Update cursor position. SetCrossHairPosition( pos, snapToGrid ); RefreshCrossHair( oldpos, aPosition, aDC ); if( aHotKey ) { SCH_SCREEN* screen = GetScreen(); if( screen->GetCurItem() && screen->GetCurItem()->GetFlags() ) eventHandled = OnHotKey( aDC, aHotKey, aPosition, screen->GetCurItem() ); else eventHandled = OnHotKey( aDC, aHotKey, aPosition, NULL ); } UpdateStatusBar(); /* Display cursor coordinates info */ return eventHandled; }
bool Host_GetKeyState(int keycode) { #ifdef _WIN32 return (0 != GetAsyncKeyState(keycode)); #elif defined __WXGTK__ std::unique_lock<std::recursive_mutex> lk(main_frame->keystate_lock, std::try_to_lock); if (!lk.owns_lock()) return false; bool key_pressed; if (!wxIsMainThread()) wxMutexGuiEnter(); key_pressed = wxGetKeyState(wxKeyCode(keycode)); if (!wxIsMainThread()) wxMutexGuiLeave(); return key_pressed; #else return wxGetKeyState(wxKeyCode(keycode)); #endif }
void CQuickFindBar::OnEnter(wxCommandEvent& e) { wxUnusedVar(e); bool shift = wxGetKeyState(WXK_SHIFT); wxButton *btn = shift ? m_buttonFindPrevious : m_buttonFindNext; wxCommandEvent evt(wxEVT_COMMAND_BUTTON_CLICKED, btn->GetId()); evt.SetEventObject(btn); btn->GetEventHandler()->AddPendingEvent(evt); }
bool cbAuiNotebook::CheckKeyModifier() { bool result = true; // this search must be case-insensitive wxString str = s_modKeys; str.MakeUpper(); if (result && str.Contains(wxT("ALT"))) result = wxGetKeyState(WXK_ALT); if (result && str.Contains(wxT("CTRL"))) result = wxGetKeyState(WXK_CONTROL); #if defined(__WXMAC__) || defined(__WXCOCOA__) if (result && str.Contains(wxT("XCTRL"))) result = wxGetKeyState(WXK_COMMAND); #endif if (result && str.Contains(wxT("SHIFT"))) result = wxGetKeyState(WXK_SHIFT); return result; }
void SearchEvtHandler::OnKeyDown(wxKeyEvent &event) { // When wxTE_PROCESS_ENTER is set, we have to manually process tab if (event.GetKeyCode() == WXK_TAB) { const int direction = wxGetKeyState(WXK_SHIFT) ? 0 : wxNavigationKeyEvent::IsForward; ((wxWindow*)event.GetEventObject())->Navigate(direction); return; } event.Skip(); }
void AButton::Listener::OnEvent() { if (!mButton->IsDown()) { int idx = 0; // Ignore the event, consult key states. One modifier key might // have gone up but another remained down. // Note that CMD (or CTRL) takes precedence over Shift if both are down // and alternates are defined for both // see also AButton::OnMouseEvent() if (wxGetKeyState(WXK_CONTROL) && mButton->HasAlternateImages(2)) idx = 2; else if (wxGetKeyState(WXK_SHIFT) && mButton->HasAlternateImages(1)) idx = 1; // Turn e.g. the "Play" button into a "Loop" button // or "Cut Preview" button mButton->SetAlternateIdx(idx); } }
// // Transition a toolbar from float to dragging // void ToolManager::OnGrabber( GrabberEvent & event ) { // No need to propagate any further event.Skip( false ); // Remember which bar we're dragging mDragBar = mBars[ event.GetId() ]; // Calculate the drag offset wxPoint mp = event.GetPosition(); mDragOffset = mp - mDragBar->GetParent()->ClientToScreen( mDragBar->GetPosition() ) + wxPoint( 1, 1 ); // Must set the bar afloat if it's currently docked if( mDragBar->IsDocked() ) { #if defined(__WXMAC__) // Disable window animation wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 ); #endif // Adjust the starting position mp -= mDragOffset; // Inform toolbar of change mDragBar->SetDocked( NULL, true ); // Construct a new floater mDragWindow = new ToolFrame( mParent, this, mDragBar, mp ); // Make sure the ferry is visible mDragWindow->Show(); // Notify parent of change Updated(); #if defined(__WXMAC__) // Reinstate original transition wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition ); #endif } else { mDragWindow = (ToolFrame *) mDragBar->GetParent(); } // We want all mouse events from this point on mParent->CaptureMouse(); // Start monitoring shift key changes mLastState = wxGetKeyState( WXK_SHIFT ); mTimer.Start( 100 ); }
void SelectionTool::OnCanvasMouseMotion(const wxMouseEvent &event) { wxRealPoint newMousePositionOnMap = m_canvas.GetMousePositionOnMap(event.GetPosition()); if (event.LeftIsDown() && wxGetKeyState(MOVE_SELECTED_KEY)) { float dx = newMousePositionOnMap.x - m_mousePositionOnMap.x; float dy = newMousePositionOnMap.y - m_mousePositionOnMap.y; m_selectionManager.MoveSelection(dx, dy); } m_mousePositionOnMap = m_canvas.GetMousePositionOnMap(event.GetPosition()); }
//---------------------------------------------------------------------------- // Workaround for bug http://trac.wxwidgets.org/ticket/11630 void mmTransDialog::OnDpcKillFocus(wxFocusEvent& event) { if (wxGetKeyState(WXK_TAB) && wxGetKeyState(WXK_SHIFT)) itemButtonCancel_->SetFocus(); else if (wxGetKeyState(WXK_TAB)) choiceStatus_->SetFocus(); else if (wxGetKeyState(WXK_UP)) { wxCommandEvent evt(wxEVT_SPIN, wxID_ANY); evt.SetInt(1); this->GetEventHandler()->AddPendingEvent(evt); } else if (wxGetKeyState(WXK_DOWN)) { wxCommandEvent evt(wxEVT_SPIN, wxID_ANY); evt.SetInt(-1); this->GetEventHandler()->AddPendingEvent(evt); } else event.Skip(); }
void EnvironmentSettingsDlg::OnMousewheelModifier(wxKeyEvent& event) { wxString keys; if (wxGetKeyState(WXK_SHIFT)) keys += keys.IsEmpty()?wxT("Shift"):wxT("+Shift"); if (wxGetKeyState(WXK_CONTROL)) keys += keys.IsEmpty()?wxT("Ctrl"):wxT("+Ctrl"); #if defined(__WXMAC__) || defined(__WXCOCOA__) if (wxGetKeyState(WXK_COMMAND)) keys += keys.IsEmpty()?wxT("XCtrl"):wxT("+XCtrl"); #endif if (wxGetKeyState(WXK_ALT)) keys += keys.IsEmpty()?wxT("Alt"):wxT("+Alt"); if (!keys.IsEmpty()) XRCCTRL(*this, "txtMousewheelModifier", wxTextCtrl)->SetValue(keys); }
void DialogAutomationManager::EditScript(AutomationScript *script) { if (!script) { wxMessageBox(_T("DialogAutomationManager::EditScript() called without a valid script object. Sloppy programming? You can probably blame jfs."), _T("Blame Canada!"), wxOK|wxICON_ERROR); return; } wxFileName sfname(script->filename); if (!sfname.FileExists()) { wxMessageBox(_T("The script file \"%s\" does not exist, and thus cannot be edited."), _T("Automation warning"), wxOK|wxICON_WARNING); return; } wxString editor; if (!Options.IsDefined(_T("automation script editor")) || wxGetKeyState(WXK_SHIFT)) { wxMessageBox(_T("You have not selected a script editor yet. Please select your script editor in the next window. It's recommended to use an editor with syntax highlighting for Lua scripts."), _T("Aegisub"), wxOK|wxICON_INFORMATION); #if defined(__WINDOWS__) editor = wxFileSelector(_T("Select script editor"), _T(""), _T("C:\\Windows\\Notepad.exe"), _T("exe"), _T("Execatuables (*.exe)|*.exe|All files (*.*)|*.*"), wxOPEN|wxFILE_MUST_EXIST); #elif defined(__APPLE__) editor = wxFileSelector(_T("Select script editor"), _T(""), _T("/Applications/TextEdit.app"), _T("app"), _T("Applications (*.app)|*.app|All files (*.*)|*.*"), wxOPEN|wxFILE_MUST_EXIST); #else char *env_editor = getenv("EDITOR"); wxString editor(env_editor ? env_editor : "/usr/bin/gvim", wxConvLocal); editor = wxFileSelector(_T("Select script editor"), _T(""), editor, _T(""), _T("All files (*)|*"), wxOPEN|wxFILE_MUST_EXIST); #endif if (editor.empty()) return; Options.SetText(_T("automation script editor"), editor); Options.Save(); } else { editor = Options.AsText(_T("automation script editor")); } wxWCharBuffer editorbuf = editor.c_str(), sfnamebuf = sfname.GetFullPath().c_str(); wchar_t **cmdline = new wchar_t*[5]; #ifndef __APPLE__ cmdline[0] = editorbuf.data(); cmdline[1] = sfnamebuf.data(); cmdline[2] = 0; #else cmdline[0] = _T("/usr/bin/open"); cmdline[1] = _T("-a"); cmdline[2] = editorbuf.data(); cmdline[3] = sfnamebuf.data(); cmdline[4] = 0; #endif long res = wxExecute(cmdline); delete cmdline; if (!res) { wxMessageBox(_T("Some error occurred trying to launch the external editor. Sorry!"), _T("Automation Error"), wxOK|wxICON_ERROR); } }
bool SelectShapesOP::onKeyDown(int keyCode) { if (DrawRectangleOP::onKeyDown(keyCode)) return true; if (keyCode == WXK_DELETE) { m_shapeImpl->removeShapeSelection(); clear(); } else if (wxGetKeyState(WXK_CONTROL_X)) { clearClipboard(); m_selection->traverse(FetchAllVisitor<IShape>(m_clipboard)); for (size_t i = 0, n = m_clipboard.size(); i < n; ++i) m_clipboard[i]->retain(); m_shapeImpl->removeShapeSelection(); } else if (m_lastCtrlPress && (keyCode == 'c' || keyCode == 'C')/*wxGetKeyState(WXK_CONTROL_C)*/) { clearClipboard(); std::vector<PolygonShape*> polys; m_selection->traverse(FetchAllVisitor<PolygonShape>(polys)); for (size_t i = 0, n = polys.size(); i < n; ++i) m_clipboard.push_back(polys[i]->clone()); } else if (wxGetKeyState(WXK_CONTROL_V)) { for (size_t i = 0, n = m_clipboard.size(); i < n; ++i) { m_shapeImpl->insertShape(m_clipboard[i]->clone()); m_editPanel->Refresh(); } } m_lastCtrlPress = keyCode == WXK_CONTROL; return false; }
void mmCalcValidator::OnChar(wxKeyEvent& event) { if (!m_validatorWindow) return event.Skip(); int keyCode = event.GetKeyCode(); // we don't filter special keys and delete if (keyCode < WXK_SPACE || keyCode == WXK_DELETE || keyCode >= WXK_START) return event.Skip(); wxString str((wxUniChar)keyCode, 1); if (!(wxIsdigit(str[0]) || wxString("+-.,*/ ()").Contains(str))) { if ( !wxValidator::IsSilent() ) wxBell(); return; // eat message } // only if it's a wxTextCtrl mmTextCtrl* text_field = wxDynamicCast(m_validatorWindow, mmTextCtrl); if (!m_validatorWindow || !text_field) return event.Skip(); wxChar decChar = text_field->currency_->DECIMAL_POINT[0]; bool numpad_dec_swap = (wxGetKeyState(wxKeyCode(WXK_NUMPAD_DECIMAL)) && decChar != str); if (numpad_dec_swap) str = wxString(decChar); // if decimal point, check if it's already in the string if (str == '.' || str == ',') { const wxString value = text_field->GetValue(); size_t ind = value.rfind(decChar); if (ind < value.Length()) { // check if after last decimal point there is an operation char (+-/*) if (value.find('+', ind + 1) >= value.Length() && value.find('-', ind + 1) >= value.Length() && value.find('*', ind + 1) >= value.Length() && value.find('/', ind + 1) >= value.Length()) return; } } if (numpad_dec_swap) return text_field->WriteText(str); else event.Skip(); }