本文整理汇总了C++中BBox::SetExplicitMaxSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BBox::SetExplicitMaxSize方法的具体用法?C++ BBox::SetExplicitMaxSize怎么用?C++ BBox::SetExplicitMaxSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBox
的用法示例。
在下文中一共展示了BBox::SetExplicitMaxSize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: time
void
DateTimeView::_InitView()
{
fCalendarView = new BCalendarView("calendar");
fCalendarView->SetWeekNumberHeaderVisible(false);
fCalendarView->SetSelectionMessage(new BMessage(kDayChanged));
fCalendarView->SetInvocationMessage(new BMessage(kDayChanged));
fDateEdit = new TDateEdit("dateEdit", 3);
fTimeEdit = new TTimeEdit("timeEdit", 4);
fClock = new TAnalogClock("analogClock");
BTime time(BTime::CurrentTime(B_LOCAL_TIME));
fClock->SetTime(time.Hour(), time.Minute(), time.Second());
BBox* divider = new BBox(BRect(0, 0, 1, 1),
B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
divider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));
const float kInset = be_control_look->DefaultItemSpacing();
BLayoutBuilder::Group<>(this)
.AddGroup(B_VERTICAL, kInset / 2)
.Add(fDateEdit)
.Add(fCalendarView)
.End()
.Add(divider)
.AddGroup(B_VERTICAL, 0)
.Add(fTimeEdit)
.Add(fClock)
.End()
.SetInsets(kInset, kInset, kInset, kInset);
}
示例2: BMessage
LookAndFeelSettingsView::LookAndFeelSettingsView(const char* name)
:
BView(name, 0),
fDecorInfoButton(NULL),
fDecorMenuField(NULL),
fDecorMenu(NULL)
{
// Decorator menu
_BuildDecorMenu();
fDecorMenuField = new BMenuField("decorator",
B_TRANSLATE("Decorator:"), fDecorMenu);
fDecorInfoButton = new BButton(B_TRANSLATE("About"),
new BMessage(kMsgDecorInfo));
// scroll bar arrow style
BBox* arrowStyleBox = new BBox("arrow style");
arrowStyleBox->SetLabel(B_TRANSLATE("Arrow style"));
fSavedDoubleArrowsValue = _DoubleScrollBarArrows();
fArrowStyleSingle = new FakeScrollBar(true, false,
new BMessage(kMsgArrowStyleSingle));
fArrowStyleDouble = new FakeScrollBar(true, true,
new BMessage(kMsgArrowStyleDouble));
BView* arrowStyleView;
arrowStyleView = BLayoutBuilder::Group<>()
.AddGroup(B_VERTICAL, 1)
.Add(new BStringView("single", B_TRANSLATE("Single:")))
.Add(fArrowStyleSingle)
.AddStrut(B_USE_DEFAULT_SPACING)
.Add(new BStringView("double", B_TRANSLATE("Double:")))
.Add(fArrowStyleDouble)
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.End()
.View();
arrowStyleBox->AddChild(arrowStyleView);
arrowStyleBox->SetExplicitAlignment(BAlignment(B_ALIGN_LEFT,
B_ALIGN_VERTICAL_CENTER));
arrowStyleBox->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BStringView* scrollBarLabel
= new BStringView("scroll bar", B_TRANSLATE("Scroll bar:"));
scrollBarLabel->SetExplicitAlignment(
BAlignment(B_ALIGN_LEFT, B_ALIGN_TOP));
// control layout
BLayoutBuilder::Grid<>(this, B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.Add(fDecorMenuField->CreateLabelLayoutItem(), 0, 0)
.Add(fDecorMenuField->CreateMenuBarLayoutItem(), 1, 0)
.Add(fDecorInfoButton, 2, 0)
.Add(scrollBarLabel, 0, 1)
.Add(arrowStyleBox, 1, 1)
.AddGlue(0, 2)
.SetInsets(B_USE_WINDOW_SPACING);
// TODO : Decorator Preview Image?
}
示例3: BMessage
void
MidiPlayerWindow::CreateViews()
{
// Set up needed views
scopeView = new ScopeView;
showScope = new BCheckBox("showScope", B_TRANSLATE("Scope"),
new BMessage(MSG_SHOW_SCOPE));
showScope->SetValue(B_CONTROL_ON);
CreateInputMenu();
CreateReverbMenu();
volumeSlider = new BSlider("volumeSlider", NULL, NULL, 0, 100,
B_HORIZONTAL);
rgb_color col = { 152, 152, 255 };
volumeSlider->UseFillColor(true, &col);
volumeSlider->SetModificationMessage(new BMessage(MSG_VOLUME));
playButton = new BButton("playButton", B_TRANSLATE("Play"),
new BMessage(MSG_PLAY_STOP));
playButton->SetEnabled(false);
BBox* divider = new BBox(B_EMPTY_STRING, B_WILL_DRAW | B_FRAME_EVENTS,
B_FANCY_BORDER);
divider->SetExplicitMaxSize(
BSize(B_SIZE_UNLIMITED, 1));
BStringView* volumeLabel = new BStringView(NULL, B_TRANSLATE("Volume:"));
volumeLabel->SetAlignment(B_ALIGN_LEFT);
volumeLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
// Build the layout
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.Add(scopeView)
.Add(BGridLayoutBuilder(10, 10)
.Add(BSpaceLayoutItem::CreateGlue(), 0, 0)
.Add(showScope, 1, 0)
.Add(reverbMenu->CreateLabelLayoutItem(), 0, 1)
.Add(reverbMenu->CreateMenuBarLayoutItem(), 1, 1)
.Add(inputMenu->CreateLabelLayoutItem(), 0, 2)
.Add(inputMenu->CreateMenuBarLayoutItem(), 1, 2)
.Add(volumeLabel, 0, 3)
.Add(volumeSlider, 1, 3)
)
.AddGlue()
.Add(divider)
.AddGlue()
.Add(playButton)
.AddGlue()
.SetInsets(5, 5, 5, 5)
);
}
示例4: BMessage
//.........这里部分代码省略.........
const char *focusLabels[] = {B_TRANSLATE_MARK("Click to focus and raise"),
B_TRANSLATE_MARK("Click to focus"),
B_TRANSLATE_MARK("Focus follows mouse")};
const mode_mouse focusModes[] = {B_NORMAL_MOUSE, B_CLICK_TO_FOCUS_MOUSE,
B_FOCUS_FOLLOWS_MOUSE};
for (int i = 0; i < 3; i++) {
BMessage* message = new BMessage(kMsgMouseFocusMode);
message->AddInt32("mode", focusModes[i]);
fFocusMenu->AddItem(new BMenuItem(B_TRANSLATE_NOCOLLECT(focusLabels[i]),
message));
}
BMenuField* focusField = new BMenuField(B_TRANSLATE("Focus mode:"),
fFocusMenu);
focusField->SetAlignment(B_ALIGN_RIGHT);
// Add the "Focus follows mouse mode" pop up menu
fFocusFollowsMouseMenu = new BPopUpMenu(B_TRANSLATE("Normal"));
const char *focusFollowsMouseLabels[] = {B_TRANSLATE_MARK("Normal"),
B_TRANSLATE_MARK("Warp"), B_TRANSLATE_MARK("Instant warp")};
const mode_focus_follows_mouse focusFollowsMouseModes[] =
{B_NORMAL_FOCUS_FOLLOWS_MOUSE, B_WARP_FOCUS_FOLLOWS_MOUSE,
B_INSTANT_WARP_FOCUS_FOLLOWS_MOUSE};
for (int i = 0; i < 3; i++) {
BMessage* message = new BMessage(kMsgFollowsMouseMode);
message->AddInt32("mode_focus_follows_mouse",
focusFollowsMouseModes[i]);
fFocusFollowsMouseMenu->AddItem(new BMenuItem(
B_TRANSLATE_NOCOLLECT(focusFollowsMouseLabels[i]), message));
}
BMenuField* focusFollowsMouseField = new BMenuField(
"Focus follows mouse mode:", fFocusFollowsMouseMenu);
focusFollowsMouseField->SetAlignment(B_ALIGN_RIGHT);
// Add the "Click-through" check box
fAcceptFirstClickBox = new BCheckBox(B_TRANSLATE("Accept first click"),
new BMessage(kMsgAcceptFirstClick));
// dividers
BBox* hdivider = new BBox(
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
hdivider->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));
BBox* vdivider = new BBox(
BRect(0, 0, 1, 1), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);
vdivider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
// Build the layout
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 10)
.AddGroup(B_HORIZONTAL, 10)
.AddGroup(B_VERTICAL, 10, 1)
.AddGroup(B_HORIZONTAL, 10)
.AddGlue()
.Add(typeField)
.AddGlue()
.End()
.AddGlue()
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
.AddGlue()
.Add(fMouseView)
.AddGlue()
)
.AddGlue()
.Add(doubleClickTextControl)
.End()
.Add(hdivider)
.AddGroup(B_VERTICAL, 5, 3)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fClickSpeedSlider)
)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fMouseSpeedSlider)
)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 0)
.Add(fAccelerationSlider)
)
.End()
.End()
.Add(vdivider)
.AddGroup(B_HORIZONTAL, 10)
.Add(focusField)
.AddGlue()
.AddGroup(B_VERTICAL, 0)
.Add(fAcceptFirstClickBox)
.End()
.End()
.SetInsets(5, 5, 5, 5)
);
}
示例5: name
ScreenshotWindow::ScreenshotWindow(const Utility& utility, bool silent,
bool clipboard)
:
BWindow(BRect(0, 0, 200.0, 100.0), B_TRANSLATE_SYSTEM_NAME("Screenshot"),
B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AVOID_FRONT
| B_QUIT_ON_WINDOW_CLOSE | B_AUTO_UPDATE_SIZE_LIMITS
| B_CLOSE_ON_ESCAPE),
fUtility(utility),
fDelayControl(NULL),
fScreenshot(NULL),
fOutputPathPanel(NULL),
fLastSelectedPath(NULL),
fSettingsWindow(NULL),
fDelay(0),
fIncludeBorder(false),
fIncludeCursor(false),
fGrabActiveWindow(false),
fOutputFilename(NULL),
fExtension(""),
fImageFileType(B_PNG_FORMAT)
{
// _ReadSettings() needs a valid fOutputPathMenu
fOutputPathMenu = new BMenu(B_TRANSLATE("Please select"));
_ReadSettings();
// _NewScreenshot() needs a valid fNameControl
BString name(B_TRANSLATE_NOCOLLECT(fUtility.sDefaultFileNameBase));
name << 1;
name = _FindValidFileName(name.String());
fNameControl = new BTextControl("", B_TRANSLATE("Name:"), name, NULL);
// Check if fUtility contains valid data
if (fUtility.wholeScreen == NULL) {
_NewScreenshot(silent, clipboard, true);
return;
}
fScreenshot = fUtility.MakeScreenshot(fIncludeCursor, fGrabActiveWindow,
fIncludeBorder);
fActiveWindow = new BCheckBox(B_TRANSLATE("Capture active window"),
new BMessage(kActiveWindow));
if (fGrabActiveWindow)
fActiveWindow->SetValue(B_CONTROL_ON);
fWindowBorder = new BCheckBox(B_TRANSLATE("Include window border"),
new BMessage(kIncludeBorder));
if (fIncludeBorder)
fWindowBorder->SetValue(B_CONTROL_ON);
if (!fGrabActiveWindow)
fWindowBorder->SetEnabled(false);
fShowCursor = new BCheckBox(B_TRANSLATE("Include mouse pointer"),
new BMessage(kIncludeCursor));
if (fIncludeCursor)
fShowCursor->SetValue(B_CONTROL_ON);
BString delay;
delay << fDelay / 1000000;
fDelayControl = new BTextControl("", B_TRANSLATE("Delay:"), delay.String(),
NULL);
_DisallowChar(fDelayControl->TextView());
fDelayControl->TextView()->SetAlignment(B_ALIGN_RIGHT);
BStringView* seconds = new BStringView("", B_TRANSLATE("seconds"));
seconds->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BMenuField* menuLocation = new BMenuField(B_TRANSLATE("Save in:"),
fOutputPathMenu);
menuLocation->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
fTranslatorMenu = new BMenu(B_TRANSLATE("Please select"));
_SetupTranslatorMenu();
BMenuField* menuFormat = new BMenuField(B_TRANSLATE("Save as:"),
fTranslatorMenu);
menuFormat->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
BButton* showSettings = new BButton("",
B_TRANSLATE("Settings" B_UTF8_ELLIPSIS), new BMessage(kSettings));
showSettings->SetExplicitAlignment(
BAlignment(B_ALIGN_RIGHT, B_ALIGN_BOTTOM));
BBox* divider = new BBox(B_FANCY_BORDER, NULL);
divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton* saveScreenshot = new BButton("", B_TRANSLATE("Save"),
new BMessage(kSaveScreenshot));
const float kSpacing = be_control_look->DefaultItemSpacing();
const float kLabelSpacing = be_control_look->DefaultLabelSpacing();
fPreview = new BView("preview", B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
BBox* previewBox = new BBox(B_FANCY_BORDER, fPreview);
BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL)
.SetInsets(B_USE_WINDOW_SPACING, B_USE_WINDOW_SPACING,
B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING)
.Add(previewBox)
.AddGroup(B_VERTICAL, 0)
.Add(fActiveWindow)
//.........这里部分代码省略.........
示例6: BMessage
FindWindow::FindWindow(BMessenger messenger, const BString& str,
bool findSelection, bool matchWord, bool matchCase, bool forwardSearch)
:
BWindow(kWindowFrame, B_TRANSLATE("Find"), B_FLOATING_WINDOW,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_CLOSE_ON_ESCAPE
| B_AUTO_UPDATE_SIZE_LIMITS),
fFindDlgMessenger(messenger)
{
SetLayout(new BGroupLayout(B_VERTICAL));
BBox* separator = new BBox("separator");
separator->SetExplicitMinSize(BSize(250.0, B_SIZE_UNSET));
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1.0));
BRadioButton* useSelection = NULL;
const float spacing = be_control_look->DefaultItemSpacing();
AddChild(BGroupLayoutBuilder(B_VERTICAL, B_USE_SMALL_SPACING)
.SetInsets(spacing, spacing, spacing, spacing)
.Add(BGridLayoutBuilder(B_USE_SMALL_SPACING, B_USE_SMALL_SPACING)
.Add(fTextRadio = new BRadioButton(B_TRANSLATE("Use text:"),
new BMessage(TOGGLE_FIND_CONTROL)), 0, 0)
.Add(fFindLabel = new BTextControl(NULL, NULL, NULL), 1, 0)
.Add(useSelection = new BRadioButton(B_TRANSLATE("Use selection"),
new BMessage(TOGGLE_FIND_CONTROL)), 0, 1))
.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4))
.Add(separator)
.Add(BSpaceLayoutItem::CreateVerticalStrut(spacing / 4))
.Add(fForwardSearchBox = new BCheckBox(B_TRANSLATE("Search forward")))
.Add(fMatchCaseBox = new BCheckBox(B_TRANSLATE("Match case")))
.Add(fMatchWordBox = new BCheckBox(B_TRANSLATE("Match word")))
.AddGroup(B_HORIZONTAL)
.AddGlue()
.Add(fFindButton = new BButton(B_TRANSLATE("Find"),
new BMessage(MSG_FIND)))
.End()
.TopView());
fFindLabel->SetDivider(0.0);
if (!findSelection) {
fFindLabel->SetText(str.String());
fFindLabel->MakeFocus(true);
} else {
fFindLabel->SetEnabled(false);
}
if (findSelection)
useSelection->SetValue(B_CONTROL_ON);
else
fTextRadio->SetValue(B_CONTROL_ON);
if (forwardSearch)
fForwardSearchBox->SetValue(B_CONTROL_ON);
if (matchCase)
fMatchCaseBox->SetValue(B_CONTROL_ON);
if (matchWord)
fMatchWordBox->SetValue(B_CONTROL_ON);
fFindButton->MakeDefault(true);
AddShortcut((uint32)'W', B_COMMAND_KEY, new BMessage(MSG_FIND_HIDE));
}
示例7: winFrame
//.........这里部分代码省略.........
fMarginView = new MarginView(int32(width), int32(height), margin,
MarginUnit(units));
BPopUpMenu* pageSizePopUpMenu = new BPopUpMenu("Page size");
pageSizePopUpMenu->SetRadioMode(true);
fPageSizeMenu = new BMenuField("page_size", "Page size:", pageSizePopUpMenu);
fPageSizeMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; pageFormat[i].label != NULL; i++) {
BMessage* message = new BMessage(PAGE_SIZE_CHANGED);
message->AddFloat("width", pageFormat[i].width);
message->AddFloat("height", pageFormat[i].height);
BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
pageSizePopUpMenu->AddItem(item);
if (label.Compare(pageFormat[i].label) == 0)
item->SetMarked(true);
}
BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
orientationPopUpMenu->SetRadioMode(true);
fOrientationMenu = new BMenuField("orientation", "Orientation:",
orientationPopUpMenu);
fOrientationMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; orientation[i].label != NULL; i++) {
BMessage* message = new BMessage(ORIENTATION_CHANGED);
message->AddInt32("orientation", orientation[i].orientation);
BMenuItem* item = new BMenuItem(orientation[i].label, message);
orientationPopUpMenu->AddItem(item);
if (fCurrentOrientation == orientation[i].orientation)
item->SetMarked(true);
}
float scale0;
BString scale;
if (fSetupMsg->FindFloat("scale", &scale0) == B_OK)
scale << (int)scale0;
else
scale = "100";
fScaleControl = new BTextControl("scale", "Scale [%]:",
scale.String(), NULL);
for (uint32 i = 0; i < '0'; i++)
fScaleControl->TextView()->DisallowChar(i);
for (uint32 i = '9' + 1; i < 255; i++)
fScaleControl->TextView()->DisallowChar(i);
fScaleControl->TextView()->SetMaxBytes(3);
BBox *separator = new BBox("separator");
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BGridView* settings = new BGridView();
BGridLayout* settingsLayout = settings->GridLayout();
settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0);
settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0);
settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1);
settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1);
settingsLayout->AddItem(fScaleControl->CreateLabelLayoutItem(), 0, 2);
settingsLayout->AddItem(fScaleControl->CreateTextViewLayoutItem(), 1, 2);
settingsLayout->SetSpacing(0, 0);
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL, 5, 1)
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(fMarginView)
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(settings)
.AddGlue()
.End()
.End()
.Add(separator)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.AddGlue()
.Add(cancel)
.Add(ok)
.End()
.SetInsets(10, 10, 10, 10)
);
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
}
示例8: BGroupView
void
BJobSetupPanel::_SetupInterface()
{
BGroupView* groupView = new BGroupView(B_VERTICAL, 10.0);
// printers
fPrinterPopUp = new BPopUpMenu("");
fPrinterPopUp->SetRadioMode(true);
fPrinterMenuField = new BMenuField("", fPrinterPopUp);
fPrinterMenuField->Menu()->SetLabelFromMarked(true);
BPrinter printer;
while (fPrinterRoster->GetNextPrinter(&printer) == B_OK) {
BMenuItem* item = new BMenuItem(printer.Name().String(), NULL);
fPrinterPopUp->AddItem(item);
if (printer == *fPrinter)
item->SetMarked(true);
}
if (fPrinterRoster->CountPrinters() > 0)
fPrinterPopUp->AddItem(new BSeparatorItem);
BMenuItem* pdf = new BMenuItem("Save as PDF file" , NULL);
fPrinterPopUp->AddItem(pdf);
if (fPrinterPopUp->FindMarked() == NULL)
pdf->SetMarked(true);
fProperties = new BButton("Properties" B_UTF8_ELLIPSIS , new BMessage('prop'));
fPrinterInfo = new BStringView("label", "");
fPrinterInfo->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
BBox* divider = new BBox(B_FANCY_BORDER, NULL);
divider->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
fPrintToFile = new BCheckBox("Print to file");
BView* view = BGroupLayoutBuilder(B_VERTICAL, 5.0)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10.0)
.Add(fPrinterMenuField->CreateMenuBarLayoutItem())
.Add(fProperties))
.Add(BGroupLayoutBuilder(B_HORIZONTAL,5.0)
.Add(new BStringView("label", "Printer info:"))
.Add(fPrinterInfo))
.Add(divider)
.Add(fPrintToFile)
.SetInsets(10.0, 5.0, 10.0, 5.0);
BBox *box = new BBox(B_FANCY_BORDER, view);
box->SetLabel(BGroupLayoutBuilder()
.Add(new BStringView("", "Printer"))
.SetInsets(2.0, 0.0, 2.0, 0.0));
groupView->AddChild(box);
// page range
fPrintAll = new BRadioButton("Print all", new BMessage('prrg'));
fPrintAll->SetValue(B_CONTROL_ON);
fPagesFrom = new BRadioButton("Pages from:", new BMessage('prrg'));
fFirstPage = new BTextControl("", "", NULL);
_DisallowChar(fFirstPage->TextView());
fLastPage = new BTextControl("to:", "", NULL);
_DisallowChar(fLastPage->TextView());
fSelection = new BRadioButton("Print selection", new BMessage('prrg'));
fFirstPage->CreateLabelLayoutItem();
view = BGroupLayoutBuilder(B_VERTICAL, 5.0)
.Add(fPrintAll)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 5.0)
.Add(fPagesFrom)
.Add(fFirstPage->CreateTextViewLayoutItem())
.Add(fLastPage->CreateLabelLayoutItem())
.Add(fLastPage->CreateTextViewLayoutItem()))
.Add(fSelection)
.SetInsets(10.0, 5.0, 10.0, 5.0);
box = new BBox(B_FANCY_BORDER, view);
box->SetLabel(BGroupLayoutBuilder()
.Add(new BStringView("", "Page range"))
.SetInsets(2.0, 0.0, 2.0, 0.0));
// copies
fNumberOfCopies = new BTextControl("Number of copies:", "1", NULL);
_DisallowChar(fNumberOfCopies->TextView());
fCollate = new BCheckBox("Collate");
fReverse = new BCheckBox("Reverse");
BView* view2 = BGroupLayoutBuilder(B_VERTICAL, 5.0)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, 5.0)
.Add(fNumberOfCopies->CreateLabelLayoutItem())
.Add(fNumberOfCopies->CreateTextViewLayoutItem()))
.Add(fCollate)
.Add(fReverse)
.SetInsets(10.0, 5.0, 10.0, 5.0);
BBox* box2 = new BBox(B_FANCY_BORDER, view2);
box2->SetLabel(BGroupLayoutBuilder()
.Add(new BStringView("", "Copies"))
.SetInsets(2.0, 0.0, 2.0, 0.0));
groupView->AddChild(BGroupLayoutBuilder(B_HORIZONTAL, 10.0)
.Add(box)
.Add(box2));
//.........这里部分代码省略.........
示例9: BMessage
//.........这里部分代码省略.........
message->AddFloat("width", pageFormat[i].width);
message->AddFloat("height", pageFormat[i].height);
BMenuItem* item = new BMenuItem(pageFormat[i].label, message);
pageSize->AddItem(item);
if (label.Compare(pageFormat[i].label) == 0)
item->SetMarked(true);
}
BPopUpMenu* orientationPopUpMenu = new BPopUpMenu("Orientation");
orientationPopUpMenu->SetRadioMode(true);
fOrientationMenu = new BMenuField("orientation", "Orientation:",
orientationPopUpMenu);
fOrientationMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; orientation[i].label != NULL; i++) {
BMessage* message = new BMessage(ORIENTATION_CHANGED);
message->AddInt32("orientation", orientation[i].orientation);
BMenuItem* item = new BMenuItem(orientation[i].label, message);
orientationPopUpMenu->AddItem(item);
if (fCurrentOrientation == orientation[i].orientation)
item->SetMarked(true);
}
BPopUpMenu* compatibility = new BPopUpMenu("PDF compatibility");
compatibility->SetRadioMode(true);
fPDFCompatibilityMenu = new BMenuField("pdf_compatibility",
"PDF compatibility:", compatibility);
fPDFCompatibilityMenu->Menu()->SetLabelFromMarked(true);
for (int32 i = 0; pdf_compatibility[i] != NULL; i++) {
BMenuItem* item = new BMenuItem(pdf_compatibility[i], NULL);
compatibility->AddItem(item);
if (setting_value == pdf_compatibility[i])
item->SetMarked(true);
}
fPDFCompressionSlider = new BSlider("pdf_compression",
"Compression:", NULL, 0, 9, B_HORIZONTAL);
fPDFCompressionSlider->SetLimitLabels("None", "Best");
fPDFCompressionSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
fPDFCompressionSlider->SetValue(compression);
BBox *separator = new BBox("separator");
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BButton *fontsButton = new BButton("fonts", "Fonts" B_UTF8_ELLIPSIS,
new BMessage(FONTS_MSG));
BButton* advancedButton = new BButton("advanced",
"Advanced" B_UTF8_ELLIPSIS,
new BMessage(ADVANCED_MSG));
BGridView* settings = new BGridView();
BGridLayout* settingsLayout = settings->GridLayout();
settingsLayout->AddItem(fPageSizeMenu->CreateLabelLayoutItem(), 0, 0);
settingsLayout->AddItem(fPageSizeMenu->CreateMenuBarLayoutItem(), 1, 0);
settingsLayout->AddItem(fOrientationMenu->CreateLabelLayoutItem(), 0, 1);
settingsLayout->AddItem(fOrientationMenu->CreateMenuBarLayoutItem(), 1, 1);
settingsLayout->AddItem(fPDFCompatibilityMenu->CreateLabelLayoutItem(), 0, 2);
settingsLayout->AddItem(fPDFCompatibilityMenu->CreateMenuBarLayoutItem(), 1, 2);
settingsLayout->AddView(fPDFCompressionSlider, 0, 3, 2);
settingsLayout->SetSpacing(0, 0);
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.AddGroup(B_HORIZONTAL, 5, 1)
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(fMarginView)
.AddGlue()
.End()
.AddGroup(B_VERTICAL, 0, 1.0f)
.Add(settings)
.AddGlue()
.End()
.End()
.Add(separator)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.Add(fontsButton)
.Add(advancedButton)
.AddGlue()
.Add(cancel)
.Add(ok)
.End()
.SetInsets(10, 10, 10, 10)
);
BRect winFrame(Frame());
BRect screenFrame(BScreen().Frame());
MoveTo((screenFrame.right - winFrame.right) / 2,
(screenFrame.bottom - winFrame.bottom) / 2);
}
示例10: BMessage
// --------------------------------------------------
JobSetupWindow::JobSetupWindow(BMessage *msg, const char * printerName)
: HWindow(BRect(0, 0, 100, 100), "Job Setup",
B_TITLED_WINDOW_LOOK,
B_MODAL_APP_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE)
{
fSetupMsg = msg;
fExitSem = create_sem(0, "JobSetup");
fResult = B_ERROR;
if (printerName) {
BString title;
title << printerName << " Job Setup";
SetTitle(title.String());
fPrinterName = printerName;
}
// PrinterDriver ensures that property exists
int32 firstPage;
fSetupMsg->FindInt32("first_page", &firstPage);
int32 lastPage;
fSetupMsg->FindInt32("last_page", &lastPage);
BMessage doc_info;
if (fSetupMsg->FindMessage("doc_info", &doc_info) != B_OK) {
// default fields
doc_info.AddString("Author", "");
doc_info.AddString("Subject", "");
doc_info.AddString("Keywords", "");
fSetupMsg->AddMessage("doc_info", &doc_info);
}
AddFields(&fDocInfo, fSetupMsg, NULL, includeKeys);
bool allPages = firstPage == 1 && lastPage == MAX_INT32;
fAll = new BRadioButton("allPages", "Print all pages",
new BMessage(ALL_PAGES_MGS));
fAll->SetValue(allPages);
fRange = new BRadioButton("pagesRange", "Print pages:",
new BMessage(RANGE_SELECTION_MSG));
fRange->SetValue(!allPages);
fFrom = new BTextControl("from", "From:", "SomeSpaceHere", NULL);
fFrom->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fFrom->SetEnabled(!allPages);
fTo = new BTextControl("to", "To:", "", NULL);
fTo->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
fTo->SetEnabled(!allPages);
BString buffer;
buffer << firstPage;
fFrom->SetText(buffer.String());
buffer = "";
buffer << lastPage;
fTo->SetText(buffer.String());
for (uint32 i = 0; i < '0'; i++) {
fTo->TextView()->DisallowChar(i);
fFrom->TextView()->DisallowChar(i);
}
for (uint32 i = '9' + 1; i < 255; i++) {
fTo->TextView()->DisallowChar(i);
fFrom->TextView()->DisallowChar(i);
}
BBox *separator = new BBox("separator");
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
BButton *documentInfo = new BButton("documentInfo",
"Document" B_UTF8_ELLIPSIS,
new BMessage(DOC_INFO_MSG));
BButton *cancel = new BButton("cancel", "Cancel", new BMessage(CANCEL_MSG));
BButton *ok = new BButton("ok", "OK", new BMessage(OK_MSG));
ok->MakeDefault(true);
BGridView* settings = new BGridView();
BGridLayout* settingsLayout = settings->GridLayout();
settingsLayout->AddItem(fFrom->CreateLabelLayoutItem(), 0, 0);
settingsLayout->AddItem(fFrom->CreateTextViewLayoutItem(), 1, 0);
settingsLayout->AddItem(fTo->CreateLabelLayoutItem(), 0, 1);
settingsLayout->AddItem(fTo->CreateTextViewLayoutItem(), 1, 1);
settingsLayout->SetSpacing(0, 0);
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(fAll)
.Add(fRange)
.Add(settings)
.AddGlue()
.Add(separator)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.Add(documentInfo)
//.........这里部分代码省略.........
示例11: BMessage
void
AddPrinterView::AttachedToWindow()
{
// protocol class box
BBox* protocolClassBox = new BBox("protocolClass");
protocolClassBox->SetLabel("Protocol classes:");
// protocol class
fProtocolClassList = new BListView("protocolClassList");
fProtocolClassList->SetExplicitMinSize(BSize(500, 200));
BScrollView* protocolClassScroller = new BScrollView(
"protocolClassListScroller",
fProtocolClassList,
0,
false,
true,
B_NO_BORDER);
fProtocolClassList->SetSelectionMessage(
new BMessage(kMsgProtocolClassChanged));
fProtocolClassList->SetTarget(this);
protocolClassBox->AddChild(protocolClassScroller);
int count = fPrinterCap->CountCap(PrinterCap::kProtocolClass);
ProtocolClassCap **protocolClasses =
(ProtocolClassCap **)fPrinterCap->GetCaps(PrinterCap::kProtocolClass);
while (count--) {
const ProtocolClassCap *protocolClass = *protocolClasses;
BStringItem* item = new ProtocolClassItem(protocolClass);
fProtocolClassList->AddItem(item);
if (protocolClass->fIsDefault) {
int index = fProtocolClassList->IndexOf(item);
fProtocolClassList->Select(index);
}
protocolClasses ++;
}
// description of protocol class box
BBox* descriptionBox = new BBox("descriptionBox");
descriptionBox->SetLabel("Description:");
// description of protocol class
fDescription = new BTextView("description");
fDescription->SetExplicitMinSize(BSize(200, 200));
fDescription->SetViewColor(descriptionBox->ViewColor());
BScrollView* descriptionScroller = new BScrollView("descriptionScroller",
fDescription,
0,
false,
true,
B_NO_BORDER);
fDescription->MakeEditable(false);
descriptionBox->AddChild(descriptionScroller);
// separator line
BBox *separator = new BBox("separator");
separator->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
// buttons
BButton* cancel = new BButton("cancel", "Cancel",
new BMessage(kMsgCancel));
BButton* ok = new BButton("ok", "OK", new BMessage(kMsgOK));
ok->MakeDefault(true);
SetLayout(new BGroupLayout(B_VERTICAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL, 0)
.Add(protocolClassBox)
.Add(descriptionBox)
.AddGlue()
.Add(separator)
.AddGroup(B_HORIZONTAL, 10, 1.0f)
.AddGlue()
.Add(cancel)
.Add(ok)
.End()
.SetInsets(0, 0, 0, 0)
);
// update description
BMessage updateDescription(kMsgProtocolClassChanged);
MessageReceived(&updateDescription);
}