本文整理汇总了C++中BTextControl::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextControl::SetText方法的具体用法?C++ BTextControl::SetText怎么用?C++ BTextControl::SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextControl
的用法示例。
在下文中一共展示了BTextControl::SetText方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doFileSelected
/**
* @brief ファイルが選択されたときの処理
* @param[in] fileIndex どっちのファイルか
* @param[in] message 選択されたパラメータを含むメッセージ
*/
void OpenFilesDialog::doFileSelected(OpenFilesDialog::FileIndex fileIndex, BMessage* message)
{
entry_ref ref;
if (B_OK != message->FindRef("refs", &ref))
{
return;
}
BPath path(&ref);
const char* viewName;
switch (fileIndex)
{
case LeftFile:
viewName = NAME_LEFT_TEXT_CONTROL;
break;
case RightFile:
viewName = NAME_RIGHT_TEXT_CONTROL;
break;
default:
viewName = NULL; // ここには来ない
break;
}
BTextControl* textControl = dynamic_cast<BTextControl*>(FindView(viewName));
if (NULL != textControl)
{
textControl->SetText(path.Path());
}
}
示例2: SetLocationBarURL
void BrowserWindow::SetLocationBarURL( const std::string &/*cURL*/ )
{
// m_pcURLView->Set( m_pcHTMLPart->url().prettyURL().utf8().data(), false );
m_pcURLView->SetText( m_pcHTMLPart->url().prettyURL().utf8().data() );
//?? m_pcURLView->SetText( cURL.c_str() );
// m_pcURLView->Set( cURL.c_str(), false );
}
示例3: locker
void
MimeTypeEditor::_UpdateText()
{
BAutolock locker(fEditor);
const char* mimeType;
if (fEditor.GetViewBuffer((const uint8 **)&mimeType) == B_OK) {
fTextControl->SetText(mimeType);
fPreviousText.SetTo(mimeType);
}
}
示例4: OpenURL
void BrowserWindow::OpenURL( const std::string& cURL, const KParts::URLArgs& cArgs )
{
// GlobalMutex::Lock();
// m_pcURLView->Set( cURL.c_str(), false );
m_pcURLView->SetText( cURL.c_str() );
m_pcHTMLPart->browserExtension()->setURLArgs( cArgs );
m_pcHTMLPart->openURL( cURL.c_str() );
// GlobalMutex::Unlock();
}
示例5: BWindow
BFIV_PrefWin::BFIV_PrefWin(BRect frame)
: BWindow(frame, "Preferences", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_RESIZABLE|B_NOT_ZOOMABLE)
{
BRect rect = Bounds();
BView *back;
BTextControl *scratchPath;
BButton *cancelButton, *okButton, *selectButton;
font_height fontHeight;
float fontSize, tmp;
// private data
filePanel = NULL;
// some font voodoo
be_plain_font->GetHeight(&fontHeight);
fontSize = fontHeight.ascent + fontHeight.descent;
// the background
back = new BView(rect, "background", B_FOLLOW_ALL, 0);
back->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(back);
// the select button
tmp = be_plain_font->StringWidth("Select");
rect.Set(frame.Width() - tmp - 20., 5., frame.Width() - 5., 5. + fontSize + 10.);
selectButton = new BButton(rect, "select", "Select", new BMessage(SELECT_SCRATCH_PATH));
back->AddChild(selectButton);
// the path
rect.Set(5.,5., selectButton->Frame().left - 5., 5. + fontSize + 10.);
scratchPath = new BTextControl(rect, "path", "Scratch Location", NULL, NULL, B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
back->AddChild(scratchPath);
scratchPath->SetText(((BFIV_App *)be_app)->ScratchDirectory()); // current dir
scratchPath->TextView()->MakeEditable(false); // only works after AddChild() (!!)
// the ok button
tmp = be_plain_font->StringWidth("OK");
rect.Set(frame.Width() - tmp - 35., Frame().Height() - fontSize - 20., frame.Width() - 10., Frame().Height() - 10.);
okButton = new BButton(rect, "ok", "OK", new BMessage(APPLY_PREFS_CHANGE));
back->AddChild(okButton);
okButton->MakeDefault(true);
// the cancel button
tmp = be_plain_font->StringWidth("Cancel");
rect.Set(okButton->Frame().left - tmp - 20., okButton->Frame().top, okButton->Frame().left - 5., okButton->Frame().bottom);
cancelButton = new BButton(rect, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED));
back->AddChild(cancelButton);
}
示例6: SetPrefs
void SetPrefs(const BMessage* prefs)
{
if( !prefs ) return;
mOldPrefs.MakeEmpty();
mOldPrefs = *prefs;
delete mRef;
mRef = 0;
bool b;
const char* str;
entry_ref ref;
if( mOnBox && prefs->FindBool( "on", &b ) == B_OK ) mOnBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
if( mNameCtrl && prefs->FindString( "name", &str ) == B_OK ) mNameCtrl->SetText( str );
if( prefs->FindRef( "ref", &ref ) == B_OK ) mRef = new entry_ref( ref );
if( mSkipBox && prefs->FindBool( "skip", &b ) == B_OK ) mSkipBox->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
}
示例7:
/***********************************************************
* MessageReceived
***********************************************************/
void
HAddressView::MessageReceived(BMessage *message)
{
switch(message->what)
{
case M_ACCOUNT_CHANGE:
{
const char* name;
if(message->FindString("name",&name) != B_OK)
break;
ChangeAccount(name);
PRINT(("Name:%s\n",name));
break;
}
case M_SEL_GROUP:
{
BMenu *menu;
BTextControl *control;
if(message->FindPointer("menu",(void**)&menu) != B_OK ||
message->FindPointer("control",(void**)&control) != B_OK)
break;
if(control)
{
BString text = control->Text();
if(text.Length() != 0)
text += ",";
int32 count = menu->CountItems();
for(int32 i = 0;i < count;i++)
{
const char* label = menu->ItemAt(i)->Label();
text += label;
if(i != count-1)
text += ",";
}
control->SetText(text.String() );
}
break;
}
default:
BView::MessageReceived(message);
}
}
示例8: SetText
void HDialog::SetText(const char *name, const char *text)
{
BView *c = FindView(name);
if (!c)
{
ASSERT(false);
return;
}
BTextControl *tc = dynamic_cast<BTextControl*>(c);
if (tc)
{
tc->SetText(text);
if (tc->IsFocus())
tc->TextView()->SelectAll();
}
else if (typeid(*c) == typeid(BStringView))
static_cast<BStringView *>(c)->SetText(text);
} /* HDialog::SetText */
示例9: New
void PecoApp::New() {
fWindow->Lock();
fListView->MakeEmpty();
//...und Updaten...
BListItem* myListItem;
fListView->AddItem(myListItem = new BStringItem(""));
fListView->RemoveItem(myListItem);
BTextControl* pfadView = (BTextControl *)fWindow->FindView("pfadView");
pfadView->SetText(NULL);
fWindow->Unlock();
for( FileListItem* myItem; (myItem = (FileListItem *)fList->RemoveItem((int32)0) ) != NULL; )
delete myItem;
UpdateWindowStatus();
}
示例10: BMailProtocolConfigView
IMAPConfig::IMAPConfig(BMessage *archive)
: BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_USERNAME
| B_MAIL_PROTOCOL_HAS_PASSWORD | B_MAIL_PROTOCOL_HAS_HOSTNAME
| B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER
#ifdef USE_SSL
| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
)
{
#ifdef USE_SSL
AddFlavor("No encryption");
AddFlavor("SSL");
#endif
SetTo(archive);
((BControl *)(FindView("leave_mail_remote")))->SetValue(B_CONTROL_ON);
((BControl *)(FindView("leave_mail_remote")))->Hide();
BRect frame = FindView("delete_remote_when_local")->Frame();
((BControl *)(FindView("delete_remote_when_local")))->SetEnabled(true);
((BControl *)(FindView("delete_remote_when_local")))->MoveBy(0,-25);
frame.right -= 10;// FindView("pass")->Frame().right;
/*frame.top += 10;
frame.bottom += 10;*/
BTextControl *folder = new BTextControl(frame,"root","Top mailbox folder: ","",NULL);
folder->SetDivider(be_plain_font->StringWidth("Top mailbox folder: "));
if (archive->HasString("root"))
folder->SetText(archive->FindString("root"));
AddChild(folder);
ResizeToPreferred();
}
示例11: sizeof
void
NumberEditor::_UpdateText()
{
if (fEditor.Lock()) {
const char* number;
if (fEditor.GetViewBuffer((const uint8**)&number) == B_OK) {
char buffer[64];
char format[16];
switch (fEditor.Type()) {
case B_FLOAT_TYPE:
{
float value = *(float*)number;
snprintf(buffer, sizeof(buffer), "%g", value);
break;
}
case B_DOUBLE_TYPE:
{
double value = *(double *)number;
snprintf(buffer, sizeof(buffer), "%g", value);
break;
}
case B_SSIZE_T_TYPE:
case B_INT8_TYPE:
case B_INT16_TYPE:
case B_INT32_TYPE:
case B_INT64_TYPE:
case B_OFF_T_TYPE:
{
_Format(format);
switch (_Size()) {
case 1:
{
int8 value = *(int8 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 2:
{
int16 value = *(int16 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 4:
{
int32 value = *(int32 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 8:
{
int64 value = *(int64 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
}
break;
}
default:
{
_Format(format);
switch (_Size()) {
case 1:
{
uint8 value = *(uint8 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 2:
{
uint16 value = *(uint16 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 4:
{
uint32 value = *(uint32 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
case 8:
{
uint64 value = *(uint64 *)number;
snprintf(buffer, sizeof(buffer), format, value);
break;
}
}
break;
}
}
fTextControl->SetText(buffer);
fPreviousText.SetTo(buffer);
}
fEditor.Unlock();
}
}
示例12: RefsReceived
void PecoApp::RefsReceived ( BMessage* msg ) {
entry_ref ref;
BPath aPath;
BEntry aEntry;
off_t size;
time_t timer;
fWindow->Lock();
BTextControl* pfadView = (BTextControl *)fWindow->FindView("pfadView");
fWindow->Unlock();
//Pfad finden
for ( int i=0; msg->FindRef("refs", i, &ref) == B_OK; i++ ) if ( ref.device > 1 ) break;
if ( ref.device > 1 ) {
New();
fWindow->Lock();
((PecoApp *)be_app)->fStatusBar->SetText(STATUS_IMPORT);
fWindow->Unlock();
aEntry = BEntry(&ref);
BPath( &aEntry ).GetParent(&fPfad);
fWindow->Lock();
pfadView->SetText( fPfad.Path() );
fWindow->Unlock();
//zählen
type_code typeFound;
long total = 0;
msg->GetInfo("refs", &typeFound, &total);
fWindow->Lock();
fStatusBar->SetMaxValue( total );
fWindow->Unlock();
BPath newPath;
bool didntshow_msgmultidir = true;
for ( int i=0; msg->FindRef("refs", i, &ref) == B_OK; i++ ) {
fWindow->Lock();
fStatusBar->Update(1);
fWindow->Unlock();
// Laufwerke ausfiltern
if ( ref.device == 1 ) continue;
// Dateien mit falschem Pfad ausfiltern
aEntry = BEntry(&ref);
aPath = BPath(&aEntry);
BPath( &aEntry ).GetParent(&newPath);
if ( (strcmp( fPfad.Path(), newPath.Path() ) != 0 ) ) {
if ( didntshow_msgmultidir ) {
BAlert* myAlert = new BAlert(NULL, MESSAGE_MULTIDIR, STR_OK);
myAlert->Go();
didntshow_msgmultidir = false;
}
continue;
}
// Werte auslesen
if (aEntry.IsFile()) aEntry.GetSize(&size);
else
if (aEntry.IsSymLink()) size = -1;
else
if (aEntry.IsDirectory()) size = -2;
else continue;
aEntry.GetModificationTime(&timer);
fList->AddItem(new FileListItem(aPath.Leaf(), size, timer, &ref));
}
fWindow->Lock();
fListView->AddList(fList);
float Hoehe = be_plain_font->Size() + 2;
if (Hoehe < 18) {
BListItem* myListItem;
for (int i=0; (myListItem = fListView->ItemAt(i)); i++) myListItem->SetHeight(18);
// Zum Updaten:
fListView->AddItem(myListItem = new BStringItem(""));
fListView->RemoveItem(myListItem);
}
fStatusBar->Reset(STATUS_STATUS);
fStatusBar->SetMaxValue(fList->CountItems());
fWindow->Unlock();
MakeList();
}
fWindow->Activate();
UpdateWindowStatus();
}
示例13: MessageReceived
//.........这里部分代码省略.........
BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
preferences.ReplaceString(prefsID.String(), textControl->Text());
}
else if (is_instance_of(changedView, BCheckBox))
{
//a checkbox value was changed, update preferences with new bool value(on/off)
BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
preferences.ReplaceBool(prefsID.String(), checkBox->Value());
}
else if (is_instance_of(changedView, BSlider))
{
//a slider value was changed, update preferences with new slider value
BSlider *slider = dynamic_cast<BSlider*>(changedView);
preferences.ReplaceInt32(prefsID.String(), slider->Value());
}
else if (is_instance_of(changedView, ColourButton))
{
//a colourcontrol value was changed, update preferences with new colour
ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
preferences.ReplaceData(prefsID.String(),B_RGB_COLOR_TYPE, &colourControl->Value(), sizeof(rgb_color));
}
prefsLock.Unlock();
}
}
break;
case PrefsConstants::K_LOAD_PREFERENCES:
{
//set preferences view values to values of the preferences message
BString prefsID;
if (message->FindString(K_PREFS_ID, &prefsID) == B_OK)
{
//find out which view value has to be updated
BView *changedView = m_parent->FindView(prefsID.String());
prefsLock.Lock();
char *name;
uint32 type;
int32 count;
for (int32 i = 0; preferences.GetInfo(B_ANY_TYPE, i, &name, &type, &count) == B_OK; i++)
{
//find out what kind of field we are using
switch (type)
{
case B_INT32_TYPE:
{
int32 value;
preferences.FindInt32(name, &value);
if (is_instance_of(changedView, BSlider))
{
BSlider *slider = dynamic_cast<BSlider*>(changedView);
slider->SetValue(value);
}
}
break;
case B_BOOL_TYPE:
{
bool value;
preferences.FindBool(name, &value);
if (is_instance_of(changedView, BCheckBox))
{
BCheckBox *checkBox = dynamic_cast<BCheckBox*>(changedView);
checkBox->SetValue(value);
}
}
break;
case B_RGB_COLOR_TYPE:
{
rgb_color *colour;
ssize_t size;
preferences.FindData(name, B_RGB_COLOR_TYPE, (const void**)&colour, &size);
if (is_instance_of(changedView, ColourButton))
{
ColourButton *colourControl = dynamic_cast<ColourButton*>(changedView);
colourControl->SetValue(*colour);
}
}
break;
case B_STRING_TYPE:
{
BString string;
preferences.FindString(name, &string);
if (is_instance_of(changedView, ColourButton))
{
BTextControl *textControl = dynamic_cast<BTextControl*>(changedView);
textControl->SetText(string.String());
}
}
break;
}
}
prefsLock.Unlock();
//make sure the new view values are drawn!
changedView->Invalidate();
}
}
break;
default:
BWindow::MessageReceived(message);
break;
}
}