本文整理汇总了C++中AddChild函数的典型用法代码示例。如果您正苦于以下问题:C++ AddChild函数的具体用法?C++ AddChild怎么用?C++ AddChild使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddChild函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: r
/**
* _ConstructGUI()
*
* Creates the GUI for the View. MUST be called AFTER the View is attached to
* the Window, or will crash and/or create strange behaviour
*
* @param none
* @return void
*/
void
MarginView::_ConstructGUI()
{
BString str;
// Create text fields
BRect r(Frame().Width() - be_plain_font->StringWidth("Top#") - kWidth,
kOffsetY, Frame().Width() - kOffsetX, kWidth);
// top
str << fMargins.top/fUnitValue;
fTop = new BTextControl( r, "top", "Top:", str.String(), NULL,
B_FOLLOW_RIGHT);
fTop->SetModificationMessage(new BMessage(TOP_MARGIN_CHANGED));
fTop->SetDivider(be_plain_font->StringWidth("Top#"));
fTop->SetTarget(this);
_AllowOnlyNumbers(fTop, kNumCount);
AddChild(fTop);
//left
r.OffsetBy(0, kOffsetY);
r.left = Frame().Width() - be_plain_font->StringWidth("Left#") - kWidth;
str = "";
str << fMargins.left/fUnitValue;
fLeft = new BTextControl( r, "left", "Left:", str.String(), NULL,
B_FOLLOW_RIGHT);
fLeft->SetModificationMessage(new BMessage(LEFT_MARGIN_CHANGED));
fLeft->SetDivider(be_plain_font->StringWidth("Left#"));
fLeft->SetTarget(this);
_AllowOnlyNumbers(fLeft, kNumCount);
AddChild(fLeft);
//bottom
r.OffsetBy(0, kOffsetY);
r.left = Frame().Width() - be_plain_font->StringWidth("Bottom#") - kWidth;
str = "";
str << fMargins.bottom/fUnitValue;
fBottom = new BTextControl( r, "bottom", "Bottom:", str.String(), NULL,
B_FOLLOW_RIGHT);
fBottom->SetModificationMessage(new BMessage(BOTTOM_MARGIN_CHANGED));
fBottom->SetDivider(be_plain_font->StringWidth("Bottom#"));
fBottom->SetTarget(this);
_AllowOnlyNumbers(fBottom, kNumCount);
AddChild(fBottom);
//right
r.OffsetBy(0, kOffsetY);
r.left = Frame().Width() - be_plain_font->StringWidth("Right#") - kWidth;
str = "";
str << fMargins.right/fUnitValue;
fRight = new BTextControl( r, "right", "Right:", str.String(), NULL,
B_FOLLOW_RIGHT);
fRight->SetModificationMessage(new BMessage(RIGHT_MARGIN_CHANGED));
fRight->SetDivider(be_plain_font->StringWidth("Right#"));
fRight->SetTarget(this);
_AllowOnlyNumbers(fRight, kNumCount);
AddChild(fRight);
// Create Units popup
r.OffsetBy(-kOffsetX, kOffsetY);
r.right += kOffsetY;
BPopUpMenu *menu = new BPopUpMenu("units");
BMenuField *mf = new BMenuField(r, "units", "Units", menu,
B_FOLLOW_BOTTOM | B_FOLLOW_RIGHT);
mf->ResizeToPreferred();
mf->SetDivider(be_plain_font->StringWidth("Units#"));
BMenuItem *item;
// Construct menu items
for (int32 i = 0; kUnitNames[i] != NULL; i++) {
BMessage *msg = new BMessage(MARGIN_UNIT_CHANGED);
msg->AddInt32("marginUnit", kUnitMsg[i]);
menu->AddItem(item = new BMenuItem(kUnitNames[i], msg));
item->SetTarget(this);
if (fMarginUnit == kUnitMsg[i])
//.........这里部分代码省略.........
示例2: AddChild
void Node::AddChild(Node* const child, int zOrder)
{
AddChild(child);
child->SetZorder(zOrder);
}
示例3: BWindow
SettingsWindow::SettingsWindow(BRect frame): BWindow(frame, "Settings",
B_FLOATING_WINDOW_LOOK,B_FLOATING_SUBSET_WINDOW_FEEL,
B_ASYNCHRONOUS_CONTROLS|B_NOT_ZOOMABLE|B_NOT_RESIZABLE)
{
view = new BView(Bounds(), "Settings View", B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
BRect the_rect = Bounds();
the_rect.InsetBy(5.0f, 5.0f);
float rectHOffset = frame.Width() / 2.0f - 2.0f;
float rectVOffset = 18.0f;
char buffer[10];
the_rect.right = the_rect.left + rectHOffset;
the_rect.bottom = the_rect.top + rectVOffset;
gState->Register(this);
if (gState->LockAsReader())
{
sprintf(buffer,FLOAT_FORMAT, ixMin);
XMinBox = new BTextControl( the_rect, "xMin", "x-Min", buffer, new BMessage(XMIN_CHG));
XMinBox->SetTarget(this);
XMinBox->SetDivider(30);
view->AddChild(XMinBox);
the_rect.OffsetBy(rectHOffset + 4,0);
sprintf(buffer,FLOAT_FORMAT, ixMax);
XMaxBox = new BTextControl( the_rect, "xMax", "x-Max", buffer, new BMessage(XMAX_CHG));
XMaxBox->SetTarget(this);
XMaxBox->SetDivider(30);
view->AddChild(XMaxBox);
the_rect.OffsetBy(-(rectHOffset + 4.0f), XMinBox->Bounds().Height() + 4.0f);
sprintf(buffer,FLOAT_FORMAT, iyMin);
YMinBox = new BTextControl( the_rect, "yMin", "y-Min", buffer, new BMessage(YMIN_CHG));
YMinBox->SetTarget(this);
YMinBox->SetDivider(30);
view->AddChild(YMinBox);
the_rect.OffsetBy(rectHOffset + 4.0f, 0.0f);
sprintf(buffer,FLOAT_FORMAT, iyMax);
YMaxBox = new BTextControl( the_rect, "yMax", "y-Max", buffer, new BMessage(YMAX_CHG));
YMaxBox->SetTarget(this);
YMaxBox->SetDivider(30);
view->AddChild(YMaxBox);
the_rect.OffsetBy(-(rectHOffset + 4.0f), YMaxBox->Bounds().Height()+4.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellxStep());
XStepBox = new BTextControl(the_rect,"x step", "x step", buffer, new BMessage(XSTEP_CHG));
XStepBox->SetDivider(35);
XStepBox->SetTarget(this);
// XStepBox->ResizeToPreferred();
view->AddChild(XStepBox);
the_rect.OffsetBy(rectHOffset +4.0f,0.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellyStep());
YStepBox = new BTextControl(the_rect,"y step", "y step", buffer, new BMessage(YSTEP_CHG));
YStepBox->SetDivider(35);
YStepBox->SetTarget(this);
// YStepBox->ResizeToPreferred();
view->AddChild(YStepBox);
the_rect.OffsetBy(-(rectHOffset+4.0f),XStepBox->Bounds().Height()+4.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStep());
ThetaStepBox = new BTextControl(the_rect,"theta step", "theta step", buffer, new BMessage(THETA_STEP_CHG));
ThetaStepBox->SetDivider(50);
ThetaStepBox->SetTarget(this);
// ThetaStepBox->ResizeToPreferred();
view->AddChild(ThetaStepBox);
the_rect.OffsetBy(0,ThetaStepBox->Bounds().Height()+4.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStart());
ThetaStartBox = new BTextControl(the_rect,"theta start", "theta start", buffer, new BMessage(THETA_START_CHG));
ThetaStartBox->SetDivider(53);
ThetaStartBox->SetTarget(this);
// ThetaStartBox->ResizeToPreferred();
view->AddChild(ThetaStartBox);
the_rect.OffsetBy(rectHOffset+4.0f,0.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellThetaStop());
ThetaStopBox = new BTextControl(the_rect,"theta stop", "theta stop", buffer, new BMessage(THETA_STOP_CHG));
ThetaStopBox->SetDivider(50);
ThetaStopBox->SetTarget(this);
// ThetaStopBox->ResizeToPreferred();
view->AddChild(ThetaStopBox);
the_rect.OffsetBy(-(rectHOffset+4.0f),ThetaStartBox->Bounds().Height()+4.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellTStep());
TStepBox = new BTextControl(the_rect,"t step", "t step", buffer, new BMessage(T_STEP_CHG));
TStepBox->SetDivider(35);
TStepBox->SetTarget(this);
// TStepBox->ResizeToPreferred();
view->AddChild(TStepBox);
the_rect.OffsetBy(0,TStepBox->Bounds().Height()+4.0f);
sprintf(buffer,FLOAT_FORMAT, gState->TellTStart());
TStartBox = new BTextControl(the_rect,"t start", "t start", buffer, new BMessage(T_START_CHG));
TStartBox->SetDivider(35);
TStartBox->SetTarget(this);
// TStartBox->ResizeToPreferred();
//.........这里部分代码省略.........
示例4: rect
void
RowSummaryView::AllAttached()
{
//Bitmaps used to hold the pictures for the Primay key picture button
BRect rect(0,0,13,11);
PrefilledBitmap firstRowOffBitmap(rect, B_COLOR_8_BIT, FirstRowOffRaw, 1344);
PrefilledBitmap firstRowOnBitmap(rect, B_COLOR_8_BIT, FirstRowOnRaw, 1344);
PrefilledBitmap previousRowOffBitmap(rect, B_COLOR_8_BIT, PreviousRowOffRaw, 1344);
PrefilledBitmap previousRowOnBitmap(rect, B_COLOR_8_BIT, PreviousRowOnRaw, 1344);
PrefilledBitmap nextRowOffBitmap(rect, B_COLOR_8_BIT, NextRowOffRaw, 1344);
PrefilledBitmap nextRowOnBitmap(rect, B_COLOR_8_BIT, NextRowOnRaw, 1344);
PrefilledBitmap lastRowOffBitmap(rect, B_COLOR_8_BIT, LastRowOffRaw, 1344);
PrefilledBitmap lastRowOnBitmap(rect, B_COLOR_8_BIT, LastRowOnRaw, 1344);
PrefilledBitmap newRowOffBitmap(rect, B_COLOR_8_BIT, NewRowOffRaw, 1344);
PrefilledBitmap newRowOnBitmap(rect, B_COLOR_8_BIT, NewRowOnRaw, 1344);
PrefilledBitmap previousRowOffDisabledBitmap(rect, B_COLOR_8_BIT, PreviousRowOffDisabledRaw, 1344);
PrefilledBitmap nextRowOffDisabledBitmap(rect, B_COLOR_8_BIT, NextRowOffDisabledRaw, 1344);
PrefilledBitmap newRowOffDisabledBitmap(rect, B_COLOR_8_BIT, NewRowOffDisabledRaw, 1344);
//TempView used to create BPictures
BView *tempView = new BView(rect, "temp", B_FOLLOW_NONE, B_WILL_DRAW);
AddChild(tempView);
//Record BPictures for Off bitmaps
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&firstRowOnBitmap);
BPicture* firstRowPictureOn = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&previousRowOffBitmap);
BPicture* previousRowPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&nextRowOffBitmap);
BPicture* nextRowPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&lastRowOffBitmap);
BPicture* lastRowPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&newRowOffBitmap);
BPicture* newRowPictureOff = tempView->EndPicture();
//Record BPicture for DisabledOff bitmaps
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&previousRowOffDisabledBitmap);
BPicture* previousRowDisabledPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&nextRowOffDisabledBitmap);
BPicture* nextRowDisabledPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&newRowOffDisabledBitmap);
BPicture* newRowDisabledPictureOff = tempView->EndPicture();
//Record BPictures for On bitmaps
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&firstRowOffBitmap);
BPicture* firstRowPictureOff = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&previousRowOnBitmap);
BPicture* previousRowPictureOn = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&nextRowOnBitmap);
BPicture* nextRowPictureOn = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&lastRowOnBitmap);
BPicture* lastRowPictureOn = tempView->EndPicture();
tempView->BeginPicture(new BPicture);
tempView->DrawBitmap(&newRowOnBitmap);
BPicture* newRowPictureOn = tempView->EndPicture();
RemoveChild(tempView);
delete tempView;
// First Row Button
BMessage* homeMsg = new BMessage(GRID_GOTO_ROW_MSG);
homeMsg->AddInt32("rowNumber", int32(0));
fFirstRowButton = new BPictureButton(BRect(48,1,61,12), "homeButton", firstRowPictureOff,
firstRowPictureOn, homeMsg);
// Previous Row Button
BMessage* prevMsg = new BMessage(GRID_GOTO_PREV_ROW_MSG);
fPreviousRowButton = new BPictureButton(BRect(63,1,76,12), "previousButton",
previousRowPictureOff, previousRowPictureOn, prevMsg);
fPreviousRowButton->SetDisabledOff(previousRowDisabledPictureOff);
//.........这里部分代码省略.........
示例5: String
EditWin::EditWin(const Rect & r, const String& name, Message *pcMsg, Looper *pcParent, const String& id)
:Window(r, "EditWin", String().Format("%s - %s", name.c_str(),ID_SETTINGS_EDITOR_WINDOW.c_str()), 0, CURRENT_DESKTOP)
{
Rect bounds = GetBounds();
m_pcMessage = pcMsg;
m_cName = name;
m_cID = id;
m_nIDCtr = 0;
m_pcMessenger = new Messenger(pcParent, pcParent);
int nCount;
pcMsg->GetNameInfo(name.c_str(), &m_nType, &nCount);
// --- Root layout node ---------------------------------------------------------
LayoutNode* pcRoot = new VLayoutNode("pcRoot");
// --- ListView -----------------------------------------------------------------
m_pcItems = new ListView(Rect(), "m_pcListView", ListView::F_NO_AUTO_SORT|ListView::F_RENDER_BORDER);
m_pcItems->InsertColumn(ID_LISTVIEW_INDEX.c_str(), 50);
m_pcItems->InsertColumn(ID_LISTVIEW_VALUE.c_str(), 250);
for(int i = 0; i < nCount; i++) {
ListViewStringRow *lvs = new ListViewStringRow;
char bfr[16];
sprintf(bfr, "%d", i);
lvs->AppendString(bfr);
lvs->AppendString(MsgDataToText(name, i, pcMsg));
sprintf(bfr, "%d", ++m_nIDCtr);
lvs->AppendString(bfr);
m_pcItems->InsertRow(lvs);
}
m_pcItems->SetInvokeMsg(new Message(ID_EDIT_ITEM));
pcRoot->AddChild(m_pcItems);
// --- Buttons ------------------------------------------------------------------
pcRoot->AddChild(new VLayoutSpacer("ButtonTopSpacer", 8, 8));
LayoutNode *pcButtons = new HLayoutNode("pcButtons", 0.0f);
pcButtons->AddChild(new HLayoutSpacer("ButtonLeftSpacer", 8, 8));
pcButtons->AddChild(new Button(Rect(), "pcAdd", ID_BUTTON_PLUS, new Message(ID_EDIT_ADD)));
pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 8, 8));
pcButtons->AddChild(new Button(Rect(), "pcRem", ID_BUTTON_MINUS, new Message(ID_EDIT_DELETE)));
pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 0, COORD_MAX));
pcButtons->AddChild(new Button(Rect(), "pcSave", ID_BUTTON_SAVE, new Message(ID_EDIT_SAVE)));
pcButtons->AddChild(new HLayoutSpacer("ButtonIntermediateSpacer", 8, 8));
pcButtons->AddChild(new Button(Rect(), "pcCancel", ID_BUTTON_CLOSE, new Message(ID_EDIT_CANCEL)));
pcButtons->AddChild(new HLayoutSpacer("ButtonRightSpacer", 8, 8));
pcButtons->SameWidth("pcSave", "pcCancel", NULL);
pcButtons->SameWidth("pcRem", "pcAdd", NULL);
pcRoot->AddChild(pcButtons);
pcRoot->AddChild(new VLayoutSpacer("ButtonBottomSpacer", 8, 8));
AddChild(new LayoutView(bounds, "pcLayout", pcRoot));
}
示例6: AddChild
void Ctrl::AddChild(Ctrl *child)
{
AddChild(child, lastchild);
}
示例7: Bounds
//------------------------------------------------------------------------------
void WindowEditor::InitFlagsBoxes()
{
BRect work = Bounds();
work.left = 10;
work.top = 100;
work.bottom -= 5;
work.right -= 10;
work.right -= 10;
int i = 20;
int inc = 10;
BBox* box = new BBox(work, "flags");
BCheckBox* cbox;
BMessage* msg;
box->SetLabel("Window Flags");
uint32 flags = fWindowInfo.flags;
bool longLabel;
for (int index = 0; WindowFlags[index].name; ++index)
{
longLabel = strlen(WindowFlags[index].label) > 20;
// First column of checkboxes
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags", WindowFlags[index].flag);
cbox = new BCheckBox(BRect(10, i, longLabel ? 210 : 125, i + inc),
WindowFlags[index].name, WindowFlags[index].label, msg);
fFlagBoxes.push_back(cbox);
box->AddChild(cbox);
if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
{
cbox->SetValue(B_CONTROL_ON);
}
// We skip to the next row as needed to make room for long labels
if (!longLabel && WindowFlags[index + 1].name)
{
++index;
// Second column of checkboxes
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags", WindowFlags[index].flag);
cbox = new BCheckBox(BRect(130, i, 210, i + inc),
WindowFlags[index].name,
WindowFlags[index].label,
msg);
fFlagBoxes.push_back(cbox);
box->AddChild(cbox);
if (WindowFlags[index].flip == (flags & WindowFlags[index].flag))
{
cbox->SetValue(B_CONTROL_ON);
}
}
i += inc * 2;
}
#if 0
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_MOVABLE);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"nmov","Movable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_CLOSABLE);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"clos","Closable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_ZOOMABLE);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"zoom","Zoomable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_NOT_MINIMIZABLE);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"mini","Minimizable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_H_RESIZABLE);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"hres","Horizontally Resizable",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NOT_V_RESIZABLE);
box->AddChild(new BCheckBox(BRect(10,i,125,i+inc),"vres","Vertically Resizable",msg));
menubox = new BCheckBox(BRect(130,i,210,i+inc),"menus","Menu Bar",new BMessage(MSG_WINDOW_ADD_MENU));
box->AddChild(menubox);
if (fWindowInfo.has_menu)
menubox->SetValue(B_CONTROL_ON);
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_OUTLINE_RESIZE);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"roiw","Resize with Outline Instead of Window",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_WILL_ACCEPT_FIRST_CLICK);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"wafc","Will Accept First Click",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_AVOID_FRONT);
box->AddChild(new BCheckBox(BRect(10,i,120,i+inc),"avfr","Avoid Front",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
msg->AddInt32("flags",B_AVOID_FOCUS);
box->AddChild(new BCheckBox(BRect(130,i,210,i+inc),"avfo","Avoid Focus",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
i+= inc*2;
msg->AddInt32("flags",B_NO_WORKSPACE_ACTIVATION);
box->AddChild(new BCheckBox(BRect(10,i,210,i+inc),"nwoa","Do Not Activate Workspace",msg));
msg = new BMessage(MSG_WINDOW_SET_FLAG);
//.........这里部分代码省略.........
示例8: BWindow
CharismaWindow::CharismaWindow(BPoint origin):
BWindow(BRect(origin.x,origin.y,origin.x+200,origin.y+80),
"Charisma", B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE|B_NOT_ZOOMABLE|B_WILL_ACCEPT_FIRST_CLICK)
{
BRect nullrect(0,0,0,0),r;
BMenu *m;
BWindow *w;
char buf[100];
isminim=0;
// le menu
menubar=new BMenuBar(BRect(0,0,0,0),"menu bar");
m=new BMenu("File");
m->AddItem(new BMenuItem("About…",new BMessage(kMsg_About)));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED),'Q'));
menubar->AddItem(m);
m=new BMenu("Settings");
m->AddItem(new BMenuItem("Select Web Directory…",new BMessage(kMsg_SelectDirectory)));
m->AddSeparatorItem();
m->AddItem(extcontrol_item=new BMenuItem("External Control",new BMessage(kMsg_ExternalControl)));
m->AddItem(netposautoset_item=new BMenuItem("Net+ Autosettings",new BMessage(kMsg_NetposAutosettings)));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("Clear Hits",new BMessage(kMsg_ClearHits)));
menubar->AddItem(m);
AddChild(menubar);
// le fond gris
r=Frame();
setupview=new BView(
BRect(0,menubar->Frame().bottom,r.Width(),r.Height()),
"background",B_FOLLOW_NONE,B_WILL_DRAW);
setupview->SetViewColor(0xDD,0xDD,0xDD);
AddChild(setupview);
// "Mode"
m=new BPopUpMenu("");
m->AddItem(new BMenuItem("Disabled",MSG));
m->AddItem(new BMenuItem("Offline",MSG));
m->AddItem(new BMenuItem("Online",MSG));
modemenu=new BMenuField(
BRect(10.0f,10.0f,20.0f,20.0f),"mode",
"Mode:",
m);
BMenuField_resize(modemenu);
setupview->AddChild(modemenu);
// "Refresh"
m=new BPopUpMenu("");
m->AddItem(new BMenuItem("Dumb",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("Always",MSG));
m->AddItem(new BMenuItem("Once per session",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("After 1 hour",MSG));
m->AddItem(new BMenuItem("After 6 hours",MSG));
m->AddItem(new BMenuItem("After 12 hours",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("After 1 day",MSG));
m->AddItem(new BMenuItem("After 2 days",MSG));
m->AddItem(new BMenuItem("After 3 days",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("After 1 week",MSG));
m->AddItem(new BMenuItem("After 2 weeks",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("After 1 month",MSG));
m->AddItem(new BMenuItem("After 2 month",MSG));
m->AddItem(new BMenuItem("After 6 month",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("After 1 year",MSG));
m->AddItem(new BMenuItem("After 2 years",MSG));
m->AddSeparatorItem();
m->AddItem(new BMenuItem("never",MSG));
smartrefresh=new BMenuField(
rectunder(modemenu),"refresh",
"Refresh:",
m);
BMenuField_resize(smartrefresh);
setupview->AddChild(smartrefresh);
// "Hits"
r.left=10.0f;
r.top=smartrefresh->Frame().bottom+10.0f;
r.right=r.left+setupview->StringWidth("hits: 99999");
r.bottom=r.top+BView_textheight(setupview);
hits=new BStringView(r,"hits","");
setupview->AddChild(hits);
if(!gregistered){
sprintf(buf,"This copy is not registered");
r.left=10.0f;
r.top=hits->Frame().bottom+10.0f;
r.right=r.left+setupview->StringWidth(buf);
r.bottom=r.top+BView_textheight(setupview);
setupview->AddChild(new BStringView(r,NULL,buf));
}
r=BView_childrenframe(setupview);
//.........这里部分代码省略.........
示例9: switch
void Slider::KeyDown (const char *bytes, int32 numBytes)
{
if (numBytes == 1)
{
switch (*bytes)
{
case B_ESCAPE:
{
if (tc)
{
// printf ("TextControl is open\n");
RemoveChild (tc);
delete (tc);
tc = NULL;
}
break;
}
case B_SPACE:
case B_ENTER:
{
//printf ("Enter\n");
if (tc)
{
// printf ("TextControl is open\n");
BMessage *key = new BMessage ('tcVC');
MessageReceived (key);
delete key;
}
else
{
knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
BRect kbr = BRect (knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3);
// kbr.PrintToStream();
tc = new BTextControl (kbr, "slider value field", "", "", new BMessage ('tcVC'));
tc->SetTarget (this);
tc->SetDivider (0);
EnterFilter *filter = new EnterFilter (this);
tc->TextView()->AddFilter (filter);
char vs[64];
sprintf (vs, fmt, value);
tc->SetText (vs);
AddChild (tc);
tc->MakeFocus (true);
inherited::KeyDown (bytes, numBytes);
}
break;
}
case B_LEFT_ARROW:
//printf ("Left\n");
if (value > min)
{
value -= step;
Invalidate();
NotifyTarget();
}
break;
case B_RIGHT_ARROW:
//printf ("Right\n");
if (value < max)
{
value += step;
Invalidate();
NotifyTarget();
}
break;
case B_TAB:
// printf ("Tab\n");
if (tc)
{
// printf ("TextControl is open\n");
BMessage *key = new BMessage ('tcVC');
MessageReceived (key);
delete key;
}
else
{
// MakeFocus (false);
inherited::KeyDown (bytes, numBytes);
Invalidate();
break;
}
default:
inherited::KeyDown (bytes, numBytes);
}
}
else
inherited::KeyDown (bytes, numBytes);
}
示例10: strncpy
//=======================================================================================
// CFuiTBROS Terra Browser
//=======================================================================================
CFuiTBROS::CFuiTBROS(Tag idn, const char *filename)
:CFuiWindow(idn,filename,600,360,0)
{ strncpy(text,"TERRA BROWSER",255);
//-------------------------------------------------
state = 0;
sel = 0;
chng = 0;
Type = -1;
inf.mADR = 0;
inf.xOBJ = 0;
inf.res = TX_HIGHTR;
obtn = 0;
abtn = 0;
lock = 1;
//----Create a label title ----------------------
CFuiLabel *lab1 = new CFuiLabel(20,10,280, 20,this);
lab1->SetText("TYPE OF TERRAIN TEXTURES");
AddChild('lbl1',lab1);
//----Create the List box -----------------------
xWIN = new CFuiList (20,30,270,256,this);
xWIN->SetVScroll();
AddChild('xlst',xWIN);
//----Create a Canvas ---------------------------
xCNV = new CFuiCanva(320,30,256,256,this);
AddChild('xcnv',xCNV);
xCNV->EraseCanvas();
//----Create Canvas Title -----------------------
wLB1 = new CFuiLabel(320,10,256,20,this);
AddChild('wlb1',wLB1);
//----Create RadioButton ------------------------
wLOK = new CFuiCheckbox(20, 300,420,16,this);
AddChild('wlok',wLOK,OptTXT[lock]);
wLOK->SetState(lock);
//----Create the button -------------------------
wBT1 = new CFuiButton(420, 300, 140,20,this);
AddChild('wbt1',wBT1,"Assign selected Texture");
//----Create Cancel button ----------------------
zBTN = new CFuiButton(420, 326, 140,20,this);
AddChild('zbtn',zBTN,"CANCEL");
//--- Create group edit -------------------------
BuildGroupEdit(10,320);
//----Create surface ----------------------------
CFuiWindow::ReadFinished();
aBOX = globals->tcm->GetTerraBox();
aBOX->SetParameters(this,'xlst',LIST_DONT_FREE);
//---Get a camera to draw texture ---------------
Cam = new CCameraSpot();
//-----------------------------------------------
tFIL = globals->tcm->GetTerraFile();
//-----------------------------------------------
aBOX->SortAndDisplay();
int tex = globals->tcm->GetGroundType();
aBOX->GoToKey(&tex);
GetSelection();
//--- Set application profile -------------------
ctx.prof = TBROS_PROF;
ctx.mode = SLEW_RCAM;
rcam = globals->ccm->SetRabbitCamera(ctx,RABBIT_S_AND_C);
}
示例11: BPoint
//.........这里部分代码省略.........
{
while (system_time() - start < dcspeed)
{
snooze (20000);
GetMouse (&bp, &bt, true);
if (!bt && click != 2)
{
click = 0;
}
if (bt && !click)
{
click = 2;
}
if (bp != pbp)
break;
}
}
if (click != 2)
{
// Now we're dragging...
while (buttons)
{
BPoint p = BPoint (point.x - sep, point.y);
float x = p.x;
if (!(knob.Contains (p)) && !dragging)
{
if (x > knob.left)
{
value += step * (x - knob.right)/10;
}
else
{
value += step * (x - knob.left)/10;
}
if (value < min)
value = min;
if (value > max)
value = max;
if (step > 1 && fmod (value - min, step)) // Hack hack!
value = int ((value - min)/step)*step + min;
// if (fmt[strlen (fmt) - 2] == '0')
// value = int (value + 0.5);
offslid->Lock();
Invalidate (BRect (sep + 1, 0, offslid->Bounds().Width() + sep, height));
offslid->Unlock();
NotifyTarget();
}
else if (px != p.x && step <= 1) // Hacks galore!
{
dragging = true;
value = (x - knobsize/2) / (width - knobsize) * (max - min) + min;
//printf ("x = %f, knobsize = %f, value = %f\n", x, knobsize, value);
//printf ("Value: %f ", value);
if (value < min)
value = min;
if (value > max)
value = max;
if (step > 1 && fmod (value - min, step))
value = int ((value - min)/step)*step + min;
if (fmt[strlen (fmt) - 2] == '0')
value = int (value + 0.5);
//printf ("-> %f\n", value);
offslid->Lock();
Invalidate (BRect (sep + 1, 0, offslid->Bounds().Width() + sep, height));
offslid->Unlock();
px = p.x;
NotifyTarget();
}
knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2);
snooze (20000);
GetMouse (&point, &buttons, true);
}
click = 1;
}
}
if (click == 2 || buttons & B_SECONDARY_MOUSE_BUTTON || modifiers() & B_CONTROL_KEY)
{
click = 1;
if (tc)
{
RemoveChild (tc);
delete tc;
}
knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
BRect kbr = BRect (knobpos.x + sep, knobpos.y, knobpos.x + knobsize - 2 + sep, knobpos.y + height - 3);
// kbr.PrintToStream();
tc = new BTextControl (kbr, "slider value field", "", "", new BMessage ('tcVC'));
tc->SetTarget (this);
tc->SetDivider (0);
EnterFilter *filter = new EnterFilter (this);
tc->TextView()->AddFilter (filter);
char vs[64];
sprintf (vs, fmt, value);
tc->SetText (vs);
AddChild (tc);
tc->MakeFocus (true);
}
NotifyTarget ();
}
示例12: StringWidth
/***********************************************************
* 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);
//.........这里部分代码省略.........
示例13: BWindow
AddTorrentWindow::AddTorrentWindow(TorrentObject* torrent)
: BWindow(BRect(),
"Add torrent",
B_TITLED_WINDOW_LOOK,
B_NORMAL_WINDOW_FEEL,
B_AUTO_UPDATE_SIZE_LIMITS |
B_ASYNCHRONOUS_CONTROLS |
B_NOT_ZOOMABLE |
B_NOT_RESIZABLE |
B_PULSE_NEEDED ),
fTorrent(torrent),
fCancelAdd(true)
{
SetPulseRate(1000000);
SetLayout(new BGroupLayout(B_VERTICAL));
float spacing = be_control_look->DefaultItemSpacing();
//
//
//
fInfoHeaderView = new InfoHeaderView(fTorrent);
fFileList = new BColumnListView("FileList", 0, B_PLAIN_BORDER, true);
fStartCheckBox = new BCheckBox("", "Start when added", NULL);
fCancelButton = new BButton("Cancel", new BMessage(B_QUIT_REQUESTED));
fAddButton = new BButton("Add", new BMessage(MSG_BUTTON_ADD));
fLoadingView = new BStatusBar("", "Downloading Metadata");
fLoadingView->SetBarHeight(12);
fLoadingView->SetMaxValue(1.0);
if( !fTorrent->IsMagnet() )
fLoadingView->Hide();
fStartCheckBox->SetValue(B_CONTROL_ON);
//
//
//
fFileList->SetColumnFlags(B_ALLOW_COLUMN_RESIZE);
fFileList->SetSortingEnabled(false);
fFileList->SetExplicitMinSize(BSize(550, FILE_COLUMN_HEIGHT * 5));
fFileList->AddColumn(new FileColumn("Name", 400, 400, 500), COLUMN_FILE_NAME);
fFileList->AddColumn(new CheckBoxColumn("DL", 40, 40, 40), COLUMN_FILE_DOWNLOAD);
//
// We're a magnet or a complete torrent file?
//
if( fTorrent->IsMagnet() )
{
fTorrent->SetMetadataCallbackHandler(this);
//const_cast<TorrentObject*>(fTorrent)->StartTransfer();
}
else
UpdateFileList();
AddChild(BGroupLayoutBuilder(B_VERTICAL, spacing)
.Add(fInfoHeaderView)
.AddGlue()
.Add(fFileList)
.Add(BGroupLayoutBuilder(B_HORIZONTAL, spacing)
.SetInsets(spacing, spacing, spacing, spacing)
.Add(fStartCheckBox)
.AddGlue()
.Add(fCancelButton)
.Add(fAddButton)
.Add(fLoadingView)
)
.SetInsets(spacing, spacing, spacing, spacing)
);
CenterOnScreen();
Run();
}
示例14: RETURN_IF_ERROR
OP_STATUS TransfersPanel::Init()
{
RETURN_IF_ERROR(OpTreeView::Construct(&m_transfers_view));
m_transfers_view->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
AddChild(m_transfers_view, TRUE);
RETURN_IF_ERROR(OpGroup::Construct(&m_item_details_group));
AddChild(m_item_details_group, TRUE);
m_item_details_group->SetSkinned(TRUE);
m_item_details_group->GetBorderSkin()->SetImage("Transfer Panel Details Skin", "Window Skin");
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_from_label));
m_item_details_from_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_from_label, TRUE);
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_to_label));
m_item_details_to_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_to_label, TRUE);
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_size_label));
m_item_details_size_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_size_label, TRUE);
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_transferred_label));
m_item_details_transferred_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_transferred_label, TRUE);
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_connections_label));
m_item_details_connections_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_connections_label, TRUE);
RETURN_IF_ERROR(OpLabel::Construct(&m_item_details_activetransfers_label));
m_item_details_activetransfers_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_activetransfers_label, TRUE);
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_from_info_label));
m_item_details_from_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_from_info_label->SetForceTextLTR(TRUE);
m_item_details_group->AddChild(m_item_details_from_info_label, TRUE);
m_item_details_from_info_label->SetFlatMode();
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_to_info_label));
m_item_details_to_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_to_info_label->SetForceTextLTR(TRUE);
m_item_details_group->AddChild(m_item_details_to_info_label, TRUE);
m_item_details_to_info_label->SetFlatMode();
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_size_info_label));
m_item_details_size_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_size_info_label, TRUE);
m_item_details_size_info_label->SetFlatMode();
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_transferred_info_label));
m_item_details_transferred_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_transferred_info_label, TRUE);
m_item_details_transferred_info_label->SetFlatMode();
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_connections_info_label));
m_item_details_connections_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_connections_info_label, TRUE);
m_item_details_connections_info_label->SetFlatMode();
RETURN_IF_ERROR(OpEdit::Construct(&m_item_details_activetransfers_info_label));
m_item_details_activetransfers_info_label->SetSystemFont(OP_SYSTEM_FONT_UI_PANEL);
m_item_details_group->AddChild(m_item_details_activetransfers_info_label, TRUE);
m_item_details_activetransfers_info_label->SetFlatMode();
SetToolbarName("Transfers Panel Toolbar", "Transfers Full Toolbar");
SetName("Transfers");
m_showdetails = g_pcui->GetIntegerPref(PrefsCollectionUI::TransWinShowDetails);
m_show_extra_info = FALSE;
m_transfers_view->SetListener(this);
OpString ui_text;
g_languageManager->GetString(Str::DI_IDL_SOURCE, ui_text);
m_item_details_from_label->SetLabel(ui_text.CStr());
g_languageManager->GetString(Str::DI_IDL_DESTINATION, ui_text);
m_item_details_to_label->SetLabel(ui_text.CStr());
g_languageManager->GetString(Str::DI_IDL_SIZE, ui_text);
m_item_details_size_label->SetLabel(ui_text.CStr());
g_languageManager->GetString(Str::DI_IDL_TRANSFERED, ui_text);
m_item_details_transferred_label->SetLabel(ui_text.CStr());
g_languageManager->GetString(Str::S_TRANSFERS_PANEL_CONNECTION_SHORT, ui_text);
m_item_details_connections_label->SetLabel(ui_text.CStr());
g_languageManager->GetString(Str::S_TRANSFERS_PANEL_ACTIVE_TRANSFERS, ui_text);
m_item_details_activetransfers_label->SetLabel(ui_text.CStr());
m_transfers_view->SetMultiselectable(TRUE);
#ifdef WINDOW_COMMANDER_TRANSFER
m_transfers_view->SetTreeModel((OpTreeModel *)g_desktop_transfer_manager);
#endif // WINDOW_COMMANDER_TRANSFER
m_transfers_view->SetColumnWeight(1, 250);
m_transfers_view->SetColumnFixedWidth(0, 18);
m_transfers_view->SetVisibility(TRUE);
if(g_pcui->GetIntegerPref(PrefsCollectionUI::EnableDrag)&DRAG_BOOKMARK)
{
m_transfers_view->SetDragEnabled(TRUE);
}
//.........这里部分代码省略.........
示例15: SetProperty
//=====================================================================================
// Window to control camera
//=====================================================================================
CFuiCamControl::CFuiCamControl(Tag idn, const char *filename)
:CFuiWindow(idn,filename,240,180,0)
{ SetProperty(FUI_TRANSPARENT);
SetProperty(FUI_NO_BORDER);
//---- Set the back bitmap ----------------------
SetBackPicture("CamControl.bmp");
CFuiWindow::ReadFinished();
//----Create all buttons ------------------------
U_INT col = MakeRGBA(255,255,255,255);
lrot = new CFuiLabel (43,48,47,19,this);
lrot->RazProperty(FUI_NO_BORDER);
lrot->SetColour(col);
AddChild('lrot',lrot,"");
rtlf = new CFuiButton( 6,48,36,20,this);
AddChild('rtlf',rtlf,"-",FUI_REPEAT_BT);
rtrt = new CFuiButton(91,48,36,20,this);
AddChild('rtrt',rtrt,"+",FUI_REPEAT_BT);
rtup = new CFuiButton(40,26,52,20,this);
AddChild('rtup',rtup,"+",FUI_REPEAT_BT);
rtdn = new CFuiButton(40,68,52,20,this);
AddChild('rtdn',rtdn,"-",FUI_REPEAT_BT);
//----Create range items ------------------------
lrng = new CFuiLabel (168,48,36,19,this);
lrng->RazProperty(FUI_NO_BORDER);
lrng->SetColour(col);
AddChild('lrng',lrng,"");
rnut = new CFuiButton(168,26,36,20,this);
AddChild('rnut',rnut,"+",FUI_REPEAT_BT);
rnin = new CFuiButton(168,68,36,20,this);
AddChild('rnin',rnin,"-",FUI_REPEAT_BT);
//----Create zoom items -------------------------
lzom = new CFuiLabel (101,130,38,19,this);
lzom->RazProperty(FUI_NO_BORDER);
lzom->SetColour(col);
AddChild('lzom',lzom,"");
zmin = new CFuiButton( 64,129,36,20,this);
AddChild('zmin',zmin,"-",FUI_REPEAT_BT);
zmup = new CFuiButton(140,129,36,20,this);
AddChild('zmup',zmup,"+",FUI_REPEAT_BT);
}