本文整理汇总了C++中BTextControl类的典型用法代码示例。如果您正苦于以下问题:C++ BTextControl类的具体用法?C++ BTextControl怎么用?C++ BTextControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BTextControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BStringView
quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width,
string name, uint16* xpos, uint16* ypos)
{
BStringView* sv = new BStringView(BRect((*xpos), (*ypos),
(*xpos) + width, (*ypos) + 10),
(name + "Text").c_str(), name.c_str());
BFont font;
sv->GetFont(&font);
font.SetSize(10);
sv->SetFont(&font);
AddChild(sv);
BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10,
(*xpos) + width, (*ypos) + 10), (name + "Field").c_str(),
"", "", 0);
(*xpos) += width;
tc->SetDivider(0);
AddChild(tc);
BPopUpMenu* pu = new BPopUpMenu("", true, false);
BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9,
(*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu);
mf->SetDivider(0);
AddChild(mf);
(*xpos) += 30;
return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv);
}
示例2: InitGUI
/***********************************************************
* Constructor.
***********************************************************/
HAddTrackerWindow::HAddTrackerWindow(BRect rect,const char* name)
:BWindow(rect,name,B_TITLED_WINDOW_LOOK,B_MODAL_APP_WINDOW_FEEL,B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_ASYNCHRONOUS_CONTROLS)
{
InitGUI();
BTextControl *control = cast_as(FindView("name"),BTextControl);
control->MakeFocus(true);
}
示例3: path
/**
* @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());
}
}
示例4: BView
/***********************************************************
* Set up GUIs.
***********************************************************/
void
HAddTrackerWindow::InitGUI()
{
BView *view = new BView(Bounds(),"bgview",0,0);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect rect = Bounds();
rect.left += 20;
rect.right -= 20;
rect.top += 10;
rect.bottom = rect.top + 20;
BTextControl *control = new BTextControl(rect,"name","Name:","",new BMessage(M_END_NAME));
control->SetDivider(50);
view->AddChild(control);
rect.OffsetBy(0,30);
control = new BTextControl(rect,"address","Address:","",NULL);
control->SetDivider(50);
view->AddChild(control);
rect.OffsetBy(0,30);
rect.left = rect.right - 70;
BButton *btn = new BButton(rect,"ok","OK",new BMessage(M_OK_MSG));
view->AddChild(btn);
rect.OffsetBy(-80,0);
btn = new BButton(rect,"cancel","Cancel",new BMessage(B_QUIT_REQUESTED));
view->AddChild(btn);
this->AddChild(view);
}
示例5: max
void
LprSetupView::AttachedToWindow()
{
float width = max(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10;
/* server name box */
// TODO remember previous value
fServer = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "192.168.0.0",
NULL);
AddChild(fServer);
fServer->SetDivider(width);
/* queue name box */
// TODO remember previous value
fQueue = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "LPT1_PASSTHRU",
NULL);
AddChild(fQueue);
fQueue->SetDivider(width);
/* cancel */
BButton *button = new BButton(CANCEL_RECT, "", CANCEL_TEXT,
new BMessage(M_CANCEL));
AddChild(button);
/* ok */
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK));
AddChild(button);
button->MakeDefault(true);
}
示例6: ResizeBy
void SplitWindow::AddCat()
{
ResizeBy(0, 25);
uint16 xpos = 20;
uint16 width = 150;
BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10,
xpos + width, ypos + 10), "CatField", "", "", 0);
xpos += width;
tc->SetDivider(0);
catTexts.push_back(tc);
v->AddChild(tc);
BPopUpMenu* pu = new BPopUpMenu("", true, false);
BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9,
xpos + 2, ypos + 9), "CatMenu", "", pu);
mf->SetDivider(0);
v->AddChild(mf);
xpos += 30;
tc = new BTextControl(BRect(xpos - 5, ypos + 10,
xpos + 75, ypos + 10), "AmountField", "", "", 0);
tc->SetDivider(0);
tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
tc->SetModificationMessage(new BMessage(AmountModifiedMSG));
amtTexts.push_back(tc);
v->AddChild(tc);
ypos += 25;
for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++)
{
if ((*ci)->IsRoot())
{
pu->AddItem(MakeCatMenu(*ci));
}
}
catnum++;
}
示例7: Visit
virtual void Visit(BStringContactField* field)
{
int count = fOwner->fControls.CountItems();
BGridLayout* layout = fOwner->GridLayout();
if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
ContactFieldTextControl* control = new ContactFieldTextControl(field);
layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
fOwner->fControls.AddItem(control);
} else {
const char* label =
BContactField::ExtendedLabel(field);
fOwner->fGroups = new BPopUpMenu(label);
fOwner->fGroups->SetRadioMode(false);
fOwner->BuildGroupMenu(field);
BMenuField* field = new BMenuField("", "", fOwner->fGroups);
BTextControl* control = new BTextControl("simpleGroup",
NULL, NULL, NULL);
field->SetEnabled(true);
layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
}
}
示例8: GameByID
/*
* Returns 0 if cancel was chose, otherwise
* returns the game no
*
*/
unsigned GameByID(int gameno /* default # */)
{
BTextView *T;
BTextControl *tC;
register int i;
char buffer[256];
if (!gameno) gameno = 1;
sprintf(buffer, "%d%c", gameno, 0);
tC = new BTextControl( *(new BRect(10, 10, 20, 50)),
"Game Number", buffer, NULL);
T = tC->TextView();
/*
* Make sure only #s can be entered
*/
for (i = 0; i < 256; i++)
T->DisallowChar(i);
for (i = '0'; i < '9' + 1; i++)
T->AllowChar(i);
AddChild(tC)
Show(); // start running
}
示例9: MAX
void
SetupView::AttachedToWindow()
{
float width = MAX(StringWidth(SERVER_TEXT), StringWidth(QUEUE_TEXT)) + 10;
/* server name box */
fServerAddress = new BTextControl(SERVER_RECT, "", SERVER_TEXT, "<printer's hostname or address>", NULL);
AddChild(fServerAddress);
fServerAddress->SetDivider(width);
/* queue name box */
fQueuePort = new BTextControl(QUEUE_RECT, "", QUEUE_TEXT, "9100", NULL); // 9100 is default HP JetDirect port number
AddChild(fQueuePort);
fQueuePort->SetDivider(width);
/* cancel */
BButton* button = new BButton(CANCEL_RECT, "", CANCEL_TEXT, new BMessage(M_CANCEL));
AddChild(button);
/* ok */
button = new BButton(OK_RECT, "", OK_TEXT, new BMessage(M_OK));
AddChild(button);
button->MakeDefault(true);
}
示例10: result
filter_result
DCCFileFilter::HandleButton (BMessage *)
{
filter_result result (B_DISPATCH_MESSAGE);
BTextControl *paneltext (dynamic_cast<BTextControl *>(
panel->Window()->FindView ("text view")));
if (paneltext)
{
BDirectory dir;
struct stat s;
entry_ref ref;
BEntry entry;
panel->GetPanelDirectory (&ref);
dir.SetTo (&ref);
if (entry.SetTo (&dir, paneltext->Text()) == B_NO_ERROR
&& entry.GetStat (&s) == B_NO_ERROR
&& S_ISREG (s.st_mode))
{
if (vision_app->GetBool ("dccAutoAccept"))
{
BMessage msg (M_FILE_PANEL_ALERT);
msg.AddInt32 ("which", 2);
panel->Window()->PostMessage (&msg);
result = B_SKIP_MESSAGE;
}
else
{
BString buffer;
BAlert *alert;
buffer << "The file \""
<< paneltext->Text()
<< "\" already exists in the specified folder. "
"Do you want to continue the transfer?";
alert = new BAlert (
"DCC Request",
buffer.String(),
"Cancel",
"Replace",
"Resume",
B_WIDTH_AS_USUAL,
B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->Go (new BInvoker (
new BMessage (M_FILE_PANEL_ALERT),
panel->Window()));
result = B_SKIP_MESSAGE;
}
}
}
return result;
}
示例11: GetText
const char* HDialog::GetText(const char *name) const
{
BTextControl *t = dynamic_cast<BTextControl *>(FindView(name));
if (t)
return t->Text();
else
return NULL;
} /* HDialog::SetText */
示例12: DoPriority
void MainWindow::DoPriority()
{
BTextControl *PriorityValue = (BTextControl *)FindView("MainPriorityValue");
if (strcmp("", PriorityValue->Text())) {
int32 value;
value = atoi(PriorityValue->Text());
DoPriority(value);
}
}
示例13: BMailProtocolConfigView
SMTPConfigView::SMTPConfigView(MailAddonSettings& settings,
BMailAccountSettings& accountSettings)
:
BMailProtocolConfigView(B_MAIL_PROTOCOL_HAS_AUTH_METHODS
| B_MAIL_PROTOCOL_HAS_USERNAME | B_MAIL_PROTOCOL_HAS_PASSWORD
| B_MAIL_PROTOCOL_HAS_HOSTNAME
#ifdef USE_SSL
| B_MAIL_PROTOCOL_HAS_FLAVORS
#endif
)
{
#if defined(USE_SSL) || defined(B_COLLECTING_CATKEYS)
static const char* kUnencryptedStr = B_TRANSLATE_MARK("Unencrypted");
static const char* kSSLStr = B_TRANSLATE_MARK("SSL");
static const char* kSTARTTLSStr = B_TRANSLATE_MARK("STARTTLS");
#endif
#ifdef USE_SSL
AddFlavor(B_TRANSLATE_NOCOLLECT(kUnencryptedStr));
AddFlavor(B_TRANSLATE(kSSLStr));
AddFlavor(B_TRANSLATE(kSTARTTLSStr));
#endif
AddAuthMethod(B_TRANSLATE("None"), false);
AddAuthMethod(B_TRANSLATE("ESMTP"));
AddAuthMethod(B_TRANSLATE("POP3 before SMTP"), false);
BTextControl *control = (BTextControl *)(FindView("host"));
control->SetLabel(B_TRANSLATE("SMTP server:"));
// Reset the dividers after changing one
float widestLabel = 0;
for (int32 i = CountChildren(); i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
widestLabel = MAX(widestLabel,text->StringWidth(text->Label()) + 5);
}
for (int32 i = CountChildren(); i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
text->SetDivider(widestLabel);
}
BMenuField *field = (BMenuField *)(FindView("auth_method"));
field->SetDivider(widestLabel);
SetTo(settings);
fFileView = new BMailFileConfigView(B_TRANSLATE("Destination:"), "path",
false, BPrivate::default_mail_out_directory().Path());
fFileView->SetTo(&settings.Settings(), NULL);
AddChild(fFileView);
float w, h;
BMailProtocolConfigView::GetPreferredSize(&w, &h);
fFileView->MoveBy(0, h - 10);
GetPreferredSize(&w, &h);
ResizeTo(w, h);
}
示例14:
void
DocInfoWindow::_ReadFieldsFromTable(BMessage& docInfo)
{
docInfo.MakeEmpty();
BView* child;
for (int32 i = 0; (child = fTable->ChildAt(i)) != NULL; i++) {
BTextControl* textControl = dynamic_cast<BTextControl*>(child);
if (textControl)
docInfo.AddString(textControl->Label(), textControl->Text());
}
}
示例15: 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);
}