当前位置: 首页>>代码示例>>C++>>正文


C++ SetSelection函数代码示例

本文整理汇总了C++中SetSelection函数的典型用法代码示例。如果您正苦于以下问题:C++ SetSelection函数的具体用法?C++ SetSelection怎么用?C++ SetSelection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetSelection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: newWord

NS_IMETHODIMP 
mozSpellChecker::Replace(const nsAString &aOldWord, const nsAString &aNewWord, bool aAllOccurrences)
{
  if(!mConverter)
    return NS_ERROR_NULL_POINTER;

  nsAutoString newWord(aNewWord); // sigh

  if(aAllOccurrences){
    int32_t selOffset;
    int32_t startBlock,currentBlock,currOffset;
    int32_t begin,end;
    bool done;
    nsresult result;
    nsAutoString str;

    // find out where we are
    result = SetupDoc(&selOffset);
    if(NS_FAILED(result))
      return result;
    result = GetCurrentBlockIndex(mTsDoc,&startBlock);
    if(NS_FAILED(result))
      return result;

    //start at the beginning
    result = mTsDoc->FirstBlock();
    currOffset=0;
    currentBlock = 0;
    while( NS_SUCCEEDED(mTsDoc->IsDone(&done)) && !done )
      {
        result = mTsDoc->GetCurrentTextBlock(&str);
        do{
          result = mConverter->FindNextWord(str.get(),str.Length(),currOffset,&begin,&end);
          if(NS_SUCCEEDED(result)&&(begin != -1)){
            if (aOldWord.Equals(Substring(str, begin, end-begin))) {
              // if we are before the current selection point but in the same block
              // move the selection point forwards
              if((currentBlock == startBlock)&&(begin < selOffset)){
                selOffset +=
                  int32_t(aNewWord.Length()) - int32_t(aOldWord.Length());
                if(selOffset < begin) selOffset=begin;
              }
              mTsDoc->SetSelection(begin, end-begin);
              mTsDoc->InsertText(&newWord);
              mTsDoc->GetCurrentTextBlock(&str);
              end += (aNewWord.Length() - aOldWord.Length());  // recursion was cute in GEB, not here.
            }
          }
          currOffset = end;
        }while(currOffset != -1);
        mTsDoc->NextBlock();
        currentBlock++;
        currOffset=0;          
      }

    // We are done replacing.  Put the selection point back where we found  it (or equivalent);
    result = mTsDoc->FirstBlock();
    currentBlock = 0;
    while(( NS_SUCCEEDED(mTsDoc->IsDone(&done)) && !done ) &&(currentBlock < startBlock)){
      mTsDoc->NextBlock();
    }

//After we have moved to the block where the first occurrence of replace was done, put the 
//selection to the next word following it. In case there is no word following it i.e if it happens
//to be the last word in that block, then move to the next block and put the selection to the 
//first word in that block, otherwise when the Setupdoc() is called, it queries the LastSelectedBlock()
//and the selection offset of the last occurrence of the replaced word is taken instead of the first 
//occurrence and things get messed up as reported in the bug 244969

    if( NS_SUCCEEDED(mTsDoc->IsDone(&done)) && !done ){
      nsString str;                                
      result = mTsDoc->GetCurrentTextBlock(&str);  
      result = mConverter->FindNextWord(str.get(),str.Length(),selOffset,&begin,&end);
            if(end == -1)
             {
                mTsDoc->NextBlock();
                selOffset=0;
                result = mTsDoc->GetCurrentTextBlock(&str); 
                result = mConverter->FindNextWord(str.get(),str.Length(),selOffset,&begin,&end);
                mTsDoc->SetSelection(begin, 0);
             }
         else
                mTsDoc->SetSelection(begin, 0);
    }
 }
  else{
    mTsDoc->InsertText(&newWord);
  }
  return NS_OK;
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:90,代码来源:mozSpellChecker.cpp

示例2: XTP_SAFE_CALL1

void CXTPCalendarViewDay::SetSelected()
{
	XTP_SAFE_CALL1(GetView_(), SetSelection(GetDayDate(), GetDayDate()));
}
开发者ID:killbug2004,项目名称:ghost2013,代码行数:4,代码来源:XTPCalendarViewDay.cpp

示例3: SetText

	void SetText(const wxString &text) {
		SetValue(text); 
		SetSelection(text.Len(),text.Len());
	}
开发者ID:JD26,项目名称:ICE,代码行数:4,代码来源:mxGdbCommandsPanel.cpp

示例4: RemoveFree


//.........这里部分代码省略.........
		pCtrl = AddTextItem(IDS_STAT_ACCURACY,LTNULL,0, LTTRUE, GetLargeFont());
		pCtrl->Enable(LTFALSE);
		LTFLOAT fAccuracy = 0.0f;
		if (pMSummary->dwNumShotsFired)
		{
			fAccuracy = (LTFLOAT) pMSummary->dwNumHits / (LTFLOAT) pMSummary->dwNumShotsFired;
			int nAccuracy =(int)( 100.0f * fAccuracy);

			//shots fired
			hTxt=g_pLTClient->FormatString(IDS_STAT_SHOTS,
					pMSummary->dwNumShotsFired,pMSummary->dwNumHits, nAccuracy);
			pCtrl= AddTextItem(hTxt,LTNULL,0,LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);

			//hit locations
			uint32 h = pMSummary->dwHitLocations[HL_HEAD];
			uint32 t = pMSummary->dwHitLocations[HL_TORSO];
			uint32 a = pMSummary->dwHitLocations[HL_ARM];
			uint32 l = pMSummary->dwHitLocations[HL_LEG];
			hTxt=g_pLTClient->FormatString(IDS_STAT_HITS,h,t,(a+l));
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);

			// casualties
			pCtrl = AddTextItem(IDS_STAT_CASUALTIES,LTNULL,0, LTTRUE, GetLargeFont());
			pCtrl->Enable(LTFALSE);
			hTxt=g_pLTClient->FormatString(IDS_STAT_KILLS, pMSummary->dwNumEnemyKills,
											pMSummary->dwNumFriendKills, pMSummary->dwNumNeutralKills);
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);


		}
		else
		{
			hTxt=g_pLTClient->FormatString(IDS_STAT_NOSHOTS);
			pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
			pCtrl->Enable(LTFALSE);
			g_pLTClient->FreeString(hTxt);
		}
	

		//stealth
		pCtrl = AddTextItem(IDS_STAT_STEALTH,LTNULL,0, LTTRUE, GetLargeFont());
		pCtrl->Enable(LTFALSE);

		hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED,pMSummary->dwNumTimesDetected,pMSummary->dwNumDisturbances);
		pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
		pCtrl->Enable(LTFALSE);
		g_pLTClient->FreeString(hTxt);
		hTxt=g_pLTClient->FormatString(IDS_STAT_DETECTED2,pMSummary->dwNumBodies,pMSummary->dwNumTimesHit);
		pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
		pCtrl->Enable(LTFALSE);
		g_pLTClient->FreeString(hTxt);
	}


	//inteligence
    pCtrl = AddTextItem(IDS_STAT_INTEL,LTNULL,0, LTTRUE, GetLargeFont());
    pCtrl->Enable(LTFALSE);

	int cur = pMSummary->m_nMissionCurNumIntel;
	int total = pMSummary->m_nMissionTotalIntel;
    hTxt=g_pLTClient->FormatString(IDS_SUMMARY_FOUND,cur,total);
    pCtrl= AddTextItem(hTxt,LTNULL,0, LTTRUE, GetSmallFont());
    pCtrl->Enable(LTFALSE);



	if (m_nFolderID == FOLDER_ID_FAILURE)
	{
		nContinueId = FOLDER_ID_LOAD;
		nContinueHelpId = IDS_HELP_LOAD;
	}
	else
	{
		//	Generate Awards
		CFolderAwards* pAwards = (CFolderAwards*)m_pFolderMgr->GetFolderFromID(FOLDER_ID_AWARDS);
		pAwards->UpdateData();
		if (pAwards->HasAwards())
		{
			nContinueId = FOLDER_ID_AWARDS;
			nContinueHelpId = IDS_HELP_AWARDS;
		}
		else
		{
			nContinueId = FOLDER_ID_BRIEFING;
			nContinueHelpId = IDS_HELP_NEXTMISSION;
		}
	}

	UseContinue(nContinueId,nContinueHelpId);
	CalculateLastDrawn();
	CheckArrows();
	SetSelection(GetIndex(m_pContinue));

}
开发者ID:germanocaldeira,项目名称:no-one-lives-forever,代码行数:101,代码来源:FolderSummary.cpp

示例5: wxCHECK_MSG

bool wxNotebook::InsertPage( size_t position,
                             wxNotebookPage* win,
                             const wxString& text,
                             bool select,
                             int imageId )
{
    wxCHECK_MSG( m_widget != NULL, false, wxT("invalid notebook") );

    wxCHECK_MSG( win->GetParent() == this, false,
               wxT("Can't add a page whose parent is not the notebook!") );

    wxCHECK_MSG( position <= GetPageCount(), false,
                 wxT("invalid page index in wxNotebookPage::InsertPage()") );

    // Hack Alert! (Part II): See above in wxNotebook::AddChildGTK
    // why this has to be done.
    gtk_widget_unparent(win->m_widget);

    if (m_themeEnabled)
        win->SetThemeEnabled(true);

    GtkNotebook *notebook = GTK_NOTEBOOK(m_widget);

    wxGtkNotebookPage* pageData = new wxGtkNotebookPage;

    m_pages.Insert(win, position);
    m_pagesData.Insert(position, pageData);

    // set the label image and text
    // this must be done before adding the page, as GetPageText
    // and GetPageImage will otherwise return wrong values in
    // the page-changed event that results from inserting the
    // first page.
    pageData->m_imageIndex = imageId;

    pageData->m_box = gtk_hbox_new(false, 1);
    gtk_container_set_border_width(GTK_CONTAINER(pageData->m_box), 2);

    pageData->m_image = NULL;
    if (imageId != -1)
    {
        if (HasImageList())
        {
            const wxBitmap* bitmap = GetImageList()->GetBitmapPtr(imageId);
            pageData->m_image = gtk_image_new_from_pixbuf(bitmap->GetPixbuf());
            gtk_box_pack_start(GTK_BOX(pageData->m_box),
                pageData->m_image, false, false, m_padding);
        }
        else
        {
            wxFAIL_MSG("invalid notebook imagelist");
        }
    }

    /* set the label text */
    pageData->m_label = gtk_label_new(wxGTK_CONV(wxStripMenuCodes(text)));
    gtk_box_pack_end(GTK_BOX(pageData->m_box),
        pageData->m_label, false, false, m_padding);

    gtk_widget_show_all(pageData->m_box);
    gtk_notebook_insert_page(notebook, win->m_widget, pageData->m_box, position);

    /* apply current style */
    GtkRcStyle *style = GTKCreateWidgetStyle();
    if ( style )
    {
        gtk_widget_modify_style(pageData->m_label, style);
        g_object_unref(style);
    }

    if (select && GetPageCount() > 1)
    {
        SetSelection( position );
    }

    InvalidateBestSize();
    return true;
}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:78,代码来源:notebook.cpp

示例6: SetSelection

VOID CFolderDialog::OnInitialized(VOID)
{
	if (::lstrlen(m_szSelPath) > 0)
		SetSelection(m_szSelPath);
}
开发者ID:Rarder44,项目名称:TamrielUnlimitedIT_Installer_Uninstaller,代码行数:5,代码来源:FolderDlg.cpp

示例7: SetSelection

void LineEdit::LeftDouble(Point, dword)
{
	int l, h;
	if(GetWordSelection(cursor, l, h))
		SetSelection(l, h);
}
开发者ID:pedia,项目名称:raidget,代码行数:6,代码来源:LineEdit.cpp

示例8: m_validatedPlural

PropertiesDialog::PropertiesDialog(wxWindow *parent, bool fileExistsOnDisk, int initialPage)
    : m_validatedPlural(-1), m_validatedLang(-1)
{
    wxXmlResource::Get()->LoadDialog(this, parent, "properties");

    m_team = XRCCTRL(*this, "team_name", wxTextCtrl);
    m_teamEmail = XRCCTRL(*this, "team_email", wxTextCtrl);
    m_project = XRCCTRL(*this, "prj_name", wxTextCtrl);
    m_language = XRCCTRL(*this, "language", LanguageCtrl);
    m_charset = XRCCTRL(*this, "charset", wxComboBox);
    m_basePath = XRCCTRL(*this, "basepath", wxTextCtrl);
    m_sourceCodeCharset = XRCCTRL(*this, "source_code_charset", wxComboBox);

    m_pluralFormsDefault = XRCCTRL(*this, "plural_forms_default", wxRadioButton);
    m_pluralFormsCustom = XRCCTRL(*this, "plural_forms_custom", wxRadioButton);
    m_pluralFormsExpr = XRCCTRL(*this, "plural_forms_expr", wxTextCtrl);
#if defined(__WXMSW__) && !wxCHECK_VERSION(3,1,0)
    m_pluralFormsExpr->SetFont(m_pluralFormsExpr->GetFont().Smaller());
#else
    m_pluralFormsExpr->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
#endif

    // my custom controls:
    m_keywords = new wxEditableListBox(this, -1, _("Additional keywords"));
    m_paths = new wxEditableListBox(this, -1, _("Paths"));
    m_excludedPaths = new wxEditableListBox(this, -1, _("Excluded paths"));

    m_paths->SetMinSize(wxSize(-1, 90));
    m_excludedPaths->SetMinSize(wxSize(-1, 90));

#ifdef __WXOSX__
    for (auto l: {m_keywords, m_paths, m_excludedPaths})
    {
        for (auto c: l->GetChildren())
        {
            c->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
            for (auto c2: c->GetChildren())
                c2->SetWindowVariant(wxWINDOW_VARIANT_SMALL);
        }
    }
#endif // __WXOSX__

    wxXmlResource::Get()->AttachUnknownControl("keywords", m_keywords);
    wxXmlResource::Get()->AttachUnknownControl("paths", m_paths);
    wxXmlResource::Get()->AttachUnknownControl("excluded_paths", m_excludedPaths);

    // Controls setup:
    m_project->SetHint(_("Name of the project the translation is for"));
    m_pluralFormsExpr->SetHint(_("e.g. nplurals=2; plural=(n > 1);"));

    Layout();
    GetSizer()->SetSizeHints(this);

    if (!fileExistsOnDisk)
        DisableSourcesControls();

    auto nb = XRCCTRL(*this, "properties_notebook", wxNotebook);
    nb->SetSelection(initialPage);

    m_language->Bind(wxEVT_TEXT, &PropertiesDialog::OnLanguageChanged, this);
    m_language->Bind(wxEVT_COMBOBOX, &PropertiesDialog::OnLanguageChanged, this);

    m_pluralFormsDefault->Bind(wxEVT_RADIOBUTTON, &PropertiesDialog::OnPluralFormsDefault, this);
    m_pluralFormsCustom->Bind(wxEVT_RADIOBUTTON, &PropertiesDialog::OnPluralFormsCustom, this);
    m_pluralFormsExpr->Bind(
        wxEVT_UPDATE_UI,
        [=](wxUpdateUIEvent& e){ e.Enable(m_pluralFormsCustom->GetValue()); });
    m_pluralFormsExpr->Bind(
        wxEVT_TEXT,
        [=](wxCommandEvent& e){ m_validatedPlural = -1; e.Skip(); });
    Bind(wxEVT_UPDATE_UI,
        [=](wxUpdateUIEvent& e){ e.Enable(Validate()); },
        wxID_OK);
    CallAfter([=]{
        m_project->SetFocus();
    });
}
开发者ID:mapme,项目名称:poedit,代码行数:77,代码来源:propertiesdlg.cpp

示例9: SetSelection

/**
 * Move the cursor to offset <code>index</code>.
 */
void Selection::SetSelection(
    /* [in] */ ISpannable* text,
    /* [in] */ Int32 index)
{
    SetSelection(text, index, index);
}
开发者ID:TheTypoMaster,项目名称:ElastosRDK5_0,代码行数:9,代码来源:Selection.cpp

示例10: GetPlanner

BOOL CBCGPPlannerViewMonth::OnKeyDown(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/)
{
	if (m_pCapturedAppointment != NULL)
	{
		GetPlanner ()->SendMessage (WM_CANCELMODE, 0, 0);
		return TRUE;
	}

	BOOL isShiftPressed = (0x8000 & GetKeyState(VK_SHIFT)) != 0;

	BOOL bHandled = FALSE;

	if (nChar == VK_PRIOR || nChar == VK_NEXT) // Page Up, Page Down
	{
		OnVScroll (nChar == VK_PRIOR ? SB_PAGEUP : SB_PAGEDOWN, 0, NULL);

		SetSelection (m_Date, m_Date);

		bHandled = TRUE;
	}
	else if (nChar == VK_HOME || nChar == VK_END)
	{
		COleDateTime date
			(
				GetFirstWeekDay2 (m_Date, CBCGPPlannerManagerCtrl::GetFirstDayOfWeek () + 1)
			);

		if (nChar == VK_END)
		{
			date += COleDateTimeSpan (6, 0, 0, 0);
		}

		if (!isShiftPressed)
		{
			m_Date = date;
		}
		else
		{
			if (nChar == VK_HOME)
			{
				COleDateTime oldDate (m_Date);

				m_Date = date;
				date   = oldDate;
			}
			else
			{
				m_Date = m_Selection[1];
			}
		}

		SetSelection (m_Date, date);

		bHandled = TRUE;
	}
	else if (nChar == VK_UP || nChar == VK_DOWN || nChar == VK_LEFT || nChar == VK_RIGHT)
	{
		COleDateTime date (m_Selection [1]);

		COleDateTimeSpan span (1, 0, 0 ,0);

		if (nChar == VK_LEFT)
		{
			date -= span;
		}
		else if (nChar == VK_RIGHT)
		{
			date += span;
		}
		else
		{
			span = COleDateTimeSpan (7, 0, 0 ,0);

			if (nChar == VK_UP)
			{
				date -= span;
			}
			else if (nChar == VK_DOWN)
			{
				date += span;
			}
		}

		BOOL bScroll = FALSE;

		if (date < m_DateStart)
		{
			OnVScroll (SB_LINEUP, 0, NULL);
			bScroll = TRUE;
		}
		else if (date >= (m_DateStart + COleDateTimeSpan (GetViewDuration (), 0, 0, 0)))
		{
			OnVScroll (SB_LINEDOWN, 0, NULL);
			bScroll = TRUE;
		}

		if (!isShiftPressed || bScroll)
		{
			m_Date = date;
			SetSelection (m_Date, m_Date);
//.........这里部分代码省略.........
开发者ID:cugxiangzhenwei,项目名称:WorkPlatForm,代码行数:101,代码来源:BCGPPlannerViewMonth.cpp

示例11: SetSelection

void __fastcall TFeatureChildForm::FormCreate(TObject *Sender)
{
  SetSelection();
}
开发者ID:chinnyannieb,项目名称:Meus-Projetos,代码行数:4,代码来源:FeatureChild.cpp

示例12: SetSelection

void wxListBoxBase::Command(wxCommandEvent& event)
{
    SetSelection(event.GetInt(), event.GetExtraLong() != 0);
    (void)GetEventHandler()->ProcessEvent(event);
}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:5,代码来源:lboxcmn.cpp

示例13: WXUNUSED

void wxComboBox::OnSelectAll(wxCommandEvent& WXUNUSED(event))
{
    SetSelection(-1, -1);
}
开发者ID:beanhome,项目名称:dev,代码行数:4,代码来源:combobox.cpp

示例14: SetSelection

void wxComboBox::SelectAll()
{
    SetSelection(0, GetLastPosition());
}
开发者ID:beanhome,项目名称:dev,代码行数:4,代码来源:combobox.cpp

示例15: SetSelection

void wxTextCtrlBase::SelectAll()
{
    SetSelection(0, GetLastPosition());
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:4,代码来源:textcmn.cpp


注:本文中的SetSelection函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。