这篇教程C++ BRect函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中BRect函数的典型用法代码示例。如果您正苦于以下问题:C++ BRect函数的具体用法?C++ BRect怎么用?C++ BRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了BRect函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: BWindowChatWindow::ChatWindow(entry_ref & ref): BWindow( BRect(100,100,400,300), "unknown contact - unknown status", B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_AVOID_FOCUS ), fEntry(ref), fMan( new IM::Manager(BMessenger(this))), fChangedNotActivated(false), fStatusBar(NULL), fSendButton(NULL), fProtocolHack(NULL){ bool command, sendButton; int32 iconBarSize; BMessage chatSettings; im_load_client_settings("im_emoclient", &chatSettings); if ( chatSettings.FindBool("command_sends", &command) != B_OK ) command = true; if ( chatSettings.FindBool("show_send_button", &sendButton) != B_OK ) sendButton = true; if ( chatSettings.FindInt32("icon_size", &iconBarSize) != B_OK ) iconBarSize = kLargeIcon; if ( iconBarSize <= 0 ) iconBarSize = kLargeIcon; if (chatSettings.FindString("people_handler", &fPeopleHandler) != B_OK) { fPeopleHandler = kDefaultPeopleHandler; }; if (chatSettings.FindString("other", &fOtherText) != B_OK ) { fOtherText.SetTo( "$name$ ($nickname$) ($protocol$) "); } // Set window size limits SetSizeLimits( 220, 8000, // width, 150, 8000 // height ); // get the size of various things font_height height; be_plain_font->GetHeight(&height); fFontHeight = height.ascent + height.descent + height.leading; // default window size BRect windowRect(100, 100, 400, 300); BPoint inputDivider(0, 150); // load window size if possible if (LoadSettings() == B_OK) { bool was_ok = true; if (fWindowSettings.FindRect("windowrect", &windowRect) != B_OK) { was_ok = false; } if (fWindowSettings.FindPoint("inputdivider", &inputDivider) != B_OK) { was_ok = false; } if ( !was_ok ) { windowRect = BRect(100, 100, 400, 300); inputDivider = BPoint(0, 200); } } // sanity check for divider location if ( inputDivider.y > windowRect.Height() - 50 ) { LOG("im_emoclient", liLow, "Insane divider, fixed."); inputDivider.y = windowRect.Height() - 50; }; // set size and position MoveTo(windowRect.left, windowRect.top); ResizeTo(windowRect.Width(), windowRect.Height()); // create views BRect textRect = Bounds(); BRect inputRect = Bounds(); BRect dockRect = Bounds(); dockRect.bottom = iconBarSize + kDockPadding; fDock = new IconBar(dockRect); #if B_BEOS_VERSION > B_BEOS_VERSION_5 fDock->SetViewUIColor(B_UI_PANEL_BACKGROUND_COLOR); fDock->SetLowUIColor(B_UI_PANEL_BACKGROUND_COLOR); fDock->SetHighUIColor(B_UI_PANEL_TEXT_COLOR);#else fDock->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); fDock->SetLowColor( ui_color(B_PANEL_BACKGROUND_COLOR) ); fDock->SetHighColor(0, 0, 0, 0);#endif AddChild(fDock); // add buttons ImageButton * btn;//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:101,
示例2: BWindowMainWin::MainWin(BRect frame_rect) : BWindow(frame_rect, B_TRANSLATE_SYSTEM_NAME(NAME), B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */) , fController(new Controller) , fIsFullscreen(false) , fKeepAspectRatio(true) , fAlwaysOnTop(false) , fNoMenu(false) , fNoBorder(false) , fSourceWidth(720) , fSourceHeight(576) , fWidthScale(1.0) , fHeightScale(1.0) , fMouseDownTracking(false) , fFrameResizedTriggeredAutomatically(false) , fIgnoreFrameResized(false) , fFrameResizedCalled(true){ BRect rect = Bounds(); // background fBackground = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fBackground->SetViewColor(0,0,0); AddChild(fBackground); // menu fMenuBar = new BMenuBar(fBackground->Bounds(), "menu"); CreateMenu(); fBackground->AddChild(fMenuBar); fMenuBar->ResizeToPreferred(); fMenuBarHeight = (int)fMenuBar->Frame().Height() + 1; fMenuBar->SetResizingMode(B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT); // video view BRect video_rect = BRect(0, fMenuBarHeight, rect.right, rect.bottom); fVideoView = new VideoView(video_rect, "video display", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fBackground->AddChild(fVideoView); fVideoView->MakeFocus();// SetSizeLimits(fControlViewMinWidth - 1, 32767,// fMenuBarHeight + fControlViewHeight - 1, fMenuBarHeight// + fControlViewHeight - 1);// SetSizeLimits(320 - 1, 32767, 240 + fMenuBarHeight - 1, 32767); SetSizeLimits(0, 32767, fMenuBarHeight - 1, 32767); fController->SetVideoView(fVideoView); fController->SetVideoNode(fVideoView->Node()); fVideoView->IsOverlaySupported(); SetupInterfaceMenu(); SelectInitialInterface(); SetInterfaceMenuMarker(); SetupChannelMenu(); SetChannelMenuMarker(); VideoFormatChange(fSourceWidth, fSourceHeight, fWidthScale, fHeightScale); CenterOnScreen();}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:66,
示例3: SetTextRectvoidEditorTextView::FrameResized(float new_width, float new_height){ SetTextRect(BRect(0, 0, new_width, new_height));}
开发者ID:mmlr,项目名称:libbsvg,代码行数:5,
示例4: switchvoid 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);}
开发者ID:gedrin,项目名称:Becasso,代码行数:88,
示例5: BWindowCharismaWindow::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);//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Stamina,代码行数:101,
示例6: SetDrawingModevoid KlondikeView::Draw(BRect rect){ SetDrawingMode(B_OP_ALPHA); int hSpacing = _CardHSpacing(); // stock int revealed = 0; for (short i = 0; i < 24; i++) if (fStock[i]->fRevealed) revealed++; if (revealed < 24) DrawBitmap(fBack[0], BRect(hSpacing, 15, hSpacing + CARD_WIDTH, 15 + CARD_HEIGHT)); else DrawBitmap(fEmpty, BRect(hSpacing, 15, hSpacing + CARD_WIDTH, 15 + CARD_HEIGHT)); // waste if (fIsWasteCardPicked) { int lastWasteCard = fWasteCard - 1; if (lastWasteCard != -1) while (fStock[lastWasteCard]->fRevealed) { lastWasteCard--; if (lastWasteCard == -1) { break; } } if (lastWasteCard != -1) DrawBitmap( fCards[fStock[lastWasteCard]->fColor * CARDS_IN_SUIT + fStock[lastWasteCard]->fValue], BRect(2 * hSpacing + CARD_WIDTH, 15, 2 * hSpacing + 2 * CARD_WIDTH, 15 + CARD_HEIGHT)); else DrawBitmap(fEmpty, BRect(2 * hSpacing + CARD_WIDTH, 15, 2 * hSpacing + 2 * CARD_WIDTH, 15 + CARD_HEIGHT)); } else if (fWasteCard != -1) { if (fWasteCard > 23) { fWasteCard = -1; fPoints -= 100; if (fPoints < 0) fPoints = 0; Invalidate(); return; } while (fStock[fWasteCard]->fRevealed) { fWasteCard++; if (fWasteCard > 23) { fWasteCard = -1; fPoints -= 100; if (fPoints < 0) fPoints = 0; break; } } rect = BRect(2 * hSpacing + CARD_WIDTH, 15, 2 * hSpacing + 2 * CARD_WIDTH, 15 + CARD_HEIGHT); if (fWasteCard != -1) DrawBitmap( fCards[fStock[fWasteCard]->fColor * CARDS_IN_SUIT + fStock[fWasteCard]->fValue], rect); else DrawBitmap(fEmpty, rect); } else DrawBitmap(fEmpty, BRect(2 * hSpacing + CARD_WIDTH, 15, 2 * hSpacing + 2 * CARD_WIDTH, 15 + CARD_HEIGHT)); // foundations for (short i = 0; i < 4; i++) { BRect rect = BRect((i + 4)*hSpacing + (i + 3)*CARD_WIDTH, 15, (i + 4)*hSpacing + (i + 4)*CARD_WIDTH, 15 + CARD_HEIGHT); if (fFoundations[i] == -1) { DrawBitmap(fEmpty, rect); } else { DrawBitmap( fCards[fFoundationsColors[i] * CARDS_IN_SUIT + fFoundations[i]], rect); } } // tableaux for (short i = 0; i < 7; i++) { BRect rect(hSpacing + i * (CARD_WIDTH + hSpacing), 146, hSpacing + (i + 1) * CARD_WIDTH + i * hSpacing, 146 + CARD_HEIGHT); if (solitare.fBoard[i] == NULL)//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:BeSpider,代码行数:101,
示例7: BWindowTeamMonitorWindow::TeamMonitorWindow() : BWindow(BRect(0, 0, 350, 100), B_TRANSLATE("Team monitor"), B_TITLED_WINDOW_LOOK, B_MODAL_ALL_WINDOW_FEEL, B_NOT_MINIMIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fQuitting(false), fUpdateRunner(NULL){ BGroupLayout* layout = new BGroupLayout(B_VERTICAL); float inset = 10; layout->SetInsets(inset, inset, inset, inset); layout->SetSpacing(inset); SetLayout(layout); layout->View()->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); fListView = new BListView("teams"); fListView->SetSelectionMessage(new BMessage(TM_SELECTED_TEAM)); BScrollView* scrollView = new BScrollView("scroll_teams", fListView, 0, B_SUPPORTS_LAYOUT, false, true, B_FANCY_BORDER); scrollView->SetExplicitMinSize(BSize(B_SIZE_UNSET, 150)); fKillButton = new BButton("kill", B_TRANSLATE("Kill application"), new BMessage(TM_KILL_APPLICATION)); fKillButton->SetEnabled(false); fQuitButton = new BButton("quit", B_TRANSLATE("Quit application"), new BMessage(TM_QUIT_APPLICATION)); fQuitButton->SetEnabled(false); fDescriptionView = new TeamDescriptionView; BButton* forceReboot = new BButton("force", B_TRANSLATE("Force reboot"), new BMessage(TM_FORCE_REBOOT)); fRestartButton = new BButton("restart", B_TRANSLATE("Restart the desktop"), new BMessage(TM_RESTART_DESKTOP)); fCancelButton = new BButton("cancel", B_TRANSLATE("Cancel"), new BMessage(TM_CANCEL)); SetDefaultButton(fCancelButton); BGroupLayoutBuilder(layout) .Add(scrollView) .AddGroup(B_HORIZONTAL) .Add(fKillButton) .Add(fQuitButton) .AddGlue() .End() .Add(fDescriptionView) .AddGroup(B_HORIZONTAL) .Add(forceReboot) .AddGlue() .Add(fRestartButton) .AddGlue(inset) .Add(fCancelButton); CenterOnScreen(); fRestartButton->Hide(); AddShortcut('T', B_COMMAND_KEY | B_OPTION_KEY, new BMessage(kMsgLaunchTerminal)); AddShortcut('W', B_COMMAND_KEY, new BMessage(B_QUIT_REQUESTED)); gLocalizedNamePreferred = BLocaleRoster::Default()->IsFilesystemTranslationPreferred(); gTeamMonitorWindow = this; this->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_KEY_DOWN, FilterKeyDown)); if (be_app->Lock()) { be_app->AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, B_LOCALE_CHANGED, FilterLocaleChanged)); be_app->Unlock(); }}
开发者ID:Ithamar,项目名称:haiku,代码行数:82,
示例8: BWindowModifierKeysWindow::ModifierKeysWindow() : BWindow(BRect(0, 0, 360, 220), B_TRANSLATE("Modifier keys"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS){ get_key_map(&fCurrentMap, &fCurrentBuffer); get_key_map(&fSavedMap, &fSavedBuffer); BStringView* keyRole = new BStringView("key role", B_TRANSLATE_COMMENT("Role", "As in the role of a modifier key")); keyRole->SetAlignment(B_ALIGN_RIGHT); keyRole->SetFont(be_bold_font); BStringView* keyLabel = new BStringView("key label", B_TRANSLATE_COMMENT("Key", "As in a computer keyboard key")); keyLabel->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNSET)); keyLabel->SetFont(be_bold_font); BMenuField* shiftMenuField = _CreateShiftMenuField(); shiftMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* controlMenuField = _CreateControlMenuField(); controlMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* optionMenuField = _CreateOptionMenuField(); optionMenuField->SetAlignment(B_ALIGN_RIGHT); BMenuField* commandMenuField = _CreateCommandMenuField(); commandMenuField->SetAlignment(B_ALIGN_RIGHT); fShiftConflictView = new ConflictView("shift warning view"); fShiftConflictView->SetExplicitMaxSize(BSize(15, 15)); fControlConflictView = new ConflictView("control warning view"); fControlConflictView->SetExplicitMaxSize(BSize(15, 15)); fOptionConflictView = new ConflictView("option warning view"); fOptionConflictView->SetExplicitMaxSize(BSize(15, 15)); fCommandConflictView = new ConflictView("command warning view"); fCommandConflictView->SetExplicitMaxSize(BSize(15, 15)); fCancelButton = new BButton("cancelButton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); fRevertButton = new BButton("revertButton", B_TRANSLATE("Revert"), new BMessage(kMsgRevertModifiers)); fRevertButton->SetEnabled(false); fOkButton = new BButton("okButton", B_TRANSLATE("Set modifier keys"), new BMessage(kMsgApplyModifiers)); fOkButton->MakeDefault(true); // Build the layout SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(BLayoutBuilder::Group<>(B_VERTICAL) .AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING) .Add(keyRole, 0, 0) .Add(keyLabel, 1, 0, 2, 1) .Add(shiftMenuField->CreateLabelLayoutItem(), 0, 1) .Add(shiftMenuField->CreateMenuBarLayoutItem(), 1, 1) .Add(fShiftConflictView, 2, 1) .Add(controlMenuField->CreateLabelLayoutItem(), 0, 2) .Add(controlMenuField->CreateMenuBarLayoutItem(), 1, 2) .Add(fControlConflictView, 2, 2) .Add(optionMenuField->CreateLabelLayoutItem(), 0, 3) .Add(optionMenuField->CreateMenuBarLayoutItem(), 1, 3) .Add(fOptionConflictView, 2, 3) .Add(commandMenuField->CreateLabelLayoutItem(), 0, 4) .Add(commandMenuField->CreateMenuBarLayoutItem(), 1, 4) .Add(fCommandConflictView, 2, 4) .End() .AddGlue() .AddGroup(B_HORIZONTAL) .Add(fCancelButton) .AddGlue() .Add(fRevertButton) .Add(fOkButton) .End() .SetInsets(B_USE_DEFAULT_SPACING) ); _MarkMenuItems(); _ValidateDuplicateKeys(); CenterOnScreen();}
开发者ID:RAZVOR,项目名称:haiku,代码行数:93,
示例9: invalid_rectstatic BRect invalid_rect(){ return BRect(-1, -1, -1, -1);}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:4,
示例10: HWindowHApp::HApp() :BApplication(APP_SIG){ HWindow *win = new HWindow(BRect(50,50,300,300),"IconMenu"); win->Show();}
开发者ID:BackupTheBerlios,项目名称:haiku-pim-svn,代码行数:5,
示例11: find_directory// fill out the icon with the stop symbol from app_servervoidConflictView::_FillSavedIcon(){ // return if the fSavedIcon has already been filled out if (fSavedIcon != NULL && fSavedIcon->InitCheck() == B_OK) return; BPath path; status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path); if (status < B_OK) { FTRACE((stderr, "_FillWarningIcon() - find_directory failed: %s/n", strerror(status))); delete fSavedIcon; fSavedIcon = NULL; return; } path.Append("app_server"); BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status < B_OK) { FTRACE((stderr, "_FillWarningIcon() - BFile init failed: %s/n", strerror(status))); delete fSavedIcon; fSavedIcon = NULL; return; } BResources resources; status = resources.SetTo(&file); if (status < B_OK) { FTRACE((stderr, "_WarningIcon() - BResources init failed: %s/n", strerror(status))); delete fSavedIcon; fSavedIcon = NULL; return; } // Allocate the fSavedIcon bitmap fSavedIcon = new(std::nothrow) BBitmap(BRect(0, 0, 15, 15), 0, B_RGBA32); if (fSavedIcon->InitCheck() < B_OK) { FTRACE((stderr, "_WarningIcon() - No memory for warning bitmap/n")); delete fSavedIcon; fSavedIcon = NULL; return; } // Load the raw stop icon data size_t size = 0; const uint8* rawIcon; rawIcon = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE, "stop", &size); // load vector warning icon into fSavedIcon if (rawIcon == NULL || BIconUtils::GetVectorIcon(rawIcon, size, fSavedIcon) < B_OK) { delete fSavedIcon; fSavedIcon = NULL; }}
开发者ID:RAZVOR,项目名称:haiku,代码行数:64,
示例12: switchBBitmap *targatobbitmap( const unsigned char* targa, int targasize){ BBitmap *bitmap; int idlength; int colormaptype; int imagetype; int height; int width; int depth; int imagedescriptor; int rowbytes; int bitssize; unsigned char *bits; const unsigned char *ptarga; unsigned char *pbits; int i,j,k; int count; unsigned char px0,px1,px2; idlength=targa[0]; colormaptype=targa[1]; if(colormaptype!=0) return NULL; imagetype=targa[2]; if(imagetype!=2 && imagetype!=10) return NULL; width=targa[12]+(targa[13]<<8); height=targa[14]+(targa[15]<<8); depth=targa[16]; if(depth!=24) return NULL; imagedescriptor=targa[17]; if(imagedescriptor!=0) return NULL; rowbytes=3*width; bitssize=height*rowbytes; if(imagetype==2 && 18+idlength+bitssize>targasize) return NULL; bits=new unsigned char[bitssize]; if(!bits) return NULL; ptarga=targa+18+idlength; switch(imagetype){ case 2: pbits=bits+(height-1)*rowbytes; for(j=0;j<height;j++){ for(i=0;i<width;i++){ pbits[2]=*ptarga++; pbits[1]=*ptarga++; pbits[0]=*ptarga++; pbits+=3; } pbits-=2*rowbytes; } break; case 10: // RLE pbits=bits+(height-1)*rowbytes; for(j=0;j<height;j++){ for(i=0;i<width;i+=count){ count=*ptarga++; if(count&0x80){ count&=0x7F; count++; if(i+count>width) count=width-i; px2=*ptarga++; px1=*ptarga++; px0=*ptarga++; for(k=0;k<count;k++){ pbits[2]=px2; pbits[1]=px1; pbits[0]=px0; pbits+=3; } }else{ count++; if(i+count>width) count=width-i; for(k=0;k<count;k++){ pbits[2]=*ptarga++; pbits[1]=*ptarga++; pbits[0]=*ptarga++; pbits+=3; } } } pbits-=2*rowbytes; } break; } bitmap=new BBitmap(BRect(0,0,width-1,height-1),B_RGB_32_BIT); bitmap->SetBits(bits,bitssize,0,B_RGB_32_BIT); delete[] bits;//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Stamina,代码行数:101,
示例13: GetMouse/*=============================================================================================*/| Draw |+-----------------------------------------------------------------------------------------------+| Effet: Redessine la view selon son status. || |/*=============================================================================================*/void BeNetButton::Draw(BRect updateRect){ BPoint pPointList[8]; BPoint cursor; uint32 iButton; float leftBmp = 0; float topBmp = 0; float leftLab = 0; float topLab = 0; bool m_bBorderIn = false; bool m_bBorderOut = false; BFont font; GetMouse(&cursor, &iButton); m_bMouseOver = false; if(cursor.x >= 0 && cursor.x < Bounds().Width() && cursor.y >= 0 && cursor.y < Bounds().Height()) { m_bMouseOver = true; } //Mode de dessinement utilisant seulement des bitmap. if(m_iDrawMode == BENET_DM_FULL_BMP || (m_iDrawMode == BENET_DM_TOGGLE && !m_bToggle)) { SetDrawingMode(B_OP_COPY); //Le bouton est disable. if(!IsEnabled()) { DrawBitmap(m_pBitmap, BRect(3 * Bounds().Width(),0, 4 * Bounds().Width()-1,Bounds().Height()-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //Le boutton est enfoncer else if(Value()) { DrawBitmap(m_pBitmap, BRect(2 * Bounds().Width(),0, 3 * Bounds().Width()-1,Bounds().Height()-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //La sourie est par dessus le bouton. else if(m_bMouseOver) { DrawBitmap(m_pBitmap, BRect(Bounds().Width(),0, 2 * Bounds().Width()-1,Bounds().Height()-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //boutton par defaut else { DrawBitmap(m_pBitmap, BRect(0,0,Bounds().Width()-1,Bounds().Height()-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } } else if(m_iDrawMode == BENET_DM_TOGGLE && m_bToggle) { SetDrawingMode(B_OP_COPY); //Le bouton est disable. if(!IsEnabled()) { DrawBitmap(m_pBitmap, BRect(3 * Bounds().Width(),Bounds().Height(), 4 * Bounds().Width()-1,Bounds().Height()*2-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //Le boutton est enfoncer else if(Value()) { DrawBitmap(m_pBitmap, BRect(2 * Bounds().Width(),Bounds().Height(), 3 * Bounds().Width()-1,Bounds().Height()*2-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //La sourie est par dessus le bouton. else if(m_bMouseOver) { DrawBitmap(m_pBitmap, BRect(Bounds().Width(),Bounds().Height(), 2 * Bounds().Width()-1,Bounds().Height()*2-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } //boutton par defaut else { DrawBitmap(m_pBitmap, BRect(0,Bounds().Height(),Bounds().Width()-1,Bounds().Height()*2-1), BRect(0,0,Bounds().Width()-1,Bounds().Height()-1)); } } /////////////////////////// // Debut de l'ancient mode de dessinement. else if(m_iDrawMode == BENET_DM_DEFAULT) { //Aller chercher les propriete du font. GetFont(&font); font_height height; font.GetHeight(&height); //Trouver le coin superieur gauche du bitmap. if(m_bLabel) { topBmp = 2; } else//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:dengon-svn,代码行数:101,
示例14: SetViewPanelBgColorvoidThemeInterfaceView::AllAttached(){ BView::AllAttached(); SetViewPanelBgColor(); fThemeManager = new ThemeManager; BRect frame = Bounds(); frame.InsetBy(10.0, 10.0); // add the theme listview BRect list_frame = frame; list_frame.right = 130; fThemeList = new BListView(list_frame.InsetByCopy(3.0, 3.0), "themelist"); fThemeListSV = new BScrollView("themelistsv", fThemeList, B_FOLLOW_LEFT|B_FOLLOW_TOP, 0, false, true); AddChild(fThemeListSV); fThemeList->SetSelectionMessage(new BMessage(kThemeSelected)); fThemeList->SetInvocationMessage(new BMessage(kApplyThemeBtn)); fThemeList->SetTarget(this); // buttons... fNewBtn = new BButton(BRect(), "create", B_TRANSLATE("New"), new BMessage(kCreateThemeBtn)); AddChild(fNewBtn); fNewBtn->SetTarget(this); fNewBtn->ResizeToPreferred(); fNewBtn->MoveTo(fThemeListSV->Frame().right + 15.0, frame.bottom - fNewBtn->Bounds().Height()); BPoint lt = fNewBtn->Frame().LeftTop(); fNameText = new BTextControl(BRect(), "text", "", "My Theme", new BMessage(kCreateThemeBtn)); AddChild(fNameText); fNameText->SetTarget(this); fNameText->ResizeToPreferred(); // default is a bit small fNameText->ResizeBy(fNameText->Bounds().Width(), 0); fNameText->MoveTo(lt); fNameText->MoveBy(0, (fNewBtn->Bounds().Height() - fNameText->Bounds().Height()) / 2); //fNameText->MoveBy(0, - fNewBtn->Bounds().Height()); fNameText->Hide(); lt.x = fNewBtn->Frame().right + 10.0; fSaveBtn = new BButton(BRect(), "save", B_TRANSLATE("Save"), new BMessage(kSaveThemeBtn)); AddChild(fSaveBtn); fSaveBtn->SetTarget(this); fSaveBtn->ResizeToPreferred(); fSaveBtn->MoveTo(lt); lt.x = fSaveBtn->Frame().right + 10.0; fDeleteBtn = new BButton(BRect(), "delete", B_TRANSLATE("Delete"), new BMessage(kDeleteThemeBtn)); AddChild(fDeleteBtn); fDeleteBtn->SetTarget(this); fDeleteBtn->ResizeToPreferred(); fDeleteBtn->MoveTo(lt); // buttons... fSetShotBtn = new BButton(BRect(), "makeshot", B_TRANSLATE("Add screenshot"), new BMessage(kMakeScreenshot), B_FOLLOW_RIGHT | B_FOLLOW_TOP); AddChild(fSetShotBtn); fSetShotBtn->SetTarget(this); fSetShotBtn->ResizeToPreferred(); fMoreThemesBtn = new BButton(BRect(), "getthemes", B_TRANSLATE("More themes"), new BMessage(skOnlineThemes), B_FOLLOW_RIGHT | B_FOLLOW_TOP); AddChild(fMoreThemesBtn); fMoreThemesBtn->SetTarget(this); fMoreThemesBtn->ResizeToPreferred(); fDefaultsBtn = new BButton(BRect(), "defaults", B_TRANSLATE("Defaults"), new BMessage(B_PREF_APP_SET_DEFAULTS), B_FOLLOW_RIGHT | B_FOLLOW_TOP); AddChild(fDefaultsBtn); fDefaultsBtn->ResizeToPreferred(); fDefaultsBtn->SetTarget(this); fApplyBtn = new BButton(BRect(), "apply", B_TRANSLATE("Apply"), new BMessage(kApplyThemeBtn), B_FOLLOW_RIGHT | B_FOLLOW_TOP); AddChild(fApplyBtn); fApplyBtn->ResizeToPreferred(); fApplyBtn->SetTarget(this); float widest = max_c(fSetShotBtn->Bounds().Width(), fMoreThemesBtn->Bounds().Width()); widest = max_c(widest, fDefaultsBtn->Bounds().Width()); widest = max_c(widest, fApplyBtn->Bounds().Width()); float height = fSetShotBtn->Bounds().Height(); fSetShotBtn->ResizeTo(widest, height); fMoreThemesBtn->ResizeTo(widest, height); fDefaultsBtn->ResizeTo(widest, height); fApplyBtn->ResizeTo(widest, height); fSetShotBtn->MoveTo(frame.right - widest, frame.top + 5.0); fMoreThemesBtn->MoveTo(frame.right - widest, fSetShotBtn->Frame().bottom + 10.0); fApplyBtn->MoveTo(frame.right - widest, fNewBtn->Frame().top - fApplyBtn->Bounds().Height() - 10); fDefaultsBtn->MoveTo(frame.right - widest, fNewBtn->Frame().top - (fApplyBtn->Bounds().Height() + 10) * 2); // add the preview screen BRect preview_frame(fNewBtn->Frame().left, fThemeListSV->Frame().top, frame.right - widest - 10, fNewBtn->Frame().top - 10); fTabView = new BTabView(preview_frame, "tabs"); fTabView->SetViewPanelBgColor(); AddChild(fTabView); preview_frame = fTabView->ContainerView()->Bounds(); fScreenshotTab = new BView(preview_frame, B_TRANSLATE("Screenshot"), B_FOLLOW_ALL, B_WILL_DRAW);//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:HaikuThemeManager,代码行数:101,
示例15: BWindowScreenWindow::ScreenWindow(ScreenSettings* settings) : BWindow(settings->WindowFrame(), B_TRANSLATE_SYSTEM_NAME("Screen"), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS, B_ALL_WORKSPACES), fIsVesa(false), fBootWorkspaceApplied(false), fOtherRefresh(NULL), fScreenMode(this), fUndoScreenMode(this), fModified(false){ BScreen screen(this); accelerant_device_info info; if (screen.GetDeviceInfo(&info) == B_OK && !strcasecmp(info.chipset, "VESA")) fIsVesa = true; _UpdateOriginal(); _BuildSupportedColorSpaces(); fActive = fSelected = fOriginal; fSettings = settings; // we need the "Current Workspace" first to get its height BPopUpMenu *popUpMenu = new BPopUpMenu(B_TRANSLATE("Current workspace"), true, true); fAllWorkspacesItem = new BMenuItem(B_TRANSLATE("All workspaces"), new BMessage(WORKSPACE_CHECK_MSG)); popUpMenu->AddItem(fAllWorkspacesItem); BMenuItem *item = new BMenuItem(B_TRANSLATE("Current workspace"), new BMessage(WORKSPACE_CHECK_MSG)); popUpMenu->AddItem(item); fAllWorkspacesItem->SetMarked(true); BMenuField* workspaceMenuField = new BMenuField("WorkspaceMenu", NULL, popUpMenu); workspaceMenuField->ResizeToPreferred(); // box on the left with workspace count and monitor view BBox* screenBox = new BBox("screen box"); BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 5.0); layout->SetInsets(10, 10, 10, 10); screenBox->SetLayout(layout); fMonitorInfo = new BStringView("monitor info", ""); screenBox->AddChild(fMonitorInfo); fMonitorView = new MonitorView(BRect(0.0, 0.0, 80.0, 80.0), "monitor", screen.Frame().IntegerWidth() + 1, screen.Frame().IntegerHeight() + 1); screenBox->AddChild(fMonitorView); fColumnsControl = new BTextControl(B_TRANSLATE("Columns:"), "0", new BMessage(kMsgWorkspaceColumnsChanged)); fRowsControl = new BTextControl(B_TRANSLATE("Rows:"), "0", new BMessage(kMsgWorkspaceRowsChanged)); screenBox->AddChild(BLayoutBuilder::Grid<>(5.0, 5.0) .Add(new BStringView("", B_TRANSLATE("Workspaces")), 0, 0, 3) .AddTextControl(fColumnsControl, 0, 1, B_ALIGN_RIGHT) .AddGroup(B_HORIZONTAL, 0, 2, 1) .Add(_CreateColumnRowButton(true, false)) .Add(_CreateColumnRowButton(true, true)) .End() .AddTextControl(fRowsControl, 0, 2, B_ALIGN_RIGHT) .AddGroup(B_HORIZONTAL, 0, 2, 2) .Add(_CreateColumnRowButton(false, false)) .Add(_CreateColumnRowButton(false, true)) .End() .View()); fBackgroundsButton = new BButton("BackgroundsButton", B_TRANSLATE("Set background" B_UTF8_ELLIPSIS), new BMessage(BUTTON_LAUNCH_BACKGROUNDS_MSG)); fBackgroundsButton->SetFontSize(be_plain_font->Size() * 0.9); screenBox->AddChild(fBackgroundsButton); // box on the right with screen resolution, etc. BBox* controlsBox = new BBox("controls box"); controlsBox->SetLabel(workspaceMenuField); BGroupView* outerControlsView = new BGroupView(B_VERTICAL, 10.0); outerControlsView->GroupLayout()->SetInsets(10, 10, 10, 10); controlsBox->AddChild(outerControlsView); fResolutionMenu = new BPopUpMenu("resolution", true, true); uint16 maxWidth = 0; uint16 maxHeight = 0; uint16 previousWidth = 0; uint16 previousHeight = 0; for (int32 i = 0; i < fScreenMode.CountModes(); i++) { screen_mode mode = fScreenMode.ModeAt(i); if (mode.width == previousWidth && mode.height == previousHeight)//.........这里部分代码省略.........
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:101,
示例16: BRectBRect _SeqCachedTool::Bounds() const{ if (mNormalIcon) return mNormalIcon->Bounds(); return BRect(0, 0, 0, 0);}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:5,
示例17: GetMouse//.........这里部分代码省略......... // pick up a stack if (stack < 7 && solitare.fBoard[stack] != NULL && point.x > hSpacing && point.y > 2 * 15 + CARD_HEIGHT) { // find clicked on card int cardNumber = 1; card* picked = solitare.fBoard[stack]; while (picked->fNextCard != NULL) { if (point.y - 18 * cardNumber - CARD_HEIGHT - 15 < 18) { break; } picked = picked->fNextCard; cardNumber++; } if (picked->fNextCard == NULL) { // on last card, if below than not clicking on card if (point.y - 18 * cardNumber - CARD_HEIGHT - 15 >= CARD_HEIGHT) { return; } if (fDoubleClick == -1) fDoubleClick = 1; else if (fDoubleClick > -1 && fAutoPlayEnabled) { MoveOneToFoundation(stack, stack); CheckBoard(); Invalidate(); fDoubleClick = -1; return; } } if (picked->fRevealed == false) return; card* currentCard = picked->fNextCard; card* lastCard = picked; short pickedHeight = 1; for (short i = 1; currentCard != NULL; i++) { pickedHeight++; if (lastCard->fColor & 1 == currentCard->fColor & 1) return; lastCard = currentCard; currentCard = currentCard->fNextCard; } fPickedCardBoardPos = stack; fPickedCard = picked; fIsCardPicked = true; solitare._RemoveCardFromPile(stack, picked); BMessage msg(B_SIMPLE_DATA); msg.AddPointer("view", this); BBitmap* img; if (pickedHeight == 1) img = new BBitmap( fCards[picked->fColor * CARDS_IN_SUIT + picked->fValue]); else { img = new BBitmap(BRect(0, 0, CARD_WIDTH - 1, CARD_HEIGHT + (pickedHeight - 1) * 18), fBack[0]->ColorSpace(), true); BView* imgView = new BView(img->Bounds(), NULL, 0, 0); BRect destRect = fBack[0]->Bounds(); img->AddChild(imgView); img->Lock(); currentCard = picked; imgView->SetDrawingMode(B_OP_COPY); imgView->DrawBitmap(fCards [currentCard->fColor * CARDS_IN_SUIT + currentCard->fValue], destRect); destRect.top = (pickedHeight - 1) * 18; destRect.bottom = destRect.top + CARD_HEIGHT; imgView->DrawBitmap(fBack[0], destRect); // we don't know the top card yet, so we'll overwrite this imgView->SetDrawingMode(B_OP_ALPHA); for (short j = 0; j < pickedHeight; j++) { destRect.top = j * 18; destRect.bottom = destRect.top + CARD_HEIGHT; imgView->DrawBitmap(fCards[currentCard->fColor * CARDS_IN_SUIT + currentCard->fValue], destRect); currentCard = currentCard->fNextCard; } imgView->Sync(); img->Unlock(); img->RemoveChild(imgView); delete imgView; } DragMessage(&msg, img, B_OP_BLEND, BPoint((int)(point.x - hSpacing) % (CARD_WIDTH + hSpacing), point.y - cardNumber * 18 - 131)); Invalidate(); }}
开发者ID:HaikuArchives,项目名称:BeSpider,代码行数:101,
示例18: spawn_thread//.........这里部分代码省略......... break; } case M_RUN_TOOL: { BString sig; if (msg->FindString("signature", &sig) == B_OK) { LaunchHelper launcher(sig.String()); launcher.Launch(); } break; } case M_MAKE_MAKE: { DPath out(fProject->GetPath().GetFolder()); out.Append("Makefile"); if (MakeMake(fProject,out) == B_OK); { BEntry entry(out.GetFullPath()); entry_ref ref; if (entry.InitCheck() == B_OK) { entry.GetRef(&ref); BMessage refmsg(B_REFS_RECEIVED); refmsg.AddRef("refs",&ref); be_app->PostMessage(&refmsg); } } break; } case M_SHOW_CODE_LIBRARY: { #ifdef BUILD_CODE_LIBRARY CodeLibWindow *libwin = CodeLibWindow::GetInstance(BRect(100,100,500,350)); libwin->Show(); #endif break; } case M_OPEN_PARTNER: { int32 selection = fProjectList->FullListCurrentSelection(); if (selection < 0) break; SourceFileItem *item = dynamic_cast<SourceFileItem*>( fProjectList->FullListItemAt(selection)); if (!item) break; entry_ref ref; BEntry(fProject->GetPathForFile(item->GetData()).GetFullPath()).GetRef(&ref); BMessage refmsg(M_OPEN_PARTNER); refmsg.AddRef("refs",&ref); be_app->PostMessage(&refmsg); break; } case M_NEW_GROUP: { MakeGroup(fProjectList->FullListCurrentSelection()); PostMessage(M_SHOW_RENAME_GROUP); break; } case M_SHOW_RENAME_GROUP: { int32 selection = fProjectList->FullListCurrentSelection(); SourceGroupItem *groupItem = NULL;
开发者ID:passick,项目名称:Paladin,代码行数:67,
示例19: StringWidth/*********************************************************** * InitGUI ***********************************************************/voidHAddressView::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);//.........这里部分代码省略.........
开发者ID:HaikuArchives,项目名称:Scooby,代码行数:101,
示例20: DWindowSCMImportWindow::SCMImportWindow(void) : DWindow(BRect(0,0,350,350), "Import from Repository"){ MakeCenteredOnShow(true); BMenu *menu = new BMenu("Providers"); for (int32 i = 0; i < fProviderMgr.CountImporters(); i++) { SCMProjectImporter *importer = fProviderMgr.ImporterAt(i); if (!importer) continue; BMessage *msg = new BMessage(M_USE_PROVIDER); menu->AddItem(new BMenuItem(importer->GetName(), msg)); } // Disable custom commands for now // menu->AddSeparatorItem();// menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER))); menu->SetLabelFromMarked(true); menu->ItemAt(0L)->SetMarked(true); fProviderField = new BMenuField("repofield", "Provider: ", menu); menu = new BMenu("Methods"); if (gHgAvailable) menu->AddItem(new BMenuItem("Mercurial", new BMessage(M_UPDATE_COMMAND))); if (gGitAvailable) menu->AddItem(new BMenuItem("Git", new BMessage(M_UPDATE_COMMAND))); if (gSvnAvailable) menu->AddItem(new BMenuItem("Subversion", new BMessage(M_UPDATE_COMMAND))); menu->SetLabelFromMarked(true); menu->ItemAt(0L)->SetMarked(true); fProvider = fProviderMgr.ImporterAt(0); fSCMField = new BMenuField("scmfield", "Method: ", menu); fProjectBox = new AutoTextControl("project", "Project: ", "", new BMessage(M_UPDATE_COMMAND)); fAnonymousBox = new BCheckBox("anonymous", "Anonymous check-out", new BMessage(M_TOGGLE_ANONYMOUS)); fAnonymousBox->SetValue(B_CONTROL_ON); fUserNameBox = new AutoTextControl("username", "Username: ", "", new BMessage(M_UPDATE_COMMAND)); fUserNameBox->SetEnabled(false); fRepository = new AutoTextControl("repository", "Repository Owner: ", "", new BMessage(M_UPDATE_COMMAND)); fCommandLabel = new BStringView("commandlabel", "Command: "); fCommandView = new BTextView("command"); BScrollView *scroll = new BScrollView("scrollview", fCommandView, 0, false, true); fCommandView->MakeEditable(false); fOK = new BButton("ok", "Import", new BMessage(M_SCM_IMPORT)); BLayoutBuilder::Group<>(this, B_VERTICAL) .SetInsets(10) .Add(fProviderField) .Add(fSCMField) .Add(fRepository) .Add(fProjectBox) .Add(fAnonymousBox) .Add(fUserNameBox) .Add(fCommandLabel) .Add(scroll) .Add(fOK) .End(); fOK->MakeDefault(true); fOK->SetEnabled(false); UpdateCommand(); fProviderField->MakeFocus(true); }
开发者ID:HaikuArchives,项目名称:Paladin,代码行数:84,
示例21: BPointvoid Slider::MouseDown (BPoint point)// Note: Still assumes horizontal slider ATM!{ if (tc) // TextControl still visible... Block other mouse movement. return; BPoint 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); ulong buttons; buttons = Window()->CurrentMessage()->FindInt32 ("buttons"); float px = -1; bool dragging = false; if (click != 2 && buttons & B_PRIMARY_MOUSE_BUTTON && !(modifiers() & B_CONTROL_KEY)) { BPoint bp, pbp; uint32 bt; GetMouse (&pbp, &bt, true); bigtime_t start = system_time(); if (knob.Contains (BPoint (pbp.x - sep, pbp.y))) { 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) {//.........这里部分代码省略.........
开发者ID:gedrin,项目名称:Becasso,代码行数:101,
示例22: BWindowInterfaceWindow::InterfaceWindow( intf_thread_t * _p_intf, BRect frame, const char * name ) : BWindow( frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ), /* Initializations */ p_intf( _p_intf ), p_input( NULL ), p_playlist( NULL ), fFilePanel( NULL ), fLastUpdateTime( system_time() ), fSettings( new BMessage( 'sett' ) ){ p_playlist = pl_Hold( p_intf ); var_AddCallback( p_playlist, "intf-change", PlaylistChanged, this ); var_AddCallback( p_playlist, "item-change", PlaylistChanged, this ); var_AddCallback( p_playlist, "playlist-item-append", PlaylistChanged, this ); var_AddCallback( p_playlist, "playlist-item-deleted", PlaylistChanged, this ); var_AddCallback( p_playlist, "item-current", PlaylistChanged, this ); char psz_tmp[1024];#define ADD_ELLIPSIS( a ) / memset( psz_tmp, 0, 1024 ); / snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS ); BScreen screen; BRect screen_rect = screen.Frame(); BRect window_rect; window_rect.Set( ( screen_rect.right - PREFS_WINDOW_WIDTH ) / 2, ( screen_rect.bottom - PREFS_WINDOW_HEIGHT ) / 2, ( screen_rect.right + PREFS_WINDOW_WIDTH ) / 2, ( screen_rect.bottom + PREFS_WINDOW_HEIGHT ) / 2 ); fPreferencesWindow = new PreferencesWindow( p_intf, window_rect, _("Preferences") ); window_rect.Set( screen_rect.right - 500, screen_rect.top + 50, screen_rect.right - 150, screen_rect.top + 250 );#if 0 fPlaylistWindow = new PlayListWindow( window_rect, _("Playlist"), this, p_intf ); window_rect.Set( screen_rect.right - 550, screen_rect.top + 300, screen_rect.right - 150, screen_rect.top + 500 );#endif fMessagesWindow = new MessagesWindow( p_intf, window_rect, _("Messages") ); // the media control view p_mediaControl = new MediaControlView( p_intf, BRect( 0.0, 0.0, 250.0, 50.0 ) ); p_mediaControl->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); float width, height; p_mediaControl->GetPreferredSize( &width, &height ); // set up the main menu fMenuBar = new BMenuBar( BRect(0.0, 0.0, width, 15.0), "main menu", B_FOLLOW_NONE, B_ITEMS_IN_ROW, false ); // make menu bar resize to correct height float menuWidth, menuHeight; fMenuBar->GetPreferredSize( &menuWidth, &menuHeight ); fMenuBar->ResizeTo( width, menuHeight ); // don't change! it's a workarround! // take care of proper size for ourself height += fMenuBar->Bounds().Height(); ResizeTo( width, height ); p_mediaControl->MoveTo( fMenuBar->Bounds().LeftBottom() + BPoint(0.0, 1.0) ); AddChild( fMenuBar ); // Add the file Menu BMenu* fileMenu = new BMenu( _("File") ); fMenuBar->AddItem( fileMenu ); ADD_ELLIPSIS( _("Open File") ); fileMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O') ); fileMenu->AddItem( new CDMenu( _("Open Disc") ) ); ADD_ELLIPSIS( _("Open Subtitles") ); fileMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( LOAD_SUBFILE ) ) ); fileMenu->AddSeparatorItem(); ADD_ELLIPSIS( _("About") ); BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( B_ABOUT_REQUESTED ), 'A'); item->SetTarget( be_app ); fileMenu->AddItem( item ); fileMenu->AddItem( new BMenuItem( _("Quit"), new BMessage( B_QUIT_REQUESTED ), 'Q') ); fLanguageMenu = new LanguageMenu( p_intf, _("Language"), "audio-es" ); fSubtitlesMenu = new LanguageMenu( p_intf, _("Subtitles"), "spu-es" ); /* Add the Audio menu */ fAudioMenu = new BMenu( _("Audio") ); fMenuBar->AddItem ( fAudioMenu ); fAudioMenu->AddItem( fLanguageMenu ); fAudioMenu->AddItem( fSubtitlesMenu ); fPrevTitleMI = new BMenuItem( _("Prev Title"), new BMessage( PREV_TITLE ) ); fNextTitleMI = new BMenuItem( _("Next Title"), new BMessage( NEXT_TITLE ) ); fPrevChapterMI = new BMenuItem( _("Previous chapter"), new BMessage( PREV_CHAPTER ) ); fNextChapterMI = new BMenuItem( _("Next chapter"), new BMessage( NEXT_CHAPTER ) );//.........这里部分代码省略.........
开发者ID:Kafay,项目名称:vlc,代码行数:101,
示例23: find_directoryBBitmap*BAlert::_CreateTypeIcon(){ if (Type() == B_EMPTY_ALERT) return NULL; // The icons are in the app_server resources BBitmap* icon = NULL; BPath path; status_t status = find_directory(B_BEOS_SERVERS_DIRECTORY, &path); if (status != B_OK) { FTRACE((stderr, "BAlert::_CreateTypeIcon() - find_directory " "failed: %s/n", strerror(status))); return NULL; } path.Append("app_server"); BFile file; status = file.SetTo(path.Path(), B_READ_ONLY); if (status != B_OK) { FTRACE((stderr, "BAlert::_CreateTypeIcon() - BFile init failed: %s/n", strerror(status))); return NULL; } BResources resources; status = resources.SetTo(&file); if (status != B_OK) { FTRACE((stderr, "BAlert::_CreateTypeIcon() - BResources init " "failed: %s/n", strerror(status))); return NULL; } // Which icon are we trying to load? const char* iconName; switch (fType) { case B_INFO_ALERT: iconName = "info"; break; case B_IDEA_ALERT: iconName = "idea"; break; case B_WARNING_ALERT: iconName = "warn"; break; case B_STOP_ALERT: iconName = "stop"; break; default: // Alert type is either invalid or B_EMPTY_ALERT; // either way, we're not going to load an icon return NULL; } int32 iconSize = 32 * icon_layout_scale(); // Allocate the icon bitmap icon = new(std::nothrow) BBitmap(BRect(0, 0, iconSize - 1, iconSize - 1), 0, B_RGBA32); if (icon == NULL || icon->InitCheck() < B_OK) { FTRACE((stderr, "BAlert::_CreateTypeIcon() - No memory for bitmap/n")); delete icon; return NULL; } // Load the raw icon data size_t size = 0; const uint8* rawIcon; // Try to load vector icon rawIcon = (const uint8*)resources.LoadResource(B_VECTOR_ICON_TYPE, iconName, &size); if (rawIcon != NULL && BIconUtils::GetVectorIcon(rawIcon, size, icon) == B_OK) { return icon; } // Fall back to bitmap icon rawIcon = (const uint8*)resources.LoadResource(B_LARGE_ICON_TYPE, iconName, &size); if (rawIcon == NULL) { FTRACE((stderr, "BAlert::_CreateTypeIcon() - Icon resource not found/n")); delete icon; return NULL; } // Handle color space conversion if (icon->ColorSpace() != B_CMAP8) { BIconUtils::ConvertFromCMAP8(rawIcon, iconSize, iconSize, iconSize, icon); } return icon;}
开发者ID:tqh,项目名称:haiku-efi,代码行数:94,
示例24: MakeFocusvoid BitmapView::MouseDown( BPoint cPosition ){ MakeFocus( true ); Icon* pcIcon = FindIcon( cPosition ); if ( pcIcon != NULL ) { if ( pcIcon->m_bSelected ) { if ( m_nHitTime + 500000 >= system_time() ) { if ( pcIcon->GetName() == "Root (List)" ) { BWindow* pcWindow = new DirWindow( BRect( 200, 150, 600, 400 ), "/" ); pcWindow->Activate(); } else if ( pcIcon->GetName() == "Root (Icon)" ) { BWindow* pcWindow = new DirIconWindow( BRect( 20, 20, 359, 220 ), "/", g_pcBackDrop ); pcWindow->Activate(); } else if ( pcIcon->GetName() == "Terminal" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "cterm", "cterm", NULL ); exit( 1 ); } } else if ( pcIcon->GetName() == "Prefs" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "guiprefs", "guiprefs", NULL ); exit( 1 ); } } else if ( pcIcon->GetName() == "Pulse" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "pulse", "pulse", NULL ); exit( 1 ); } } else if ( pcIcon->GetName() == "Calculator" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "calc", "calc", NULL ); exit( 1 ); } } else if ( pcIcon->GetName() == "Editor" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "aedit", "aedit", NULL ); exit( 1 ); } } else if ( pcIcon->GetName() == "Guido" ) { pid_t nPid = fork(); if ( nPid == 0 ) { set_thread_priority( -1, 0 ); execlp( "guido", "guido", NULL ); exit( 1 ); } } } else { m_bCanDrag = true; } m_nHitTime = system_time(); return; } } for ( uint i = 0 ; i < m_cIcons.size() ; ++i ) { m_cIcons[i]->Select( this, false ); } if ( pcIcon != NULL ) { m_bCanDrag = true;//.........这里部分代码省略.........
开发者ID:Ithamar,项目名称:cosmoe,代码行数:101,
示例25: ifvoidNotificationView::_LoadIcon(){ // First try to get the icon from the caller application app_info info; BMessenger msgr = fDetails->ReturnAddress(); if (msgr.IsValid()) be_roster->GetRunningAppInfo(msgr.Team(), &info); else if (fType == B_PROGRESS_NOTIFICATION) be_roster->GetAppInfo("application/x-vnd.Haiku-notification_server", &info); BPath path; path.SetTo(&info.ref); fBitmap = _ReadNodeIcon(path.Path(), fParent->IconSize()); if (fBitmap) return; // If that failed get icons from app_server if (find_directory(B_BEOS_SERVERS_DIRECTORY, &path) != B_OK) return; path.Append("app_server"); BFile file(path.Path(), B_READ_ONLY); if (file.InitCheck() != B_OK) return; BResources res(&file); if (res.InitCheck() != B_OK) return; // Which one should we choose? const char* iconName = ""; switch (fType) { case B_INFORMATION_NOTIFICATION: iconName = "info"; break; case B_ERROR_NOTIFICATION: iconName = "stop"; break; case B_IMPORTANT_NOTIFICATION: iconName = "warn"; break; default: return; } // Allocate the bitmap fBitmap = new BBitmap(BRect(0, 0, (float)B_LARGE_ICON - 1, (float)B_LARGE_ICON - 1), B_RGBA32); if (!fBitmap || fBitmap->InitCheck() != B_OK) { fBitmap = NULL; return; } // Load raw icon data size_t size = 0; const uint8* data = (const uint8*)res.LoadResource(B_VECTOR_ICON_TYPE, iconName, &size); if ((data == NULL || BIconUtils::GetVectorIcon(data, size, fBitmap) != B_OK)) fBitmap = NULL;}
开发者ID:mariuz,项目名称:haiku,代码行数:66,
示例26: NodeHarnessWinvoidNodeHarnessApp::ReadyToRun(){ BWindow* win = new NodeHarnessWin(BRect(100, 200, 210, 330), "ToneProducer"); win->Show();}
开发者ID:DonCN,项目名称:haiku,代码行数:6,
示例27: BViewStatusView::StatusView() : BView(NULL, B_WILL_DRAW), fCurrentFileInfo(NULL){ SetViewColor(kPieBGColor); SetLowColor(kPieBGColor); fSizeView = new BStringView(NULL, kEmptyStr); fSizeView->SetExplicitMinSize(BSize(StringWidth("9999.99 GiB"), B_SIZE_UNSET)); fSizeView->SetExplicitMaxSize(BSize(StringWidth("9999.99 GiB"), B_SIZE_UNSET)); char testLabel[256]; snprintf(testLabel, sizeof(testLabel), B_TRANSLATE_COMMENT("%d files", "For UI layouting only, use the longest plural form for your language"), 999999); fCountView = new BStringView(NULL, kEmptyStr); float width, height; fCountView->GetPreferredSize(&width, &height); fCountView->SetExplicitMinSize(BSize(StringWidth(testLabel), B_SIZE_UNSET)); fCountView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height)); fPathView = new BStringView(NULL, kEmptyStr); fPathView->GetPreferredSize(&width, &height); fPathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height)); fRefreshBtn = new BButton(NULL, B_TRANSLATE("Scan"), new BMessage(kBtnRescan)); fRefreshBtn->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED)); BBox* divider1 = new BBox(BRect(), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER); BBox* divider2 = new BBox(BRect(), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER); divider1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1)); divider2->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED)); SetLayout(new BGroupLayout(B_VERTICAL)); AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 0) .AddGroup(B_VERTICAL, 0) .Add(fPathView) .Add(divider1) .AddGroup(B_HORIZONTAL, 0) .Add(fCountView) .Add(divider2) .Add(fSizeView) .End() .End() .AddStrut(kSmallHMargin) .Add(fRefreshBtn) .SetInsets(kSmallVMargin, kSmallVMargin, kSmallVMargin, kSmallVMargin) );}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:61,
示例28: strcpyvoidTListItem::DrawItem(BView *owner, BRect r, bool /* complete */){ if (IsSelected()) { owner->SetHighColor(180, 180, 180); owner->SetLowColor(180, 180, 180); } else { owner->SetHighColor(255, 255, 255); owner->SetLowColor(255, 255, 255); } owner->FillRect(r); owner->SetHighColor(0, 0, 0); BFont font = *be_plain_font; font.SetSize(font.Size() * kPlainFontSizeScale); owner->SetFont(&font); owner->MovePenTo(r.left + 24, r.bottom - 4); if (fComponent) { // if it's already a mail component, we don't have an icon to // draw, and the entry_ref is invalid BMailAttachment *attachment = dynamic_cast<BMailAttachment *>(fComponent); char name[B_FILE_NAME_LENGTH * 2]; if ((attachment == NULL) || (attachment->FileName(name) < B_OK)) strcpy(name, "unnamed"); BMimeType type; if (fComponent->MIMEType(&type) == B_OK) sprintf(name + strlen(name), ", Type: %s", type.Type()); owner->DrawString(name); BRect iconRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1); BBitmap bitmap(iconRect, B_COLOR_8_BIT); if (GetTrackerIcon(type, &bitmap, B_MINI_ICON) == B_NO_ERROR) { BRect rect(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15); owner->SetDrawingMode(B_OP_OVER); owner->DrawBitmap(&bitmap, iconRect, rect); owner->SetDrawingMode(B_OP_COPY); } else { // ToDo: find some nicer image for this :-) owner->SetHighColor(150, 150, 150); owner->FillEllipse(BRect(r.left + 8, r.top + 4, r.left + 16, r.top + 13)); } return; } BFile file(&fRef, O_RDONLY); BEntry entry(&fRef); BPath path; if (entry.GetPath(&path) == B_OK && file.InitCheck() == B_OK) { owner->DrawString(path.Path()); BNodeInfo info(&file); BRect sr(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1); BBitmap bitmap(sr, B_COLOR_8_BIT); if (info.GetTrackerIcon(&bitmap, B_MINI_ICON) == B_NO_ERROR) { BRect dr(r.left + 4, r.top + 1, r.left + 4 + 15, r.top + 1 + 15); owner->SetDrawingMode(B_OP_OVER); owner->DrawBitmap(&bitmap, sr, dr); owner->SetDrawingMode(B_OP_COPY); } } else owner->DrawString("<missing attachment>");}
开发者ID:mmanley,项目名称:Antares,代码行数:68,
注:本文中的BRect函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ BSLS_ASSERT函数代码示例 C++ BROADCAST函数代码示例 |