本文整理汇总了C++中BTextControl::TextView方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextControl::TextView方法的具体用法?C++ BTextControl::TextView怎么用?C++ BTextControl::TextView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextControl
的用法示例。
在下文中一共展示了BTextControl::TextView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BTextControl
BTextControl*
DocInfoWindow::_AddPasswordControl(BRect r, BView* panel, const char* name,
const char* label)
{
BString text;
_DocInfo()->FindString(name, &text);
BTextControl* textControl = new BTextControl(r, name, label, "", NULL,
B_FOLLOW_LEFT_RIGHT);
panel->AddChild(textControl);
textControl->ResizeToPreferred();
textControl->TextView()->HideTyping(true);
textControl->TextView()->SetText(text.String());
return textControl;
}
示例2: 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
}
示例3: 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);
}
示例4: rect
Window::Window()
: BWindow(BRect(100, 100, 590, 260), "EventMask-Test",
B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
BView* view = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(view);
BTextControl* textControl = new BTextControl(BRect(10, 10, 290, 30),
"text", "Type to test focus suspending:", "", NULL, B_FOLLOW_LEFT_RIGHT);
textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8);
view->AddChild(textControl);
textControl = new BTextControl(BRect(300, 10, 420, 30),
"all", "All keys:", "", NULL, B_FOLLOW_LEFT_RIGHT);
textControl->SetDivider(textControl->StringWidth(textControl->Label()) + 8);
view->AddChild(textControl);
textControl->TextView()->SetEventMask(B_KEYBOARD_EVENTS, 0);
BRect rect(10, 40, 120, 120);
for (int32 i = 0; i < 4; i++) {
uint32 options = 0;
switch (i) {
case 1:
options = B_SUSPEND_VIEW_FOCUS;
break;
case 2:
options = B_LOCK_WINDOW_FOCUS;
break;
case 3:
options = B_SUSPEND_VIEW_FOCUS | B_LOCK_WINDOW_FOCUS;
break;
}
fViews[i] = new PositionView(rect, options);
view->AddChild(fViews[i]);
rect.OffsetBy(120, 0);
}
BCheckBox* checkBox = new BCheckBox(BRect(10, 130, 200, 160), "permanent", "Get all pointer events", new BMessage(kMsgPointerEvents));
view->AddChild(checkBox);
}
示例5: BWindow
Fenster::Fenster() : BWindow( BRect( 20, 40, 620, 460), "PecoRename", B_TITLED_WINDOW, 0){
// Menü
BMenuBar* MenuBar = new BMenuBar( BRect( 0, 0, 0, 0 ), "MenuBar" );
BMenu* Menu;
Menu = new BMenu(STR_MENU_FILE);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_NEW, new BMessage(MSG_MENU_NEW), 'N'));
Menu->AddItem(new BMenuItem(STR_MENU_OPEN, new BMessage(MSG_SELECT_FILES), 'O'));
Menu->AddSeparatorItem();
Menu->AddItem(new BMenuItem(STR_MENU_ABOUT, new BMessage(B_ABOUT_REQUESTED)));
Menu->AddSeparatorItem();
Menu->AddItem(new BMenuItem(STR_MENU_QUIT, new BMessage(B_QUIT_REQUESTED), 'Q'));
Menu = new BMenu(STR_MENU_TOOLS);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_CREATE_SCRIPT, new BMessage(MSG_MENU_SCRIPT)));
Menu = new BMenu(STR_MENU_HELP);
MenuBar->AddItem(Menu);
Menu->AddItem(new BMenuItem(STR_MENU_DOCU, new BMessage(MSG_MENU_DOCU)));
AddChild( MenuBar );
// Größe bestimmen + Fenster anpassen
float BarWidth, BarHeight;
MenuBar->GetPreferredSize ( &BarWidth, &BarHeight );
SetSizeLimits( 600, 600, 10000, 155 + BarHeight + 5 * be_plain_font->Size() + 2 * be_bold_font->Size());
// Main Frame
BRect MainFrame = Bounds();
MainFrame.top += BarHeight;
MainView* mainView = new MainView( MainFrame );
AddChild( mainView );
BTextControl* TextControl = (BTextControl *)FindView("pfadView");
TextControl->TextView()->MakeEditable(false);
};
示例6: 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 */
示例7: MessageReceived
void BrowserWindow::MessageReceived( BMessage* pcMsg )
{
switch( pcMsg->what )
{
case ID_URL_CHANGED:
{
std::string cURL = m_pcURLView->Text();
for ( uint i = 0 ; i <= cURL.size() ; ++i ) {
if ( i == cURL.size() || isalnum( cURL[i] ) == false ) {
if ( i == cURL.size() || cURL[i] != ':' ) {
std::string cTmp = cURL;
cURL = "http://";
for ( uint j = 0 ; j < cTmp.size() ; ++j ) {
if ( cTmp[j] != '/' ) {
cURL.insert( cURL.end(), cTmp.begin() + j, cTmp.end() );
break;
}
}
}
break;
}
}
m_pcHTMLPart->view()->MakeFocus();
OpenURL( cURL, KParts::URLArgs() );
//----------------------------------------------
#if 0
uint32 nEvents = 0;
pcMsg->FindInt( "events", &nEvents );
if ( nEvents & os::TextView::EI_ESC_PRESSED ) {
m_pcURLView->Set( m_pcHTMLPart->url().prettyURL().utf8().data() );
m_pcHTMLPart->view()->MakeFocus();
break;
}
if ( nEvents & os::TextView::EI_ENTER_PRESSED ) {
std::string cURL = m_pcURLView->GetBuffer()[0];
for ( uint i = 0 ; i <= cURL.size() ; ++i ) {
if ( i == cURL.size() || isalnum( cURL[i] ) == false ) {
if ( i == cURL.size() || cURL[i] != ':' ) {
std::string cTmp = cURL;
cURL = "http://";
for ( uint j = 0 ; j < cTmp.size() ; ++j ) {
if ( cTmp[j] != '/' ) {
cURL.insert( cURL.end(), cTmp.begin() + j, cTmp.end() );
break;
}
}
}
break;
}
}
UpdateHistory();
AddHistoryEntry();
m_pcHTMLPart->view()->MakeFocus();
OpenURL( cURL, KParts::URLArgs() );
UpdateHistory();
}
#endif
break;
}
case ID_ACTIVATE_URLEDIT:
m_pcURLView->MakeFocus( true );
#if 0
m_pcURLView->SetCursor( -1, 0 );
#endif
m_pcURLView->TextView()->SelectAll();
break;
case ID_RELOAD:
{
KParts::URLArgs cArgs;
cArgs.reload = true;
cArgs.xOffset = m_pcHTMLPart->browserExtension()->xOffset();
cArgs.yOffset = m_pcHTMLPart->browserExtension()->yOffset();
#if 0
OpenURL( m_pcURLView->GetBuffer()[0], cArgs );
#endif
OpenURL( m_pcURLView->Text(), cArgs );
break;
}
case ID_NEW_WINDOW:
{
BrowserWindow* pcNewWindow = new BrowserWindow( Frame().OffsetByCopy( 30.0f, 30.0f ), false );
pcNewWindow->Show();
#if 0
UpdateHistory();
std::vector<HistoryEntry*> cHistory = m_cHistory;
cHistory.resize( m_nCurHistoryPos + 1 );
BrowserWindow* pcNewWindow = new BrowserWindow( GetFrame() + os::Point( 30.0f, 30.0f ), &cHistory, false );
pcNewWindow->GoHistory(0);
pcNewWindow->Show( true );
pcNewWindow->MakeFocus( true );
#endif
break;
}
case ID_OPEN_LINK:
{
BString cURL;
//.........这里部分代码省略.........
示例8: rect
//----------------Real code----------------------
BMailProtocolConfigView::BMailProtocolConfigView(uint32 options_mask)
:
BView (BRect(0,0,100,20), "protocol_config_view", B_FOLLOW_LEFT
| B_FOLLOW_TOP, B_WILL_DRAW),
fBodyDownloadConfig(NULL)
{
BRect rect(5,5,245,25);
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
// determine font height
font_height fontHeight;
GetFontHeight(&fontHeight);
sItemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13;
rect.bottom = rect.top - 2 + sItemHeight;
if (options_mask & B_MAIL_PROTOCOL_HAS_HOSTNAME)
AddChild(AddTextField(rect, "host", B_TRANSLATE("Mail server:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_USERNAME)
AddChild(AddTextField(rect, "user", B_TRANSLATE("Username:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_PASSWORD) {
BTextControl *control = AddTextField(rect, "pass",
B_TRANSLATE("Password:"));
control->TextView()->HideTyping(true);
AddChild(control);
}
if (options_mask & B_MAIL_PROTOCOL_HAS_FLAVORS)
AddChild(AddMenuField(rect, "flavor", B_TRANSLATE("Connection type:")));
if (options_mask & B_MAIL_PROTOCOL_HAS_AUTH_METHODS)
AddChild(AddMenuField(rect, "auth_method", B_TRANSLATE("Login type:")));
// set divider
float width = FindWidestLabel(this);
for (int32 i = CountChildren();i-- > 0;) {
if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i)))
text->SetDivider(width + 6);
}
if (options_mask & B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER) {
AddChild(AddCheckBox(rect, "leave_mail_on_server",
B_TRANSLATE("Leave mail on server"), new BMessage('lmos')));
BCheckBox* box = AddCheckBox(rect, "delete_remote_when_local",
B_TRANSLATE("Remove mail from server when deleted"));
box->SetEnabled(false);
AddChild(box);
}
if (options_mask & B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD) {
fBodyDownloadConfig = new BodyDownloadConfig();
fBodyDownloadConfig->MoveBy(0, rect.bottom + 5);
AddChild(fBodyDownloadConfig);
}
// resize views
float height;
GetPreferredSize(&width,&height);
ResizeTo(width,height);
for (int32 i = CountChildren();i-- > 0;) {
// this doesn't work with BTextControl, does anyone know why? -- axeld.
if (BView *view = ChildAt(i))
view->ResizeTo(width - 10,view->Bounds().Height());
}
}