本文整理汇总了C++中BButton::SetEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ BButton::SetEnabled方法的具体用法?C++ BButton::SetEnabled怎么用?C++ BButton::SetEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BButton
的用法示例。
在下文中一共展示了BButton::SetEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BMessage
void
HWindow::_InitGUI()
{
fEventList = new HEventList();
fEventList->SetType(BMediaFiles::B_SOUNDS);
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
BMenu* menu = new BMenu("file");
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
new BMessage(M_OTHER_MESSAGE)));
BString label(B_TRANSLATE("Sound file:"));
BMenuField* menuField = new BMenuField("filemenu", label, menu);
menuField->SetDivider(menuField->StringWidth(label) + 10);
BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);
BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
new BMessage(M_STOP_MESSAGE));
stopbutton->SetEnabled(false);
stopbutton->SetExplicitSize(buttonsSize);
// We need at least one view to trigger B_PULSE_NEEDED events which we will
// intercept in DispatchMessage to trigger the buttons enabling or disabling.
stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);
BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
new BMessage(M_PLAY_MESSAGE));
playbutton->SetEnabled(false);
playbutton->SetExplicitSize(buttonsSize);
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_WINDOW_SPACING)
.Add(fEventList)
.AddGroup(B_HORIZONTAL)
.Add(menuField)
.AddGroup(B_HORIZONTAL, 0)
.Add(playbutton)
.Add(stopbutton)
.End()
.End();
// setup file menu
_SetupMenuField();
BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
if (noneItem != NULL)
noneItem->SetMarked(true);
_UpdateZoomLimits();
}
示例2: SelectionChanged
void _OwqList::SelectionChanged()
{
inherited::SelectionChanged();
BRow* selection = CurrentSelection();
if( selection ) {
if( mChange ) mChange->SetEnabled( true );
if( mRemove ) mRemove->SetEnabled( true );
} else {
if( mChange ) mChange->SetEnabled( false );
if( mRemove ) mRemove->SetEnabled( false );
}
}
示例3: UpdateFields
void CPrefsDialog::UpdateFields()
{
if (fNewOrCur->IndexOf(fNewOrCur->FindMarked()) == 1)
GrabDocFont();
else
GrabNewFont();
BButton *b;
b = (BButton *)FindView("ok");
b->SetEnabled(true);
b = (BButton *)FindView("cancel");
b->SetEnabled(true);
} /* CPrefsDialog::UpdateFields */
示例4: CancelClicked
bool CPrefsDialog::CancelClicked()
{
char s[256];
ResetFontSheet();
SetOn("autorecalc", fAutoRecalc);
SetOn("displayzero", fDisplayZero);
s[1] = 0;
s[0] = gDecimalPoint;
SetText("decsep", s);
s[0] = gThousandSeparator;
SetText("thoussep", s);
s[0] = gListSeparator;
SetText("listsep", s);
s[0] = gTimeSeparator;
SetText("timesep", s);
s[0] = gDateSeparator;
SetText("datesep", s);
fDMY->FindItem(gPrefs->GetPrefString("date order"))->SetMarked(true);
SetOn("24 hours", g24Hours);
SetOn("excel", gPrefs->GetPrefInt("Excel keys", 0));
SetOn("grayselect", gPrefs->GetPrefInt("Select Gray", 0));
SetOn(gPrefs->GetPrefInt("start with new", 1) ? "donew" : "doopen", B_CONTROL_ON);
SetOn("formula starts with equal", gPrefs->GetPrefInt("formula starts with equal", 0));
SetOn("dark gridlines", gPrefs->GetPrefInt("dark gridlines"));
SetText("c_symbol", gPrefs->GetPrefString("c_symbol", "$"));
SetOn(gPrefs->GetPrefInt("c_before", 1) ? "c_before" : "c_after", B_CONTROL_ON);
SetOn("c_neg_par", gPrefs->GetPrefInt("c_neg_par", 1) ? B_CONTROL_ON : B_CONTROL_OFF);
sprintf(s, "%d", gPrefs->GetPrefInt("c_digits"));
SetText("c_digits", s);
if (fPageSetup) FREE(fPageSetup);
fPageSetup = (char *)Hex2Bin(gPrefs->GetPrefString("default page setup", ""), fPageSetupSize);
SetOn("prgrid", fPrGrid);
SetOn("prhead", fPrBorders);
SetOn("dispgrid", fShGrid);
SetOn("disphead", fShBorders);
BButton *b;
b = (BButton *)FindView("ok");
b->SetEnabled(false);
b = (BButton *)FindView("cancel");
b->SetEnabled(false);
return false;
} /* CPrefsDialog::CancelClicked */
示例5: SelectionChanged
// Buttons are enabled or not depending on the selection in the list
// so each time you click in the list, this method is called to update the buttons
void NetListView::SelectionChanged(void)
{
int32 index = CurrentSelection();
BView *parent = Parent();
if (index >= 0) {
// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {
BButton *settings = dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
BButton *clear = dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
settings->SetEnabled(true);
clear->SetEnabled(true);
}
else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
BButton *restore = dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
BButton *remove = dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
restore ->SetEnabled(true);
remove ->SetEnabled(true);
}
}
else {
// There are 2 lists that are instances of this class, so we have to see in which list you are clicking
if (strcmp(parent->Name(),"Interfaces_Scroller") == 0) {
BButton *settings=dynamic_cast <BButton *> ((parent->Parent())->FindView("Settings"));
BButton *clear=dynamic_cast <BButton *> ((parent->Parent())->FindView("Clear"));
settings->SetEnabled(false);
clear->SetEnabled(false);
}
else if (strcmp(parent->Name(),"Configurations_Scroller") == 0) {
BButton *restore=dynamic_cast <BButton *> ((parent->Parent())->FindView("Restore"));
BButton *remove=dynamic_cast <BButton *> ((parent->Parent())->FindView("Delete"));
restore->SetEnabled(false);
remove->SetEnabled(false);
}
}
}
示例6:
void
FadeView::UpdateStatus()
{
Window()->DisableUpdates();
bool enabled = fEnableCheckBox->Value() == B_CONTROL_ON;
fPasswordCheckBox->SetEnabled(enabled);
fTurnOffCheckBox->SetEnabled(enabled && fTurnOffScreenFlags != 0);
fRunSlider->SetEnabled(enabled);
fTurnOffSlider->SetEnabled(enabled && fTurnOffCheckBox->Value());
fPasswordSlider->SetEnabled(enabled && fPasswordCheckBox->Value());
fPasswordButton->SetEnabled(enabled && fPasswordCheckBox->Value());
Window()->EnableUpdates();
// Update the saved preferences
fSettings.SetWindowFrame(Frame());
fSettings.SetTimeFlags((enabled ? ENABLE_SAVER : 0)
| (fTurnOffCheckBox->Value() ? fTurnOffScreenFlags : 0));
fSettings.SetBlankTime(fRunSlider->Time());
bigtime_t offTime = fTurnOffSlider->Time() - fSettings.BlankTime();
fSettings.SetOffTime(offTime);
fSettings.SetSuspendTime(offTime);
fSettings.SetStandByTime(offTime);
fSettings.SetBlankCorner(fFadeNow->Corner());
fSettings.SetNeverBlankCorner(fFadeNever->Corner());
fSettings.SetLockEnable(fPasswordCheckBox->Value());
fSettings.SetPasswordTime(fPasswordSlider->Time());
// TODO - Tell the password window to update its stuff
}
示例7: BView
MainView::MainView( BRect frame ) : BView (frame, "mainView", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) {
SetViewColor(216, 216, 216);
// nutzbare Größe
frame.OffsetTo( 0.0, 0.0 );
frame.InsetBy( 5.0, 5.0 );
// Erstellen der beiden inneren Frames
TopView* topView = new TopView( BRect( frame.left, frame.top, frame.right, frame.bottom - 72.0 - be_plain_font->Size() - be_bold_font->Size() ) );
AddChild( topView );
BottomView* bottomView = new BottomView( BRect( frame.left, frame.bottom - 67.0 - be_plain_font->Size() - be_bold_font->Size(), frame.right, frame.bottom - 43.0 ) );
AddChild( bottomView );
// StatusBar
BStatusBar* statusBar = new BStatusBar( BRect(frame.left + 5.0, frame.bottom - be_plain_font->Size() - 23.0, frame.left + 400.0, frame.bottom), "statusBar", STATUS_STATUS, NULL);
statusBar->SetText(STATUS_SELECT_FILES);
statusBar->SetResizingMode(B_FOLLOW_BOTTOM);
rgb_color color = { 70, 100, 180, 255};
statusBar->SetBarColor(color);
statusBar->SetBarHeight(14.0);
AddChild(statusBar);
// Do it! - Button
BButton* DoItButton = new BButton( BRect ( frame.right - be_plain_font->StringWidth(STR_DO_IT) - 25.0, frame.bottom - 30.0, frame.right - 5.0 , frame.bottom - 5.0 ), "DoIt", STR_DO_IT, new BMessage(MSG_DO_IT), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM );
DoItButton->SetEnabled(false);
AddChild(DoItButton);
};
示例8:
void
HWindow::_Pulse()
{
BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
if (stop == NULL)
return;
if (fPlayer != NULL) {
if (fPlayer->IsPlaying())
stop->SetEnabled(true);
else
stop->SetEnabled(false);
} else
stop->SetEnabled(false);
}
示例9: BView
TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
: BView(frame, name, resizingMode, flags)
{
BFont font;
BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
btn->ForceFontAliasing(true);
if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
btn->SetFontSize(20);
AddChild(btn);
btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
btn->ForceFontAliasing(true);
if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
btn->SetFontSize(24);
}
AddChild(btn);
btn->ResizeToPreferred();
btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
btn->SetEnabled(false);
AddChild(btn);
btn->ResizeToPreferred();
}
示例10: Window
// Stuff we can only do when the main view is attached to a window
void
OutputFormatView::AttachedToWindow()
{
// Get the window and lock it
the_window = Window();
the_window->Lock();
// Set some size limits on the window
the_window->SetSizeLimits(
200.0,
32767.0,
Bounds().Height() - scroll_view->Bounds().Height() + 50.0,
32767.0);
// Set the target for messages sent to this view
list_view->SetTarget(this);
the_button->SetTarget(this);
// Make the list view the keyboard focus
list_view->MakeFocus();
// Select the first item in the list,
// and make its config view show up
if (list_view->CountItems() > 0)
list_view->Select(0);
else
the_button->SetEnabled(false);
// Unlock the window
the_window->Unlock();
// Call the base class
BView::AttachedToWindow();
}
示例11:
void
HWindow::Pulse()
{
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
BMenuField* menufield = dynamic_cast<BMenuField*>(FindView("filemenu"));
BButton* button = dynamic_cast<BButton*>(FindView("play"));
BButton* stop = dynamic_cast<BButton*>(FindView("stop"));
if (menufield == NULL || button == NULL || stop == NULL)
return;
if (row != NULL) {
menufield->SetEnabled(true);
const char* path = row->Path();
if (path != NULL && strcmp(path, ""))
button->SetEnabled(true);
else
button->SetEnabled(false);
} else {
menufield->SetEnabled(false);
button->SetEnabled(false);
}
if (fPlayer != NULL) {
if (fPlayer->IsPlaying())
stop->SetEnabled(true);
else
stop->SetEnabled(false);
} else
stop->SetEnabled(false);
}
示例12: sizeof
void
ProgressWindow::MessageReceived(BMessage* message)
{
switch (message->what) {
case B_UPDATE_STATUS_BAR:
char count[100];
snprintf(count, sizeof(count), "%" B_PRId32,
(int32)fStatusBar->CurrentValue() + 1);
fStatusBar->Update(1, NULL, count);
break;
case B_CANCEL:
fAbortButton->SetEnabled(false);
if (fQuitListener != NULL)
*fQuitListener = true;
break;
default:
BWindow::MessageReceived(message);
break;
}
}
示例13: BMessage
void
HWindow::InitGUI()
{
fEventList = new HEventList();
fEventList->SetType(BMediaFiles::B_SOUNDS);
fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);
BGroupView* view = new BGroupView();
BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);
BMenu* menu = new BMenu("file");
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
new BMessage(M_NONE_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
new BMessage(M_OTHER_MESSAGE)));
BString label(B_TRANSLATE("Sound file:"));
BMenuField* menuField = new BMenuField("filemenu", label, menu);
menuField->SetDivider(menuField->StringWidth(label) + 10);
BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"),
new BMessage(M_STOP_MESSAGE));
stopbutton->SetEnabled(false);
BButton* playbutton = new BButton("play", B_TRANSLATE("Play"),
new BMessage(M_PLAY_MESSAGE));
playbutton->SetEnabled(false);
const float kInset = be_control_look->DefaultItemSpacing();
view->SetLayout(new BGroupLayout(B_HORIZONTAL));
view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset)
.AddGroup(B_HORIZONTAL)
.Add(menuField)
.AddGlue()
.End()
.AddGroup(B_HORIZONTAL, kInset)
.AddGlue()
.Add(playbutton)
.Add(stopbutton)
.End()
.SetInsets(kInset, kInset, kInset, kInset)
);
box->AddChild(view);
SetLayout(new BGroupLayout(B_HORIZONTAL));
AddChild(BGroupLayoutBuilder(B_VERTICAL)
.AddGroup(B_VERTICAL, kInset)
.Add(fEventList)
.Add(box)
.End()
.SetInsets(kInset, kInset, kInset, kInset)
);
// setup file menu
SetupMenuField();
BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
if (noneItem != NULL)
noneItem->SetMarked(true);
}
示例14: OKClicked
bool CPrefsDialog::OKClicked()
{
font_family defFamily;
font_style defStyle;
be_plain_font->GetFamilyAndStyle(&defFamily, &defStyle);
gPrefs->SetPrefString("defdoc font family", fNewFontFamily);
gPrefs->SetPrefString("defdoc font style", defStyle);
gPrefs->SetPrefDouble("defdoc font size", fNewFontSize);
be_bold_font->GetFamilyAndStyle(&defFamily, &defStyle);
gPrefs->SetPrefString("border font family", fNewBFontFamily);
gPrefs->SetPrefString("border font style", defStyle);
gPrefs->SetPrefDouble("border font size", fNewBFontSize);
gPrefs->SetPrefInt("decimal point", *GetText("decsep"));
gPrefs->SetPrefInt("thousands separator", *GetText("thoussep"));
gPrefs->SetPrefInt("list separator", *GetText("listsep"));
gPrefs->SetPrefInt("date separator", *GetText("datesep"));
gPrefs->SetPrefInt("time separator", *GetText("timesep"));
gPrefs->SetPrefString("date order", fDMY->FindMarked()->Label());
gPrefs->SetPrefInt("24 hours", IsOn("24 hours"));
gPrefs->SetPrefInt("Excel keys", IsOn("excel"));
gPrefs->SetPrefInt("Select Gray", IsOn("grayselect"));
gPrefs->SetPrefInt("start with new", IsOn("donew"));
gWithEqualSign = IsOn("formula starts with equal");
gPrefs->SetPrefInt("formula starts with equal", gWithEqualSign);
gPrefs->SetPrefInt("dark gridlines", IsOn("dark gridlines"));
if (gPrefs->GetPrefInt("dark gridlines", 0))
gGridColor = 10;
else
gGridColor = 6;
gPrefs->SetPrefString("c_symbol", GetText("c_symbol"));
gPrefs->SetPrefInt("c_before", IsOn("c_before"));
gPrefs->SetPrefInt("c_neg_par", IsOn("c_neg_par"));
gPrefs->SetPrefInt("c_digits", atoi(GetText("c_digits")));
if (fPageSetup)
{
char *ps = Bin2Hex(fPageSetup, fPageSetupSize);
gPrefs->SetPrefString("default page setup", ps);
FREE(ps);
}
BMessage msg(msg_WindowOptions);
msg.AddString("docfamily", fDocFontFamily);
msg.AddString("docstyle", "Roman");
msg.AddFloat("docsize", fDocFontSize);
msg.AddString("borderfamily", fDocBFontFamily);
msg.AddString("borderstyle", "Bold");
msg.AddFloat("bordersize", fDocBFontSize);
msg.AddBool("autorecalc", IsOn("autorecalc"));
msg.AddBool("displayzero", IsOn("displayzero"));
msg.AddBool("dispgrid", IsOn("dispgrid"));
msg.AddBool("disphead", IsOn("disphead"));
msg.AddBool("prgrid", IsOn("prgrid"));
msg.AddBool("prhead", IsOn("prhead"));
fOwner->PostMessage(&msg, fOwner->GetCellView());
BButton *b;
b = (BButton *)FindView("ok");
b->SetEnabled(false);
b = (BButton *)FindView("cancel");
b->SetEnabled(false);
InitFormatter();
return false;
} /* CPrefsDialog::OKClicked */
示例15: SetControlEnable
void SetControlEnable(bool enable)
{
if( mNameCtrl ) mNameCtrl->SetEnabled( enable );
if( mFileButton ) mFileButton->SetEnabled( enable );
if( mSkipBox ) mSkipBox->SetEnabled( enable );
}