void CNewPlayer::Enter() { Winsys.ShowCursor(!param.ice_cursor); Music.Play(param.menu_music, true); int framewidth = 400 * Winsys.scale; int frameheight = 50 * Winsys.scale; int frametop = AutoYPosN(38); TArea area = AutoAreaN(30, 80, framewidth); int prevoffs = 80; prevleft = area.left + prevoffs; prevtop = AutoYPosN(52); prevwidth = 75 * Winsys.scale; ResetGUI(); avatar = AddUpDown(area.left + prevwidth + prevoffs + 8, prevtop, 0, (int)Players.numAvatars() - 1, 0, prevwidth - 34); int siz = FT.AutoSizeN(5); textbuttons[0] = AddTextButton(Trans.Text(8), area.left+50, AutoYPosN(70), siz); float len = FT.GetTextWidth(Trans.Text(15)); textbuttons[1] = AddTextButton(Trans.Text(15), area.right-len-50, AutoYPosN(70), siz); textfield = AddTextField(emptyString, area.left, frametop, framewidth, frameheight); }
//----------------Real code---------------------- BMailProtocolConfigView::BMailProtocolConfigView(uint32 options_mask) : BView (BRect(0,0,100,20), "protocol_config_view", B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW), fBodyDownloadConfig(NULL) { BRect rect(5,5,245,25); SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); // determine font height font_height fontHeight; GetFontHeight(&fontHeight); sItemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 13; rect.bottom = rect.top - 2 + sItemHeight; if (options_mask & B_MAIL_PROTOCOL_HAS_HOSTNAME) AddChild(AddTextField(rect, "host", B_TRANSLATE("Mail server:"))); if (options_mask & B_MAIL_PROTOCOL_HAS_USERNAME) AddChild(AddTextField(rect, "user", B_TRANSLATE("Username:"******"pass", B_TRANSLATE("Password:"******"flavor", B_TRANSLATE("Connection type:"))); if (options_mask & B_MAIL_PROTOCOL_HAS_AUTH_METHODS) AddChild(AddMenuField(rect, "auth_method", B_TRANSLATE("Login type:"))); // set divider float width = FindWidestLabel(this); for (int32 i = CountChildren();i-- > 0;) { if (BTextControl *text = dynamic_cast<BTextControl *>(ChildAt(i))) text->SetDivider(width + 6); } if (options_mask & B_MAIL_PROTOCOL_CAN_LEAVE_MAIL_ON_SERVER) { AddChild(AddCheckBox(rect, "leave_mail_on_server", B_TRANSLATE("Leave mail on server"), new BMessage('lmos'))); BCheckBox* box = AddCheckBox(rect, "delete_remote_when_local", B_TRANSLATE("Remove mail from server when deleted")); box->SetEnabled(false); AddChild(box); } if (options_mask & B_MAIL_PROTOCOL_PARTIAL_DOWNLOAD) { fBodyDownloadConfig = new BodyDownloadConfig(); fBodyDownloadConfig->MoveBy(0, rect.bottom + 5); AddChild(fBodyDownloadConfig); } // resize views float height; GetPreferredSize(&width,&height); ResizeTo(width,height); for (int32 i = CountChildren();i-- > 0;) { // this doesn't work with BTextControl, does anyone know why? -- axeld. if (BView *view = ChildAt(i)) view->ResizeTo(width - 10,view->Bounds().Height()); } }