本文整理汇总了C++中BTextControl::SetMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ BTextControl::SetMessage方法的具体用法?C++ BTextControl::SetMessage怎么用?C++ BTextControl::SetMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BTextControl
的用法示例。
在下文中一共展示了BTextControl::SetMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChildAt
void
AccountView::AttachedToWindow()
{
// Once we are attached to window, the GUI is already created
// so we can set our window as target for messages
for (int32 i = 0; i < CountChildren(); i++) {
BView* child = ChildAt(i);
BMenu* menu = dynamic_cast<BMenu*>(child);
BMenuField* menuField
= dynamic_cast<BMenuField*>(child);
BTextControl* textControl
= dynamic_cast<BTextControl*>(child);
NotifyingTextView* textView
= dynamic_cast<NotifyingTextView*>(child);
BCheckBox* checkBox = dynamic_cast<BCheckBox*>(child);
if (menuField)
menu = menuField->Menu();
if (menu) {
for (int32 j = 0; j < menu->CountItems(); j++) {
BMenuItem* item = menu->ItemAt(j);
item->SetMessage(new BMessage(kChanged));
item->SetTarget(Window());
}
menu->SetTargetForItems(Window());
}
if (textControl) {
textControl->SetMessage(new BMessage(kChanged));
textControl->SetTarget(Window());
}
if (checkBox) {
checkBox->SetMessage(new BMessage(kChanged));
checkBox->SetTarget(Window());
}
if (textView) {
textView->SetMessage(new BMessage(kChanged));
textView->SetTarget(Window());
}
}
}
示例2: ValueChanged
void MessageView::ValueChanged(void)
{
char *name;
uint32 type;
int32 count;
#ifdef B_ZETA_VERSION_1_0_0
for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(const char **) &name, &type, &count) == B_OK; i++)
#else
for (int32 i = 0; configMessage->GetInfo(B_ANY_TYPE, i,(char **) &name, &type, &count) == B_OK; i++)
#endif
{
//calculate the Position where to add the next View
float top = ItemTop();
BRect rect = BRect(MARGIN_SPACE,top,Bounds().right-MARGIN_SPACE,top);
switch(type)
{
case B_STRING_TYPE:
{
char *string;
configMessage->FindString(name,count-1,(const char **)&string);
BTextControl *stringItem = new BTextControl(rect,name,name,string,NULL);
AddChild(stringItem);
BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED);
tmpMessage->AddString("name",name);
tmpMessage->AddInt32("count",count-1);
tmpMessage->AddInt32("type",type);
stringItem->SetMessage(tmpMessage);
break;
}
case B_RECT_TYPE:
{
BRect valueRect;
configMessage->FindRect(name,count-1,&valueRect);
RectItem *rectItem = new RectItem(rect,name,valueRect);
AddChild(rectItem);
BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED);
tmpMessage->AddString("name",name);
tmpMessage->AddInt32("count",count-1);
tmpMessage->AddInt32("type",type);
rectItem->SetMessage(tmpMessage);
break;
}
case B_FLOAT_TYPE:
{
float value;
configMessage->FindFloat(name,count-1,&value);
BString floatString;
floatString<<value;
BTextControl *stringItem = new BTextControl(rect,name,name,floatString.String(),NULL);
AddChild(stringItem);
BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED);
tmpMessage->AddString("name",name);
tmpMessage->AddInt32("count",count-1);
tmpMessage->AddInt32("type",type);
stringItem->SetMessage(tmpMessage);
break;
}
case B_INT8_TYPE:
case B_INT16_TYPE:
case B_INT32_TYPE:
{
int32 value;
configMessage->FindInt32(name,count-1,&value);
BString intString;
intString<<value;
BTextControl *stringItem = new BTextControl(rect,name,name,intString.String(),NULL);
AddChild(stringItem);
BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED);
tmpMessage->AddString("name",name);
tmpMessage->AddInt32("count",count-1);
tmpMessage->AddInt32("type",type);
stringItem->SetMessage(tmpMessage);
break;
}
case B_BOOL_TYPE:
{
bool value;
configMessage->FindBool(name,count-1,&value);
BCheckBox *boolItem = new BCheckBox(rect,name,name,NULL);
AddChild(boolItem);
boolItem->SetValue(value);
BMessage *tmpMessage = new BMessage(B_CONTROL_INVOKED);
tmpMessage->AddString("name",name);
tmpMessage->AddInt32("count",count-1);
tmpMessage->AddInt32("type",type);
boolItem->SetMessage(tmpMessage);
break;
}
}
}
}