本文整理汇总了C++中BView::StringWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::StringWidth方法的具体用法?C++ BView::StringWidth怎么用?C++ BView::StringWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::StringWidth方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: NewEditView
BView* SeqPrefWin::NewEditView(BRect bounds, const BMessage& prefs)
{
BView* v = new BView(bounds, EDIT_STR, B_FOLLOW_ALL, 0);
if (!v) return v;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
const char* label = "Undo history:";
float top = INDENT;
float fh = view_font_height(v);
float ih = Prefs().Size(INT_CTRL_Y);
float max = (fh > ih) ? fh : ih;
BRect r(INDENT, top, INDENT + v->StringWidth(label), top + max);
BStringView* sv = new BStringView(r, "undolevellabel", label);
if (sv) v->AddChild(sv);
r.left = r.right + LABEL_PAD;
r.right = r.left + v->StringWidth("999") + 5;
mUndoLevelCtrl = new ArpIntControl( r, UNDO_LEVEL_INT, NULL, new BMessage(CHANGE_UNDO_HISTORY_MSG) );
if (mUndoLevelCtrl) {
mUndoLevelCtrl->SetLimits(0, UNDO_HISTORY_MAX);
int32 level;
if (prefs.FindInt32(UNDO_HISTORY_PREF, &level) != B_OK) level = AM_DEFAULT_UNDO_HISTORY;
if (level < 0 || level > UNDO_HISTORY_MAX) level = AM_DEFAULT_UNDO_HISTORY;
mUndoLevelCtrl->SetValue(level);
v->AddChild(mUndoLevelCtrl);
}
return v;
}
示例2: NewGeneralView
BView* SeqEditMultiFilterWindow::NewGeneralView(BRect frame)
{
BView* v = new BView(frame, GENERAL_STR, B_FOLLOW_ALL, 0);
if (!v) return NULL;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float fh = arp_get_font_height(v);
float spaceX = 5, spaceY = 5;
float divider = v->StringWidth("Author:") + 10;
BRect f(spaceX, 0, frame.Width() - spaceX, fh);
/* The Name field.
*/
mNameCtrl = new BTextControl(f, "name_ctrl", "Name:", NULL, new BMessage(NAME_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (mNameCtrl) {
f.top = mNameCtrl->Frame().bottom;
mNameCtrl->SetDivider(divider);
mNameCtrl->MakeFocus(true);
v->AddChild(mNameCtrl);
}
/* The Key field.
*/
f.top += spaceY;
f.bottom = f.top + fh;
mKeyCtrl = new BTextControl(f, "key_ctrl", "Key:", NULL, new BMessage(KEY_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (mKeyCtrl) {
f.top = mKeyCtrl->Frame().bottom;
mKeyCtrl->SetDivider(divider);
v->AddChild(mKeyCtrl);
}
/* The Author field.
*/
f.top += spaceY;
f.bottom = f.top + fh;
mAuthorCtrl = new BTextControl(f, "author_ctrl", "Author:", NULL, new BMessage(AUTHOR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (mAuthorCtrl) {
f.top = mAuthorCtrl->Frame().bottom;
mAuthorCtrl->SetDivider(divider);
v->AddChild(mAuthorCtrl);
}
/* The Email field.
*/
f.top += spaceY;
f.bottom = f.top + fh;
mEmailCtrl = new BTextControl(f, "email_ctrl", "Email:", NULL, new BMessage(EMAIL_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if (mEmailCtrl) {
f.top = mEmailCtrl->Frame().bottom;
mEmailCtrl->SetDivider(divider);
v->AddChild(mEmailCtrl);
}
return v;
}
示例3: revertBounds
ColorPicker::ColorPicker(BLooper * target) : BWindow(BRect(50, 75, 100 + (CP_COL_WIDTH * 32), 120 + (CP_COL_WIDTH * 8)), str(STR_SET_COLORS), B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE), _target(target), _whichColor(0)
{
const float margin = 5.0f;
const float topRowHeight = 25.0f;
_colControl = new BColorControl(BPoint(margin, margin+topRowHeight+margin), B_CELLS_32x8, CP_COL_WIDTH, "color_picker", new BMessage(CP_COL_UPDATE));
ResizeTo(_colControl->Frame().right+margin, _colControl->Frame().bottom+margin);
BView * view = new BView(Bounds(), NULL, B_FOLLOW_ALL, 0);
AddChild(view);
view->SetViewColor(BeBackgroundGrey);
const BRect & bounds = view->Bounds();
float revertWidth = view->StringWidth(str(STR_REVERT))+10.0f;
BRect revertBounds(bounds.right-(revertWidth+margin), margin, bounds.right-margin, margin+topRowHeight);
view->AddChild(_revert = new BButton(revertBounds, NULL, str(STR_REVERT), new BMessage(CP_BUTTON_REVERT)));
float defaultWidth = view->StringWidth(str(STR_DEFAULT))+10.0f;
BRect defaultBounds(revertBounds.left-(margin+defaultWidth), revertBounds.top, revertBounds.left-margin, revertBounds.bottom);
view->AddChild(_default = new BButton(defaultBounds, NULL, str(STR_DEFAULT), new BMessage(CP_BUTTON_DEFAULT)));
view->AddChild(_sampleView = new BView(BRect(margin, margin, margin+topRowHeight, margin+topRowHeight), NULL, B_FOLLOW_TOP|B_FOLLOW_LEFT, B_WILL_DRAW));
_colorMenu = new BMenu("");
_colorMenu->SetLabelFromMarked(true);
for (int i=0; i<NUM_COLORS; i++)
{
BMessage * msg = new BMessage(CP_SELECTION_CHANGED);
msg->AddInt32("which", i);
BMenuItem * mi = new BMenuItem(str(STR_COLOR_BG+i), msg);
_colorMenu->AddItem(mi);
if (i==0) mi->SetMarked(true);
}
view->AddChild(new BMenuField(BRect(margin+topRowHeight+margin, margin, revertBounds.left-margin, revertBounds.bottom), NULL, NULL, _colorMenu));
view->AddChild(_colControl);
BMessage initMsg(CP_INIT);
PostMessage(&initMsg);
}
示例4: FrameResized
void CounterView::FrameResized (float width, float height)
{
BRect BitmapRect (0, 0, width, height);
char TempString [40];
m_BndRect = Bounds ();
m_MovingDotSize = (int) (height / 20);
if (m_MovingDotSize < 1)
m_MovingDotSize = 1;
m_MoveSpeed = m_MovingDotSize / 2.0;
// Resize the offscreen bitmap and its view.
if (m_BackingBitmap != NULL)
{
m_BackingBitmap->RemoveChild (&m_BackingView);
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
m_BackingView.ResizeTo (width, height);
m_BackingBitmap = new BBitmap (BitmapRect, B_RGBA32, true /* Accepts subviews */);
if (!m_BackingBitmap->IsValid ())
{
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
else
{
m_BackingBitmap->AddChild (&m_BackingView);
m_BackingBitmap->Lock ();
m_BackingView.SetDrawingMode (B_OP_ALPHA);
m_BackingView.SetFontSize (height * 0.8);
sprintf (TempString, "%d", m_CurrentCount);
m_TextStartPoint.x = width / 2 - m_BackingView.StringWidth (TempString) / 2;
m_TextStartPoint.y = height / 2 + height * 0.25;
m_BackingBitmap->Unlock ();
}
}
示例5: NewPipelineView
BView* SeqEditMultiFilterWindow::NewPipelineView(BRect frame)
{
BView* v = new BView(frame, PIPELINE_STR, B_FOLLOW_ALL, 0);
if (!v) return NULL;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float x = 5, y = 5;
const char* addL = "Add";
const char* deleteL = "Delete";
float buttonW = v->StringWidth(deleteL) + 30, buttonH = 24;
/* Lay out the views.
*/
BRect addF(x, 0, x + buttonW, buttonH);
BRect deleteF(addF.right + x, addF.top, addF.right + x + buttonW, addF.bottom);
float sbW = Prefs().Size(V_SCROLLBAR_X) + 3, sbH = Prefs().Size(H_SCROLLBAR_Y) + 3;
BRect pipelineF(x, addF.bottom + y, frame.Width() - sbW, frame.Height() - sbH);
/* Create and add the views.
*/
BButton* button = new BButton(addF, "add_btn", addL, new BMessage(ADD_PIPELINE_MSG), B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (button) v->AddChild(button);
button = new BButton(deleteF, "del_btn", deleteL, new BMessage(DELETE_PIPELINE_MSG), B_FOLLOW_LEFT | B_FOLLOW_TOP);
if (button) v->AddChild(button);
mPipelineView = new SeqPipelineMatrixView( pipelineF, "pipeline_matrix",
AmPipelineMatrixRef(mMultiFilter),
NULLINPUTOUTPUT_PIPELINE, SEQ_SUPPRESS_BACKGROUND);
if (mPipelineView) {
mPipelineView->SetResizingMode(B_FOLLOW_ALL);
mPipelineView->SetShowProperties(true);
mPipelineView->ForceViewColor( tint_color(Prefs().Color(AM_AUX_WINDOW_BG_C), B_DARKEN_1_TINT) );
mPipelineScrollView = new BScrollView("pipeline_scroll", mPipelineView, B_FOLLOW_ALL, 0, true, true);
if (mPipelineScrollView) {
v->AddChild(mPipelineScrollView);
mPipelineScrollView->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
} else v->AddChild(mPipelineView);
}
return v;
}
示例6: rect
ConfigWindow::ConfigWindow()
:
BWindow(BRect(100.0, 100.0, 580.0, 540.0), "E-mail", B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
fLastSelectedAccount(NULL),
fSaveSettings(false)
{
// create controls
BRect rect(Bounds());
BView *top = new BView(rect, NULL, B_FOLLOW_ALL, 0);
top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
AddChild(top);
// determine font height
font_height fontHeight;
top->GetFontHeight(&fontHeight);
int32 height = (int32)(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading) + 5;
rect.InsetBy(5, 5);
rect.bottom -= 11 + height;
BTabView *tabView = new BTabView(rect, NULL);
BView *view;
rect = tabView->Bounds();
rect.bottom -= tabView->TabHeight() + 4;
tabView->AddTab(view = new BView(rect, NULL, B_FOLLOW_ALL, 0));
tabView->TabAt(0)->SetLabel(B_TRANSLATE("Accounts"));
view->SetViewColor(top->ViewColor());
// accounts listview
rect = view->Bounds().InsetByCopy(8, 8);
rect.right = 140 - B_V_SCROLL_BAR_WIDTH;
rect.bottom -= height + 12;
fAccountsListView = new AccountsListView(rect);
view->AddChild(new BScrollView(NULL, fAccountsListView, B_FOLLOW_ALL, 0,
false, true));
rect.right += B_V_SCROLL_BAR_WIDTH;
rect.top = rect.bottom + 8;
rect.bottom = rect.top + height;
BRect sizeRect = rect;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(
B_TRANSLATE("Add"));
view->AddChild(new BButton(sizeRect, NULL, B_TRANSLATE("Add"),
new BMessage(kMsgAddAccount), B_FOLLOW_BOTTOM));
sizeRect.left = sizeRect.right+3;
sizeRect.right = sizeRect.left + 30 + view->StringWidth(
B_TRANSLATE("Remove"));
view->AddChild(fRemoveButton = new BButton(
sizeRect, NULL, B_TRANSLATE("Remove"),
new BMessage(kMsgRemoveAccount), B_FOLLOW_BOTTOM));
// accounts config view
rect = view->Bounds();
rect.left = fAccountsListView->Frame().right + B_V_SCROLL_BAR_WIDTH + 16;
rect.right -= 10;
view->AddChild(fConfigView = new CenterContainer(rect));
MakeHowToView();
// general settings
rect = tabView->Bounds();
rect.bottom -= tabView->TabHeight() + 4;
tabView->AddTab(view = new CenterContainer(rect));
tabView->TabAt(1)->SetLabel(B_TRANSLATE("Settings"));
rect = view->Bounds().InsetByCopy(8, 8);
rect.right -= 1;
rect.bottom = rect.top + height * 5 + 15;
BBox *box = new BBox(rect);
box->SetLabel(B_TRANSLATE("Mail checking"));
view->AddChild(box);
rect = box->Bounds().InsetByCopy(8, 8);
rect.top += 7;
rect.bottom = rect.top + height + 5;
BRect tile = rect.OffsetByCopy(0, 1);
int32 labelWidth = (int32)view->StringWidth(B_TRANSLATE("Check every")) + 6;
tile.right = 80 + labelWidth;
fIntervalControl = new BTextControl(tile, "time",
B_TRANSLATE("Check every"), NULL, NULL);
fIntervalControl->SetDivider(labelWidth);
box->AddChild(fIntervalControl);
BPopUpMenu *frequencyPopUp = new BPopUpMenu(B_EMPTY_STRING);
const char *frequencyStrings[] = {
B_TRANSLATE("never"),
B_TRANSLATE("minutes"),
B_TRANSLATE("hours"),
B_TRANSLATE("days")
};
BMenuItem *item;
for (int32 i = 0; i < 4; i++) {
frequencyPopUp->AddItem(item = new BMenuItem(frequencyStrings[i],
new BMessage(kMsgIntervalUnitChanged)));
//.........这里部分代码省略.........
示例7: cursor
// MouseMoved
void
ObjectView::MouseMoved(BPoint where, uint32 transit,
const BMessage* dragMessage)
{
// BRect dirty(where, where);
// dirty.InsetBy(-10, -10);
// Invalidate(dirty);
if (dragMessage) {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f)) - DRAG MESSAGE\n", where.x, where.y);
//Window()->CurrentMessage()->PrintToStream();
} else {
//printf("ObjectView::MouseMoved(BPoint(%.1f, %.1f))\n", where.x, where.y);
}
if (fScrolling) {
BCursor cursor(kGrabCursor);
SetViewCursor(&cursor);
BPoint offset = fLastMousePos - where;
ScrollBy(offset.x, offset.y);
fLastMousePos = where + offset;
} else if (fInitiatingDrag) {
BPoint offset = fLastMousePos - where;
if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) {
BMessage newDragMessage('drag');
BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32,
true);
if (dragBitmap->Lock()) {
BView* helper = new BView(dragBitmap->Bounds(),
"offscreen view", B_FOLLOW_ALL, B_WILL_DRAW);
dragBitmap->AddChild(helper);
helper->SetDrawingMode(B_OP_ALPHA);
helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
BRect r(helper->Bounds());
helper->SetHighColor(0, 0, 0, 128);
helper->StrokeRect(r);
helper->SetHighColor(200, 200, 200, 100);
r.InsetBy(1, 1);
helper->FillRect(r);
helper->SetHighColor(0, 0, 0, 255);
const char* text = B_TRANSLATE("Test");
float pos = (r.Width() - helper->StringWidth(text)) / 2;
helper->DrawString(text, BPoint(pos, 25));
helper->Sync();
}
DragMessage(&newDragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN,
this);
fInitiatingDrag = false;
}
} else {
BCursor cursor(kMoveCursor);
SetViewCursor(&cursor);
if (fState && fState->IsTracking()) {
BRect before = fState->Bounds();
fState->MouseMoved(where);
BRect after = fState->Bounds();
BRect invalid(before | after);
Invalidate(invalid);
}
}
// SetViewCursor();
}
示例8: BWindow
_OwqWindow(BMessenger target, const BMessage* prefs = 0)
: BWindow( BRect(100, 100, 300, 300),
"Open From Query",
B_TITLED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
mTarget(target), mFilePanel(0), mOnBox(0), mNameCtrl(0), mFileButton(0), mSkipBox(0),
mRef(0)
{
BRect b = Bounds();
BView* v = new BView( b, "bg", B_FOLLOW_ALL, 0 );
float bottom = b.bottom;
if (v) {
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float cbH = check_box_height( v );
BRect f(5, 5, b.right - 5, 5 + cbH);
mOnBox = new BCheckBox( f, "on_box", "On", new BMessage( OWQ_ON_MSG ) );
if( mOnBox ) {
mOnBox->SetValue( B_CONTROL_ON );
v->AddChild( mOnBox );
}
f.OffsetBy( 0, f.Height() + 10 );
f.bottom = f.top + text_control_height( v );
mNameCtrl = new BTextControl( f, "name_ctrl", "Name: ", "", new BMessage( OWQ_NAME_MSG ) );
if( mNameCtrl ) {
mNameCtrl->SetDivider( v->StringWidth( "Name:" ) + 10 );
v->AddChild( mNameCtrl );
}
f.OffsetBy( 0, f.Height() + 10 );
f.bottom = f.top + button_height( v );
mFileButton = new BButton( f, "file_ctrl", "Choose Query", new BMessage( OWQ_CHOOSE_FILE_MSG ) );
if( mFileButton ) v->AddChild( mFileButton );
/* I've turned off skip for now -- I think just having it on
* is easier than explaining it.
*/
#if 0
f.OffsetBy( 0, f.Height() + 5 );
f.bottom = f.top + cbH;
mSkipBox = new BCheckBox( f, "skip_box", "Skip top level", new BMessage( OWQ_SKIP_MSG ) );
if( mSkipBox ) v->AddChild( mSkipBox );
#endif
f.top = f.bottom + 10;
f.bottom = f.top + button_height( v );
float buttonW = 60;
f.left = f.right - buttonW;
BButton* button = new BButton( f, "ok_button", "OK", new BMessage( OK_MSG ) );
if( button ) {
v->AddChild( button );
button->MakeDefault( true );
}
f.OffsetBy( 0-(buttonW + 10), 0 );
button = new BButton( f, "cancel_button", "Cancel", new BMessage( CANCEL_MSG ) );
if( button ) v->AddChild( button );
bottom = f.bottom + 5;
AddChild( v );
}
ResizeTo( b.Width(), bottom );
if( prefs ) SetPrefs( prefs );
bool enable = false;
if( mOnBox && mOnBox->Value() == B_CONTROL_ON ) enable = true;
SetControlEnable(enable);
}
示例9: NewTrackView
BView* SeqPrefWin::NewTrackView(BRect bounds, const BMessage& prefs)
{
BView* v = new BView(bounds, TRACK_STR, B_FOLLOW_ALL, 0);
if (!v) return v;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float fh = view_font_height(v);
/* The Track windows follow playback position preference.
*/
const char* str = "Track windows follow playback position";
float w = v->StringWidth(str) + 25;
BRect f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
mTrackWinFollowCtrl = new BCheckBox( f, TRACK_WIN_FOLLOW_STR, str, new BMessage(TRACK_WIN_FOLLOW_MSG) );
if (mTrackWinFollowCtrl) {
bool b;
if (prefs.FindBool(TRACK_WIN_FOLLOW_PREF, &b) != B_OK) b = false;
mTrackWinFollowCtrl->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
v->AddChild(mTrackWinFollowCtrl);
f.top = mTrackWinFollowCtrl->Frame().bottom + 5;
}
/* The Track windows play to end of song preference.
*/
str = "Track windows play to end of song";
w = v->StringWidth(str) + 25;
f.bottom = f.top + Prefs().Size(INT_CTRL_Y);
f.right = f.left + w;
mTrackWinPlayToEndCtrl = new BCheckBox(f, TRACK_WIN_PLAY_TO_END_STR, str, new BMessage(TRACK_WIN_PLAY_TO_END_MSG) );
if (mTrackWinPlayToEndCtrl) {
bool b;
if (prefs.FindBool(TRACK_WIN_PLAY_TO_END_PREF, &b) != B_OK) b = false;
mTrackWinPlayToEndCtrl->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
v->AddChild(mTrackWinPlayToEndCtrl);
f.top = mTrackWinPlayToEndCtrl->Frame().bottom + 5;
}
/* The Initial track height preference.
*/
const char* label = "Initial track height:";
float divider = v->StringWidth(label) + 5;
f.bottom = f.top + Prefs().Size(INT_CTRL_Y);
f.right = f.left + divider + v->StringWidth("200") + 10;
mTrackHeightCtrl = new ArpIntControl(f, "track_height_ctrl", label, new BMessage(TRACK_HEIGHT_MSG) );
if (mTrackHeightCtrl) {
mTrackHeightCtrl->SetLimits(AM_DEFAULT_TRACK_HEIGHT, 199);
int32 level;
if (prefs.FindInt32(TRACK_HEIGHT_PREF, &level) != B_OK) level = AM_DEFAULT_TRACK_HEIGHT;
if (level < AM_DEFAULT_TRACK_HEIGHT || level > 199) level = AM_DEFAULT_TRACK_HEIGHT;
mTrackHeightCtrl->SetValue(level);
mTrackHeightCtrl->SetFormatter(new _UpOneFormat() );
mTrackHeightCtrl->SetDivider(divider);
v->AddChild(mTrackHeightCtrl);
}
/* The Track label height preference.
*/
label = "Track label height:";
f.top = f.bottom + 5;
f.bottom = f.top + Prefs().Size(INT_CTRL_Y);
mLabelHeightCtrl = new ArpIntControl(f, "label_height_ctrl", label, new BMessage(LABEL_HEIGHT_MSG) );
if (mLabelHeightCtrl) {
mLabelHeightCtrl->SetLimits(6, 50);
int32 level;
if (prefs.FindInt32(PHRASE_LABEL_HEIGHT_PREF, &level) != B_OK) level = 8;
if (level < 6 || level > 50) level = 8;
mLabelHeightCtrl->SetValue(level);
mLabelHeightCtrl->SetDivider(divider);
v->AddChild(mLabelHeightCtrl);
}
return v;
}
示例10: NewFileView
BView* SeqPrefWin::NewFileView(BRect bounds, const BMessage& prefs) const
{
BView* v = new BView( bounds, FILE_STR, B_FOLLOW_ALL, 0 );
if( !v ) return v;
v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
float fh = view_font_height(v);
float bfh = bold_font_height();
float openH = bfh + 5 + fh + 5 + fh + 5 + fh;
/* The Remember Open Songs preference.
*/
float w = v->StringWidth("Remember open songs") + 25;
BRect f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
BCheckBox* cb = new BCheckBox( f, REMEMBER_OPEN_STR, "Remember open songs", new BMessage(REMEMBER_OPEN_MSG) );
if( cb ) {
bool b;
if( prefs.FindBool(REMEBER_OPEN_SONGS_PREF, &b) != B_OK ) b = false;
cb->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
v->AddChild( cb );
}
/* The Skin preference.
*/
BMenu* menu = new BMenu("skin_menu");
BMessage skinMsg(CHANGE_SKIN_MSG);
BMenuItem* item = new BMenuItem( "Default", new BMessage(CHANGE_SKIN_TO_DEFAULT_MSG) );
item->SetMarked(true);
menu->AddItem(item);
menu->AddSeparatorItem();
menu->SetLabelFromMarked(true);
if( seq_make_skin_menu(menu, &skinMsg) == B_OK ) {
const char* label = "Choose skin:";
f.Set(f.left, f.bottom + 8, bounds.right - 5, f.bottom + 8 + fh + 10);
BMenuField* field = new BMenuField(f, "skin_field", label, menu);
if (field) {
field->SetDivider( v->StringWidth(label) + 10 );
v->AddChild(field);
} else delete menu;
} else delete menu;
/* The Open New Songs preferences.
*/
f.Set(bounds.left + 5, f.bottom + 10, bounds.right - 5, f.bottom + 10 + openH + 10);
BBox* box = new BBox( f,
"open_new_songs",
B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
if( box ) {
box->SetLabel( "Open New Songs" );
BRect boxB = box->Bounds();
BRect sf(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.top + 5 + bfh + fh);
const char* choice;
if( prefs.FindString(OPEN_NEW_SONG_PREF, &choice) != B_OK ) choice = 0;
BRadioButton* button = new BRadioButton( sf, OPEN_BLANK_STR, "Blank", new BMessage(OPEN_BLANK_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "blank") == 0 ) button->SetValue( B_CONTROL_ON );
box->AddChild( button );
}
sf.OffsetBy( 0, 5 + fh );
button = new BRadioButton( sf, OPEN_FOUR_STR, "With two channels of each device", new BMessage(OPEN_FOUR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "channels") == 0 ) button->SetValue( B_CONTROL_ON );
box->AddChild( button );
}
sf.OffsetBy( 0, 5 + fh );
button = new BRadioButton( sf, OPEN_FILE_STR, "From file: <click to select>", new BMessage(OPEN_FILE_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
if( button ) {
if( choice && strcmp(choice, "file") == 0 ) button->SetValue( B_CONTROL_ON );
entry_ref ref;
if( prefs.FindRef(OPEN_NEW_SONG_FILE_PREF, &ref) == B_OK )
button->SetLabel( label_for_open_new_from_file(&ref).String() );
box->AddChild( button );
}
v->AddChild( box );
f.OffsetBy(0, f.bottom - f.top + 10 );
}
/* The Open From Query preferences
*/
f.bottom = bounds.bottom - 27;
box = new BBox( f, "open_from_query", B_FOLLOW_ALL);
if( box ) {
box->SetLabel("Open From Query");
BRect boxB = box->Bounds();
BRect tableF(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.bottom - 35);
mOwqTable = new _OwqList( tableF, mPreferences );
if( mOwqTable ) {
mOwqTable->SetLatchWidth( 0 );
box->AddChild( mOwqTable );
mOwqTable->AddColumn( new BStringColumn(ON_STR, 40, 20, 100, B_TRUNCATE_END), 0 );
mOwqTable->AddColumn( new BStringColumn(NAME_STR, 100, 20, 150, B_TRUNCATE_END), 1 );
mOwqTable->AddColumn( new BStringColumn(QUERY_STR, 180, 20, 450, B_TRUNCATE_MIDDLE), 2 );
// mOwqTable->AddColumn( new BStringColumn(SKIP_TOP_LEVEL_STR, 100, 20, 250, B_TRUNCATE_END), 3 );
mOwqTable->SetSortColumn(mOwqTable->ColumnAt(1), false, true);
// mOwqTable->SetSortColumn(mOwqTable->ColumnAt(), true, true);
mOwqTable->SetSelectionMode( B_SINGLE_SELECTION_LIST );
BRect bF(tableF.left, tableF.bottom + 5, tableF.left + 55, tableF.Height() - 10);
BButton* add = new BButton( bF, "owq_add", "Add", new BMessage(OWQ_INVOKE_ADD), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
if( add ) box->AddChild( add );
bF.OffsetBy( bF.Width() + 5, 0 );
BButton* change = new BButton( bF, "owq_change", "Change", new BMessage(OWQ_CHANGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
if( change ) {
//.........这里部分代码省略.........
示例11: BuildGUI
//.........这里部分代码省略.........
name, _T(desc), enabling);
if (active) ((BCheckBox*)control)->SetValue(B_CONTROL_ON);
} break;
default: {
continue;
};
};
if (!value) value = "";
if (!control) {
if (freeText) {
if (multiLine == false) {
control = new BTextControl(
BRect(0, 0, kControlWidth, fFontHeight), name,
_T(desc), value, NULL);
if (secret) {
((BTextControl *)control)->TextView()->HideTyping(true);
((BTextControl *)control)->SetText(_T(value));
};
((BTextControl *)control)->SetDivider(kDividerWidth);
} else
{
BRect rect;
BRect textRect;
if (desc) //andrea: add description only if available.
{
BRect labelRect(0, 0, kDividerWidth, fFontHeight);
BStringView *label = new BStringView(labelRect, "NA", _T(desc),
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
view->AddChild(label);
label->MoveTo(kEdgeOffset, yOffset);
rect = BRect(0, 0, kControlWidth - kDividerWidth, fFontHeight * 4);
rect.right -= B_V_SCROLL_BAR_WIDTH + kEdgeOffset + kControlOffset;
xOffset = kEdgeOffset + kDividerWidth;
}
else
{
rect = BRect(0, 0, kControlWidth, fFontHeight * 4);
rect.right -= B_V_SCROLL_BAR_WIDTH + kControlOffset;
xOffset = 0;
}
textRect = rect;
textRect.InsetBy(kEdgeOffset, kEdgeOffset);
textRect.OffsetTo(1.0, 1.0);
BTextView *textView = new BTextView(rect, name, textRect,
B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
control = new BScrollView("NA", textView, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_NAVIGABLE, false, true);
textView->SetText(_T(value));
};
} else {
control = new BMenuField(BRect(0, 0, kControlWidth, fFontHeight),
name, _T(desc), menu);
float size=kDividerWidth;
if(control->StringWidth(_T(desc)) > kDividerWidth)
size=control->StringWidth(_T(desc)) + 20;
((BMenuField *)control)->SetDivider(size);
};
};
view->AddChild(control);
if(enabling)
((BCheckBox*)control)->SetTarget(this);
float h, w = 0;
control->GetPreferredSize(&w, &h);
if (h < control->Bounds().Height())
h = control->Bounds().Height();
control->MoveTo(kEdgeOffset + xOffset, yOffset);
yOffset += kControlOffset + h ;
xOffset = 0;
};
for (int j = 0; postAdded.FindString("disable", j); j++)
{
const char* name=postAdded.FindString("disable", j);
BView* viewz=view->FindView(name);
if(viewz)
((BControl*)viewz)->SetEnabled(false);
}
//if ( yOffset < view->Bounds().Height() )
// yOffset = view->Bounds().Height();
return yOffset;//view->ResizeTo( view->Bounds().Width(), yOffset
}
示例12: clipRect
// This function returns the number of pixels of the text that
// were clipped if the text does not fit into the clipping rect.
// If the text all fit, it returns 0.
int
BeOSCanvas::RenderText( int iFontHeight, Rect& oClipRect,
string& oText, AlignEnum eAlign,
Font* pFont, const Color& oColor,
bool bBold, bool bItalic, bool bUnderline )
{
Erase( oClipRect );
BView* v = m_pBufferBitmap->OffscreenView();
if ( !v ) return 0;
BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();
assert( bitmap );
BFont font;
font_height fontHeight;
BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
float(oClipRect.x2-1), float(oClipRect.y2-1) );
BRegion clipRegion;
clipRegion.Set( clipRect );
if ( !bitmap->Lock() )
{
puts( "lock failed" );
return 0;
}
v->ConstrainClippingRegion( &clipRegion );
v->SetDrawingMode( B_OP_OVER );
if ( bBold )
{
v->SetFont( be_bold_font );
}
else
{
v->SetFont( be_plain_font );
}
v->SetFontSize( (float)iFontHeight - 1 );
v->GetFont( &font );
font.GetHeight( &fontHeight );
float width = v->StringWidth(oText.c_str(), oText.size());
if(eAlign == eCenter)
v->MovePenTo( float(oClipRect.x1) +
(float(oClipRect.x2 - oClipRect.x1) - width)/2,
float(oClipRect.y2-fontHeight.descent) );
else if (eAlign == eRight)
v->MovePenTo( float(oClipRect.x2) - width,
float(oClipRect.y2-fontHeight.descent) );
else
v->MovePenTo( float(oClipRect.x1),
float(oClipRect.y2-fontHeight.descent) );
v->DrawString( oText.c_str() );
v->Sync();
bitmap->Unlock();
Invalidate( oClipRect );
return (width < oClipRect.Width()) ? 0 : int(width - oClipRect.Width());
}