本文整理汇总了C++中BAlert::ButtonAt方法的典型用法代码示例。如果您正苦于以下问题:C++ BAlert::ButtonAt方法的具体用法?C++ BAlert::ButtonAt怎么用?C++ BAlert::ButtonAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BAlert
的用法示例。
在下文中一共展示了BAlert::ButtonAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
filter_result
_BAlertFilter_::Filter(BMessage* msg, BHandler** target)
{
if (msg->what == B_KEY_DOWN) {
char byte;
if (msg->FindInt8("byte", (int8*)&byte) == B_OK) {
for (int i = 0; i < 3; ++i) {
if (byte == fAlert->Shortcut(i) && fAlert->ButtonAt(i)) {
char space = ' ';
fAlert->ButtonAt(i)->KeyDown(&space, 1);
return B_SKIP_MESSAGE;
}
}
}
}
return B_DISPATCH_MESSAGE;
}
示例2: QuitRequested
/*
* bool QuitRequested();
*
* B_QUIT_REQUESTED was send. Tell the BApplication that we want out...
*/
bool BLSettingsWindow::QuitRequested()
{
bool modified = Settings->HasBeenModified();
if(modified == true)
{
BAlert* alert = new BAlert("Save changes", "Do you want to save your changes?", "Cancel", "Don't save", "Save", B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_INFO_ALERT);
alert->SetShortcut(0, B_ESCAPE);
alert->ButtonAt(2)->MakeDefault(true);
int32 index = alert->Go();
switch(index)
{
/* Cancel */
case 0:
{
return false;
}
/* Don't save */
case 1:
{
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
/* Save */
case 2:
{
Settings->Save();
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
}
}
be_app->PostMessage(B_QUIT_REQUESTED);
return true;
}
示例3: BAlert
void
AlertTestWindow::Test()
{
BAlert *pAlert = new BAlert(
"alert1",
k60X,
k20X, "OK", "Cancel",
B_WIDTH_AS_USUAL, // widthStyle
B_OFFSET_SPACING,
B_EMPTY_ALERT // alert_type
);
if (fAlertType == 'H') {
BView *master = pAlert->ChildAt(0);
master->SetViewColor(ui_color(B_MENU_BACKGROUND_COLOR));
}
BPoint pt;
BString strLabel;
BButton *pBtns[3] = { NULL };
pBtns[0] = pAlert->ButtonAt(0);
pBtns[1] = pAlert->ButtonAt(1);
pBtns[2] = pAlert->ButtonAt(2);
BTextView *pTextView = pAlert->TextView();
// Window info
printf("wi.width = %.1ff;\n"
"wi.height = %.1ff;\n"
"ati.SetWinInfo(wi);\n",
pAlert->Bounds().Width(), pAlert->Bounds().Height());
// TextView info
printf("\n");
which_label(pTextView->Text(), strLabel);
pt = pTextView->ConvertToParent(BPoint(0, 0));
printf("ti.label = %s;\n"
"ti.width = %.1ff;\n"
"ti.height = %.1ff;\n"
"ti.topleft.Set(%.1ff, %.1ff);\n"
"ati.SetTextViewInfo(ti);\n",
strLabel.String(), pTextView->Bounds().Width(),
pTextView->Bounds().Height(), pt.x, pt.y);
// Button info
printf("\n");
int32 i = 0;
while (i < 3 && pBtns[i] != NULL) {
BButton *pb = pBtns[i];
which_label(pb->Label(), strLabel);
pt = pb->ConvertToParent(BPoint(0, 0));
printf("bi.label = %s;\n"
"bi.width = %.1ff;\n"
"bi.height = %.1ff;\n"
"bi.topleft.Set(%.1ff, %.1ff);\n"
"ati.SetButtonInfo(%d, bi);\n",
strLabel.String(), pb->Bounds().Width(),
pb->Bounds().Height(), pt.x, pt.y,
(int)i);
i++;
}
int32 result = pAlert->Go();
printf("%c<Clicked: %d\n", fAlertType, static_cast<int>(result));
pAlert = NULL;
}