本文整理汇总了C++中BStringView::SetAlignment方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringView::SetAlignment方法的具体用法?C++ BStringView::SetAlignment怎么用?C++ BStringView::SetAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringView
的用法示例。
在下文中一共展示了BStringView::SetAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachedToWindow
void VisualColorControl::AttachedToWindow()
{
BPoint *points = new BPoint[3];
points[0] = BPoint(0,0);
points[1] = BPoint(-4,-4);
points[2] = BPoint(4,-4);
// calculate the initial ramps
CalcRamps();
// create the arrow-pictures
BeginPicture(new BPicture());
SetHighColor(100,100,255);
FillPolygon(points,3);
SetHighColor(0,0,0);
StrokePolygon(points,3);
down_arrow = EndPicture();
if (Parent() != NULL)
SetViewColor(Parent()->ViewColor());
BStringView *sv = new BStringView(BRect(0,COLOR_HEIGHT/2,1,COLOR_HEIGHT/2),"label view",label1);
AddChild(sv);
float sv_width = sv->StringWidth(label1);
sv_width = max_c(sv_width,sv->StringWidth(label2));
sv_width = max_c(sv_width,sv->StringWidth(label3));
font_height fHeight;
sv->GetFontHeight(&fHeight);
sv->ResizeTo(sv_width,fHeight.ascent+fHeight.descent);
sv->MoveBy(0,-(fHeight.ascent+fHeight.descent)/2.0);
BRect sv_frame = sv->Frame();
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv->SetAlignment(B_ALIGN_CENTER);
sv = new BStringView(sv_frame,"label view",label2);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv = new BStringView(sv_frame,"label view",label3);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv = new BStringView(sv_frame,"label view",label4);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
ramp_left_edge = sv->Bounds().IntegerWidth()+2;
ResizeBy(ramp_left_edge,0);
delete[] points;
}
示例2: 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)
);
}
示例3: str
status_t
PLabel::SetProperty(const char *name, PValue *value, const int32 &index)
{
if (!name || !value)
return B_ERROR;
BString str(name);
PProperty *prop = FindProperty(name,index);
if (!prop)
return B_NAME_NOT_FOUND;
if (FlagsForProperty(prop) & PROPERTY_READ_ONLY)
return B_READ_ONLY;
BStringView *backend = (BStringView*)fView;
BoolValue boolval;
CharValue charval;
ColorValue colorval;
FloatValue floatval;
IntValue intval;
PointValue pointval;
RectValue rectval;
StringValue stringval;
status_t status = prop->SetValue(value);
if (status != B_OK)
return status;
if (backend->Window())
backend->Window()->Lock();
if (str.ICompare("Alignment") == 0)
{
prop->GetValue(&intval);
backend->SetAlignment((alignment)*intval.value);
}
else if (str.ICompare("Text") == 0)
{
prop->GetValue(&stringval);
backend->SetText(*stringval.value);
}
else
{
if (backend->Window())
backend->Window()->Unlock();
return PView::SetProperty(name, value, index);
}
if (backend->Window())
backend->Window()->Unlock();
return prop->GetValue(value);
}
示例4: BStringView
BStringView*
InfoWin::_CreateLabel(const char* name, const char* label)
{
static const rgb_color kLabelColor = tint_color(
ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_3_TINT);
BStringView* view = new BStringView(name, label);
view->SetAlignment(B_ALIGN_RIGHT);
view->SetHighColor(kLabelColor);
return view;
}
示例5: MakeViewFor
/*! This creates a view that handles all incoming messages itself - that's
what is meant with self-hosting.
*/
BView *
DefaultMediaTheme::MakeSelfHostingViewFor(BParameter& parameter,
const BRect* hintRect)
{
if (parameter.Flags() & B_HIDDEN_PARAMETER
|| parameter_should_be_hidden(parameter))
return NULL;
BView *view = MakeViewFor(¶meter, hintRect);
if (view == NULL) {
// The MakeViewFor() method above returns a BControl - which we
// don't need for a null parameter; that's why it returns NULL.
// But we want to see something anyway, so we add a string view
// here.
if (parameter.Type() == BParameter::B_NULL_PARAMETER) {
if (parameter.Group()->ParameterAt(0) == ¶meter) {
// this is the first parameter in this group, so
// let's use a nice title view
TitleView *titleView = new TitleView(BRect(0, 0, 10, 10), parameter.Name());
titleView->ResizeToPreferred();
return titleView;
}
BStringView *stringView = new BStringView(BRect(0, 0, 10, 10),
parameter.Name(), parameter.Name());
stringView->SetAlignment(B_ALIGN_CENTER);
stringView->ResizeToPreferred();
return stringView;
}
return NULL;
}
MessageFilter *filter = MessageFilter::FilterFor(view, parameter);
if (filter != NULL)
view->AddFilter(filter);
return view;
}
示例6: unlimited
void
MediaWindow::_MakeEmptyParamView()
{
fParamWeb = NULL;
BStringView* stringView = new BStringView("noControls",
B_TRANSLATE("This hardware has no controls."));
BSize unlimited(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED);
stringView->SetExplicitMaxSize(unlimited);
BAlignment centered(B_ALIGN_HORIZONTAL_CENTER,
B_ALIGN_VERTICAL_CENTER);
stringView->SetExplicitAlignment(centered);
stringView->SetAlignment(B_ALIGN_CENTER);
fContentLayout->AddView(stringView);
fContentLayout->SetVisibleItem(fContentLayout->CountItems() - 1);
rgb_color panel = stringView->LowColor();
stringView->SetHighColor(tint_color(panel,
B_DISABLED_LABEL_TINT));
}
示例7: Init
void ChannelOptions::Init(void)
{
BString temp(S_CHANOPTS_TITLE);
temp.Prepend(chan_name);
SetTitle(temp.String());
bgView = new BView(Bounds(), "Background", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
bgView->AdoptSystemColors();
AddChild(bgView);
BStringView* tempStringView = new BStringView(Bounds(), "temp", "AEIOUglqj", 0, 0);
tempStringView->ResizeToPreferred();
float stringHeight = tempStringView->Frame().bottom;
delete tempStringView;
privilegesView = new BView(BRect(bgView->Frame().left + 2, bgView->Frame().top + 2,
bgView->Frame().right - 2, stringHeight + 2),
"privilege message", 0, B_WILL_DRAW);
privilegesView->SetViewColor(0, 100, 0);
bgView->AddChild(privilegesView);
BString privString; // this will become dynamic based on the current mode
privString += S_CHANOPTS_OPID1;
privString += S_CHANOPTS_OPID2;
BStringView* privMsgView =
new BStringView(BRect(privilegesView->Bounds().left, privilegesView->Bounds().top,
privilegesView->Bounds().right, stringHeight),
"privMsgView", privString.String(), 0, B_WILL_DRAW);
privMsgView->SetHighColor(255, 255, 255);
privMsgView->SetAlignment(B_ALIGN_CENTER);
privilegesView->ResizeToPreferred();
privilegesView->AddChild(privMsgView);
}
示例8: rect
//.........这里部分代码省略.........
rect.OffsetBy(0, height + 6);
fStatusLookField = new BMenuField(rect,"status look",
MDR_DIALECT_CHOICE ("Window Look:","ウィンドウ外観:"),lookPopUp);
fStatusLookField->SetDivider(labelWidth);
box->AddChild(fStatusLookField);
BPopUpMenu *workspacesPopUp = new BPopUpMenu(B_EMPTY_STRING);
workspacesPopUp->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("Current Workspace","使用中ワークスペース"),
msg = new BMessage(kMsgStatusWorkspaceChanged)));
msg->AddInt32("StatusWindowWorkSpace", 0);
workspacesPopUp->AddItem(item = new BMenuItem(
MDR_DIALECT_CHOICE ("All Workspaces","全てのワークスペース"),
msg = new BMessage(kMsgStatusWorkspaceChanged)));
msg->AddInt32("StatusWindowWorkSpace", -1);
rect.OffsetBy(0,height + 6);
fStatusWorkspaceField = new BMenuField(rect,"status workspace",
MDR_DIALECT_CHOICE ("Window visible on:","表示場所:"),workspacesPopUp);
fStatusWorkspaceField->SetDivider(labelWidth);
box->AddChild(fStatusWorkspaceField);
rect = box->Frame(); rect.bottom = rect.top + 3*height + 13;
box = new BBox(rect);
box->SetLabel(MDR_DIALECT_CHOICE ("Deskbar Icon","デスクバーアイコンリンク"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.bottom = rect.top + height + 5;
BStringView *stringView = new BStringView(rect,B_EMPTY_STRING, MDR_DIALECT_CHOICE (
"The menu links are links to folders in a real folder like the Be menu.",
"デスクバーで表示する項目の設定"));
box->AddChild(stringView);
stringView->SetAlignment(B_ALIGN_CENTER);
stringView->ResizeToPreferred();
// BStringView::ResizeToPreferred() changes the width, so that the
// alignment has no effect anymore
stringView->ResizeTo(rect.Width(), stringView->Bounds().Height());
rect.left += 100; rect.right -= 100;
rect.OffsetBy(0,height + 1);
BButton *button = new BButton(rect,B_EMPTY_STRING,
MDR_DIALECT_CHOICE ("Configure Menu Links","メニューリンクの設定"),
msg = new BMessage(B_REFS_RECEIVED));
box->AddChild(button);
button->SetTarget(BMessenger("application/x-vnd.Be-TRAK"));
BPath path;
find_directory(B_USER_SETTINGS_DIRECTORY, &path);
path.Append("Mail/Menu Links");
BEntry entry(path.Path());
if (entry.InitCheck() == B_OK && entry.Exists()) {
entry_ref ref;
entry.GetRef(&ref);
msg->AddRef("refs", &ref);
}
else
button->SetEnabled(false);
rect = box->Frame(); rect.bottom = rect.top + 2*height + 6;
box = new BBox(rect);
box->SetLabel(MDR_DIALECT_CHOICE ("Misc.","その他の設定"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8,8);
rect.top += 7; rect.bottom = rect.top + height + 5;
示例9: BCheckBox
FilePermissionsView::FilePermissionsView(BRect rect, Model* model)
:
BView(rect, "FilePermissionsView", B_FOLLOW_LEFT_RIGHT, B_WILL_DRAW),
fModel(model)
{
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
// Constants for the column labels: "User", "Group" and "Other".
const float kColumnLabelMiddle = 77, kColumnLabelTop = 0,
kColumnLabelSpacing = 37, kColumnLabelBottom = 39,
kColumnLabelWidth = 80, kAttribFontHeight = 10;
BStringView* strView;
strView = new RotatedStringView(
BRect(kColumnLabelMiddle - kColumnLabelWidth / 2,
kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2,
kColumnLabelBottom),
"", B_TRANSLATE("Owner"));
AddChild(strView);
strView->SetFontSize(kAttribFontHeight);
strView = new RotatedStringView(
BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
+ kColumnLabelSpacing,
kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2 + kColumnLabelSpacing,
kColumnLabelBottom),
"", B_TRANSLATE("Group"));
AddChild(strView);
strView->SetFontSize(kAttribFontHeight);
strView = new RotatedStringView(
BRect(kColumnLabelMiddle - kColumnLabelWidth / 2
+ 2 * kColumnLabelSpacing,
kColumnLabelTop,
kColumnLabelMiddle + kColumnLabelWidth / 2
+ 2 * kColumnLabelSpacing,
kColumnLabelBottom),
"", B_TRANSLATE("Other"));
AddChild(strView);
strView->SetFontSize(kAttribFontHeight);
// Constants for the row labels: "Read", "Write" and "Execute".
const float kRowLabelLeft = 10, kRowLabelTop = kColumnLabelBottom + 5,
kRowLabelVerticalSpacing = 18, kRowLabelRight = kColumnLabelMiddle
- kColumnLabelSpacing / 2 - 5, kRowLabelHeight = 14;
strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop,
kRowLabelRight, kRowLabelTop + kRowLabelHeight),
"", B_TRANSLATE("Read"));
AddChild(strView);
strView->SetAlignment(B_ALIGN_RIGHT);
strView->SetFontSize(kAttribFontHeight);
strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop
+ kRowLabelVerticalSpacing, kRowLabelRight, kRowLabelTop
+ kRowLabelVerticalSpacing + kRowLabelHeight),
"", B_TRANSLATE("Write"));
AddChild(strView);
strView->SetAlignment(B_ALIGN_RIGHT);
strView->SetFontSize(kAttribFontHeight);
strView = new BStringView(BRect(kRowLabelLeft, kRowLabelTop
+ 2 * kRowLabelVerticalSpacing, kRowLabelRight, kRowLabelTop
+ 2 * kRowLabelVerticalSpacing + kRowLabelHeight),
"", B_TRANSLATE("Execute"));
AddChild(strView);
strView->SetAlignment(B_ALIGN_RIGHT);
strView->SetFontSize(kAttribFontHeight);
// Constants for the 3x3 check box array.
const float kLeftMargin = kRowLabelRight + 5,
kTopMargin = kRowLabelTop - 2,
kHorizontalSpacing = kColumnLabelSpacing,
kVerticalSpacing = kRowLabelVerticalSpacing,
kCheckBoxWidth = 18, kCheckBoxHeight = 18;
BCheckBox** checkBoxArray[3][3] = {
{
&fReadUserCheckBox,
&fReadGroupCheckBox,
&fReadOtherCheckBox
},
{
&fWriteUserCheckBox,
&fWriteGroupCheckBox,
&fWriteOtherCheckBox
},
{
&fExecuteUserCheckBox,
&fExecuteGroupCheckBox,
&fExecuteOtherCheckBox
}
};
for (int32 x = 0; x < 3; x++) {
for (int32 y = 0; y < 3; y++) {
*checkBoxArray[y][x] =
//.........这里部分代码省略.........
示例10: AttachedToWindow
//.........这里部分代码省略.........
s.Append("ноября ");
break;
}
case 12:
{
s.Append("декабря ");
break;
}
}
s<<tyear;
s.Append(" г.");
#else // localized, english and french
BString s("");
s<<tday;
s.Append(" ");
s.Append(monthNames[tmonth-1]);
s.Append(" ");
s<<tyear;
#endif
msng=new BMessenger(this);
todayStringView=new MouseSenseStringView(new BMessage('TODA'), msng,
BRect(10,10,100,100),"todayMStringViewAViX",
s.String());
AddChild(todayStringView);
todayStringView->ResizeToPreferred();
todayStringView->SetViewColor(VIEW_COLOR);
monthStringView=new BStringView(BRect(10,10,100,100),"monthStringViewAViX",
monthNames[8]);
monthStringView->SetAlignment(B_ALIGN_CENTER);
AddChild(monthStringView);
monthStringView->ResizeToPreferred();
monthStringView->SetText(monthNames[cmonth-1]);
monthStringView->SetViewColor(VIEW_COLOR);
s.SetTo("");
if(cyear<10) s.Append("000");
else if(cyear<100) s.Append("00");
else if(cyear<1000) s.Append("0");
s<<cyear;
yearStringView=new BStringView(BRect(10,10,100,100),"yearStringViewAViX",
"0000");
AddChild(yearStringView);
yearStringView->ResizeToPreferred();
yearStringView->SetText(s.String());
yearStringView->SetViewColor(VIEW_COLOR);
ResizeTo(w_cell*7+1,h_cell*7+3+16+yearStringView->Bounds().bottom+todayStringView->Bounds().bottom);
Window()->ResizeTo(Bounds().right, Bounds().bottom);
yearMStringView[0]=new MouseSenseStringView(new BMessage('YEA0'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX0",
"<<");
AddChild(yearMStringView[0]);
yearMStringView[0]->ResizeToPreferred();
yearMStringView[0]->SetViewColor(VIEW_COLOR);
yearMStringView[1]=new MouseSenseStringView(new BMessage('YEA1'),msng,
BRect(10,10,100,100),
"yearMStringViewAViX1",
示例11: lvrc
ColorsPreflet::ColorsPreflet(PrefsWindow *parent)
: Preflet(parent)
{
// clear colors listview
BRect lvrc(Bounds());
lvrc.InsetBy(20, 50);
lvrc.OffsetBy(0, -5);
lvrc.right--;
lvrc.top += 12; // make room for cut/paste instructions
lvrc.bottom -= 2; // looks nicer
lvrc.OffsetBy(0, 1);
// create list
lvrc.InsetBy(2, 2);
lvrc.right -= B_V_SCROLL_BAR_WIDTH;
fColorsList = new ColorView(lvrc, parent);
// create scrollview
fScrollView = new BScrollView("sv", fColorsList, B_FOLLOW_ALL, 0, false, true);
AddChild(fScrollView);
lvrc.right += B_V_SCROLL_BAR_WIDTH;
// the real TargetedByScrollView is for some reason called BEFORE the scrollbars
// are created, so it doesn't work properly, fix up...
fColorsList->TargetedByScrollView(fScrollView);
// cut/paste instructions
BStringView *paste;
BRect rc(lvrc);
rc.bottom = rc.top - 1;
rc.top -= 18;
//rc.bottom = rc.top + 15;
rc.right = rc.left + (WIDTHOF(rc) / 2);
AddChild(new BStringView(rc, "", "Right-click: pick up color", 0));
rc.left = rc.right + 1;
rc.right = lvrc.right;
paste = new BStringView(rc, "", "Ctrl-click: paste color", 0);
paste->SetAlignment(B_ALIGN_RIGHT);
AddChild(paste);
// font selector area
fFontMenu = new BPopUpMenu("fontsel");
fFontMenu->AddItem(new BMenuItem("System Fixed Font ", NULL));
int x = 10;
int y = 273;
rc.Set(x, y, x+20, y+20);
fFontField = new BMenuField(rc, "fontfld", "", fFontMenu);
fFontMenu->ItemAt(0)->SetMarked(true);
AddChild(fFontField);
rc.Set(200, 270, 353, 290);
fFontSize = new Spinner(rc, "fontsz", "Point size", new BMessage(M_POINTSIZE_CHANGED));
fFontSize->SetRange(4, 24);
fFontSize->SetValue(editor.settings.font_size);
fFontSize->SetTarget(Looper());
AddChild(fFontSize);
// scheme selector area
fSchemeMenu = new BPopUpMenu("schemesel");
UpdateSchemesMenu();
x = 10;
y = 10;
rc.Set(x, y, x+20, y+20);
fSchemeField = new BMenuField(rc, "schemefld", "", fSchemeMenu);
AddChild(fSchemeField);
rc.right = lvrc.right;
rc.left = rc.right - 48;
rc.OffsetBy(-80, 0);
BButton *delbtn = new BButton(rc, "", "Del", new BMessage(M_SCHEME_DELETE));
rc.OffsetBy(-58, 0);
BButton *newbtn = new BButton(rc, "", "New", new BMessage(M_SCHEME_NEW));
rc.OffsetBy(115, 0);
rc.right = lvrc.right + 1;
BButton *defaultsbtn = new BButton(rc, "", "Defaults", new BMessage(M_SCHEME_DEFAULTS));
newbtn->SetTarget(Looper());
delbtn->SetTarget(Looper());
defaultsbtn->SetTarget(Looper());
AddChild(newbtn);
AddChild(delbtn);
AddChild(defaultsbtn);
}
示例12: BMessage
ModifierKeysWindow::ModifierKeysWindow()
:
BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"),
B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE
| B_AUTO_UPDATE_SIZE_LIMITS)
{
get_key_map(&fCurrentMap, &fCurrentBuffer);
get_key_map(&fSavedMap, &fSavedBuffer);
BStringView* keyRole = new BStringView("key role",
B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key"));
keyRole->SetAlignment(B_ALIGN_RIGHT);
keyRole->SetFont(be_bold_font);
BStringView* keyLabel = new BStringView("key label",
B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key"));
keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
keyLabel->SetFont(be_bold_font);
BMenuField* shiftMenuField = _CreateShiftMenuField();
shiftMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* controlMenuField = _CreateControlMenuField();
controlMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* optionMenuField = _CreateOptionMenuField();
optionMenuField->SetAlignment(B_ALIGN_RIGHT);
BMenuField* commandMenuField = _CreateCommandMenuField();
commandMenuField->SetAlignment(B_ALIGN_RIGHT);
fShiftConflictView = new ConflictView("shift warning view");
fShiftConflictView->SetExplicitMaxSize(BSize(15, 15));
fControlConflictView = new ConflictView("control warning view");
fControlConflictView->SetExplicitMaxSize(BSize(15, 15));
fOptionConflictView = new ConflictView("option warning view");
fOptionConflictView->SetExplicitMaxSize(BSize(15, 15));
fCommandConflictView = new ConflictView("command warning view");
fCommandConflictView->SetExplicitMaxSize(BSize(15, 15));
fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"),
new BMessage(B_QUIT_REQUESTED));
fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"),
new BMessage(kMsgRevertModifiers));
fRevertButton->SetEnabled(false);
fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"),
new BMessage(kMsgApplyModifiers));
fOkButton->MakeDefault(true);
// Build the layout
SetLayout(new BGroupLayout(B_VERTICAL));
float forcedMinWidth = be_plain_font->StringWidth("XXX") * 4;
keyRole->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* shiftLabel = shiftMenuField->CreateLabelLayoutItem();
shiftLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* controlLabel = controlMenuField->CreateLabelLayoutItem();
controlLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* optionLabel = optionMenuField->CreateLabelLayoutItem();
optionLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
BLayoutItem* commandLabel = commandMenuField->CreateLabelLayoutItem();
commandLabel->SetExplicitMinSize(BSize(forcedMinWidth, B_SIZE_UNSET));
AddChild(BLayoutBuilder::Group<>(B_VERTICAL, B_USE_SMALL_SPACING)
.AddGroup(B_HORIZONTAL)
.Add(keyRole)
.Add(keyLabel)
.End()
.AddGroup(B_HORIZONTAL)
.Add(shiftLabel)
.Add(shiftMenuField->CreateMenuBarLayoutItem())
.Add(fShiftConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(controlLabel)
.Add(controlMenuField->CreateMenuBarLayoutItem())
.Add(fControlConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(optionLabel)
.Add(optionMenuField->CreateMenuBarLayoutItem())
.Add(fOptionConflictView)
.End()
.AddGroup(B_HORIZONTAL)
.Add(commandLabel)
.Add(commandMenuField->CreateMenuBarLayoutItem())
.Add(fCommandConflictView)
.End()
.AddGlue()
.AddGroup(B_HORIZONTAL)
.Add(fCancelButton)
.AddGlue()
.Add(fRevertButton)
.Add(fOkButton)
//.........这里部分代码省略.........
示例13: _
// constructor
NavigationInfoPanel::NavigationInfoPanel(BWindow* parent,
const BMessage& message, const BMessenger& target)
: BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK,
B_FLOATING_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE)
, fMessage(message)
, fTarget(target)
{
// create the interface and resize to fit
BRect frame = Bounds();
frame.InsetBy(5, 5);
frame.bottom = frame.top + 15;
// label string view
fLabelView = new BStringView(frame, "label", kLabel,
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
fLabelView->ResizeToPreferred();
frame = fLabelView->Frame();
// target clip text control
frame.OffsetBy(0, frame.Height() + 5);
fTargetClipTC = new BTextControl(frame, "clip id",
"Target Playlist ID", "", new BMessage(MSG_INVOKE),
B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
fTargetClipTC->ResizeToPreferred();
frame = fTargetClipTC->Frame();
// help string view
frame.OffsetBy(0, frame.Height() + 5);
BStringView* helpView = new BStringView(frame, "help",
"Drag and drop a playlist clip here.",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
BFont font;
helpView->GetFont(&font);
font.SetFace(B_ITALIC_FACE);
font.SetSize(font.Size() * 0.9);
helpView->SetFont(&font);
helpView->SetAlignment(B_ALIGN_CENTER);
helpView->ResizeToPreferred();
// parent view
frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame();
frame.InsetBy(-5, -5);
fInfoView = new InfoView(frame, this);
fInfoView->AddChild(fLabelView);
fInfoView->AddChild(fTargetClipTC);
fInfoView->AddChild(helpView);
// resize to fit and adjust size limits
ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height());
AddChild(fInfoView);
float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
minWidth = Frame().Width();
minHeight = maxHeight = Frame().Height();
SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
// modify the high color after the help view is attached to a window
helpView->SetHighColor(tint_color(helpView->LowColor(),
B_DISABLED_LABEL_TINT));
helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE);
// help the buggy BeOS BStringView (when text alignment != left...)
fInfoView->SetEventMask(B_POINTER_EVENTS);
// resize controls to the same (maximum) width
float maxControlWidth = fLabelView->Frame().Width();
maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width());
maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width());
fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height());
fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height());
helpView->ResizeTo(maxControlWidth, helpView->Frame().Height());
// center above parent window
BAutolock _(parent);
frame = Frame();
BRect parentFrame = parent->Frame();
MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2,
(parentFrame.top + parentFrame.bottom - frame.Height()) / 2);
AddToSubset(parent);
}
示例14: stringTitle
//.........这里部分代码省略.........
char tmp[B_PATH_NAME_LENGTH] = { 0 };
string_for_size(f->size, tmp, sizeof(tmp));
name.ReplaceFirst("%size%", tmp);
info.push_back(Item(B_TRANSLATE_MARK("Size"), name.String()));
// Created & modified dates
BEntry entry(&f->ref);
time_t t;
entry.GetCreationTime(&t);
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
info.push_back(Item(B_TRANSLATE("Created"), tmp));
entry.GetModificationTime(&t);
strftime(tmp, 64, B_TRANSLATE("%a, %d %b %Y, %r"), localtime(&t));
info.push_back(Item(B_TRANSLATE("Modified"), tmp));
// Kind
BMimeType* type = f->Type();
type->GetShortDescription(tmp);
info.push_back(Item(B_TRANSLATE("Kind"), tmp));
delete type;
// Path
string path;
f->GetPath(path);
info.push_back(Item(B_TRANSLATE("Path"), path));
// Icon
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
entry_ref ref;
entry.GetRef(&ref);
BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);
// Compute the window size and add the views.
BFont smallFont(be_plain_font);
smallFont.SetSize(floorf(smallFont.Size() * 0.95));
struct font_height fh;
smallFont.GetHeight(&fh);
float fontHeight = fh.ascent + fh.descent + fh.leading;
float leftWidth = 32.0;
float rightWidth = 0.0;
InfoList::iterator i = info.begin();
while (i != info.end()) {
float w = smallFont.StringWidth((*i).first.c_str())
+ 2.0 * kSmallHMargin;
leftWidth = max_c(leftWidth, w);
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
rightWidth = max_c(rightWidth, w);
i++;
}
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight
+ kSmallVMargin);
float winWidth = leftWidth + rightWidth;
ResizeTo(winWidth, winHeight);
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight),
icon);
BView *rightView = new BView(
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(leftView);
AddChild(rightView);
BStringView *sv = new BStringView(
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(),
kSmallVMargin + 30.0), NULL, f->ref.name, B_FOLLOW_ALL);
BFont largeFont(be_plain_font);
largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
sv->SetFont(&largeFont);
rightView->AddChild(sv);
float y = 32.0 + 4.0 * kSmallVMargin;
i = info.begin();
while (i != info.end()) {
sv = new BStringView(
BRect(kSmallHMargin, y, leftView->Bounds().Width(),
y + fontHeight), NULL, (*i).first.c_str());
sv->SetFont(&smallFont);
sv->SetAlignment(B_ALIGN_RIGHT);
sv->SetHighColor(kBasePieColor[1]); // arbitrary
leftView->AddChild(sv);
sv = new BStringView(
BRect(kSmallHMargin, y, rightView->Bounds().Width(),
y + fontHeight), NULL, (*i).second.c_str());
sv->SetFont(&smallFont);
rightView->AddChild(sv);
y += fontHeight + kSmallVMargin;
i++;
}
Show();
}
示例15: entry
//.........这里部分代码省略.........
// Size
size_to_string(f->size, name);
if (f->count > 0) {
// This is a directory.
char str[64];
sprintf(str, kInfoInFiles, f->count);
strcat(name, str);
}
info.push_back(Item(kInfoSize, name));
// Created & modified dates
BEntry entry(&f->ref);
time_t t;
entry.GetCreationTime(&t);
strftime(name, 64, kInfoTimeFmt, localtime(&t));
info.push_back(Item(kInfoCreated, name));
entry.GetModificationTime(&t);
strftime(name, 64, kInfoTimeFmt, localtime(&t));
info.push_back(Item(kInfoModified, name));
// Kind
BMimeType* type = f->Type();
type->GetShortDescription(name);
info.push_back(Item(kInfoKind, name));
delete type;
// Path
string path;
f->GetPath(path);
info.push_back(Item(kInfoPath, path));
// Icon
BBitmap *icon = new BBitmap(BRect(0.0, 0.0, 31.0, 31.0), B_RGBA32);
entry_ref ref;
entry.GetRef(&ref);
BNodeInfo::GetTrackerIcon(&ref, icon, B_LARGE_ICON);
// Compute the window size and add the views.
BFont smallFont(be_plain_font);
smallFont.SetSize(floorf(smallFont.Size() * 0.95));
struct font_height fh;
smallFont.GetHeight(&fh);
float fontHeight = fh.ascent + fh.descent + fh.leading;
float leftWidth = 32.0;
float rightWidth = 0.0;
InfoList::iterator i = info.begin();
while (i != info.end()) {
float w = smallFont.StringWidth((*i).first.c_str()) + 2.0 * kSmallHMargin;
leftWidth = max_c(leftWidth, w);
w = smallFont.StringWidth((*i).second.c_str()) + 2.0 * kSmallHMargin;
rightWidth = max_c(rightWidth, w);
i++;
}
float winHeight = 32.0 + 4.0 * kSmallVMargin + 5.0 * (fontHeight + kSmallVMargin);
float winWidth = leftWidth + rightWidth;
ResizeTo(winWidth, winHeight);
LeftView *leftView = new LeftView(BRect(0.0, 0.0, leftWidth, winHeight), icon);
BView *rightView = new BView(
BRect(leftWidth + 1.0, 0.0, winWidth, winHeight), NULL,
B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(leftView);
AddChild(rightView);
BStringView *sv = new BStringView(
BRect(kSmallHMargin, kSmallVMargin, rightView->Bounds().Width(), kSmallVMargin + 30.0),
NULL, f->ref.name, B_FOLLOW_ALL);
BFont largeFont(be_plain_font);
largeFont.SetSize(ceilf(largeFont.Size() * 1.1));
sv->SetFont(&largeFont);
rightView->AddChild(sv);
float y = 32.0 + 4.0 * kSmallVMargin;
i = info.begin();
while (i != info.end()) {
sv = new BStringView(
BRect(kSmallHMargin, y, leftView->Bounds().Width(), y + fontHeight),
NULL, (*i).first.c_str());
sv->SetFont(&smallFont);
sv->SetAlignment(B_ALIGN_RIGHT);
sv->SetHighColor(kBasePieColor[1]); // arbitrary
leftView->AddChild(sv);
sv = new BStringView(
BRect(kSmallHMargin, y, rightView->Bounds().Width(), y + fontHeight),
NULL, (*i).second.c_str());
sv->SetFont(&smallFont);
rightView->AddChild(sv);
y += fontHeight + kSmallVMargin;
i++;
}
Show();
}