void CLibraryFolderCtrl::OnLButtonDown(UINT nFlags, CPoint point) { UINT nItemFlags = 0; HTREEITEM hItem = HitTest( point, &nItemFlags ); if ( nItemFlags == TVHT_ONITEMBUTTON ) { CTreeCtrl::OnLButtonDown( nFlags, point ); return; } if ( ( nFlags & MK_CONTROL ) && m_bMultiSelect ) { if ( hItem ) { UINT nNewState = GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ? 0 : TVIS_SELECTED; SetItemState( hItem, nNewState, TVIS_SELECTED ); m_hFirstSelected = NULL; NotifySelectionChanged(); } } else if ( ( nFlags & MK_SHIFT ) && m_bMultiSelect ) { hItem = HitTest( point ); if ( ! m_hFirstSelected ) m_hFirstSelected = GetFirstSelectedItem(); if ( hItem ) SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED ); if ( m_hFirstSelected ) SelectItems( m_hFirstSelected, hItem ); NotifySelectionChanged(); } else { BOOL bChanged = FALSE; BOOL bSelected = hItem && ( GetItemState( hItem, TVIS_SELECTED ) & TVIS_SELECTED ); if ( ! bSelected || ( nFlags & MK_RBUTTON ) == 0 ) { if ( m_bFirstClick && hItem != GetRootItem() ) Select( hItem, TVGN_CARET ); bChanged = ClearSelection( hItem ); m_hFirstSelected = NULL; } if ( hItem && ! bSelected ) { SetItemState( hItem, TVIS_SELECTED, TVIS_SELECTED ); bChanged = TRUE; } if ( bChanged ) NotifySelectionChanged(); } m_bFirstClick = FALSE; SetFocus(); }
FX_BOOL CPDF_FormField::ResetField(FX_BOOL bNotify) { switch (m_Type) { case CPDF_FormField::CheckBox: case CPDF_FormField::RadioButton: { CFX_ByteArray statusArray; if (bNotify && m_pForm->m_pFormNotify != NULL) { SaveCheckedFieldStatus(this, statusArray); } int iCount = CountControls(); if (iCount) { if (PDF_FormField_IsUnison(this)) { for(int i = 0; i < iCount; i++) { CheckControl(i, GetControl(i)->IsDefaultChecked(), FALSE); } } else { for (int i = 0; i < iCount; i ++) { CPDF_FormControl* pControl = GetControl(i); FX_BOOL bChecked = pControl->IsDefaultChecked(); CheckControl(i, bChecked, FALSE); } } } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterCheckedStatusChange(this, statusArray); } } break; case CPDF_FormField::ComboBox: { CFX_WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } if (bNotify && m_pForm->m_pFormNotify != NULL) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterValueChange(this); } } break; case CPDF_FormField::ListBox: { CFX_WideString csValue; ClearSelection(); int iIndex = GetDefaultSelectedItem(); if (iIndex >= 0) { csValue = GetOptionLabel(iIndex); } if (bNotify && m_pForm->m_pFormNotify != NULL) { int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { return FALSE; } } SetItemSelection(iIndex, TRUE); if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } } break; case CPDF_FormField::Text: case CPDF_FormField::RichText: case CPDF_FormField::File: default: { CPDF_Object* pDV = FPDF_GetFieldAttr(m_pDict, "DV"); CFX_WideString csDValue; if (pDV != NULL) { csDValue = pDV->GetUnicodeText(); } CPDF_Object* pV = FPDF_GetFieldAttr(m_pDict, "V"); CFX_WideString csValue; if (pV != NULL) { csValue = pV->GetUnicodeText(); } CPDF_Object* pRV = FPDF_GetFieldAttr(m_pDict, "RV"); if (!pRV && (csDValue == csValue)) { return FALSE; } if (bNotify && m_pForm->m_pFormNotify != NULL) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csDValue); if (iRet < 0) { return FALSE; } } if (pDV == NULL) { m_pDict->RemoveAt("V"); m_pDict->RemoveAt("RV"); } else { CPDF_Object* pClone = pDV->Clone(); if (pClone == NULL) { return FALSE; } m_pDict->SetAt("V", pClone); if(pRV) { CPDF_Object* pCloneR = pDV->Clone(); m_pDict->SetAt("RV", pCloneR); } } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; } break; } return TRUE; }
void CLeftView::UseBothLeftFirst() { if (!IsRightViewGood()) return; int nFirstViewLine = 0; // first view line in selection int nLastViewLine = 0; // last view line in selection if (!IsWritable()) return; if (!GetViewSelection(nFirstViewLine, nLastViewLine)) return; int nNextViewLine = nLastViewLine + 1; // first view line after selected block CUndo::GetInstance().BeginGrouping(); // right original become added for (int viewLine = nFirstViewLine; viewLine <= nLastViewLine; viewLine++) { if (!IsStateEmpty(GetViewState(viewLine))) { SetViewState(viewLine, DIFFSTATE_REMOVED); } } SaveUndoStep(); // your block is done, now insert their block int viewindex = nNextViewLine; for (int viewLine = nFirstViewLine; viewLine <= nLastViewLine; viewLine++) { viewdata line = m_pwndRight->GetViewData(viewLine); if (IsStateEmpty(line.state)) { line.state = DIFFSTATE_EMPTY; } else { if (line.state!=DIFFSTATE_NORMAL) { m_pwndRight->SetViewState(viewLine, DIFFSTATE_NORMAL); line.state = DIFFSTATE_NORMAL; } SetModified(); } InsertViewData(viewindex++, line); } SaveUndoStep(); // now insert an empty block in right view int nCount = nLastViewLine - nFirstViewLine + 1; m_pwndRight->InsertViewEmptyLines(nFirstViewLine, nCount); m_pwndRight->Invalidate(); SaveUndoStep(); // clean up int nRemovedLines = CleanEmptyLines(); SaveUndoStep(); UpdateViewLineNumbers(); SaveUndoStep(); CUndo::GetInstance().EndGrouping(); // final clean up ClearSelection(); SetupAllViewSelection(nFirstViewLine, 2*nLastViewLine - nFirstViewLine - nRemovedLines + 1); BuildAllScreen2ViewVector(); RefreshViews(); }
void gameDialog::render() { static bool first = true; // Only true first time function is called // Clear list of special effects. It will be added again automatically every frame gShadows.Clear(); gFogs.Clear(); gPlayer.UpdatePositionSmooth(); // Can't select objects that are dead if (fSelectedObject && (fSelectedObject->IsDead() || !fSelectedObject->InGame())) ClearSelection(); glm::vec3 playerOffset = gPlayer.GetOffsetToChunk(); gViewMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -fCameraDistance)); gViewMatrix = glm::rotate(gViewMatrix, _angleVert, glm::vec3(1.0f, 0.0f, 0.0f)); gViewMatrix = glm::rotate(gViewMatrix, _angleHor, glm::vec3(0.0f, 1.0f, 0.0f)); gViewMatrix = glm::translate(gViewMatrix, -playerOffset); glm::mat4 T1 = glm::translate(glm::mat4(1), playerOffset); glm::mat4 R1 = glm::rotate(glm::mat4(1), _angleVert, glm::vec3(-1.0f, 0.0f, 0.0f)); glm::mat4 R2 = glm::rotate(glm::mat4(1), _angleHor, glm::vec3(0.0f, -1.0f, 0.0f)); glm::mat4 T2 = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, fCameraDistance)); glm::vec4 camera = T1 * R2 * R1 * T2 * glm::vec4(0,0,0,1); gUniformBuffer.Camera(camera); gDrawnQuads = 0; gNumDraw = 0; gUniformBuffer.Update(); if (first) { gBillboard.InitializeTextures(fShader); } fRenderControl->Draw(fSelectedObject, fUnderWater, this->ThirdPersonView(), fSelectedObject, fDrawMap && !gDebugOpenGL, fMapWidth); //========================================================================= // Various effects drawn after the deferred shader //========================================================================= if (!fDrawMap) { this->DrawPlayerStats(); if (fShowWeapon && gMode.Get() != GameMode::CONSTRUCT && !fShowInventory && !this->ThirdPersonView()) this->DrawWeapon(); static bool wasDead = false; if (gPlayer.IsDead() && !wasDead) { wasDead = true; fShowMainDialog = true; fHideDialog = false; dialog::DispatchDraw(fDrawTexture, 1.0f, new MessageDialog("Oops", "You are dead.\n\nYou will be revived, and transported back to your starting place.\n\nThe place can be changed with a scroll of resurrection point.", revive)); this->ClearForDialog(); } else if (fShowInventory) gInventory.DrawInventory(fDrawTexture); else if (fShowMainDialog) dialog::DispatchDraw(fDrawTexture, fHideDialog ? 0.5f : 1.0f); else if (sgPopup.length() > 0) { // There are some messages that shall be shown in a popup dialog. fShowMainDialog = true; fHideDialog = false; dialog::DispatchDraw(fDrawTexture, 1.0f, new MessageDialog(sgPopupTitle, sgPopup, 0)); sgPopupTitle = "Ephenation"; // Reset to default. sgPopup.clear(); this->ClearForDialog(); } if (!gPlayer.IsDead()) wasDead = false; DrawCompassRose(); } if (fDrawMap && gDebugOpenGL) { // Very inefficient algorithm, computing the map every frame. std::unique_ptr<Map> map(new Map); float alpha = 1.0f; if (!sShowAlternateBitmap) sTextureIterator = gDebugTextures.begin(); glBindTexture(GL_TEXTURE_2D, *sTextureIterator); // Override map->Draw(alpha); } if (fSelectedObject) { fSelectedObject->RenderHealthBar(fHealthBar, _angleHor); } gOtherPlayers.RenderPlayerStats(fHealthBar, _angleHor); bool newHealing = false; if (gPlayer.fFlags & UserFlagHealed) { newHealing = true; gPlayer.fFlags &= ~UserFlagHealed; } this->DrawHealingAnimation(newHealing); char buff[1000]; // TODO: Ugly way to create dynamic strings static double slAverageFps = 0.0; double tm = gCurrentFrameTime; static double prevTime = 0.0; double deltaTime = tm - prevTime; // Use a decay filter on the FPS slAverageFps = 0.97*slAverageFps + 0.03/deltaTime; prevTime = tm; if (gMode.Get() == GameMode::TELEPORT) { TeleportClick(fHealthBar, _angleHor, renderViewAngle, 0, 0, false); } //========================================================================= // Various text messages //========================================================================= { // A big chunk with text drawing. But first some background to improve contrast. int yOffset = Options::fgOptions.fFontSize*2; float totalWinHeight = gViewport[3]; // Measured in pixels glm::mat4 model = glm::translate(glm::mat4(1.0f), glm::vec3(-1.0f, 1.0f - yOffset*2/totalWinHeight, 0.0f)); float yScale = yOffset*2/totalWinHeight; model = glm::scale(model, glm::vec3(2.0f, yScale, 1.0f)); this->fHealthBar->DrawSquare(model, 0.0f, 0.0f, 0.0f, 0.3f); // Draw a black square, almost transparent, as a background gDrawFont.Enable(); gDrawFont.UpdateProjection(); sprintf(buff, "Level %ld, Hp %d%%, Exp %d%%", gPlayer.fLevel, (int)(gPlayer.fHp * 100), (int)(gPlayer.fExp * 100)); gDrawFont.vsfl.prepareSentence(fPlayerStatusSentence, buff); int w = int(strlen(buff)*Options::fgOptions.fFontSize*0.8f); // An approximation gDrawFont.SetOffset(gViewport[2]-w, 0); gDrawFont.vsfl.renderSentence(fPlayerStatusSentence); if (gCurrentPing == 0.0) sprintf(buff, "Triangles %7d, draw calls %d. Fps %03d", gDrawnQuads, gNumDraw, int(slAverageFps)); else sprintf(buff, "Triangles %7d, draw calls %d. Fps %03d, ping %.1f ms", gDrawnQuads, gNumDraw, int(slAverageFps), gCurrentPing*1000.0); gDrawFont.SetOffset(0,0); gDrawFont.vsfl.prepareSentence(fFPSsentence, buff); gDrawFont.vsfl.renderSentence(fFPSsentence); if (gMode.Get() == GameMode::CONSTRUCT) { ChunkCoord cc; gPlayer.GetChunkCoord(&cc); const chunk *cp = ChunkFind(&cc, false); unsigned int uid = 1000000; shared_ptr<ChunkBlocks> cb; if (cp) cb = cp->fChunkBlocks; if (cb) uid = cb->fOwner; gDrawFont.SetOffset(0,float(yOffset)); sprintf(buff, "Construction mode, Chunk (%d,%d,%d) offset: %.1f,%.1f,%.1f, coord(%.1f,%.1f,%.1f) owner %d", cc.x, cc.y, cc.z, playerOffset.x, playerOffset.y, playerOffset.z, gPlayer.x/100.0, gPlayer.y/100.0, gPlayer.z/100.0, uid); gDrawFont.vsfl.renderAndDiscard(buff); } if (fEnterDebugText) { int bottomLine = gViewport[3]-25; gDrawFont.SetOffset(0, float(bottomLine)); gDrawFont.vsfl.renderSentence(fInputPromptSentence); } gDrawFont.Disable(); gScrollingMessages.Update(); } if (!fDrawMap && !fShowInventory && (!fShowMainDialog || fHideDialog)) { if (gShowMsgWindow) gMsgWindow.Render(); if (gMode.Get() == GameMode::CONSTRUCT) fBuildingBlocks->Draw(gProjectionMatrix); } if (gDebugOpenGL) { checkError("gameDialog::render debug", false); static double prevPrint = 0.0; if (gCurrentFrameTime > prevPrint + 5.0) { if (gToggleTesting) WorstTime::Report(); else TimeMeasure::Report(); prevPrint = gCurrentFrameTime; } } chunk::DegradeBusyList_gl(); first = false; }
gd::InstructionsList * EventsEditorSelection::EndDragInstruction(bool deleteDraggedInstruction, bool dropAfterHighlightedElement) { if (!draggingInstruction) return NULL; draggingInstruction = false; //Find where to drag gd::InstructionsList * list = NULL; size_t positionInList = std::string::npos; if ( instructionHighlighted.instructionList != NULL ) { list = instructionHighlighted.instructionList; positionInList = instructionHighlighted.positionInList; if ( instructionHighlighted.event != NULL ) instructionHighlighted.event->eventHeightNeedUpdate = true; else std::cout << "WARNING : Instruction hightlighted event is not valid! " << std::endl; if ( dropAfterHighlightedElement ) positionInList++; } else if ( instructionListHighlighted.instructionList != NULL ) { list = instructionListHighlighted.instructionList; if ( instructionListHighlighted.event != NULL ) instructionListHighlighted.event->eventHeightNeedUpdate = true; else std::cout << "WARNING : Instruction list hightlighted event is not valid! " << std::endl; } else return NULL; //Be sure we do not try to drag inside an instruction selected if (instructionHighlighted.instruction != NULL) { for (std::unordered_set< gd::InstructionItem >::iterator it = instructionsSelected.begin();it!=instructionsSelected.end();++it) { if ( (*it).instruction == NULL ) { std::cout << "WARNING: Bad instr in selection"; continue; } if ( (*it).instruction == instructionHighlighted.instruction || (FindInInstructionsAndSubInstructions((*it).instruction->GetSubInstructions(), instructionHighlighted.instruction)) ) { return NULL; } if (FindInInstructionsAndSubInstructions(instructionHighlighted.instruction->GetSubInstructions(), (*it).instruction) ) { return NULL; } } } //Copy dragged instructions gd::InstructionsList draggedInstructions; for (std::unordered_set< gd::InstructionItem >::iterator it = instructionsSelected.begin();it!=instructionsSelected.end();++it) { if ( (*it).instruction != NULL ) draggedInstructions.Insert(*(*it).instruction); } //Insert dragged instructions into their new list. for (unsigned int i = 0;i<draggedInstructions.size();++i) { if ( positionInList < list->size() ) list->Insert(draggedInstructions[i], positionInList); else list->Insert(draggedInstructions[i]); } if ( deleteDraggedInstruction ) { //Update selection as some selected instruction can have become invalid std::unordered_set< gd::InstructionItem > newInstructionsSelected; for (std::unordered_set< gd::InstructionItem >::iterator it = instructionsSelected.begin();it!=instructionsSelected.end();++it) { if ((*it).instructionList == instructionHighlighted.instructionList && (*it).positionInList > instructionHighlighted.positionInList) { gd::InstructionItem newItem = (*it); newItem.instruction = NULL; newItem.positionInList += draggedInstructions.size(); newInstructionsSelected.insert(newItem); } else newInstructionsSelected.insert(*it); } instructionsSelected = newInstructionsSelected; //Remove dragged instructions DeleteAllInstructionSelected(); } ClearSelection(); return list; }
bool CTelnetView::OnKeyDown(GdkEventKey* evt) { INFO("CTelnetView::OnKeyDown (keyval=0x%x, state=0x%x)", evt->keyval, evt->state); CTermCharAttr* pAttr = m_pTermData->GetLineAttr( m_pTermData->m_Screen[m_pTermData->m_CaretPos.y] ); int x = m_pTermData->m_CaretPos.x; bool clear = true; bool reconnect = false; if( evt->keyval < 127 && GDK_MODIFIER_DOWN(evt->state, GDK_CONTROL_MASK))// Ctrl down { char ch = toupper(char(evt->keyval)); if( ch >= '@' && ch <= '_' && !isdigit(ch) ) { // clear the old selection if (!m_pTermData->m_Sel->Empty()) ClearSelection(); ch -= '@'; GetCon()->SendRawString(&ch,1); return true; } } switch(evt->keyval) { case GDK_Left: case GDK_KP_Left: LeaveWrapper(GetCon(), pAttr, x); break; case GDK_Right: case GDK_KP_Right: EnterWrapper(GetCon(), pAttr, x); break; case GDK_Up: case GDK_KP_Up: GetCon()->SendString("\x1bOA"); break; case GDK_Down: case GDK_KP_Down: GetCon()->SendString("\x1bOB"); break; case GDK_BackSpace: if (GetCon()->DetectDBChar() && x > 0 && pAttr[x-1].GetCharSet() == CTermCharAttr::CS_MBCS2) GetCon()->SendString("\b\b"); else GetCon()->SendString("\b"); break; case GDK_Return: case GDK_KP_Enter: reconnect = GetCon()->IsClosed(); GetCon()->SendString("\r"); break; case GDK_Delete: case GDK_KP_Delete: if (GetCon()->DetectDBChar() && pAttr[x].GetCharSet() == CTermCharAttr::CS_MBCS1) GetCon()->SendString("\x1b[3~\x1b[3~"); else GetCon()->SendString("\x1b[3~"); break; case GDK_Insert: case GDK_KP_Insert: GetCon()->SendString("\x1b[2~"); break; case GDK_Home: case GDK_KP_Home: GetCon()->SendString("\x1b[1~"); break; case GDK_End: case GDK_KP_End: GetCon()->SendString("\x1b[4~"); break; // case GDK_Prior: case GDK_Page_Up: case GDK_KP_Page_Up: GetCon()->SendString("\x1b[5~"); break; // case GDK_Next: case GDK_Page_Down: case GDK_KP_Page_Down: GetCon()->SendString("\x1b[6~"); break; case GDK_Tab: GetCon()->SendString("\t"); break; case GDK_Escape: GetCon()->SendString("\x1b"); break; // F1-F12 keys case GDK_F1: case GDK_KP_F1: GetCon()->SendString("\x1bOP"); break; case GDK_F2: case GDK_KP_F2: GetCon()->SendString("\x1bOQ"); break; case GDK_F3: case GDK_KP_F3: GetCon()->SendString("\x1bOR"); break; case GDK_F4: case GDK_KP_F4: GetCon()->SendString("\x1bOS"); break; case GDK_F5: GetCon()->SendString("\x1b[15~"); break; case GDK_F6: GetCon()->SendString("\x1b[17~"); break; case GDK_F7: GetCon()->SendString("\x1b[18~"); break; case GDK_F8: GetCon()->SendString("\x1b[19~"); break; case GDK_F9: GetCon()->SendString("\x1b[20~"); break; case GDK_F10: GetCon()->SendString("\x1b[21~"); break; case GDK_F11: GetCon()->SendString("\x1b[23~"); break; case GDK_F12: GetCon()->SendString("\x1b[24~"); break; default: clear = false; } // Only clear selection if we handled the key if (clear) ClearSelection(); if (reconnect) GetCon()->Reconnect(); return true; }
int PL_SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { // Main loop: keep receiving events while( OPT_TOOL_EVENT evt = Wait() ) { // Should selected items be added to the current selection or // become the new selection (discarding previously selected items) m_additive = evt->Modifier( MD_SHIFT ); // Should selected items be REMOVED from the current selection? // This will be ignored if the SHIFT modifier is pressed m_subtractive = !m_additive && evt->Modifier( MD_CTRL ); // Is the user requesting that the selection list include all possible // items without removing less likely selection candidates m_skip_heuristics = !!evt->Modifier( MD_ALT ); // Single click? Select single object if( evt->IsClick( BUT_LEFT ) ) { // If no modifier keys are pressed, clear the selection if( !m_additive ) ClearSelection(); SelectPoint( evt->Position()); } // right click? if there is any object - show the context menu else if( evt->IsClick( BUT_RIGHT ) ) { bool selectionCancelled = false; if( m_selection.Empty() ) { SelectPoint( evt->Position(), &selectionCancelled ); m_selection.SetIsHover( true ); } if( !selectionCancelled ) m_menu.ShowContextMenu( m_selection ); } // double click? Display the properties window else if( evt->IsDblClick( BUT_LEFT ) ) { // No double-click actions currently defined } // drag with LMB? Select multiple objects (or at least draw a selection box) or drag them else if( evt->IsDrag( BUT_LEFT ) ) { if( m_additive || m_subtractive || m_selection.Empty() ) { selectMultiple(); } else { // Check if dragging has started within any of selected items bounding box if( selectionContains( evt->Position() ) ) { // Yes -> run the move tool and wait till it finishes m_toolMgr->InvokeTool( "plEditor.InteractiveEdit" ); } else { // No -> clear the selection list ClearSelection(); } } } else if( evt->IsAction( &ACTIONS::cancelInteractive ) || evt->IsCancel() ) { ClearSelection(); } else if( evt->Action() == TA_UNDO_REDO_PRE ) { ClearSelection(); } else if( evt->Action() == TA_CONTEXT_MENU_CLOSED ) { m_menu.CloseContextMenu( evt ); } else m_toolMgr->PassEvent(); } // This tool is supposed to be active forever assert( false ); return 0; }
const char *idListWindow::HandleEvent( const sysEvent_t *event, bool *updateVisuals ) { // need to call this to allow proper focus and capturing on embedded children const char *ret = idWindow::HandleEvent( event, updateVisuals ); float vert = GetMaxCharHeight(); int numVisibleLines = textRect.h / vert; int key = event->evValue; if( event->evType == SE_KEY ) { if( !event->evValue2 ) { // We only care about key down, not up return ret; } if( key == K_MOUSE1 || key == K_MOUSE2 ) { // If the user clicked in the scroller, then ignore it if( scroller->Contains( gui->CursorX(), gui->CursorY() ) ) { return ret; } } if( ( key == K_ENTER || key == K_KP_ENTER ) ) { RunScript( ON_ENTER ); return cmd; } if( key == K_MWHEELUP ) { key = K_UPARROW; } else if( key == K_MWHEELDOWN ) { key = K_DOWNARROW; } if( key == K_MOUSE1 ) { if( Contains( gui->CursorX(), gui->CursorY() ) ) { int cur = ( int )( ( gui->CursorY() - actualY - pixelOffset ) / vert ) + top; if( cur >= 0 && cur < listItems.Num() ) { if( multipleSel && idKeyInput::IsDown( K_CTRL ) ) { if( IsSelected( cur ) ) { ClearSelection( cur ); } else { AddCurrentSel( cur ); } } else { if( IsSelected( cur ) && ( gui->GetTime() < clickTime + doubleClickSpeed ) ) { // Double-click causes ON_ENTER to get run RunScript( ON_ENTER ); return cmd; } SetCurrentSel( cur ); clickTime = gui->GetTime(); } } else { SetCurrentSel( listItems.Num() - 1 ); } } } else if( key == K_UPARROW || key == K_PGUP || key == K_DOWNARROW || key == K_PGDN ) { int numLines = 1; if( key == K_PGUP || key == K_PGDN ) { numLines = numVisibleLines / 2; } if( key == K_UPARROW || key == K_PGUP ) { numLines = -numLines; } if( idKeyInput::IsDown( K_CTRL ) ) { top += numLines; } else { SetCurrentSel( GetCurrentSel() + numLines ); } } else { return ret; } } else if( event->evType == SE_CHAR ) { if( !idStr::CharIsPrintable( key ) ) { return ret; } if( gui->GetTime() > typedTime + 1000 ) { typed = ""; } typedTime = gui->GetTime(); typed.Append( key ); for( int i = 0; i < listItems.Num(); i++ ) { if( idStr::Icmpn( typed, listItems[i], typed.Length() ) == 0 ) { SetCurrentSel( i ); break; } } } else { return ret; } if( GetCurrentSel() < 0 ) { SetCurrentSel( 0 ); } if( GetCurrentSel() >= listItems.Num() ) { SetCurrentSel( listItems.Num() - 1 ); } if( scroller->GetHigh() > 0.0f ) { if( !idKeyInput::IsDown( K_CTRL ) ) { if( top > GetCurrentSel() - 1 ) { top = GetCurrentSel() - 1; } if( top < GetCurrentSel() - numVisibleLines + 2 ) { top = GetCurrentSel() - numVisibleLines + 2; } } if( top > listItems.Num() - 2 ) { top = listItems.Num() - 2; } if( top < 0 ) { top = 0; } scroller->SetValue( top ); } else { top = 0; scroller->SetValue( 0.0f ); } if( key != K_MOUSE1 ) { // Send a fake mouse click event so onAction gets run in our parents const sysEvent_t ev = sys->GenerateMouseButtonEvent( 1, true ); idWindow::HandleEvent( &ev, updateVisuals ); } if( currentSel.Num() > 0 ) { for( int i = 0; i < currentSel.Num(); i++ ) { gui->SetStateInt( va( "%s_sel_%i", listName.c_str(), i ), currentSel[i] ); } } else { gui->SetStateInt( va( "%s_sel_0", listName.c_str() ), 0 ); } gui->SetStateInt( va( "%s_numsel", listName.c_str() ), currentSel.Num() ); return ret; }
int ListBox::OnLButtonDown(int x, int y) { if (!captured) captured = SetCapture(); mouse_x = x - rect.x; mouse_y = y - rect.y; int x_scroll_bar = rect.w; if (IsScrollVisible()) x_scroll_bar -= SCROLL_WIDTH; if (mouse_x < x_scroll_bar) { scrolling = SCROLL_NONE; if (show_headings && mouse_y < line_height+BORDER_WIDTH+EXTRA_WIDTH) { int next_col_start = 0; int max_column = columns.size()-1; int column; for (column = 0; column < max_column; column++) { next_col_start += GetColumnWidth(column); if (mouse_x < next_col_start) break; } sort_column = column; int& sort_criteria = columns[sort_column]->sort; if (sort_criteria != LIST_SORT_NEVER) { if (!sort_criteria) sort_criteria = LIST_SORT_ALPHA_DESCENDING; else sort_criteria = -sort_criteria; SortItems(); } } else { selecting = true; } } else { selecting = false; if (mouse_y < TRACK_START) { scrolling = SCROLL_UP; Scroll(scrolling, 1); Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y > rect.h-TRACK_START) { scrolling = SCROLL_DOWN; if (top_index < items.size()-1) top_index++; Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y < thumb_pos) { scrolling = SCROLL_PAGE_UP; Scroll(scrolling, page_size); Button::PlaySound(Button::SND_LIST_SCROLL); } else if (mouse_y > thumb_pos+THUMB_HEIGHT) { scrolling = SCROLL_PAGE_DOWN; Scroll(scrolling, page_size); Button::PlaySound(Button::SND_LIST_SCROLL); } else { scrolling = SCROLL_THUMB; } } if (selecting) { list_index = IndexFromPoint(mouse_x, mouse_y); preselected = IsSelected(list_index); if (!multiselect || !Keyboard::KeyDown(VK_SHIFT)) ClearSelection(); SetSelected(list_index); EnsureVisible(list_index); Button::PlaySound(Button::SND_LIST_SELECT); } return ActiveWindow::OnLButtonDown(x,y); }
BOOL StartGame(void) { char buf[1024]; extern void *screen; int i; StopMenuMusic(); D(bug("Before FreeMenuStuff()\n")); FreeMenuStuff(); D(bug("After FreeMenuStuff()\n")); for(i=0;i<ARCADE_TEAMS+1;i++) arcade_gfx[i]=NULL; os_stop_audio(); game_start=TRUE; game_main(); if(network_game) { network_game=FALSE; free_network(); } { SDL_Event e; while(SDL_PollEvent(&e)); } game_start = FALSE; snprintf(buf, 1024, "%sthismatch", TEMP_DIR); #ifdef __CODEGUARD__ if(access(buf,0) != -1) #endif remove(buf/*-*/); WINDOW_WIDTH=wanted_width; WINDOW_HEIGHT=wanted_height; OpenMenuScreen(); SDL_ShowCursor(1); if(!screen || !(LoadMenuStuff())) { request("Unable to load the menu datas!"); return FALSE; } os_start_audio(); if(arcade_teams) LoadArcadeGfx(); ClearSelection(); return TRUE; }
long wxWebViewWebKit::Find(const wxString& text, int flags) { bool newSearch = false; if(text != m_findText || (flags & wxWEBVIEW_FIND_MATCH_CASE) != (m_findFlags & wxWEBVIEW_FIND_MATCH_CASE)) { newSearch = true; //If it is a new search we need to clear existing highlights webkit_web_view_unmark_text_matches(m_web_view); webkit_web_view_set_highlight_text_matches(m_web_view, false); } m_findFlags = flags; m_findText = text; //If the search string is empty then we clear any selection and highlight if(text == "") { webkit_web_view_unmark_text_matches(m_web_view); webkit_web_view_set_highlight_text_matches(m_web_view, false); ClearSelection(); return wxNOT_FOUND; } bool wrap = false, matchCase = false, forward = true; if(flags & wxWEBVIEW_FIND_WRAP) wrap = true; if(flags & wxWEBVIEW_FIND_MATCH_CASE) matchCase = true; if(flags & wxWEBVIEW_FIND_BACKWARDS) forward = false; if(newSearch) { //Initially we mark the matches to know how many we have m_findCount = webkit_web_view_mark_text_matches(m_web_view, wxGTK_CONV(text), matchCase, 0); //In this case we return early to match IE behaviour m_findPosition = -1; return m_findCount; } else { if(forward) m_findPosition++; else m_findPosition--; if(m_findPosition < 0) m_findPosition += m_findCount; if(m_findPosition > m_findCount) m_findPosition -= m_findCount; } //Highlight them if needed bool highlight = flags & wxWEBVIEW_FIND_HIGHLIGHT_RESULT ? true : false; webkit_web_view_set_highlight_text_matches(m_web_view, highlight); if(!webkit_web_view_search_text(m_web_view, wxGTK_CONV(text), matchCase, forward, wrap)) { m_findPosition = -1; ClearSelection(); return wxNOT_FOUND; } wxLogMessage(wxString::Format("Returning %d", m_findPosition)); return newSearch ? m_findCount : m_findPosition; }
// LR 1.66 -- complete rewrite (basically) of this entire routine...it was UGLY! OSStatus HandleMenu( long mSelect, short modifiers ) { short menuID = HiWord( mSelect ); short menuItem = LoWord( mSelect ); short colorResID; WindowRef frontWindow; DialogPtr dlgRef = NULL; EditWindowPtr dWin = NULL; Str255 currentWindowName, newFrontWindowName; // NS: v1.6.6, for window menu WindowRef currentWindow; // NS: this too // Predetermine what type of window we have to work with frontWindow = FrontNonFloatingWindow(); if( frontWindow ) { DialogPtr dlg = GetDialogFromWindow( frontWindow ); if( kHexEditWindowTag == GetWindowKind( frontWindow ) ) dWin = (EditWindowPtr) GetWRefCon( frontWindow ); else if( g.gotoDlg == dlg || g.searchDlg == dlg ) dlgRef = dlg; } switch( menuID ) { case kAppleMenu: if( menuItem == AM_About ) HexEditAboutBox(); #if !TARGET_API_MAC_CARBON else { GrafPtr savePort; Str255 name; GetPort( &savePort ); GetMenuItemText( appleMenu, menuItem, name ); OpenDeskAcc( name ); SetPort( savePort ); } #endif break; case kFileMenu: switch( menuItem ) { case FM_New: gPrefs.overwrite = false; //LR 190 -- overwrite mode makes no sense in a new document NewEditWindow(); break; case FM_Open: AskEditWindow( kWindowNormal ); break; // HR/LR 050328 - Handle FM_Disassemble menu item case FM_Disassemble: g.disassemble = !g.disassemble; if ( g.disassemble ) { dWin->drawMode = DM_Disassembly; dWin->bytesPerLine = kDisBytesPerLine; dWin->hexStart = kDisHexStart; dWin->asciiStart = kDisASCIIStart; } else { dWin->drawMode = DM_Dump; dWin->bytesPerLine = kHexBytesPerLine; dWin->hexStart = kHexHexStart; dWin->asciiStart = kHexASCIIStart; } /* Make sure the editOffset position starts on a new line */ dWin->editOffset -= dWin->editOffset % dWin->bytesPerLine; UpdateEditWindows(); break; case FM_OtherFork: // LR: I want to see both! if( dWin ) { short fork; //LR 180 EditWindowPtr ewin; if( dWin->fork == FT_Data ) fork = FT_Resource; else fork = FT_Data; /*LR 180 -- OpenEditWindow checks for this if( NULL != (ewin = LocateEditWindow( &dWin->fsSpec, fork )) ) // LR: 1.7 - boolean typecast causes failure! { SelectWindow( ewin->oWin.theWin ); // just select existing theWin } else // try to open other fork in new theWin! */ { g.forkMode = fork; OpenEditWindow( &dWin->fsSpec, kWindowNormal, true ); } } break; case FM_CompareFiles: //LR 180 -- now pass in modifiers to allow select override if( GetCompareFiles( modifiers ) ) DoComparison(); break; //LR: 1.66 - NOTE: dWin == NULL == frontWindow! case FM_Save: if( dWin && dWin->oWin.Save ) dWin->oWin.Save( frontWindow ); break; case FM_SaveAs: if( dWin && dWin->oWin.SaveAs ) dWin->oWin.SaveAs( frontWindow ); break; case FM_Revert: if( dWin && dWin->oWin.Revert ) //LR 1.72 -- check before reverting (could be dangerous!) { ParamText( dWin->fsSpec.name, NULL, NULL, NULL ); switch( CautionAlert( alertRevert, NULL ) ) { case ok: dWin->oWin.Revert( frontWindow ); break; } } break; case FM_Close: if( dWin ) CloseEditWindow( frontWindow ); else if( dlgRef ) { HideWindow( frontWindow ); //LR: 1.7 -- no need.GetDialogWindow( dlgRef ) ); } break; case FM_Quit: if( CloseAllEditWindows() ) g.quitFlag = true; break; case FM_PageSetup: #if TARGET_API_MAC_CARBON // sel - carbon session based printing _doPageSetupDialog(&g.pageFormat); #else PrOpen(); PrStlDialog( g.HPrint ); PrClose(); #endif break; case FM_Print: if( dWin ) PrintWindow( dWin ); break; } break; case kEditMenu: #if !TARGET_API_MAC_CARBON if( !SystemEdit( menuItem -1 ) ) #endif { if( dWin ) switch( menuItem ) { case EM_Undo: UndoOperation(); break; case EM_Cut: CutSelection( dWin ); break; case EM_Copy: CopySelection( dWin ); break; case EM_Paste: PasteSelection( dWin ); break; case EM_Clear: ClearSelection( dWin ); break; case EM_SelectAll: dWin->startSel = 0; dWin->endSel = dWin->fileSize; UpdateOnscreen( dWin->oWin.theWin ); break; } else if( dlgRef ) switch( menuItem ) { case EM_Cut: DialogCut( dlgRef ); TEToScrap(); break; case EM_Copy: DialogCopy( dlgRef ); TEToScrap(); break; case EM_Paste: TEFromScrap(); DialogPaste( dlgRef ); break; case EM_Clear: DialogDelete( dlgRef ); break; case EM_SelectAll: break; } } break; case kFindMenu: switch ( menuItem ) { case SM_Find: openfind: OpenSearchDialog(); break; case SM_FindForward: gPrefs.searchForward = true; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window, if any (allows search in find dialog) break; case SM_FindBackward: gPrefs.searchForward = false; PerformTextSearch( dWin, kSearchUpdateUI ); //LR 190 -- if dWin is NULL will operate on first edit window break; case SM_Replace: //LR 190 -- add replace & find next (must have a window with selection to start!) if( !dWin ) dWin = FindFirstEditWindow(); // allow this to work in find dialog, etc. if( dWin && dWin->startSel != dWin->endSel ) { EditChunk **replaceChunk; if( !g.searchBuffer[0] ) // if nothing to find open dialog goto openfind; replaceChunk = NewChunk( g.replaceText[0], 0, 0, CT_Unwritten ); if( replaceChunk ) { // Copy replacement text to chunk buffer BlockMoveData( g.replaceText+1, *(*replaceChunk)->data, g.replaceText[0] ); // Do the replacement (with undo) g.replaceAll = false; RememberOperation( dWin, EO_Paste, &gUndo ); PasteOperation( dWin, replaceChunk ); // We're done with the chunk now DisposeChunk( NULL, replaceChunk ); } // Then try to find the next occurance (in LAST direction searched!) and display it if( !PerformTextSearch( dWin, kSearchUpdateUI ) ) ScrollToSelection( dWin, dWin->startSel, true ); } break; case SM_GotoAddress: OpenGotoAddress(); break; } break; case kOptionsMenu: switch ( menuItem ) { case OM_HiAscii: gPrefs.asciiMode = !gPrefs.asciiMode; if( gPrefs.asciiMode ) g.highChar = 0xFF; else g.highChar = 0x7F; UpdateEditWindows(); break; case OM_DecimalAddr: gPrefs.decimalAddr = !gPrefs.decimalAddr; UpdateEditWindows(); break; case OM_Backups: gPrefs.backupFlag = !gPrefs.backupFlag; break; case OM_WinSize: gPrefs.constrainSize = !gPrefs.constrainSize; break; case OM_Overwrite: gPrefs.overwrite = !gPrefs.overwrite; break; case OM_NonDestructive: gPrefs.nonDestructive = !gPrefs.nonDestructive; break; case OM_MoveOnlyPaging: gPrefs.moveOnlyPaging = !gPrefs.moveOnlyPaging; break; case OM_Unformatted: gPrefs.formatCopies = !gPrefs.formatCopies; break; case OM_VertBars: gPrefs.vertBars = !gPrefs.vertBars; UpdateEditWindows(); break; case OM_ComparePref: // LR: compare options ComparisonPreferences(); break; case OM_OpenOnLaunch: gPrefs.dialogAtLaunch = !gPrefs.dialogAtLaunch; //LR -- 192 break; } break; // LR: Add color scheme menu case kColorMenu: colorResID = GetColorMenuResID( menuItem ); if( menuItem == CM_UseColor ) { gPrefs.useColor = !gPrefs.useColor; // toggle color usage } else if( dWin && dWin->csResID > 0 ) // can't color B&W windows! { if( _cmCheckedItem ) CheckMenuItem( colorMenu, _cmCheckedItem, false ); if( (modifiers & optionKey) ) // option down == change all windows (set default color) { EditWindowPtr eWin = FindFirstEditWindow(); while( eWin ) { if( GetWindowKind( eWin->oWin.theWin ) == kHexEditWindowTag ) { eWin->csResID = colorResID; eWin->csMenuID = menuItem; //LR 181 -- for menu tagging } eWin = FindNextEditWindow( eWin ); } goto savepref; } else //LR 181 -- default is (back) to changing color of a single window! { if( GetWindowKind( dWin->oWin.theWin ) == kHexEditWindowTag ) { dWin->csResID = colorResID; dWin->csMenuID = menuItem; //LR 181 -- for menu tagging } } } else { savepref: //LR 190 -- no window open == set preferred color gPrefs.csResID = colorResID; //LR 180 -- save prefs when changing all gPrefs.csMenuID = menuItem; } UpdateEditWindows(); break; // LR : 1.7 - rewrite with bug checking (could crash accessing NULL window) case kWindowMenu: GetMenuItemText( windowMenu, menuItem, newFrontWindowName ); currentWindow = FrontNonFloatingWindow(); while( currentWindow ) { GetWTitle( currentWindow, currentWindowName ); if( EqualPStrings( currentWindowName, newFrontWindowName ) ) { SelectWindow( currentWindow ); break; } currentWindow = GetNextWindow( currentWindow ); } break; } HiliteMenu( 0 ); AdjustMenus(); return( noErr ); }
void StyledTextBox::OnKeyPressed(wxKeyEvent& keyEvent) { bool eventHandled = false; int keycode = keyEvent.GetKeyCode(); int originalCursorPosition = GetCursorPosition(); // Used to indicate there was a cursor navigation event bool navigationEvent = false; if (keyEvent.GetModifiers() & wxMOD_SHIFT) { EnsureSelectionStarted(); } // Select All if (keyEvent.ControlDown() && keycode == 'A') { SetCursorPosition(GetText().Length()); SetSelection(0, 0); SetSelectionEnd(GetCursorPosition()); eventHandled = true; } // Copy if (keyEvent.ControlDown() && keycode == 'C') { if (wxTheClipboard->Open()) { wxTheClipboard->SetData(new wxTextDataObject(GetSelectedText())); wxTheClipboard->Close(); } eventHandled = true; } // Paste if (keyEvent.ControlDown() && keycode == 'V') { if (wxTheClipboard->Open()) { if (wxTheClipboard->IsSupported(wxDF_TEXT)) { wxTextDataObject data; wxTheClipboard->GetData(data); if (HasSelectedText()) { RemoveSelectedText(); } auto text = GetText(); text.insert(GetCursorPosition(), data.GetText()); SetText(text); SetCursorPosition(GetCursorPosition() + data.GetText().Length()); } wxTheClipboard->Close(); } } if (keycode == WXK_BACK) { if (HasSelectedText()) { RemoveSelectedText(); } else if (GetCursorPosition() > 0) { auto text = GetStdText(); auto eraseStart = begin(text) + GetCursorPosition() - 1; auto eraseEnd = eraseStart + 1; text.erase(eraseStart, eraseEnd); SetText(text); SetCursorPosition(GetCursorPosition() - 1); } eventHandled = true; navigationEvent = true; } if (keycode == WXK_DELETE) { if (HasSelectedText()) { RemoveSelectedText(); } else if (GetCursorPosition() < GetText().Length()) { auto text = GetStdText(); auto eraseStart = begin(text) + GetCursorPosition(); auto eraseEnd = eraseStart + 1; text.erase(eraseStart, eraseEnd); SetText(text); } return; } if (keycode == WXK_LEFT) { if (GetCursorPosition() > 0) { SetCursorPosition(GetCursorPosition() - 1); } eventHandled = true; navigationEvent = true; } if (keycode == WXK_RIGHT) { if (GetCursorPosition() < GetText().Length()) { SetCursorPosition(GetCursorPosition() + 1); } eventHandled = true; navigationEvent = true; } if (keycode == WXK_END) { SetCursorPosition(GetText().Length()); eventHandled = true; navigationEvent = true; } if (keycode == WXK_HOME) { SetCursorPosition(0); eventHandled = true; navigationEvent = true; } if (keyEvent.GetModifiers() & wxMOD_SHIFT) { SetSelectionEnd(GetCursorPosition()); } else { if (navigationEvent) { ClearSelection(); } } if (!eventHandled) { keyEvent.Skip(); } Refresh(); }
FX_BOOL CPDF_FormField::SetValue(const CFX_WideString& value, FX_BOOL bDefault, FX_BOOL bNotify) { switch (m_Type) { case CheckBox: case RadioButton: { SetCheckValue(value, bDefault, bNotify); return TRUE; } case File: case RichText: case Text: case ComboBox: { CFX_WideString csValue = value; if (bNotify && m_pForm->m_pFormNotify != NULL) { int iRet = m_pForm->m_pFormNotify->BeforeValueChange(this, csValue); if (iRet < 0) { return FALSE; } } int iIndex = FindOptionValue(csValue); if (iIndex < 0) { CFX_ByteString bsEncodeText = PDF_EncodeText(csValue); m_pDict->SetAtString(bDefault ? "DV" : "V", bsEncodeText); if (m_Type == RichText && !bDefault) { m_pDict->SetAtString("RV", bsEncodeText); } m_pDict->RemoveAt("I"); } else { m_pDict->SetAtString(bDefault ? "DV" : "V", PDF_EncodeText(csValue)); if (bDefault) { } else { ClearSelection(); SetItemSelection(iIndex, TRUE); } } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterValueChange(this); } m_pForm->m_bUpdated = TRUE; } break; case ListBox: { int iIndex = FindOptionValue(value); if (iIndex < 0) { return FALSE; } if (bDefault && iIndex == GetDefaultSelectedItem()) { return FALSE; } if (bNotify && m_pForm->m_pFormNotify != NULL) { CFX_WideString csValue = value; int iRet = m_pForm->m_pFormNotify->BeforeSelectionChange(this, csValue); if (iRet < 0) { return FALSE; } } if (bDefault) { } else { ClearSelection(); SetItemSelection(iIndex, TRUE); } if (bNotify && m_pForm->m_pFormNotify != NULL) { m_pForm->m_pFormNotify->AfterSelectionChange(this); } m_pForm->m_bUpdated = TRUE; break; } default: break; } if (CPDF_InterForm::m_bUpdateAP) { UpdateAP(NULL); } return TRUE; }
int PL_SELECTION_TOOL::ClearSelection( const TOOL_EVENT& aEvent ) { ClearSelection(); return 0; }
void HKStringEntryLogic::Update() { bool shiftL = !!MFInput_Read(Key_LShift, IDD_Keyboard); bool shiftR = !!MFInput_Read(Key_RShift, IDD_Keyboard); bool ctrlL = !!MFInput_Read(Key_LControl, IDD_Keyboard); bool ctrlR = !!MFInput_Read(Key_RControl, IDD_Keyboard); int keyPressed = 0; bool shift = shiftL || shiftR; bool ctrl = ctrlL || ctrlR; #if defined(MF_WINDOWS) if(ctrl && MFInput_WasPressed(Key_C, IDD_Keyboard) && selectionStart != selectionEnd) { BOOL opened = OpenClipboard(apphWnd); if(opened) { int selMin = MFMin(selectionStart, selectionEnd); int selMax = MFMax(selectionStart, selectionEnd); int numChars = selMax-selMin; HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, numChars + 1); char *pString = (char*)GlobalLock(hData); MFString_Copy(pString, GetRenderString().SubStr(selMin, numChars).CStr()); GlobalUnlock(hData); EmptyClipboard(); SetClipboardData(CF_TEXT, hData); CloseClipboard(); } } else if(ctrl && MFInput_WasPressed(Key_X, IDD_Keyboard) && selectionStart != selectionEnd) { BOOL opened = OpenClipboard(apphWnd); if(opened) { int selMin = MFMin(selectionStart, selectionEnd); int selMax = MFMax(selectionStart, selectionEnd); int numChars = selMax-selMin; HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, numChars + 1); char *pString = (char*)GlobalLock(hData); MFString_Copy(pString, GetRenderString().SubStr(selMin, numChars).CStr()); GlobalUnlock(hData); EmptyClipboard(); SetClipboardData(CF_TEXT, hData); CloseClipboard(); ClearSelection(); } } else if(ctrl && MFInput_WasPressed(Key_V, IDD_Keyboard)) { BOOL opened = OpenClipboard(apphWnd); if(opened) { int selMin = MFMin(selectionStart, selectionEnd); int selMax = MFMax(selectionStart, selectionEnd); int numChars = selMax-selMin; HANDLE hData = GetClipboardData(CF_TEXT); MFString paste((const char*)GlobalLock(hData), true); buffer.Replace(selMin, numChars, paste); GlobalUnlock(hData); cursorPos = selMin + paste.NumBytes(); selectionStart = selectionEnd = cursorPos; GlobalUnlock(hData); CloseClipboard(); if((numChars || cursorPos != selMin) && changeCallback) changeCallback(buffer.CStr()); } } else #endif { // check for new keypresses for(int a=0; a<255; a++) { if(MFInput_WasPressed(a, IDD_Keyboard)) { keyPressed = a; holdKey = a; repeatDelay = gRepeatDelay; break; } } // handle repeat keys if(holdKey && MFInput_Read(holdKey, IDD_Keyboard)) { repeatDelay -= MFSystem_TimeDelta(); if(repeatDelay <= 0.f) { keyPressed = holdKey; repeatDelay += gRepeatRate; } } else holdKey = 0; // if there was a new key press if(keyPressed) { switch(keyPressed) { case Key_Backspace: case Key_Delete: { if(selectionStart != selectionEnd) { ClearSelection(); } else { if(keyPressed == Key_Backspace && cursorPos > 0) { buffer.ClearRange(--cursorPos, 1); selectionStart = selectionEnd = cursorPos; if(changeCallback) changeCallback(buffer.CStr()); } else if(keyPressed == Key_Delete && cursorPos < buffer.NumBytes()) { buffer.ClearRange(cursorPos, 1); selectionStart = selectionEnd = cursorPos; if(changeCallback) changeCallback(buffer.CStr()); } } break; } case Key_Left: case Key_Right: case Key_Home: case Key_End: { if(ctrl) { if(keyPressed == Key_Left) { while(cursorPos && MFIsWhite(buffer[cursorPos-1])) --cursorPos; if(MFIsAlphaNumeric(buffer[cursorPos-1])) { while(cursorPos && MFIsAlphaNumeric(buffer[cursorPos-1])) --cursorPos; } else if(cursorPos) { --cursorPos; while(cursorPos && buffer[cursorPos-1] == buffer[cursorPos]) --cursorPos; } } else if(keyPressed == Key_Right) { while(cursorPos < buffer.NumBytes() && MFIsWhite(buffer[cursorPos])) ++cursorPos; if(MFIsAlphaNumeric(buffer[cursorPos])) { while(cursorPos < buffer.NumBytes() && MFIsAlphaNumeric(buffer[cursorPos])) ++cursorPos; } else if(cursorPos < buffer.NumBytes()) { ++cursorPos; while(cursorPos < buffer.NumBytes() && buffer[cursorPos] == buffer[cursorPos-1]) ++cursorPos; } } else if(keyPressed == Key_Home) cursorPos = 0; else if(keyPressed == Key_End) cursorPos = buffer.NumBytes(); } else { if(keyPressed == Key_Left) cursorPos = (!shift && selectionStart != selectionEnd ? MFMin(selectionStart, selectionEnd) : MFMax(cursorPos-1, 0)); else if(keyPressed == Key_Right) cursorPos = (!shift && selectionStart != selectionEnd ? MFMax(selectionStart, selectionEnd) : MFMin(cursorPos+1, buffer.NumBytes())); else if(keyPressed == Key_Home) cursorPos = 0; // TODO: if multiline, go to start of line.. else if(keyPressed == Key_End) cursorPos = buffer.NumBytes(); // TODO: if multiline, go to end of line... } if(shift) selectionEnd = cursorPos; else selectionStart = selectionEnd = cursorPos; break; } default: { bool caps = MFInput_GetKeyboardStatusState(KSS_CapsLock); int ascii = MFInput_KeyToAscii(keyPressed, shift, caps); if(ascii && (!maxLen || buffer.NumBytes() < maxLen-1)) { // check character exclusions if(MFIsNewline(ascii) && type != ST_MultiLine) break; if(ascii == '\t' && type != ST_MultiLine) break; if(type == ST_Numeric && !MFIsNumeric(ascii)) break; if(include) { if(include.FindChar(ascii) < 0) break; } if(exclude) { if(exclude.FindChar(ascii) >= 0) break; } int selMin = MFMin(selectionStart, selectionEnd); int selMax = MFMax(selectionStart, selectionEnd); int selRange = selMax - selMin; const uint16 wstr[] = { (uint16)ascii, 0 }; char insert[5]; MFString_CopyUTF16ToUTF8(insert, wstr); buffer.Replace(selMin, selRange, insert); cursorPos = selMin + 1; selectionStart = selectionEnd = cursorPos; if(changeCallback) changeCallback(buffer.CStr()); } break; } } } } }
void LocalBrowserController::RefreshSavesList() { ClearSelection(); browserModel->UpdateSavesList(browserModel->GetPageNum()); }
void wxCustomHeightListCtrl::AllowSelection(bool allow_selection) { m_allow_selection = allow_selection; if (!allow_selection) ClearSelection(); }
// This is called when the screen gets or loses focus void CMenuIntel::OnFocus(LTBOOL bFocus) { if (!m_PopupText.IsVisible()) { ClearSelection(); } if (bFocus) { uint16 nextItem = 0; CIntelItemList *pList = g_pPlayerStats->GetIntelList(); char szTemp[512] = ""; for (uint16 i = 0; i < pList->GetCount(); i++) { uint16 nIndex = (pList->GetCount() - i) - 1; INTEL_ITEM* pItem = pList->Get(nIndex); if (!pItem) { continue; } GetIntelName(pItem->nTextId,szTemp,sizeof(szTemp)); CLTGUITextCtrl* pCtrl = LTNULL; if (nextItem < m_List.GetNumControls()) { pCtrl = (CLTGUITextCtrl*)m_List.GetControl(nextItem); if (pCtrl) { pCtrl->SetString(szTemp); pCtrl->Show(LTTRUE); nextItem++; } } else { uint16 ndx = AddControl(szTemp,MC_INTEL); pCtrl = (CLTGUITextCtrl*)m_List.GetControl(ndx); nextItem++; } if (pCtrl) { pCtrl->SetParam1(nIndex); if (pItem->bIsIntel) { pCtrl->SetColors(0xFFFF0000,0xFFA00000,m_DisabledColor); } else { pCtrl->SetColors(m_SelectedColor,m_NonSelectedColor,m_DisabledColor); } } } for (uint16 nIndex = nextItem; nIndex < m_List.GetNumControls(); nIndex++) { CLTGUITextCtrl* pCtrl = (CLTGUITextCtrl*)m_List.GetControl(nIndex); if (pCtrl) { pCtrl->Show(LTFALSE); } } if (m_fScale != g_pInterfaceResMgr->GetXRatio()) { SetScale(g_pInterfaceResMgr->GetXRatio()); } SetSelection(GetIndex(&m_List)); } }