1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2005, Haiku, Inc. 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: MenuWindow.cpp 23 // Authors: Marc Flerackers (mflerackers@androme.be) 24 // Stefano Ceccherini (burton666@libero.it) 25 // Description: BMenuWindow is a custom BWindow for BMenus. 26 //------------------------------------------------------------------------------ 27 // TODO: Add scrollers 28 29 #include <Menu.h> 30 #include <MenuWindow.h> 31 32 // TODO: taken from Deskbar's WindowMenu.cpp. 33 // this should go to some private header. 34 const window_feel kMenuWindowFeel = (window_feel)1025; 35 36 // This draws the frame around the BMenu 37 class BMenuFrame : public BView { 38 public: 39 BMenuFrame() : 40 BView(BRect(0, 0, 1, 1), "menu frame", B_FOLLOW_ALL_SIDES, B_WILL_DRAW) 41 { 42 }; 43 44 virtual void AttachedToWindow() 45 { 46 BView::AttachedToWindow(); 47 ResizeTo(Window()->Bounds().Width(), Window()->Bounds().Height()); 48 }; 49 50 virtual void Draw(BRect updateRect) 51 { 52 BRect bounds(Bounds()); 53 54 SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT)); 55 StrokeLine(BPoint(bounds.right, bounds.top), 56 BPoint(bounds.right, bounds.bottom - 1)); 57 StrokeLine(BPoint(bounds.left + 1, bounds.bottom), 58 BPoint(bounds.right, bounds.bottom)); 59 }; 60 61 }; 62 63 64 BMenuWindow::BMenuWindow(const char *name) 65 : 66 // The window will be resized by BMenu, so just pass a dummy rect 67 //BWindow(BRect(0, 0, 0, 0), name, B_BORDERED_WINDOW_LOOK, kMenuWindowFeel, 68 // B_NOT_ZOOMABLE), 69 BWindow(BRect(0, 0, 0, 0), name, B_BORDERED_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, 70 B_NOT_ZOOMABLE|B_AVOID_FRONT|B_AVOID_FOCUS), 71 fUpperScroller(NULL), 72 fLowerScroller(NULL) 73 { 74 BMenuFrame *menuFrame = new BMenuFrame(); 75 AddChild(menuFrame); 76 } 77 78 79 BMenuWindow::~BMenuWindow() 80 { 81 } 82