本文整理汇总了C++中BTextView::DisallowChar方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextView::DisallowChar方法的具体用法?C++ BTextView::DisallowChar怎么用?C++ BTextView::DisallowChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextView
的用法示例。
在下文中一共展示了BTextView::DisallowChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2:
int32_t
PTextViewDisallowChars(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 *inArgs = static_cast<PArgs*>(in);
BString string;
if (inArgs->FindString("chars", &string) != B_OK)
return B_ERROR;
if (backend->Window())
backend->Window()->Lock();
for (int32 i = 0; i < string.CountChars(); i++)
{
char c = string.ByteAt(i);
if (c)
backend->DisallowChar(c);
}
if (backend->Window())
backend->Window()->Unlock();
return B_OK;
}
示例3: r
void
Spinner::_InitObject(void)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect r(Bounds());
if (r.Height() < B_H_SCROLL_BAR_HEIGHT * 2)
r.bottom = r.top + 1 + B_H_SCROLL_BAR_HEIGHT * 2;
ResizeTo(r.Width(),r.Height());
r.right -= B_V_SCROLL_BAR_WIDTH;
font_height fh;
BFont font;
font.GetHeight(&fh);
float textheight = fh.ascent + fh.descent + fh.leading;
r.top = 0;
r.bottom = textheight;
fTextControl = new BTextControl(r,"textcontrol",Label(),"0",
new BMessage(M_TEXT_CHANGED), B_FOLLOW_TOP |
B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW | B_NAVIGABLE);
AddChild(fTextControl);
fTextControl->ResizeTo(r.Width(), MAX(textheight, fTextControl->TextView()->LineHeight(0) + 4.0));
fTextControl->MoveTo(0,
((B_H_SCROLL_BAR_HEIGHT * 2) - fTextControl->Bounds().Height()) / 2);
fTextControl->SetDivider(StringWidth(Label()) + 5);
BTextView *tview = fTextControl->TextView();
tview->SetAlignment(B_ALIGN_LEFT);
tview->SetWordWrap(false);
BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| "
"asdfghjkl:\"zxcvbnm<>[email protected]#$%^&*()-_=+`~\r");
for (int32 i = 0; i < string.CountChars(); i++) {
char c = string.ByteAt(i);
tview->DisallowChar(c);
}
r = Bounds();
r.left = r.right - B_V_SCROLL_BAR_WIDTH;
r.bottom = B_H_SCROLL_BAR_HEIGHT;
fUpButton = new SpinnerArrowButton(r.LeftTop(),"up",ARROW_UP);
AddChild(fUpButton);
r.OffsetBy(0,r.Height() + 1);
fDownButton = new SpinnerArrowButton(r.LeftTop(),"down",ARROW_DOWN);
AddChild(fDownButton);
fPrivateData = new SpinnerPrivateData;
fFilter = new SpinnerMsgFilter;
}
示例4:
void
ApplicationTypeWindow::_MakeNumberTextControl(BTextControl* control)
{
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = control->TextView();
textView->SetMaxBytes(10);
for (int32 i = 0; i < 256; i++) {
if (!isdigit(i))
textView->DisallowChar(i);
}
}
示例5: done
ID_Win::ID_Win(BLooper *l, unsigned int g):
Txt_Ctl(NULL), done(0), Game(0),
BWindow(BRect(100, 100, 300, 180), "New Game By ID",
B_TITLED_WINDOW,
B_NOT_RESIZABLE | /*B_NOT_CLOSABLE |*/ B_NOT_ZOOMABLE
| B_NOT_MINIMIZABLE)
{
BView *back;
BButton * Cancel;
BButton * Accept;
BTextView *T;
register int i;
loop = l;
Game = g;
back = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
back->SetViewColor(216, 216, 216);
AddChild(back);
Accept = new BButton( BRect(10, 40, 90, 55), "Accept",
"Accept", new BMessage(ACCEPT_BUTTON));
Accept->MakeDefault(true);
back->AddChild(Accept);
Cancel = new BButton( BRect(120, 40, 190, 55), "Cancel",
"Cancel", new BMessage(CANCEL_BUTTON));
back->AddChild(Cancel);
Txt_Ctl = new BTextControl(BRect(10, 10, 190, 25), "",
"Game Number", "", NULL);
T = Txt_Ctl->TextView();
/*
* Only allow #s in there.
*/
for (i = 0; i < 256; i++)
T->DisallowChar(i);
for (i = '0'; i < '9' + 1; i++)
T->AllowChar(i);
back->AddChild(Txt_Ctl);
char buffer[64];
if (!Game) Game = rand();
sprintf(buffer, "%d", Game);
Txt_Ctl->SetText(buffer);
Txt_Ctl->MakeFocus(true);
//Port = create_port(1, "ID Window Port");
Show();
}
示例6:
/**
* AllowOnlyNumbers()
*
* @param BTextControl, the control we want to only allow numbers
* @param maxNum, the maximun number of characters allowed
* @return void
*/
void
MarginView::_AllowOnlyNumbers(BTextControl *textControl, int32 maxNum)
{
BTextView *tv = textControl->TextView();
for (int32 i = 0; i < 256; i++)
tv->DisallowChar(i);
for (int32 i = '0'; i <= '9'; i++)
tv->AllowChar(i);
tv->AllowChar(B_BACKSPACE);
tv->AllowChar('.');
tv->SetMaxBytes(maxNum);
}
示例7: BMessage
FileTypeWindow::FileTypeWindow(BPoint position, const BMessage& refs)
:
BWindow(BRect(0.0f, 0.0f, 300.0f, 200.0f).OffsetBySelf(position),
B_TRANSLATE("File type"), B_TITLED_WINDOW,
B_NOT_V_RESIZABLE | B_NOT_ZOOMABLE
| B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
float padding = be_control_look->DefaultItemSpacing();
// "File Type" group
BBox* fileTypeBox = new BBox("file type BBox");
fileTypeBox->SetLabel(B_TRANSLATE("File type"));
fTypeControl = new BTextControl("type", NULL, "Type Control",
new BMessage(kMsgTypeEntered));
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fTypeControl->TextView();
const char* disallowedCharacters = "<>@,;:\"()[]?=";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
fSelectTypeButton = new BButton("select type",
B_TRANSLATE("Select" B_UTF8_ELLIPSIS), new BMessage(kMsgSelectType));
fSameTypeAsButton = new BButton("same type as",
B_TRANSLATE_COMMENT("Same as" B_UTF8_ELLIPSIS,
"The same TYPE as ..."), new BMessage(kMsgSameTypeAs));
BLayoutBuilder::Grid<>(fileTypeBox, padding, padding / 2)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fTypeControl, 0, 0, 3, 1)
.Add(fSelectTypeButton, 0, 1)
.Add(fSameTypeAsButton, 1, 1);
// "Icon" group
BBox* iconBox = new BBox("icon BBox");
iconBox->SetLabel(B_TRANSLATE("Icon"));
fIconView = new IconView("icon");
BLayoutBuilder::Group<>(iconBox, B_HORIZONTAL)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fIconView);
// "Preferred Application" group
BBox* preferredBox = new BBox("preferred BBox");
preferredBox->SetLabel(B_TRANSLATE("Preferred application"));
BMenu* menu = new BPopUpMenu("preferred");
BMenuItem* item;
menu->AddItem(item = new BMenuItem(B_TRANSLATE("Default application"),
new BMessage(kMsgPreferredAppChosen)));
item->SetMarked(true);
fPreferredField = new BMenuField("preferred", NULL, menu);
fSelectAppButton = new BButton("select app",
B_TRANSLATE("Select" B_UTF8_ELLIPSIS),
new BMessage(kMsgSelectPreferredApp));
fSameAppAsButton = new BButton("same app as",
B_TRANSLATE_COMMENT("Same as" B_UTF8_ELLIPSIS,
"The same APPLICATION as ..."),
new BMessage(kMsgSamePreferredAppAs));
BLayoutBuilder::Grid<>(preferredBox, padding, padding / 2)
.SetInsets(padding, padding * 2, padding, padding)
.Add(fPreferredField, 0, 0, 3, 1)
.Add(fSelectAppButton, 0, 1)
.Add(fSameAppAsButton, 1, 1);
BLayoutBuilder::Grid<>(this)
.SetInsets(padding)
.Add(fileTypeBox, 0, 0, 2, 1)
.Add(preferredBox, 0, 1, 1, 1)
.Add(iconBox, 1, 1, 1, 1);
fTypeControl->MakeFocus(true);
BMimeType::StartWatching(this);
_SetTo(refs);
}
示例8: BMessage
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position,
const BEntry& entry)
:
BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
B_TRANSLATE("Application type"), B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS |
B_FRAME_EVENTS | B_AUTO_UPDATE_SIZE_LIMITS),
fChangedProperties(0)
{
float padding = be_control_look->DefaultItemSpacing();
BAlignment labelAlignment = be_control_look->DefaultLabelAlignment();
BMenuBar* menuBar = new BMenuBar((char*)NULL);
menuBar->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
BMenu* menu = new BMenu(B_TRANSLATE("File"));
fSaveMenuItem = new BMenuItem(B_TRANSLATE("Save"),
new BMessage(kMsgSave), 'S');
fSaveMenuItem->SetEnabled(false);
menu->AddItem(fSaveMenuItem);
BMenuItem* item;
menu->AddItem(item = new BMenuItem(
B_TRANSLATE("Save into resource file" B_UTF8_ELLIPSIS), NULL));
item->SetEnabled(false);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
new BMessage(B_QUIT_REQUESTED), 'W', B_COMMAND_KEY));
menuBar->AddItem(menu);
// Signature
fSignatureControl = new BTextControl(B_TRANSLATE("Signature:"), NULL,
new BMessage(kMsgSignatureChanged));
fSignatureControl->SetModificationMessage(
new BMessage(kMsgSignatureChanged));
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fSignatureControl->TextView();
textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
const char* disallowedCharacters = "<>@,;:\"()[]?=";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
// "Application Flags" group
BBox* flagsBox = new BBox("flagsBox");
fFlagsCheckBox = new BCheckBox("flags", B_TRANSLATE("Application flags"),
new BMessage(kMsgToggleAppFlags));
fFlagsCheckBox->SetValue(B_CONTROL_ON);
fSingleLaunchButton = new BRadioButton("single",
B_TRANSLATE("Single launch"), new BMessage(kMsgAppFlagsChanged));
fMultipleLaunchButton = new BRadioButton("multiple",
B_TRANSLATE("Multiple launch"), new BMessage(kMsgAppFlagsChanged));
fExclusiveLaunchButton = new BRadioButton("exclusive",
B_TRANSLATE("Exclusive launch"), new BMessage(kMsgAppFlagsChanged));
fArgsOnlyCheckBox = new BCheckBox("args only", B_TRANSLATE("Args only"),
new BMessage(kMsgAppFlagsChanged));
fBackgroundAppCheckBox = new BCheckBox("background",
B_TRANSLATE("Background app"), new BMessage(kMsgAppFlagsChanged));
flagsBox->AddChild(BGridLayoutBuilder()
.Add(fSingleLaunchButton, 0, 0).Add(fArgsOnlyCheckBox, 1, 0)
.Add(fMultipleLaunchButton, 0, 1).Add(fBackgroundAppCheckBox, 1, 1)
.Add(fExclusiveLaunchButton, 0, 2)
.SetInsets(padding, padding, padding, padding));
flagsBox->SetLabel(fFlagsCheckBox);
// "Icon" group
BBox* iconBox = new BBox("IconBox");
iconBox->SetLabel(B_TRANSLATE("Icon"));
fIconView = new IconView("icon");
fIconView->SetModificationMessage(new BMessage(kMsgIconChanged));
iconBox->AddChild(BGroupLayoutBuilder(B_HORIZONTAL)
.Add(fIconView)
.SetInsets(padding, padding, padding, padding));
// "Supported Types" group
BBox* typeBox = new BBox("typesBox");
typeBox->SetLabel(B_TRANSLATE("Supported types"));
fTypeListView = new SupportedTypeListView("Suppported Types",
B_SINGLE_SELECTION_LIST);
fTypeListView->SetSelectionMessage(new BMessage(kMsgTypeSelected));
BScrollView* scrollView = new BScrollView("type scrollview", fTypeListView,
B_FRAME_EVENTS | B_WILL_DRAW, false, true);
fAddTypeButton = new BButton("add type",
B_TRANSLATE("Add" B_UTF8_ELLIPSIS), new BMessage(kMsgAddType));
//.........这里部分代码省略.........
示例9: BMessage
ApplicationTypeWindow::ApplicationTypeWindow(BPoint position, const BEntry& entry)
: BWindow(BRect(0.0f, 0.0f, 250.0f, 340.0f).OffsetBySelf(position),
"Application Type", B_TITLED_WINDOW,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS),
fChangedProperties(0)
{
// add the menu
BMenuBar* menuBar = new BMenuBar(BRect(0, 0, 0, 0), NULL);
AddChild(menuBar);
BMenu* menu = new BMenu("File");
fSaveMenuItem = new BMenuItem("Save", new BMessage(kMsgSave), 'S');
fSaveMenuItem->SetEnabled(false);
menu->AddItem(fSaveMenuItem);
BMenuItem* item;
menu->AddItem(item = new BMenuItem("Save into resource file" B_UTF8_ELLIPSIS,
NULL));
item->SetEnabled(false);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Close", new BMessage(B_QUIT_REQUESTED),
'W', B_COMMAND_KEY));
menuBar->AddItem(menu);
// Top view and signature
BRect rect = Bounds();
rect.top = menuBar->Bounds().Height() + 1.0f;
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
rect = topView->Bounds().InsetByCopy(8.0f, 8.0f);
fSignatureControl = new BTextControl(rect, "signature", "Signature:", NULL,
new BMessage(kMsgSignatureChanged), B_FOLLOW_LEFT_RIGHT);
fSignatureControl->SetModificationMessage(
new BMessage(kMsgSignatureChanged));
fSignatureControl->SetDivider(fSignatureControl->StringWidth(
fSignatureControl->Label()) + 4.0f);
float width, height;
fSignatureControl->GetPreferredSize(&width, &height);
fSignatureControl->ResizeTo(rect.Width(), height);
topView->AddChild(fSignatureControl);
// filter out invalid characters that can't be part of a MIME type name
BTextView* textView = fSignatureControl->TextView();
textView->SetMaxBytes(B_MIME_TYPE_LENGTH);
const char* disallowedCharacters = "<>@,;:\"()[]?=";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
// "Application Flags" group
BFont font(be_bold_font);
font_height fontHeight;
font.GetHeight(&fontHeight);
width = font.StringWidth("Icon") + 16.0f;
if (width < B_LARGE_ICON + 16.0f)
width = B_LARGE_ICON + 16.0f;
rect.top = fSignatureControl->Frame().bottom + 4.0f;
rect.bottom = rect.top + 100.0f;
rect.right -= width + 8.0f;
BBox* box = new BBox(rect, NULL, B_FOLLOW_LEFT_RIGHT);
topView->AddChild(box);
fFlagsCheckBox = new BCheckBox(rect, "flags", "Application flags",
new BMessage(kMsgToggleAppFlags));
fFlagsCheckBox->SetValue(B_CONTROL_ON);
fFlagsCheckBox->ResizeToPreferred();
box->SetLabel(fFlagsCheckBox);
rect.top = fFlagsCheckBox->Bounds().Height() + 4.0f;
fSingleLaunchButton = new BRadioButton(rect, "single", "Single launch",
new BMessage(kMsgAppFlagsChanged));
fSingleLaunchButton->ResizeToPreferred();
box->AddChild(fSingleLaunchButton);
rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
fMultipleLaunchButton = new BRadioButton(rect, "multiple",
"Multiple launch", new BMessage(kMsgAppFlagsChanged));
fMultipleLaunchButton->ResizeToPreferred();
box->AddChild(fMultipleLaunchButton);
rect.OffsetBy(0.0f, fSingleLaunchButton->Bounds().Height() + 0.0f);
fExclusiveLaunchButton = new BRadioButton(rect, "exclusive",
"Exclusive launch", new BMessage(kMsgAppFlagsChanged));
fExclusiveLaunchButton->ResizeToPreferred();
box->AddChild(fExclusiveLaunchButton);
rect.top = fSingleLaunchButton->Frame().top;
rect.left = fExclusiveLaunchButton->Frame().right + 4.0f;
fArgsOnlyCheckBox = new BCheckBox(rect, "args only", "Args only",
new BMessage(kMsgAppFlagsChanged));
fArgsOnlyCheckBox->ResizeToPreferred();
box->AddChild(fArgsOnlyCheckBox);
//.........这里部分代码省略.........
示例10: BMessage
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
AttributeItem* attributeItem)
: BWindow(BRect(100, 100, 350, 200), "Attribute", B_MODAL_WINDOW_LOOK,
B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
| B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fMimeType(mimeType.Type())
{
if (attributeItem != NULL)
fAttribute = *attributeItem;
BRect rect = Bounds();
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
rect.InsetBy(8.0f, 8.0f);
fPublicNameControl = new BTextControl(rect, "public", "Attribute name:",
fAttribute.PublicName(), NULL, B_FOLLOW_LEFT_RIGHT);
fPublicNameControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
float labelWidth = fPublicNameControl->StringWidth(fPublicNameControl->Label()) + 2.0f;
fPublicNameControl->SetDivider(labelWidth);
fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
float width, height;
fPublicNameControl->GetPreferredSize(&width, &height);
fPublicNameControl->ResizeTo(rect.Width(), height);
topView->AddChild(fPublicNameControl);
rect = fPublicNameControl->Frame();
rect.OffsetBy(0.0f, rect.Height() + 5.0f);
fAttributeControl = new BTextControl(rect, "internal", "Internal name:",
fAttribute.Name(), NULL, B_FOLLOW_LEFT_RIGHT);
fAttributeControl->SetModificationMessage(new BMessage(kMsgAttributeUpdated));
fAttributeControl->SetDivider(labelWidth);
fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of an attribute
BTextView* textView = fAttributeControl->TextView();
const char* disallowedCharacters = "/";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
topView->AddChild(fAttributeControl);
fTypeMenu = new BPopUpMenu("type");
BMenuItem* item = NULL;
for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgTypeChosen);
message->AddInt32("type", kTypeMap[i].type);
item = new BMenuItem(kTypeMap[i].name, message);
fTypeMenu->AddItem(item);
if (kTypeMap[i].type == fAttribute.Type())
item->SetMarked(true);
}
rect.OffsetBy(0.0f, rect.Height() + 4.0f);
BMenuField* menuField = new BMenuField(rect, "types",
"Type:", fTypeMenu);
menuField->SetDivider(labelWidth);
menuField->SetAlignment(B_ALIGN_RIGHT);
menuField->GetPreferredSize(&width, &height);
menuField->ResizeTo(rect.Width(), height);
topView->AddChild(menuField);
rect.OffsetBy(0.0f, rect.Height() + 4.0f);
rect.bottom = rect.top + fAttributeControl->Bounds().Height() * 2.0f + 18.0f;
BBox* box = new BBox(rect, "", B_FOLLOW_LEFT_RIGHT);
topView->AddChild(box);
fVisibleCheckBox = new BCheckBox(rect, "visible", "Visible",
new BMessage(kMsgVisibilityChanged));
fVisibleCheckBox->SetValue(fAttribute.Visible());
fVisibleCheckBox->ResizeToPreferred();
box->SetLabel(fVisibleCheckBox);
labelWidth -= 8.0f;
BMenu* menu = new BPopUpMenu("display as");
for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgDisplayAsChosen);
if (kDisplayAsMap[i].identifier != NULL) {
message->AddString("identifier", kDisplayAsMap[i].identifier);
for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
}
}
item = new BMenuItem(kDisplayAsMap[i].name, message);
menu->AddItem(item);
if (compare_display_as(kDisplayAsMap[i].identifier, fAttribute.DisplayAs()))
item->SetMarked(true);
}
rect.OffsetTo(8.0f, fVisibleCheckBox->Bounds().Height());
//.........这里部分代码省略.........
示例11: BMessage
PreferencesWindow::PreferencesWindow(BRect frame)
:
BWindow(frame, B_TRANSLATE("Deskbar preferences"), B_TITLED_WINDOW,
B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_NOT_ZOOMABLE)
{
// Menu controls
fMenuRecentDocuments = new BCheckBox(B_TRANSLATE("Recent documents:"),
new BMessage(kUpdateRecentCounts));
fMenuRecentApplications = new BCheckBox(B_TRANSLATE("Recent applications:"),
new BMessage(kUpdateRecentCounts));
fMenuRecentFolders = new BCheckBox(B_TRANSLATE("Recent folders:"),
new BMessage(kUpdateRecentCounts));
fMenuRecentDocumentCount = new BTextControl(NULL, NULL,
new BMessage(kUpdateRecentCounts));
fMenuRecentApplicationCount = new BTextControl(NULL, NULL,
new BMessage(kUpdateRecentCounts));
fMenuRecentFolderCount = new BTextControl(NULL, NULL,
new BMessage(kUpdateRecentCounts));
// Applications controls
fAppsSort = new BCheckBox(B_TRANSLATE("Sort running applications"),
new BMessage(kSortRunningApps));
fAppsSortTrackerFirst = new BCheckBox(B_TRANSLATE("Tracker always first"),
new BMessage(kTrackerFirst));
fAppsShowExpanders = new BCheckBox(B_TRANSLATE("Show application expander"),
new BMessage(kSuperExpando));
fAppsExpandNew = new BCheckBox(B_TRANSLATE("Expand new applications"),
new BMessage(kExpandNewTeams));
fAppsHideLabels = new BCheckBox(B_TRANSLATE("Hide application names"),
new BMessage(kHideLabels));
fAppsIconSizeSlider = new BSlider("icon_size", B_TRANSLATE("Icon size"),
NULL, kMinimumIconSize / kIconSizeInterval,
kMaximumIconSize / kIconSizeInterval, B_HORIZONTAL);
fAppsIconSizeSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fAppsIconSizeSlider->SetHashMarkCount((kMaximumIconSize - kMinimumIconSize)
/ kIconSizeInterval + 1);
fAppsIconSizeSlider->SetLimitLabels(B_TRANSLATE("Small"),
B_TRANSLATE("Large"));
fAppsIconSizeSlider->SetModificationMessage(new BMessage(kResizeTeamIcons));
// Window controls
fWindowAlwaysOnTop = new BCheckBox(B_TRANSLATE("Always on top"),
new BMessage(kAlwaysTop));
fWindowAutoRaise = new BCheckBox(B_TRANSLATE("Auto-raise"),
new BMessage(kAutoRaise));
fWindowAutoHide = new BCheckBox(B_TRANSLATE("Auto-hide"),
new BMessage(kAutoHide));
// Clock controls
fShowSeconds = new BCheckBox(B_TRANSLATE("Show seconds"),
new BMessage(kShowSeconds));
fShowDayOfWeek = new BCheckBox(B_TRANSLATE("Show day of week"),
new BMessage(kShowDayOfWeek));
// Get settings from BarApp
TBarApp* barApp = static_cast<TBarApp*>(be_app);
desk_settings* settings = barApp->Settings();
// Menu settings
BTextView* docTextView = fMenuRecentDocumentCount->TextView();
BTextView* appTextView = fMenuRecentApplicationCount->TextView();
BTextView* folderTextView = fMenuRecentFolderCount->TextView();
for (int32 i = 0; i < 256; i++) {
if (!isdigit(i)) {
docTextView->DisallowChar(i);
appTextView->DisallowChar(i);
folderTextView->DisallowChar(i);
}
}
docTextView->SetMaxBytes(4);
appTextView->SetMaxBytes(4);
folderTextView->SetMaxBytes(4);
int32 docCount = settings->recentDocsCount;
int32 appCount = settings->recentAppsCount;
int32 folderCount = settings->recentFoldersCount;
fMenuRecentDocuments->SetValue(settings->recentDocsEnabled);
fMenuRecentDocumentCount->SetEnabled(settings->recentDocsEnabled);
fMenuRecentApplications->SetValue(settings->recentAppsEnabled);
fMenuRecentApplicationCount->SetEnabled(settings->recentAppsEnabled);
fMenuRecentFolders->SetValue(settings->recentFoldersEnabled);
fMenuRecentFolderCount->SetEnabled(settings->recentFoldersEnabled);
BString docString;
BString appString;
BString folderString;
docString << docCount;
appString << appCount;
folderString << folderCount;
fMenuRecentDocumentCount->SetText(docString.String());
fMenuRecentApplicationCount->SetText(appString.String());
fMenuRecentFolderCount->SetText(folderString.String());
//.........这里部分代码省略.........
示例12: BMessage
AttributeWindow::AttributeWindow(FileTypesWindow* target, BMimeType& mimeType,
AttributeItem* attributeItem)
:
BWindow(BRect(100, 100, 350, 200), B_TRANSLATE("Attribute"),
B_MODAL_WINDOW_LOOK, B_MODAL_SUBSET_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS | B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fMimeType(mimeType.Type())
{
float padding = be_control_look->DefaultItemSpacing();
if (attributeItem != NULL)
fAttribute = *attributeItem;
fPublicNameControl = new BTextControl(B_TRANSLATE("Attribute name:"),
fAttribute.PublicName(), NULL);
fPublicNameControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fPublicNameControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fAttributeControl = new BTextControl(B_TRANSLATE("Internal name:"),
fAttribute.Name(), NULL);
fAttributeControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fAttributeControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of an attribute
BTextView* textView = fAttributeControl->TextView();
const char* disallowedCharacters = "/";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
fTypeMenu = new BPopUpMenu("type");
BMenuItem* item = NULL;
for (int32 i = 0; kTypeMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgTypeChosen);
message->AddInt32("type", kTypeMap[i].type);
item = new BMenuItem(kTypeMap[i].name, message);
fTypeMenu->AddItem(item);
if (kTypeMap[i].type == fAttribute.Type())
item->SetMarked(true);
}
BMenuField* typeMenuField = new BMenuField("types" , B_TRANSLATE("Type:"),
fTypeMenu);
typeMenuField->SetAlignment(B_ALIGN_RIGHT);
// we must set the color manually when adding a menuField directly
// into a window.
typeMenuField->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
typeMenuField->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fVisibleCheckBox = new BCheckBox("visible", B_TRANSLATE("Visible"),
new BMessage(kMsgVisibilityChanged));
fVisibleCheckBox->SetValue(fAttribute.Visible());
BMenu* menu = new BPopUpMenu("display as");
for (int32 i = 0; kDisplayAsMap[i].name != NULL; i++) {
BMessage* message = new BMessage(kMsgDisplayAsChosen);
if (kDisplayAsMap[i].identifier != NULL) {
message->AddString("identifier", kDisplayAsMap[i].identifier);
for (int32 j = 0; kDisplayAsMap[i].supported[j]; j++) {
message->AddInt32("supports", kDisplayAsMap[i].supported[j]);
}
}
item = new BMenuItem(kDisplayAsMap[i].name, message);
menu->AddItem(item);
if (compare_display_as(kDisplayAsMap[i].identifier,
fAttribute.DisplayAs()))
item->SetMarked(true);
}
fDisplayAsMenuField = new BMenuField("display as",
B_TRANSLATE_COMMENT("Display as:",
"Tracker offers different display modes for attributes."), menu);
fDisplayAsMenuField->SetAlignment(B_ALIGN_RIGHT);
fEditableCheckBox = new BCheckBox("editable",
B_TRANSLATE_COMMENT("Editable",
"If Tracker allows to edit this attribute."),
new BMessage(kMsgAttributeUpdated));
fEditableCheckBox->SetValue(fAttribute.Editable());
fSpecialControl = new BTextControl(B_TRANSLATE("Special:"),
display_as_parameter(fAttribute.DisplayAs()), NULL);
fSpecialControl->SetModificationMessage(
new BMessage(kMsgAttributeUpdated));
fSpecialControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
fSpecialControl->SetEnabled(false);
char text[64];
snprintf(text, sizeof(text), "%ld", fAttribute.Width());
fWidthControl = new BTextControl(B_TRANSLATE_COMMENT("Width:",
"Default column width in Tracker for this attribute."),
text, NULL);
fWidthControl->SetModificationMessage(
//.........这里部分代码省略.........
示例13: BMessage
//.........这里部分代码省略.........
fPaletteM->AddItem(fWebSafeMI);
fPaletteM->AddItem(fBeOSSystemMI);
fPaletteM->AddItem(fGreyScaleMI);
fPaletteM->AddItem(fOptimalMI);
fColorCountM = new BPopUpMenu("ColorCountPopUpMenu", true, true,
B_ITEMS_IN_COLUMN);
int32 count = 2;
for (int32 i = 0; i < 8; i++) {
BMessage* message = new BMessage(GV_SET_COLOR_COUNT);
message->AddInt32(GIF_SETTING_PALETTE_SIZE, i + 1);
BString label;
label << count;
fColorCountMI[i] = new BMenuItem(label.String(), message, 0, 0);
fColorCountM->AddItem(fColorCountMI[i]);
count *= 2;
}
fColorCount256MI = fColorCountMI[7];
fPaletteMF = new BMenuField(B_TRANSLATE("Palette:"), fPaletteM);
fPaletteMF->SetAlignment(B_ALIGN_RIGHT);
fColorCountMF = new BMenuField(B_TRANSLATE("Colors:"), fColorCountM);
fColorCountMF->SetAlignment(B_ALIGN_RIGHT);
// check boxes
fUseDitheringCB = new BCheckBox(B_TRANSLATE("Use dithering"),
new BMessage(GV_USE_DITHERING));
fDitheringBox = new BBox("dithering", B_WILL_DRAW, B_NO_BORDER);
fDitheringBox->SetLabel(fUseDitheringCB);
fInterlacedCB = new BCheckBox(B_TRANSLATE("Write interlaced images"),
new BMessage(GV_INTERLACED));
fInterlacedBox = new BBox("interlaced", B_WILL_DRAW, B_NO_BORDER);
fInterlacedBox->SetLabel(fInterlacedCB);
fUseTransparentCB = new BCheckBox(B_TRANSLATE("Write transparent images"),
new BMessage(GV_USE_TRANSPARENT));
// radio buttons
fUseTransparentAutoRB = new BRadioButton(
B_TRANSLATE("Automatic (from alpha channel)"),
new BMessage(GV_USE_TRANSPARENT_AUTO));
fUseTransparentColorRB = new BRadioButton(B_TRANSLATE("Use RGB color"),
new BMessage(GV_USE_TRANSPARENT_COLOR));
// text controls
fRedTextControl = new BTextControl("", "0",
new BMessage(GV_TRANSPARENT_RED));
fGreenTextControl = new BTextControl("", "0",
new BMessage(GV_TRANSPARENT_GREEN));
fBlueTextControl = new BTextControl("", "0",
new BMessage(GV_TRANSPARENT_BLUE));
fTransparentBox = new BBox(B_FANCY_BORDER,
BLayoutBuilder::Grid<>(3.0f, 5.0f)
.Add(fUseTransparentAutoRB, 0, 0, 4, 1)
.Add(fUseTransparentColorRB, 0, 1)
.Add(fRedTextControl, 1, 1)
.Add(fGreenTextControl, 2, 1)
.Add(fBlueTextControl, 3, 1)
.SetInsets(10.0f, 6.0f, 10.0f, 10.0f)
.View());
fTransparentBox->SetLabel(fUseTransparentCB);
BTextView* redTextView = fRedTextControl->TextView();
BTextView* greenTextView = fGreenTextControl->TextView();
BTextView* bluetextView = fBlueTextControl->TextView();
for (uint32 x = 0; x < 256; x++) {
if (x < '0' || x > '9') {
redTextView->DisallowChar(x);
greenTextView->DisallowChar(x);
bluetextView->DisallowChar(x);
}
}
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.SetInsets(B_USE_DEFAULT_SPACING)
.Add(fTitle)
.Add(fVersion)
.Add(fCopyright)
.AddGlue()
.AddGrid(10.0f, 5.0f)
.Add(fPaletteMF->CreateLabelLayoutItem(), 0, 0)
.Add(fPaletteMF->CreateMenuBarLayoutItem(), 1, 0)
.Add(fColorCountMF->CreateLabelLayoutItem(), 0, 1)
.Add(fColorCountMF->CreateMenuBarLayoutItem(), 1, 1)
.End()
.AddStrut(B_USE_SMALL_SPACING)
.Add(fDitheringBox)
.Add(fInterlacedBox)
.Add(fTransparentBox)
.AddGlue()
.End();
fSettings->Acquire();
RestorePrefs();
}
示例14: CreateField
void HDialog::CreateField(int kind, BPositionIO& data, BView*& inside)
{
dRect r;
char name[256];
char label[256];
uint32 cmd;
BView *v;
switch (kind)
{
case 'btn ':
data >> r >> name >> label >> cmd;
inside->AddChild(v = new BButton(r.ToBe(), name, label, new BMessage(cmd)));
if (cmd == msg_OK || strcmp(name, "ok") == 0)
SetDefaultButton(static_cast<BButton*>(v));
break;
case 'radb':
data >> r >> name >> label;
inside->AddChild(new BRadioButton(r.ToBe(), name, label, new BMessage(msg_FieldChanged)));
break;
case 'chkb':
data >> r >> name >> label;
inside->AddChild(new BCheckBox(r.ToBe(), name, label, new BMessage(msg_FieldChanged)));
break;
case 'edit':
{
char val[256], allowed[256];
short max, divider;
data >> r >> name >> label >> val >> allowed >> max >> divider;
BRect b = r.ToBe();
inside->AddChild(v = new BTextControl(b, name, *label ? label : NULL,
val, new BMessage(msg_FieldChanged), B_FOLLOW_NONE));
BTextView *tv = static_cast<BTextControl*>(v)->TextView();
if (*allowed)
{
for (int i = 0; i < 256; i++)
if (isprint(i))
{
if (strchr(allowed, i)) tv->AllowChar(i);
else tv->DisallowChar(i);
}
}
if (max) tv->SetMaxBytes(max);
if (divider) static_cast<BTextControl*>(v)->SetDivider(divider * gFactor);
if (v->Bounds().Height() < b.Height())
{
float d = v->Bounds().Height() - tv->Bounds().Height();
v->ResizeTo(b.Width(), b.Height());
tv->ResizeTo(tv->Bounds().Width(), b.Height() - d);
}
break;
}
case 'capt':
data >> r >> name >> label;
inside->AddChild(v = new BStringView(r.ToBe(), name, label));
v->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
break;
case 'popu':
{
short id, div;
data >> r >> name >> label >> id >> div;
inside->AddChild(v = new BMenuField(r.ToBe(), name, *label ? label : NULL,
HResources::GetMenu(id, true)));
if (div) static_cast<BMenuField*>(v)->SetDivider(div * gFactor);
break;
}
case 'tabb':
data >> r >> name;
inside->AddChild(v = new HTabSheet(r.ToBe(), name));
inside = v;
break;
case 'tabe':
inside = inside->Parent();
break;
case 'shet':
data >> name >> label;
inside = dynamic_cast<HTabSheet*>(inside)->AddSheet(name, label);
break;
case 'shte':
inside = inside->Parent();
break;
case 'box ':
data >> r >> name;
inside->AddChild(v = new BBox(r.ToBe(), name));
if (*name) dynamic_cast<BBox*>(v)->SetLabel(name);
v->SetFont(be_plain_font);
inside = v;
break;
case 'boxe':
inside = inside->Parent();
break;
case 'list':
case 'olst':
{
data >> r >> name;
//.........这里部分代码省略.........
示例15: BMessage
ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type,
const char* extension)
: BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK,
B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
| B_ASYNCHRONOUS_CONTROLS),
fTarget(target),
fMimeType(type.Type()),
fExtension(extension)
{
BRect rect = Bounds();
BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(topView);
rect.InsetBy(8.0f, 8.0f);
fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension,
NULL, B_FOLLOW_LEFT_RIGHT);
float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f;
fExtensionControl->SetModificationMessage(new BMessage(kMsgExtensionUpdated));
fExtensionControl->SetDivider(labelWidth);
fExtensionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
// filter out invalid characters that can't be part of an extension
BTextView* textView = fExtensionControl->TextView();
const char* disallowedCharacters = "/:";
for (int32 i = 0; disallowedCharacters[i]; i++) {
textView->DisallowChar(disallowedCharacters[i]);
}
float width, height;
fExtensionControl->GetPreferredSize(&width, &height);
fExtensionControl->ResizeTo(rect.Width(), height);
topView->AddChild(fExtensionControl);
fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add",
new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
fAcceptButton->ResizeToPreferred();
fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
fAcceptButton->SetEnabled(false);
topView->AddChild(fAcceptButton);
BButton* button = new BButton(rect, "cancel", "Cancel",
new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
button->ResizeToPreferred();
button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
fAcceptButton->Frame().top);
topView->AddChild(button);
ResizeTo(labelWidth * 4.0f + 24.0f, fExtensionControl->Bounds().Height()
+ fAcceptButton->Bounds().Height() + 28.0f);
SetSizeLimits(button->Bounds().Width() + fAcceptButton->Bounds().Width() + 26.0f,
32767.0f, Frame().Height(), Frame().Height());
// omit the leading dot
if (fExtension.ByteAt(0) == '.')
fExtension.Remove(0, 1);
fAcceptButton->MakeDefault(true);
fExtensionControl->MakeFocus(true);
target->PlaceSubWindow(this);
AddToSubset(target);
}