本文整理汇总了C++中BMenuField::SetEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ BMenuField::SetEnabled方法的具体用法?C++ BMenuField::SetEnabled怎么用?C++ BMenuField::SetEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BMenuField
的用法示例。
在下文中一共展示了BMenuField::SetEnabled方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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);
}
示例2: SelectionChanged
void _EndpointList::SelectionChanged()
{
inherited::SelectionChanged();
_EndpointRow* row = dynamic_cast<_EndpointRow*>( CurrentSelection() );
if (row && row->mIsValid) {
row->SelectionSetup(this);
if (mDeviceTarget && !mDeviceTarget->IsEnabled() ) mDeviceTarget->SetEnabled(true);
if (mLabelTarget && !mLabelTarget->IsEnabled() ) mLabelTarget->SetEnabled(true);
} else {
if (mDeviceTarget && mDeviceTarget->IsEnabled() ) mDeviceTarget->SetEnabled(false);
if (mLabelTarget && mLabelTarget->IsEnabled() ) mLabelTarget->SetEnabled(false);
}
}
示例3: ContactFieldTextControl
virtual void Visit(BStringContactField* field)
{
int count = fOwner->fControls.CountItems();
BGridLayout* layout = fOwner->GridLayout();
if (field->FieldType() != B_CONTACT_SIMPLE_GROUP) {
ContactFieldTextControl* control = new ContactFieldTextControl(field);
layout->AddItem(control->CreateLabelLayoutItem(), 1, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, count);
fOwner->fControls.AddItem(control);
} else {
const char* label =
BContactField::ExtendedLabel(field);
fOwner->fGroups = new BPopUpMenu(label);
fOwner->fGroups->SetRadioMode(false);
fOwner->BuildGroupMenu(field);
BMenuField* field = new BMenuField("", "", fOwner->fGroups);
BTextControl* control = new BTextControl("simpleGroup",
NULL, NULL, NULL);
field->SetEnabled(true);
layout->AddItem(field->CreateLabelLayoutItem(), 1, 0, count);
layout->AddItem(field->CreateMenuBarLayoutItem(), 1, 1, count);
layout->AddItem(control->CreateLabelLayoutItem(), 2, 0, count);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, 1, count);
}
}
示例4: BMessage
OpenGLView::OpenGLView()
:
BGroupView("OpenGLView", B_VERTICAL)
{
BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
BGL_RGB | BGL_DOUBLE);
glView->Hide();
AddChild(glView);
glView->LockGL();
BMenu* menu = new BMenu(B_TRANSLATE("Automatic"));
menu->SetRadioMode(true);
menu->SetLabelFromMarked(true);
menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"),
new BMessage(MENU_AUTO_MESSAGE)));
menu->AddSeparatorItem();
menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"),
new BMessage(MENU_SWRAST_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"),
new BMessage(MENU_SWPIPE_MESSAGE)));
menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"),
new BMessage(MENU_SWLLVM_MESSAGE)));
BMenuField* menuField = new BMenuField("renderer",
B_TRANSLATE("3D Rendering Engine:"), menu);
// TODO: Set current Renderer
menuField->SetEnabled(false);
BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
tabView->AddTab(new InfoView());
tabView->AddTab(new CapabilitiesView());
tabView->AddTab(new ExtensionsView());
glView->UnlockGL();
GroupLayout()->SetSpacing(0);
BLayoutBuilder::Group<>(this)
.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
.Add(menuField)
.AddGroup(B_HORIZONTAL)
.Add(tabView)
.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0);
}
示例5: AttributeTextControl
void
PersonView::AddAttribute(const char* label, const char* attribute)
{
// Check if this attribute has already been added.
AttributeTextControl* control = NULL;
for (int32 i = fControls.CountItems() - 1; i >= 0; i--) {
if (fControls.ItemAt(i)->Attribute() == attribute) {
return;
}
}
control = new AttributeTextControl(label, attribute);
fControls.AddItem(control);
BGridLayout* layout = GridLayout();
int32 row = fControls.CountItems();
if (fCategoryAttribute == attribute) {
// Special case the category attribute. The Group popup field will
// be added as the label instead.
fGroups = new BPopUpMenu(label);
fGroups->SetRadioMode(false);
BuildGroupMenu();
BMenuField* field = new BMenuField("", "", fGroups);
field->SetEnabled(true);
layout->AddView(field, 1, row);
control->SetLabel("");
layout->AddView(control, 2, row);
} else {
layout->AddItem(control->CreateLabelLayoutItem(), 1, row);
layout->AddItem(control->CreateTextViewLayoutItem(), 2, row);
}
SetAttribute(attribute, true);
}
示例6: name
//.........这里部分代码省略.........
} else {
r.Set(x - 12, y, windowRect.Width() - SEPARATOR_MARGIN,
y + menuFieldHeight);
string[0] = 0;
}
y += controlHeight;
fTo = new TTextControl(r, string, new BMessage(TO_FIELD), fIncoming,
resending, B_FOLLOW_LEFT_RIGHT);
fTo->SetFilter(mail_to_filter);
if (!fIncoming || resending) {
fTo->SetChoiceList(&fEmailList);
fTo->SetAutoComplete(true);
} else {
fTo->SetDivider(x - 12 - SEPARATOR_MARGIN);
fTo->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
}
AddChild(fTo);
msg = new BMessage(FIELD_CHANGED);
msg->AddInt32("bitmask", FIELD_TO);
fTo->SetModificationMessage(msg);
if (!fIncoming || resending) {
r.right = r.left - 5;
r.left = r.right - ceilf(be_plain_font->StringWidth(
B_TRANSLATE("To:")) + 25);
r.top -= 1;
fToMenu = new QPopupMenu(B_TRANSLATE("To:"));
field = new BMenuField(r, "", "", fToMenu, true,
B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
field->SetDivider(0.0);
field->SetEnabled(true);
AddChild(field);
}
// "From:" accounts Menu and Encoding Menu.
if (!fIncoming || resending) {
// Put the character set box on the right of the From field.
r.Set(windowRect.Width() - widestCharacterSet -
StringWidth(B_TRANSLATE("Encoding:")) - 2 * SEPARATOR_MARGIN,
y - 2, windowRect.Width() - SEPARATOR_MARGIN, y + menuFieldHeight);
BMenuField* encodingField = new BMenuField(r, "encoding",
B_TRANSLATE("Encoding:"), fEncodingMenu, true /* fixedSize */,
B_FOLLOW_TOP | B_FOLLOW_RIGHT,
B_WILL_DRAW | B_NAVIGABLE | B_NAVIGABLE_JUMP);
encodingField->SetDivider(encodingField->StringWidth(
B_TRANSLATE("Encoding:")) + 5);
AddChild(encodingField);
field = encodingField;
// And now the "from account" pop-up menu, on the left side, taking the
// remaining space.
fAccountMenu = new BPopUpMenu(B_EMPTY_STRING);
BMailAccounts accounts;
bool marked = false;
for (int32 i = 0; i < accounts.CountAccounts(); i++) {
BMailAccountSettings* account = accounts.AccountAt(i);
BString name = account->Name();
name << ": " << account->RealName() << " <"
<< account->ReturnAddress() << ">";
示例7: path
//.........这里部分代码省略.........
msg->AddRef("refs", &ref);
BMenuItem* menuitem = menu->FindItem(path.Leaf());
if (menuitem == NULL)
menu->AddItem(menuitem = new BMenuItem(path.Leaf(), msg), 0);
// refresh item
fEventList->SetPath(BPath(&ref).Path());
// check file menu
if (menuitem != NULL)
menuitem->SetMarked(true);
}
break;
}
case M_PLAY_MESSAGE:
{
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
if (row != NULL) {
const char* path = row->Path();
if (path != NULL) {
entry_ref ref;
::get_ref_for_path(path, &ref);
delete fPlayer;
fPlayer = new BFileGameSound(&ref, false);
fPlayer->StartPlaying();
}
}
break;
}
case M_STOP_MESSAGE:
{
if (fPlayer == NULL)
break;
if (fPlayer->IsPlaying()) {
fPlayer->StopPlaying();
delete fPlayer;
fPlayer = NULL;
}
break;
}
case M_EVENT_CHANGED:
{
const char* path;
BMenuField* menufield
= dynamic_cast<BMenuField*>(FindView("filemenu"));
if (menufield == NULL)
return;
BMenu* menu = menufield->Menu();
if (message->FindString("path", &path) == B_OK) {
BPath path(path);
if (path.InitCheck() != B_OK) {
BMenuItem* item = menu->FindItem(B_TRANSLATE("<none>"));
if (item != NULL)
item->SetMarked(true);
} else {
BMenuItem* item = menu->FindItem(path.Leaf());
if (item != NULL)
item->SetMarked(true);
}
HEventRow* row = (HEventRow*)fEventList->CurrentSelection();
BButton* button = dynamic_cast<BButton*>(FindView("play"));
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);
}
}
break;
}
case M_ITEM_MESSAGE:
{
entry_ref ref;
if (message->FindRef("refs", &ref) == B_OK) {
fEventList->SetPath(BPath(&ref).Path());
_UpdateZoomLimits();
}
break;
}
case M_NONE_MESSAGE:
{
fEventList->SetPath(NULL);
break;
}
default:
BWindow::MessageReceived(message);
}
}
示例8: BMessage
NetworkWindow::NetworkWindow()
:
BWindow(BRect(100, 100, 400, 400), B_TRANSLATE("Network"), B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
fServicesItem(NULL),
fDialUpItem(NULL),
fOtherItem(NULL)
{
// Profiles section
#if ENABLE_PROFILES
BPopUpMenu* profilesPopup = new BPopUpMenu("<none>");
_BuildProfilesMenu(profilesPopup, kMsgProfileSelected);
BMenuField* profilesMenuField = new BMenuField("profiles_menu",
B_TRANSLATE("Profile:"), profilesPopup);
profilesMenuField->SetFont(be_bold_font);
profilesMenuField->SetEnabled(false);
#endif
// Settings section
fRevertButton = new BButton("revert", B_TRANSLATE("Revert"),
new BMessage(kMsgRevert));
BMessage* message = new BMessage(kMsgToggleReplicant);
BCheckBox* showReplicantCheckBox = new BCheckBox("showReplicantCheckBox",
B_TRANSLATE("Show network status in Deskbar"), message);
showReplicantCheckBox->SetExplicitMaxSize(
BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
showReplicantCheckBox->SetValue(_IsReplicantInstalled());
fListView = new BOutlineListView("list", B_SINGLE_SELECTION_LIST,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_FRAME_EVENTS | B_NAVIGABLE);
fListView->SetSelectionMessage(new BMessage(kMsgItemSelected));
BScrollView* scrollView = new BScrollView("ScrollView", fListView,
0, false, true);
scrollView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET));
fAddOnShellView = new BView("add-on shell", 0,
new BGroupLayout(B_VERTICAL));
fAddOnShellView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fInterfaceView = new InterfaceView();
// Build the layout
BLayoutBuilder::Group<>(this, B_VERTICAL)
.SetInsets(B_USE_DEFAULT_SPACING)
#if ENABLE_PROFILES
.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
.Add(profilesMenuField)
.AddGlue()
.End()
#endif
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(scrollView)
.Add(fAddOnShellView)
.End()
.Add(showReplicantCheckBox)
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
.Add(fRevertButton)
.AddGlue()
.End();
gNetworkWindow = this;
_ScanInterfaces();
_ScanAddOns();
_UpdateRevertButton();
fListView->Select(0);
_SelectItem(fListView->ItemAt(0));
// Call this manually, so that CenterOnScreen() below already
// knows the final window size.
// Set size of the list view from its contents
float width;
float height;
fListView->GetPreferredSize(&width, &height);
width += 2 * be_control_look->DefaultItemSpacing();
fListView->SetExplicitSize(BSize(width, B_SIZE_UNSET));
fListView->SetExplicitMinSize(BSize(width, std::min(height, 400.f)));
CenterOnScreen();
fSettings.StartMonitoring(this);
start_watching_network(B_WATCH_NETWORK_INTERFACE_CHANGES
| B_WATCH_NETWORK_LINK_CHANGES | B_WATCH_NETWORK_WLAN_CHANGES, this);
}
示例9: update_proxy_settings
void CharismaWindow::update_proxy_settings()
{
const long sroffsets[]={
0,
0,
0,
0,
0,
3600,
3600*6,
3600*12,
0,
3600*24,
3600*24*2,
3600*24*3,
0,
3600*24*7,
3600*24*14,
0,
3600*24*30,
3600*24*30*2,
3600*24*30*6,
0,
3600*24*365,
3600*24*365*2,
0,
3600*24*365*10
};
BMenu *m;
int i;
struct system_info sinfo;
// g_mode
m=modemenu->Menu();
g_mode=m->IndexOf(m->FindMarked());
smartrefresh->SetEnabled(g_mode==k_online);
// g_extcontrol
g_extcontrol=extcontrol_item->IsMarked();
// g_refreshdate
m=smartrefresh->Menu();
i=m->IndexOf(m->FindMarked());
switch(i){
case 0: // dumb
g_refreshdate=0;
break;
case 2: // always
g_refreshdate=LONG_MAX;
break;
case 3: // once per session
get_system_info(&sinfo);
g_refreshdate=sinfo.boot_time/1000000;
break;
case 23: // never
g_refreshdate=-2;
break;
default:
g_refreshdate=-sroffsets[i];
// il faut ajouter time(NULL) à cette valeur !
// (voir proxy.cpp)
break;
}
}
示例10: node
/***********************************************************
* InitGUI
***********************************************************/
void
HAddressView::InitGUI()
{
float divider = StringWidth(_("Subject:")) + 20;
divider = max_c(divider , StringWidth(_("From:"))+20);
divider = max_c(divider , StringWidth(_("To:"))+20);
divider = max_c(divider , StringWidth(_("Bcc:"))+20);
BRect rect = Bounds();
rect.top += 5;
rect.left += 20 + divider;
rect.right = Bounds().right - 5;
rect.bottom = rect.top + 25;
BTextControl *ctrl;
ResourceUtils rutils;
const char* name[] = {"to","subject","from","cc","bcc"};
for(int32 i = 0;i < 5;i++)
{
ctrl = new BTextControl(BRect(rect.left,rect.top
,(i == 1)?rect.right+divider:rect.right
,rect.bottom)
,name[i],"","",NULL
,B_FOLLOW_LEFT_RIGHT|B_FOLLOW_TOP,B_WILL_DRAW|B_NAVIGABLE);
if(i == 1)
{
ctrl->SetLabel(_("Subject:"));
ctrl->SetDivider(divider);
ctrl->MoveBy(-divider,0);
}else{
ctrl->SetDivider(0);
}
BMessage *msg = new BMessage(M_MODIFIED);
msg->AddPointer("pointer",ctrl);
ctrl->SetModificationMessage(msg);
ctrl->SetEnabled(!fReadOnly);
AddChild(ctrl);
rect.OffsetBy(0,25);
switch(i)
{
case 0:
fTo = ctrl;
break;
case 1:
fSubject = ctrl;
break;
case 2:
fFrom = ctrl;
fFrom->SetEnabled(false);
fFrom->SetFlags(fFrom->Flags() & ~B_NAVIGABLE);
break;
case 3:
fCc = ctrl;
break;
case 4:
fBcc = ctrl;
break;
}
}
//
BRect menuRect= Bounds();
menuRect.top += 5;
menuRect.left += 22;
menuRect.bottom = menuRect.top + 25;
menuRect.right = menuRect.left + 16;
BMenu *toMenu = new BMenu(_("To:"));
BMenu *ccMenu = new BMenu(_("Cc:"));
BMenu *bccMenu = new BMenu(_("Bcc:"));
BQuery query;
BVolume volume;
BVolumeRoster().GetBootVolume(&volume);
query.SetVolume(&volume);
query.SetPredicate("((META:email=*)&&(BEOS:TYPE=application/x-person))");
if(!fReadOnly && query.Fetch() == B_OK)
{
BString addr[4],name,group,nick;
entry_ref ref;
BList peopleList;
while(query.GetNextRef(&ref) == B_OK)
{
BNode node(&ref);
if(node.InitCheck() != B_OK)
continue;
ReadNodeAttrString(&node,"META:name",&name);
ReadNodeAttrString(&node,"META:email",&addr[0]);
ReadNodeAttrString(&node,"META:email2",&addr[1]);
ReadNodeAttrString(&node,"META:email3",&addr[2]);
ReadNodeAttrString(&node,"META:email4",&addr[3]);
ReadNodeAttrString(&node,"META:group",&group);
//.........这里部分代码省略.........