int wxComboBox::GetSelection() const { // if the popup is currently opened, use the selection as it had been // before it dropped down return g_SelectionBeforePopup == wxID_NONE ? GetCurrentSelection() : g_SelectionBeforePopup; }
void GtagFileListbox::SetTTText() { std::wstring tt; GetCurrentSelection( tt, FALSE); // Create the tooltip. g_hInst is the global instance handle. HWND hwndTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, WS_POPUP |TTS_ALWAYSTIP | TTS_BALLOON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, _hParent, NULL, _hInst, NULL); if (!hwndTip) return; // Associate the tooltip with the tool. TOOLINFO toolInfo = { 0 }; toolInfo.cbSize = sizeof(toolInfo); toolInfo.hwnd = _hParent; toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS; toolInfo.uId = (UINT_PTR)_hSelf; toolInfo.lpszText = (LPWSTR)tt.c_str(); SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); return; }
void Menu::CalculateMenuSelectorCubePosition() { SetSelectItemY(GetMenuItems()[GetCurrentSelection()]->GetMenuItemY() + 7); SetSelectItemX(GetMenuX() + GetMenuWidth() - 25); SetSelectItemHeight(Constants::TileSize()); SetSelectItemWidth(Constants::TileSize()); }
void CEditToolSelector::NotifyLeftClick( void ) { EEditorTool eSelected = GetCurrentSelection(); if ( eSelected != ETool_COUNT ) { CMMMContext::GetInstance().SetEditTool( gs_EditTool[eSelected] ); } }
int ctlComboBox::GetGuessedSelection() const { int sel=GetCurrentSelection(); if (sel < 0) sel = FindString(GetValue()); return sel; }
/* * Function GetUnitScale * return the scaling factor to convert users units * to normalized units ( ohm ) */ double UNIT_SELECTOR_RESISTOR::GetUnitScale() { switch( GetCurrentSelection() ) { case 0: return UNIT_OHM; break; case 1: return UNIT_KOHM; break; } return 1.0; }
/* * Function GetUnitScale * return the scaling factor to convert users units * to normalized units ( radian ) */ double UNIT_SELECTOR_ANGLE::GetUnitScale() { switch( GetCurrentSelection() ) { case 0: return UNIT_RADIAN; break; case 1: return UNIT_DEGREE; break; } return 1.0; }
BOOL ComboBox::GetCurrentSelectionItemData(DWORD_PTR *pData) { int selection; BOOL bResult = GetCurrentSelection(&selection); if (bResult) { bResult = GetItemData(selection, pData); } return bResult; }
int wxChoice::GetSelection() const { // if m_lastAcceptedSelection is set, it means that the dropdown is // currently shown and that we want to use the last "permanent" selection // instead of whatever is under the mouse pointer currently // // otherwise, get the selection from the control return m_lastAcceptedSelection == wxID_NONE ? GetCurrentSelection() : m_lastAcceptedSelection; }
int ctlComboBox::GetSelection() const { int sel=0; #ifdef __WXMSW__ sel=GetCurrentSelection(); if (sel < 0) #endif sel = FindString(GetValue()); return sel; }
/* * Function GetUnitScale * return the scaling factor to convert users units * to normalized units (herz ) */ double UNIT_SELECTOR_FREQUENCY::GetUnitScale() { switch( GetCurrentSelection() ) { case 0: return UNIT_GHZ; case 1: return UNIT_MHZ; case 2: return UNIT_KHZ; case 3: return 1.0; } return 1.0; }
/* * Function GetUnitScale * return the scaling factor to convert users units * to normalized units (meter) */ double UNIT_SELECTOR_LEN::GetUnitScale() { switch( GetCurrentSelection() ) { case 0: return UNIT_MM; break; case 1: return UNIT_MICRON; break; case 2: return UNIT_CM; break; case 3: return UNIT_MIL; break; case 4: return UNIT_INCH; break; } return 1.0; }
BOOL ComboBox::GetSelectedString(TCHAR **ppBuffer) { int index = 0; if (GetCurrentSelection(&index)) { return GetString(index, ppBuffer); } else { return FALSE; } }
void CWeaponChooser::Update() { // If Weapon chooser is being drawn, see if we want to change weapons... if (!IsOpen()) return; // See if we should close ourselves... if (m_AutoCloseTimer.IsStarted() && m_AutoCloseTimer.IsTimedOut()) { g_pClientSoundMgr->PlayInterfaceSound((char*)g_pInterfaceResMgr->GetSoundSelect()); Close(); } else if (m_NextWeaponKeyDownTimer.IsStarted() && m_NextWeaponKeyDownTimer.IsTimedOut()) { // See if we should switch to the next weapon... if (m_AutoSwitchTimer.IsStarted()) { if (m_AutoSwitchTimer.IsTimedOut()) { NextWeapon(-1); g_pClientWeaponMgr->ChangeWeapon( GetCurrentSelection() ); m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else { m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } else if (m_PrevWeaponKeyDownTimer.IsStarted() && m_PrevWeaponKeyDownTimer.IsTimedOut()) { if (m_AutoSwitchTimer.IsTimedOut()) { PrevWeapon(); g_pClientWeaponMgr->ChangeWeapon( GetCurrentSelection()); m_AutoSwitchTimer.Start(g_vtChooserAutoSwitchFreq.GetFloat()); } } }
/*---------------------------------------------------------------------- TtaIsDocumentSelected answers TRUE if the document is selected. ----------------------------------------------------------------------*/ ThotBool TtaIsDocumentSelected (Document document) { PtrDocument docsel; PtrElement firstSelection, lastSelection; int firstChar, lastChar; if (!GetCurrentSelection (&docsel, &firstSelection, &lastSelection, &firstChar, &lastChar)) return (FALSE); else if (LoadedDocument[document - 1] != docsel) return (FALSE); else return (TRUE); }
WXLRESULT wxComboBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { // TODO: handle WM_CTLCOLOR messages from our EDIT control to be able to // set its colour correctly (to be the same as our own one) switch ( nMsg ) { case WM_SIZE: // wxStaticBox can generate this message, when modifying the control's style. // This causes the content of the combobox to be selected, for some reason. case WM_STYLECHANGED: { // combobox selection sometimes spontaneously changes when its // size changes, restore it to the old value if necessary if ( !GetEditHWNDIfAvailable() ) break; long fromOld, toOld; GetSelection(&fromOld, &toOld); // if an editable combobox has a not empty text not from the // list, it tries to autocomplete it from the list when it is // resized, but we don't want this to happen as it doesn't seem // to make any sense, so we forcefully restore the old text wxString textOld; if ( !HasFlag(wxCB_READONLY) && GetCurrentSelection() == -1 ) textOld = GetValue(); // eliminate flickering during following hacks wxWindowUpdateLocker lock(this); WXLRESULT result = wxChoice::MSWWindowProc(nMsg, wParam, lParam); if ( !textOld.empty() && GetValue() != textOld ) SetLabel(textOld); long fromNew, toNew; GetSelection(&fromNew, &toNew); if ( fromOld != fromNew || toOld != toNew ) { SetSelection(fromOld, toOld); } return result; } } return wxChoice::MSWWindowProc(nMsg, wParam, lParam); }
int wxComboBox::GetSelection() const { #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { GtkComboBox* combobox = GTK_COMBO_BOX( m_widget ); return gtk_combo_box_get_active( combobox ); } else #endif // if the popup is currently opened, use the selection as it had been // before it dropped down return g_SelectionBeforePopup == wxID_NONE ? GetCurrentSelection() : g_SelectionBeforePopup; }
void IncrementalSelectListBase::OnKeyDown(wxKeyEvent& event) { int selected = 0, selectedMax = 0; GetCurrentSelection(selected, selectedMax); if (selected == wxNOT_FOUND) selected = 0; // remember previous selection int selectedPrevious = selected; KeyDownAction(event, selected, selectedMax); if (selectedMax < 0) return; UpdateCurrentSelection(selected, selectedPrevious); }
/*---------------------------------------------------------------------- TtaExtendSelection Extends the current selection to a given element. Parameters: document: the document for which the selection must be extended. element: the element to which the selection must be extended. lastCharacter: position within this element of the last character to be selected. 0 if the whole element must be selected. ----------------------------------------------------------------------*/ void TtaExtendSelection (Document document, Element element, int lastCharacter) { PtrDocument pDoc; PtrElement firstSelection, lastSelection; DisplayMode dispMode; int firstChar, lastChar; ThotBool ok; ThotBool abort; UserErrorCode = 0; if (element == NULL) TtaError (ERR_invalid_parameter); else if (((PtrElement) element)->ElParent == NULL) TtaError (ERR_invalid_parameter); /* Checks the parameter document */ else if (document < 1 || document > MAX_DOCUMENTS) TtaError (ERR_invalid_document_parameter); else if (LoadedDocument[document - 1] == NULL) TtaError (ERR_invalid_document_parameter); else /* Parameter document is correct */ { /* verifies if there is a selection */ ok = GetCurrentSelection (&pDoc, &firstSelection, &lastSelection, &firstChar, &lastChar); dispMode = TtaGetDisplayMode (document); if (dispMode == DisplayImmediately) /* The command can be executed */ { if (ok) /* verifies that the selection is into the document */ ok = (pDoc == LoadedDocument[document - 1]); } /* verifies if a selection is applied */ else if (IsSelectionRegistered (document, &abort)) /* There is an application, the extension is accepted if there is a request which is not for aborting */ ok = !abort; if (!ok) /* Error: no selection */ TtaError (ERR_no_selection_in_document); else if (dispMode == DisplayImmediately) ExtendSelection ((PtrElement) element, lastCharacter, TRUE, FALSE, FALSE); else NewSelectionExtension (document, element, lastCharacter); } }
/*---------------------------------------------------------------------- TtaGiveLastSelectedElement Returns the last element in the current selection in a given document. If this element is a Text element and if only a substring is selected, return also the rank of the first and last characters in the selection. Parameter: document: the document for which the selection is asked. Return values: selectedElement: the last selected element, NULL if no element is selected in the document. firstCharacter: rank of the first selected character in the element, or 0 if the whole element is in the selection. lastCharacter: rank of the last selected character in the element, or 0 if the whole element is in the selection, or firstCharacter - 1 for a position. ----------------------------------------------------------------------*/ void TtaGiveLastSelectedElement (Document document, Element *selectedElement, int *firstCharacter, int *lastCharacter) { PtrDocument pDoc; PtrElement firstSelection, lastSelection; int firstChar, lastChar; ThotBool ok; UserErrorCode = 0; *selectedElement = NULL; *firstCharacter = 0; *lastCharacter = 0; /* Checks the parameter document */ if (document < 1 || document > MAX_DOCUMENTS) TtaError (ERR_invalid_document_parameter); else if (LoadedDocument[document - 1] == NULL) TtaError (ERR_invalid_document_parameter); else { /* Parameter document is correct */ ok = GetCurrentSelection (&pDoc, &firstSelection, &lastSelection, &firstChar, &lastChar); if (ok) if (pDoc == LoadedDocument[document - 1]) { *selectedElement = (Element) lastSelection; if (lastSelection == firstSelection) { /* only one element */ *firstCharacter = firstChar; if (SelPosition) /* a position */ *lastCharacter = firstChar - 1; else *lastCharacter = lastChar; } else if (lastChar > 0) { /* the selection ends in the middle of the element */ *firstCharacter = 1; *lastCharacter = lastChar; } } } }
void CEditToolSelector::Render( void ) { // CMMMContext::GetInstance().GetMouse()->SetValidPos( MouseIsValidPos() ); const FLOAT32 fTOP_LEFT_X = 10.0f; const FLOAT32 fTOP_LEFT_Y = 10.0f; const FLOAT32 fWIDTH = 300.0f; const FLOAT32 fLINE_OFFSET = 20.0f; const FLOAT32 fDEPTH = fTOP_LEFT_X + (ETool_COUNT-1) * fLINE_OFFSET; GDE::SVertex BoxVerts[4]; BoxVerts[0].m_fX = fTOP_LEFT_X; BoxVerts[0].m_fY = fTOP_LEFT_Y; BoxVerts[1].m_fX = fTOP_LEFT_X+fWIDTH; BoxVerts[1].m_fY = fTOP_LEFT_Y; BoxVerts[2].m_fX = fTOP_LEFT_X+fWIDTH; BoxVerts[2].m_fY = fTOP_LEFT_Y+fDEPTH; BoxVerts[3].m_fX = fTOP_LEFT_X; BoxVerts[3].m_fY = fTOP_LEFT_Y+fDEPTH; for ( UINT32 i=0; i<4; i++ ) { BoxVerts[i].m_fZ = 0.5f; BoxVerts[i].m_uColour = 0x3F000000; // very grey } // untextured: CMMMContext::GetInstance().GetRenderer()->GetTextureManager().GetNULLTexture()->Apply( 0 ); CMMMContext::GetInstance().GetRenderer()->DrawPrimitives( GDE::PT_QuadList, 1, BoxVerts ); const UINT32 uStartCol = CMMMContext::GetInstance().GetFont()->GetColour(); const EEditorTool eCurrent = GetCurrentSelection(); FLOAT32 fY = fTOP_LEFT_Y + 5.0f; for ( UINT32 i=1; i<ETool_COUNT; i++ ) { const UINT32 uCol = (i==(UINT32)eCurrent)?0xFF7F7FFF:0xFFFFFFFF; CMMMContext::GetInstance().GetFont()->SetColour( uCol ); CMMMContext::GetInstance().GetFont()->Render( fTOP_LEFT_X + 5.0f, fY, GDE::FJ_Left, gs_EditTool[i]->GetName() ); fY += fLINE_OFFSET; } CMMMContext::GetInstance().GetFont()->SetColour( uStartCol ); }
/*---------------------------------------------------------------------- La frame d'indice frame devient la fenetre active. ----------------------------------------------------------------------*/ void ChangeSelFrame (int frame) { Document doc, olddoc; PtrDocument docsel; PtrElement first, last; View view; //AmayaFrame *p_frame; int oldframe, firstChar, lastChar; if (ActiveFrame != frame) { CloseTextInsertion (); oldframe = ActiveFrame; FrameToView (oldframe, &olddoc, &view); ActiveFrame = frame; FrameToView (frame, &doc, &view); // set the new focus if (ChangeFocusFunction && doc && LoadedDocument[doc-1]->DocTypeName && strcmp (LoadedDocument[doc-1]->DocTypeName, "log") && olddoc && LoadedDocument[olddoc-1]->DocTypeName && strcmp (LoadedDocument[olddoc-1]->DocTypeName, "log")) (*(Proc1)ChangeFocusFunction) ((void *) doc); /* update the class list */ TtaExecuteMenuAction ("ApplyClass", doc, 1, FALSE); TtaRefreshElementMenu (doc, 1); UpdateAttrMenu (LoadedDocument[doc-1], TRUE); // update the show errors TtaExecuteMenuAction ("UpdateShowError", doc, 1, FALSE); TtaExecuteMenuAction ("UpdateStyleList", doc, 1, FALSE); GetCurrentSelection (&docsel, &first, &last, &firstChar, &lastChar); if (LoadedDocument[doc-1] != docsel) TtaSetStatusSelectedElement (doc, 1, NULL); else TtaSetStatusSelectedElement (doc, 1, (Element)first); /* the active frame changed so update the application focus */ /*p_frame = TtaGetFrameFromId(frame); if (p_frame) p_frame->GetCanvas()->SetFocus();*/ } }
/*---------------------------------------------------------------------- TtaAddElementToSelection Add a new element to the current selection. The new selection may then contain separate elements. Parameters: document: the document to which the element belongs. This element must belong to the same document as the elements selected by previous calls to TtaAddElementToSelection and by the last call to TtaSelectElement. element: the element to be added to the current selection ----------------------------------------------------------------------*/ void TtaAddElementToSelection (Document document, Element element) { PtrDocument pDoc; PtrElement firstSelection, lastSelection; DisplayMode dispMode; int firstChar, lastChar; ThotBool ok; UserErrorCode = 0; if (element == NULL) TtaError (ERR_invalid_parameter); else if (((PtrElement) element)->ElParent == NULL) TtaError (ERR_invalid_parameter); /* Checks the parameter document */ else if (document < 1 || document > MAX_DOCUMENTS) TtaError (ERR_invalid_document_parameter); else if (LoadedDocument[document - 1] == NULL) TtaError (ERR_invalid_document_parameter); else /* Parameter document is correct */ { /* is there a current selection */ ok = GetCurrentSelection (&pDoc, &firstSelection, &lastSelection, &firstChar, &lastChar); dispMode = TtaGetDisplayMode (document); if (ok) { if (dispMode == NoComputedDisplay) /* accept only if immediate display mode */ ok = FALSE; else /* is the current selection is in the same document? */ ok = (pDoc == LoadedDocument[document - 1]); } if (!ok) /* Error: no selection */ TtaError (ERR_no_selection_in_document); else AddInSelection ((PtrElement) element, FALSE); } }
/*---------------------------------------------------------------------- TtaGiveNextSelectedElement Returns the element that follows a given element in the current selection in a given document. If this element is a Text element and if only a substring is selected, return also the rank of the first and last characters in the selection. Parameters: document: the document for which the selection is asked. selectedElement: the current element. Return parameters: selectedElement: the next selected element, NULL if this was the last selected element in the document. firstCharacter: rank of the first character in the selection, or 0 if the whole element is in the selection. lastCharacter: rank of the last character in the selection, or 0 if the whole element is in the selection. ----------------------------------------------------------------------*/ void TtaGiveNextSelectedElement (Document document, Element *selectedElement, int *firstCharacter, int *lastCharacter) { PtrDocument pDoc; PtrElement pEl; PtrElement firstSelection, lastSelection; int firstChar, lastChar; ThotBool ok; UserErrorCode = 0; *firstCharacter = 0; *lastCharacter = 0; /* Checks the parameter document */ if (document < 1 || document > MAX_DOCUMENTS) TtaError (ERR_invalid_document_parameter); else if (LoadedDocument[document - 1] == NULL) TtaError (ERR_invalid_document_parameter); else { /* Parameter document is correct */ ok = GetCurrentSelection (&pDoc, &firstSelection, &lastSelection, &firstChar, &lastChar); if (!ok) *selectedElement = NULL; else if (pDoc != LoadedDocument[document - 1]) *selectedElement = NULL; else { pEl = NextInSelection ((PtrElement) *selectedElement, lastSelection); *selectedElement = (Element) pEl; if (pEl == lastSelection && lastChar > 0) { *firstCharacter = 1; *lastCharacter = lastChar; } } } }
bool wxComboBox::MSWCommand(WXUINT param, WXWORD id) { int sel = -1; wxString value; switch ( param ) { case CBN_DROPDOWN: // remember the last selection, just as wxChoice does m_lastAcceptedSelection = GetCurrentSelection(); { wxCommandEvent event(wxEVT_COMBOBOX_DROPDOWN, GetId()); event.SetEventObject(this); ProcessCommand(event); } break; case CBN_CLOSEUP: // Do the same thing as in wxChoice but using different event type. if ( m_pendingSelection != wxID_NONE ) { SendSelectionChangedEvent(wxEVT_COMBOBOX); m_pendingSelection = wxID_NONE; } { wxCommandEvent event(wxEVT_COMBOBOX_CLOSEUP, GetId()); event.SetEventObject(this); ProcessCommand(event); } break; case CBN_SELENDOK: #ifndef __SMARTPHONE__ // we need to reset this to prevent the selection from being undone // by wxChoice, see wxChoice::MSWCommand() and comments there m_lastAcceptedSelection = wxID_NONE; #endif // set these variables so that they could be also fixed in // CBN_EDITCHANGE below sel = GetSelection(); value = GetStringSelection(); // this string is going to become the new combobox value soon but // we need it to be done right now, otherwise the event handler // could get a wrong value when it calls our GetValue() ::SetWindowText(GetHwnd(), value.t_str()); SendSelectionChangedEvent(wxEVT_COMBOBOX); // fall through: for compatibility with wxGTK, also send the text // update event when the selection changes (this also seems more // logical as the text does change) case CBN_EDITCHANGE: if ( m_allowTextEvents ) { wxCommandEvent event(wxEVT_TEXT, GetId()); // if sel != -1, value was already initialized above if ( sel == -1 ) { value = wxGetWindowText(GetHwnd()); } event.SetString(value); InitCommandEventWithItems(event, sel); ProcessCommand(event); } break; default: return wxChoice::MSWCommand(param, id); } // skip wxChoice version as it would generate its own events for // CBN_SELENDOK and also interfere with our handling of CBN_DROPDOWN return true; }
bool wxChoice::MSWCommand(WXUINT param, WXWORD WXUNUSED(id)) { /* The native control provides a great variety in the events it sends in the different selection scenarios (undoubtedly for greater amusement of the programmers using it). For the reference, here are the cases when the final selection is accepted (things are quite interesting when it is cancelled too): A. Selecting with just the arrows without opening the dropdown: 1. CBN_SELENDOK 2. CBN_SELCHANGE B. Opening dropdown with F4 and selecting with arrows: 1. CBN_DROPDOWN 2. many CBN_SELCHANGE while changing selection in the list 3. CBN_SELENDOK 4. CBN_CLOSEUP C. Selecting with the mouse: 1. CBN_DROPDOWN -- no intermediate CBN_SELCHANGEs -- 2. CBN_SELENDOK 3. CBN_CLOSEUP 4. CBN_SELCHANGE Admire the different order of messages in all of those cases, it must surely have taken a lot of effort to Microsoft developers to achieve such originality. */ switch ( param ) { case CBN_DROPDOWN: // we use this value both because we don't want to track selection // using CB_GETCURSEL while the dropdown is opened and because we // need to reset the selection back to it if it's eventually // cancelled by user m_lastAcceptedSelection = GetCurrentSelection(); break; case CBN_CLOSEUP: // if the selection was accepted by the user, it should have been // reset to wxID_NONE by CBN_SELENDOK, otherwise the selection was // cancelled and we must restore the old one if ( m_lastAcceptedSelection != wxID_NONE ) { SetSelection(m_lastAcceptedSelection); m_lastAcceptedSelection = wxID_NONE; } break; case CBN_SELENDOK: // reset it to prevent CBN_CLOSEUP from undoing the selection (it's // ok to reset it now as GetCurrentSelection() will now return the // same thing anyhow) m_lastAcceptedSelection = wxID_NONE; { const int n = GetSelection(); wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId); event.SetInt(n); event.SetEventObject(this); if ( n > -1 ) { event.SetString(GetStringSelection()); InitCommandEventWithItems(event, n); } ProcessCommand(event); } break; // don't handle CBN_SELENDCANCEL: just leave m_lastAcceptedSelection // valid and the selection will be undone in CBN_CLOSEUP above // don't handle CBN_SELCHANGE neither, we don't want to generate events // while the dropdown is opened -- but do add it if we ever need this default: return false; } return true; }
/*---------------------------------------------------------------------- FindReference cherche une reference a` l'element selectionne'. A l'appel: - pPrevRef: pointeur sur la derniere reference trouvee ou NULL si on cherche la premiere reference (dans ce cas, pExtDoc doit aussi etre NULL). - pReferredEl: l'element dont on cherche les references, NULL si on cherche la premiere reference. - pDoc: le document auquel appartient l'element dont on cherche les references, NULL si on cherche la premiere reference. Au retour: - pPrevRef: pointeur sur la reference trouvee ou NULL si on n'a pas trouve' de reference. - pReferredEl: l'element dont on cherche les references. ----------------------------------------------------------------------*/ void FindReference (PtrReference *pPrevRef, PtrDocument pDoc, PtrElement *pReferredEl) { PtrElement firstSel; PtrElement lastSel; PtrElement pEl; PtrDocument pSelDoc; PtrElement pAncest; int firstChar; int lastChar; ThotBool ok; ThotBool found; ok = TRUE; if (*pPrevRef) /* on a deja une reference courante */ *pPrevRef = NextReferenceToEl (*pReferredEl, pDoc, *pPrevRef); else /* pas de reference courante */ { /* prend la selection courante */ ok = GetCurrentSelection (&pSelDoc, &firstSel, &lastSel, &firstChar, &lastChar); if (ok) /* cherche le premier element reference' qui englobe la */ /* selection courante */ { pEl = firstSel; found = FALSE; do { if (pEl->ElReferredDescr && /* l'element a un descripteur d'element reference' */ pEl->ElReferredDescr->ReFirstReference) /* l'element est effectivement reference' */ found = TRUE; if (!found) /* l'element n'est pas reference', on passe au pere */ pEl = pEl->ElParent; } while (!found && pEl); if (found) /* on a trouve' un ascendant reference' */ { /* conserve un pointeur sur l'element dont on cherche les */ /* references ainsi que sur son document */ *pReferredEl = pEl; /* cherche la premiere reference a cet element */ *pPrevRef = NextReferenceToEl (*pReferredEl, pDoc, *pPrevRef); } } } if (*pPrevRef != NULL) /* on a trouve' une reference */ { ok = TRUE; /* on ignore les references qui sont a l'interieur d'une inclusion */ if ((*pPrevRef)->RdElement != NULL) { pAncest = (*pPrevRef)->RdElement->ElParent; while (pAncest->ElParent != NULL && pAncest->ElSource == NULL) pAncest = pAncest->ElParent; if (pAncest->ElSource != NULL) /* on est dans une inclusion */ ok = FALSE; } /* on ignore les references dans les partie cachees */ if (ok) if (ElementIsHidden ((*pPrevRef)->RdElement)) /* on est dans une partie cachee */ ok = FALSE; /* on ignore les references qui sont dans le tampon de Copier-Couper */ if (ok) if (IsASavedElement ((*pPrevRef)->RdElement)) ok = FALSE; if (!ok) /* cherche la reference suivante au meme element */ FindReference (pPrevRef, pDoc, pReferredEl); else /* selectionne la reference trouvee */ SelectElementWithEvent (pDoc, (*pPrevRef)->RdElement, FALSE, FALSE); } }
void EditPolyData::Hide (EditPolyMod *pMod, bool isFaceLevel, bool hideSelected) { if (theHold.Holding()) { theHold.Put (new EditPolyHideRestore (pMod, this, false)); if (isFaceLevel) theHold.Put (new EditPolyHideRestore (pMod, this, true)); if (isFaceLevel || hideSelected) theHold.Put (new EditPolySelectRestore (pMod, this, EPM_SL_VERTEX)); if (isFaceLevel && hideSelected) theHold.Put (new EditPolySelectRestore (pMod, this, EPM_SL_FACE)); } SynchBitArrays (); bool stackSel = pMod->getParamBlock()->GetInt (epm_stack_selection) != 0; if (isFaceLevel) { BitArray & faceSel = *(GetCurrentSelection (MNM_SL_FACE, stackSel)); int i, max = faceSel.GetSize(); if (mFaceHide.GetSize()<max) max = mFaceHide.GetSize(); if (hideSelected) { if (mpMesh) { // Hide vertices used by all hidden or selected faces first: BitArray touchedByHidden, touchedByNonHidden; touchedByHidden.SetSize (mpMesh->numv); touchedByNonHidden.SetSize (mpMesh->numv); int mmax = max; if (mmax>mpMesh->numf) mmax = mpMesh->numf; for (i=0; i<mmax; i++) { if (faceSel[i]) { for (int j=0; j<mpMesh->f[i].deg; j++) touchedByHidden.Set (mpMesh->f[i].vtx[j]); } else if (!mFaceHide[i]) { for (int j=0; j<mpMesh->f[i].deg; j++) touchedByNonHidden.Set (mpMesh->f[i].vtx[j]); } } for (i=0; i<mpMesh->numv; i++) { if (touchedByNonHidden[i]) touchedByHidden.Clear(i); } // Ok, now everything left in touchedByHidden should be hidden and deselected. mVertHide |= touchedByHidden; if (!stackSel) mVertSel &= ~touchedByHidden; } for (i=0; i<max; i++) { if (faceSel[i]) { if (!stackSel) faceSel.Clear(i); mFaceHide.Set(i,true); } } } else { if (mpMesh) { // Hide vertices used by all hidden or nonselected faces first: BitArray touchedByHidden, touchedByNonHidden; touchedByHidden.SetSize (mpMesh->numv); touchedByNonHidden.SetSize (mpMesh->numv); int mmax = max; if (mmax>mpMesh->numf) mmax = mpMesh->numf; for (i=0; i<mmax; i++) { if (!faceSel[i]) { for (int j=0; j<mpMesh->f[i].deg; j++) touchedByHidden.Set (mpMesh->f[i].vtx[j]); } else if (!mFaceHide[i]) { for (int j=0; j<mpMesh->f[i].deg; j++) touchedByNonHidden.Set (mpMesh->f[i].vtx[j]); } } for (i=0; i<mpMesh->numv; i++) { if (touchedByNonHidden[i]) touchedByHidden.Clear(i); } // Ok, now everything left in touchedByHidden should be hidden and deselected. mVertHide |= touchedByHidden; if (!stackSel) mVertSel &= ~touchedByHidden; } for (int i=0; i<max; i++) if (!faceSel[i]) mFaceHide.Set(i,true); } } else { BitArray & vertSel = *GetCurrentSelection (MNM_SL_VERTEX, pMod->getParamBlock()->GetInt(epm_stack_selection)!=0); int max = vertSel.GetSize(); if (mVertHide.GetSize()<max) max = mVertHide.GetSize(); if (hideSelected) { for (int i=0; i<max; i++) { if (vertSel[i]) { if (!stackSel) vertSel.Clear(i); mVertHide.Set(i,true); } } } else { for (int i=0; i<max; i++) if (!vertSel[i]) mVertHide.Set(i,true); } } }
/*---------------------------------------------------------------------- CallbackChecker ----------------------------------------------------------------------*/ void CallbackChecker (int ref, int dataType, char *data) { PtrElement pEl1, pElN; int c1, cN; if (ref == -1) /* detruit le dialogue du correcteur */ RemoveSpellForm (); else switch (ref - SpellingBase) { case ChkrMenuIgnore: switch ((long int) data) { case 0: /* ignorer les mots ecrits en majuscule */ IgnoreUppercase = !IgnoreUppercase; break; case 1: /* ignorer les mots contenant un chiffre arabe */ IgnoreArabic = !IgnoreArabic; break; case 2: /* ignorer les chiffres romains */ IgnoreRoman = !IgnoreRoman; break; case 3: /* ignorer les mots contenant certains car speciaux */ IgnoreSpecial = !IgnoreSpecial; break; } /* end of switch */ break; case ChkrSpecial: /* recopier la liste des car. speciaux dans RejectedChar[] */ strncpy (RejectedChar, data, MAX_REJECTED_CHARS); /* bascule automatiquement l'indicateur IgnoreSpecial */ if (!IgnoreSpecial) { IgnoreSpecial = TRUE; #ifdef _GTK TtaSetToggleMenu (SpellingBase + ChkrMenuIgnore, 3, IgnoreSpecial); #endif /* _GTK */ } break; case ChkrMenuOR: /* definition du sens de correction OU? */ switch ((long int) data) { case 0: /* ElemIsBefore la selection */ ChkrRange->SStartToEnd = FALSE; break; case 1: /* Dans la selection */ FirstStep = TRUE; break; case 2: /* Apres la selection */ ChkrRange->SStartToEnd = TRUE; break; case 3: /* Dans tout le document */ FirstStep = TRUE; break; } /* La premiere fois on initialise le domaine de recherche */ if (FirstStep) { InitSearchDomain ((long int) data, ChkrRange); /* On prepare la recheche suivante */ #ifdef _GTK if (ChkrRange->SStartToEnd) TtaSetMenuForm (SpellingBase + ChkrMenuOR, 2); else TtaSetMenuForm (SpellingBase + ChkrMenuOR, 0); #endif /* GTK */ } else if (ChkrRange != NULL) /* Est-ce que le document vient de recevoir la selection */ if (pDocSel != ChkrRange->SDocument) { /* Est-ce encore vrai */ GetCurrentSelection (&pDocSel, &pEl1, &pElN, &c1, &cN); #ifdef _GTK if (pDocSel == ChkrRange->SDocument) { /* Il faut reactiver les entree */ TtaRedrawMenuEntry (SpellingBase + ChkrMenuOR, 0, NULL, (ThotColor)-1, 1); TtaRedrawMenuEntry (SpellingBase + ChkrMenuOR, 1, NULL, (ThotColor)-1, 1); TtaRedrawMenuEntry (SpellingBase + ChkrMenuOR, 2, NULL, (ThotColor)-1, 1); } #endif /* GTK */ } break; case ChkrSelectProp: /* retour du selecteur de propositions */ /* recopier le choix dans CorrectWord */ strcpy (CorrectWord, data); if (CorrectWord[0] != EOS && BadWord != EOS && strcmp (CorrectWord, BadWord) != 0) ToReplace = TRUE; break; case ChkrFormCorrect: /* retour de la feuille de dialogue CORRECTION */ /* effectuer l'action demandee */ ApplyCommand ((long int) data); break; } }
/*---------------------------------------------------------------------- TtcSpellCheck active le formulaire de correction ----------------------------------------------------------------------*/ void TtcSpellCheck (Document doc, View view) { PtrDocument document; PtrElement pEl1, pElN; int c1, cN; int i; ThotBool ok; #ifdef _WX ThotBool created; #endif /* _WX */ /* Document concerne */ document = LoadedDocument[doc - 1]; if (document == NULL) return; SpellCheckLoadResources (); /* Afficher une liste de mots EMPTY */ strcpy (ChkrCorrection[0], " "); for (i = 1; i <= NB_PROPOSALS; i++) strcpy (ChkrCorrection[i], "$"); /* ne pas ignorer les mots en capitale, chiffres romains */ /* ou contenant des chiffres arabes, certains car. speciaux */ strncpy (RejectedChar, "@#$&+~", MAX_REJECTED_CHARS); /* liste par defaut */ IgnoreUppercase = TRUE; IgnoreArabic = TRUE; IgnoreRoman = TRUE; IgnoreSpecial = TRUE; /* Document selectionne */ ok = GetCurrentSelection (&pDocSel, &pEl1, &pElN, &c1, &cN); /* Indique que c'est une nouvelle correction qui debute */ FirstStep = TRUE; ChkrRange = NULL; /* pas de contexte de correction alloue */ /* On alloue le contexte */ GetSearchContext (&ChkrRange); ChkrRange->SDocument = document; /* ne cree pas inutilement le dictionnaire fichier */ TtaLoadDocumentDictionary (document, (int*) &ChkrFileDict, FALSE); #ifdef _WINGUI /* to have the same behavior as under Unix, we need to destroy the dialog if it already existed */ if (SpellChecker) { EndDialog (SpellChecker, ID_DONE); SpellChecker = NULL; hwndLanguage = NULL; } DialogBox (hInstance, MAKEINTRESOURCE (SPELLCHECKDIALOG), NULL, (DLGPROC) SpellCheckDlgProc); #endif /* _WINGUI */ #ifdef _WX if (!ok || pDocSel != document) i = 1; else i = 2; created = CreateSpellCheckDlgWX (SpellingBase + ChkrFormCorrect, SpellingBase, TtaGetViewFrame (doc, view), i); CallbackChecker (SpellingBase + ChkrMenuOR, INTEGER_DATA, (char *)i); if (created) TtaShowDialogue (SpellingBase + ChkrFormCorrect, FALSE, TRUE); #endif /* _WX */ }