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


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

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


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

示例1: text

void
BAboutWindow::AddText(const char* header, const char** contents)
{
	BTextView* infoView = fAboutView->InfoView();
	int32 textLength = infoView->TextLength();
	BString text("");

	if (textLength > 0) {
		text << "\n\n";
		textLength += 2;
	}

	const char* indent = "";
	if (header != NULL) {
		indent = "    ";
		text << header;
	}

	if (contents != NULL) {
		text << "\n";
		for (int32 i = 0; contents[i]; i++)
			text << indent << contents[i] << "\n";
	}

	infoView->Insert(text.String());

	if (contents != NULL && header != NULL) {
		infoView->SetFontAndColor(textLength, textLength + strlen(header),
			be_bold_font);
	}
}
开发者ID:ysei,项目名称:Faber,代码行数:31,代码来源:AboutWindow.cpp

示例2:

void
StringEditor::CommitChanges()
{
	if (fPreviousText != fTextView->Text()) {
		fEditor.Replace(0, (const uint8 *)fTextView->Text(),
			fTextView->TextLength() + 1);
	}
}
开发者ID:DonCN,项目名称:haiku,代码行数:8,代码来源:TypeEditors.cpp

示例3: BTextView

/***********************************************************
 * HardWrap
 ***********************************************************/
void
HWrapTextView::GetHardWrapedText(BString &out)
{
	MakeEditable(false);
	
	BTextView *offview = new BTextView(Bounds(),NULL,TextRect(),B_FOLLOW_ALL);
	offview->SetText(Text());
	
	BFont font;
	uint32 propa;
	GetFontAndColor(&font,&propa);
	out = "";
	offview->SetFontAndColor(&font,B_FONT_ALL);
	BString line;
	int32 length = offview->TextLength();
	float view_width = offview->TextRect().Width();
	char c=0;
	bool inserted;
	
	for(int32 i=0;i < length;i++)
	{
		c = offview->ByteAt(i);
		if(c == '\n')
		{
			line = "";
			continue;
		}
		line += c;
		if(font.StringWidth(line.String())>=view_width)
		{
			// Back 1 charactor.
			i--;
			line.Truncate(line.Length()-1);
			// Insert line break.
			inserted = false;
			int32 len = line.Length();
			for(int32 k = 0;k<len;k++)
			{
				if(offview->CanEndLine(i-k))
				{
					offview->Insert(i-k,"\n",1);
					inserted=true;
					i = i-k;
					break;
				}
			}
			// If could not find proper position, add line break to end.
			if(!inserted)
				offview->Insert(i,"\n",1);
			line = "";
		}
	}
	out = offview->Text();
	
	delete offview;
	MakeEditable(true);
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:60,代码来源:HWrapTextView.cpp

示例4: 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

示例5: file

/***********************************************************
 * ChangeAccount
 ***********************************************************/
void
HAddressView::ChangeAccount(const char* name)
{
	BPath path;
	::find_directory(B_USER_SETTINGS_DIRECTORY,&path);
	path.Append(APP_NAME);
	path.Append("Accounts");
	path.Append(name);
	
	BFile file(path.Path(),B_READ_ONLY);
	if(file.InitCheck() == B_OK)
	{
		BMessage msg;
		msg.Unflatten(&file);
		BString name,from,address;
		
		if(msg.FindString("real_name",&name) != B_OK)
			name = "";
		if(msg.FindString("address",&address) != B_OK)
		{
			address = "";
			(new BAlert("",_("Cound not find your email address!\nPlease check your account"),_("OK")))->Go();
			return;
		}
		if(name.Length() > 0)
			from << "\"" <<name << "\" <";
		from += address;
		
		if(name.Length() > 0)
			from << ">";
		fFrom->SetText(from.String());
		// Insert signature.
		BTextView *view = cast_as(Window()->FindView("HMailView"),BTextView);
		if(view)
		{	
			const char* sig_path;
			if(msg.FindString("signature",&sig_path) == B_OK)
			{
				BFile sigfile(sig_path,B_READ_ONLY);
				if(sigfile.InitCheck() == B_OK)
				{
					BString str;
					str << "\n" << sigfile;
					view->Insert(view->TextLength(),str.String(),str.Length());
					view->Select(0,0);
				}
			}
		}
	}
}
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:53,代码来源:HAddressView.cpp

示例6:

void
PersonView::MessageReceived(BMessage* msg)
{
	switch (msg->what) {
		case M_SAVE:
			Save();
			break;

		case M_REVERT:
			if (fPictureView)
				fPictureView->Revert();

			if (fAddrView)
				fAddrView->Reload();

			for (int32 i = fControls.CountItems() - 1; i >= 0; i--)
				fControls.ItemAt(i)->Reload();
			break;

		case M_SELECT:
			for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
				BTextView* text = fControls.ItemAt(i)->TextView();
				if (text->IsFocus()) {
					text->Select(0, text->TextLength());
					break;
				}
			}
			break;

		case M_GROUP_MENU:
		{
			/*const char* name = NULL;
			if (msg->FindString("group", &name) == B_OK)
				SetAttribute(fCategoryAttribute, name, false);*/
			break;
		}

	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:39,代码来源:PersonView.cpp

示例7: AddressWindow

void
PersonView::MessageReceived(BMessage* msg)
{
	msg->PrintToStream();
	switch (msg->what) {
		case M_SAVE:
			Save();
			break;

		case M_REVERT:
			if (fPictureView)
				fPictureView->Revert();

			if (fAddressWindow)
				fAddressWindow->Reload();

			for (int32 i = fControls.CountItems() - 1; i >= 0; i--)
				fControls.ItemAt(i)->Reload();
			break;

		case M_SELECT:
			for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
				BTextView* text = fControls.ItemAt(i)->TextView();
				if (text->IsFocus()) {
					text->Select(0, text->TextLength());
					break;
				}
			}
			break;

		case M_GROUP_MENU:
		{
			/*const char* name = NULL;
			if (msg->FindString("group", &name) == B_OK)
				SetAttribute(fCategoryAttribute, name, false);*/
			break;
		}

		case M_SHOW_LOCATIONS:
		{
			if (fAddressWindow == NULL) {
				fAddressWindow = new AddressWindow(fContact);
			}
			fAddressWindow->Show();
			fAddressWindow->Activate(true);
			break;
		}

		case M_ADD_FIELD:
		{
			field_type type;
			if (msg->FindInt32("field_type", (int32*)&type) == B_OK) {
				BContactField* contactField 
					= BContactField::InstantiateChildClass(type);
				fContact->AddField(contactField);
				AddNewField(contactField);
				fSaved = false;
			}
			break;
		}

		case M_REMOVE_FIELD:
		{
			ContactFieldTextControl* control;
			if (msg->FindPointer("fieldtextcontrol",
				(void**)&control) == B_OK) {
				_RemoveField(control);
				fSaved = false;
			}
			break;
		}
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:73,代码来源:PersonView.cpp

示例8: str

status_t
PTextView::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BTextView *backend = (BTextView*)fView;

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

	if (str.ICompare("LineCount") == 0)
		((IntProperty*)prop)->SetValue(backend->CountLines());
	else if (str.ICompare("Selectable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsSelectable());
	else if (str.ICompare("CurrentLine") == 0)
		((IntProperty*)prop)->SetValue(backend->CurrentLine());
	else if (str.ICompare("TabWidth") == 0)
		((FloatProperty*)prop)->SetValue(backend->TabWidth());
	else if (str.ICompare("TextRect") == 0)
		((RectProperty*)prop)->SetValue(backend->TextRect());
	else if (str.ICompare("MaxBytes") == 0)
		((IntProperty*)prop)->SetValue(backend->MaxBytes());
	else if (str.ICompare("UseWordWrap") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesWordWrap());
	else if (str.ICompare("HideTyping") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsTypingHidden());
	else if (str.ICompare("Editable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsEditable());
	else if (str.ICompare("ColorSpace") == 0)
		((IntProperty*)prop)->SetValue(backend->ColorSpace());
	else if (str.ICompare("TextLength") == 0)
		((IntProperty*)prop)->SetValue(backend->TextLength());
	else if (str.ICompare("Text") == 0)
		((StringProperty*)prop)->SetValue(backend->Text());
	else if (str.ICompare("Resizable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsResizable());
	else if (str.ICompare("Alignment") == 0)
		((EnumProperty*)prop)->SetValue(backend->Alignment());
	else if (str.ICompare("Undoable") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesUndo());
	else if (str.ICompare("AutoIndent") == 0)
		((BoolProperty*)prop)->SetValue(backend->DoesAutoindent());
	else if (str.ICompare("Stylable") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsStylable());
	else
	{
		if (backend->Window())
			backend->Window()->Unlock();

		return PView::GetProperty(name, value, index);
	}

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

	return prop->GetValue(value);
}
开发者ID:HaikuArchives,项目名称:PDesigner,代码行数:63,代码来源:PTextView.cpp

示例9: message


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

							if (fRefDropMenu->CountItems() > 1) {
								fRefDropMenu->SetTargetForItems(this);
								fRefDropMenu->Go(point, true, true, true);
								return;
							} else {
								delete fRefDropMenu;
								fRefDropMenu = NULL;
							}
						}

						BString email;
						file.ReadAttrString(attr.String(), &email);

						// we got something...
						if (email.Length() > 0) {
							// see if we can get a username as well
							BString name;
							file.ReadAttrString("META:name", &name);

							BString	address;
							if (name.Length() == 0) {
								// if we have no Name, just use the email address
								address = email;
							} else {
								// otherwise, pretty-format it
								address << "\"" << name << "\" <" << email << ">";
							}

							if (addressList.Length() > 0)
								addressList << ", ";
							addressList << address;
						}
					} else {
						enclosure = true;
						message.AddRef("refs", &ref);
					}
				}
			}

			if (addressList.Length() > 0) {
				BTextView *textView = TextView();
				int end = textView->TextLength();
				if (end != 0) {
					textView->Select(end, end);
					textView->Insert(", ");
				}
				textView->Insert(addressList.String());
			}

			if (enclosure)
				Window()->PostMessage(&message, Window());
			break;
		}

		case M_SELECT:
		{
			BTextView *textView = (BTextView *)ChildAt(0);
			if (textView != NULL)
				textView->Select(0, textView->TextLength());
			break;
		}

		case kMsgAddressChosen: {
			BString display;
			BString address;
			entry_ref ref;

			if (msg->FindString("address", &address) != B_OK
				|| msg->FindRef("ref", &ref) != B_OK)
				return;

			if (address.Length() > 0) {
				BString name;
				BNode node(&ref);

				display = address;

				node.ReadAttrString("META:name", &name);
				if (name.Length() > 0) {
					display = "";
					display << "\"" << name << "\" <" << address << ">";
				}

				BTextView *textView = TextView();
				int end = textView->TextLength();
				if (end != 0) {
					textView->Select(end, end);
					textView->Insert(", ");
				}
				textView->Insert(display.String());
			}
			break;
		}

		default:
			// BTextControl::MessageReceived(msg);
			BComboBox::MessageReceived(msg);
	}
}
开发者ID:sahil9912,项目名称:haiku,代码行数:101,代码来源:Header.cpp

示例10: switch


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

        /* grab this little tidbit so we can set the correct Family */
        if (msg->FindInt32("parent_index", &family_menu_index) == B_OK)
            fFontMenu->ItemAt(family_menu_index)->SetMarked(true);
        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();
        // To do: insert at selection point rather than at the end.
        text->Insert(text->TextLength(), 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:mmadia,项目名称:haiku-1,代码行数:101,代码来源:Prefs.cpp


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