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


C++ BTextView::GetSelection方法代码示例

本文整理汇总了C++中BTextView::GetSelection方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::GetSelection方法的具体用法?C++ BTextView::GetSelection怎么用?C++ BTextView::GetSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BTextView的用法示例。


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

示例1:

int32_t
PTextViewGetSelection(void *pobject, void *in, void *out, void *extraData)
{
	if (!pobject || !in || !out)
		return B_ERROR;

	PView *parent = static_cast<PView*>(pobject);
	if (!parent)
		return B_BAD_TYPE;
	
	BTextView *backend = (BTextView*)parent->GetView();


	PArgs *outArgs = static_cast<PArgs*>(out);

	if (backend->Window())
		backend->Window()->Lock();

	int32 outValue1;
	int32 outValue2;

	backend->GetSelection(&outValue1, &outValue2);

	if (backend->Window())
		backend->Window()->Unlock();

	outArgs->MakeEmpty();
	outArgs->AddInt32("start", outValue1);
	outArgs->AddInt32("end", outValue2);

	return B_OK;
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:32,代码来源:PTextView.cpp

示例2:

bool
PersonView::IsTextSelected() const
{
	for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
		BTextView* text = fControls.ItemAt(i)->TextView();

		int32 start, end;
		text->GetSelection(&start, &end);
		if (start != end)
			return true;
	}
	return false;
}
开发者ID:looncraz,项目名称:haiku,代码行数:13,代码来源:PersonView.cpp

示例3: if

void
PersonView::SetAttribute(const char* attribute, const char* value,
	bool update)
{
	if (!LockLooper())
		return;

	AttributeTextControl* control = NULL;
	for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
		if (fControls.ItemAt(i)->Attribute() == attribute) {
			control = fControls.ItemAt(i);
			break;
		}
	}

	if (control == NULL)
		return;

	if (update) {
		control->SetText(value);
		control->Update();
	} else {
		BTextView* text = control->TextView();

		int32 start, end;
		text->GetSelection(&start, &end);
		if (start != end) {
			text->Delete();
			text->Insert(value);
		} else if ((end = text->TextLength())) {
			text->Select(end, end);
			text->Insert(",");
			text->Insert(value);
			text->Select(text->TextLength(), text->TextLength());
		} else
			control->SetText(value);
	}

	UnlockLooper();
}
开发者ID:looncraz,项目名称:haiku,代码行数:40,代码来源:PersonView.cpp

示例4: strcmp


//.........这里部分代码省略.........
			break;

		case P_SIZE:
			old_size = (int32) fNewFont->Size();
			msg->FindInt32("size", &new_size);
			if (old_size != new_size) {
				fNewFont->SetSize(new_size);
				message.what = M_FONT;
				be_app->PostMessage(&message);
			}
			break;

		case P_WRAP:
			msg->FindBool("wrap", fNewWrap);
			break;
		case P_ATTACH_ATTRIBUTES:
			msg->FindBool("attachAttributes", fNewAttachAttributes);
			break;
		case P_COLORED_QUOTES:
			msg->FindBool("cquotes", fNewColoredQuotes);
			break;
		case P_ACCOUNT:
			msg->FindInt32("id",(int32*)fNewAccount);
			break;
		case P_REPLYTO:
			msg->FindInt32("replyTo", fNewReplyTo);
			break;
		case P_REPLY_PREAMBLE:
		{
			int32 index = -1;
			if (msg->FindInt32("index", &index) < B_OK)
				break;
			BMenuItem *item = fReplyPreambleMenu->ItemAt(index);
			if (item == NULL) {
				msg->PrintToStream();
				break;
			}

			BTextView *text = fReplyPreamble->TextView();
			int32 selectionStart;
			int32 selectionEnd;
			text->GetSelection(&selectionStart, &selectionEnd);
			if (selectionStart != selectionEnd)
				text->Delete(selectionStart, selectionEnd);
			text->Insert(item->Label(), 2);
		}
		case P_SIG:
			free(*fNewSignature);
			if (msg->FindString("signature", &signature) == B_NO_ERROR) {
				*fNewSignature = (char*)malloc(strlen(signature) + 1);
				strcpy(*fNewSignature, signature);
			} else {
				*fNewSignature = (char*)malloc(
					strlen(B_TRANSLATE("None")) + 1);
				strcpy(*fNewSignature, B_TRANSLATE("None"));
			}
			break;
		case P_ENC:
			msg->FindInt32("encoding", (int32*)fNewEncoding);
			break;
		case P_WARN_UNENCODABLE:
			msg->FindBool("warnUnencodable", fNewWarnUnencodable);
			break;
		case P_SPELL_CHECK_START_ON:
			msg->FindBool("spellCheckStartOn", fNewSpellCheckStartOn);
			break;
		case P_MARK_READ:
			msg->FindBool("autoMarkRead", fNewAutoMarkRead);
			be_app->PostMessage(PREFS_CHANGED);
			break;
		case P_BUTTON_BAR:
			msg->FindInt8("bar", (int8*)fNewButtonBar);
			be_app->PostMessage(PREFS_CHANGED);
			break;

		default:
			BWindow::MessageReceived(msg);
	}

	fFont.GetFamilyAndStyle(&old_family, &old_style);
	fNewFont->GetFamilyAndStyle(&new_family, &new_style);
	old_size = (int32) fFont.Size();
	new_size = (int32) fNewFont->Size();
	bool changed = old_size != new_size
		|| fWrap != *fNewWrap
		|| fAttachAttributes != *fNewAttachAttributes
		|| fColoredQuotes != *fNewColoredQuotes
		|| fAccount != *fNewAccount
		|| fReplyTo != *fNewReplyTo
		|| strcmp(old_family, new_family)
		|| strcmp(old_style, new_style)
		|| strcmp(fReplyPreamble->Text(), *fNewPreamble)
		|| strcmp(fSignature, *fNewSignature)
		|| fEncoding != *fNewEncoding
		|| fWarnUnencodable != *fNewWarnUnencodable
		|| fSpellCheckStartOn != *fNewSpellCheckStartOn
		|| fAutoMarkRead != *fNewAutoMarkRead
		|| fButtonBar != *fNewButtonBar;
	fRevert->SetEnabled(changed);
}
开发者ID:simonsouth,项目名称:haiku,代码行数:101,代码来源:Prefs.cpp


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