diff options
author | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 12:29:49 +0000 |
---|---|---|
committer | Vladimir Glazounov <vg@openoffice.org> | 2008-08-18 12:29:49 +0000 |
commit | 6ac1428d5b9577c3d83077f26a1eddfe56ef2c24 (patch) | |
tree | 084365ca5df191b5d80b00bd9004fd301f22f29b /vcl | |
parent | c1057053677157770a13710e3054d062bb091c87 (diff) |
INTEGRATION: CWS aquaupdateicon (1.5.42); FILE MERGED
2008/07/31 13:55:07 pl 1.5.42.2: #i92043# refactor for tiger, which has problems with NSStatusItems at exit, so use one and only one
2008/07/29 17:39:19 pl 1.5.42.1: #i92043# add: native menubar add buttons
Diffstat (limited to 'vcl')
-rwxr-xr-x | vcl/aqua/source/window/salnsmenu.mm | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/vcl/aqua/source/window/salnsmenu.mm b/vcl/aqua/source/window/salnsmenu.mm index 4135efa87a1f..4778bc2f71d5 100755 --- a/vcl/aqua/source/window/salnsmenu.mm +++ b/vcl/aqua/source/window/salnsmenu.mm @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: salnsmenu.mm,v $ - * $Revision: 1.5 $ + * $Revision: 1.6 $ * * This file is part of OpenOffice.org. * @@ -92,9 +92,7 @@ const AquaSalFrame* pFrame = mpMenuItem->mpParentMenu ? mpMenuItem->mpParentMenu->getFrame() : NULL; if( pFrame && AquaSalFrame::isAlive( pFrame ) && ! pFrame->GetWindow()->IsInModalMode() ) { - SalMenuEvent aMenuEvt; - aMenuEvt.mnId = mpMenuItem->mnId; - aMenuEvt.mpMenu = mpMenuItem->mpVCLMenu; + SalMenuEvent aMenuEvt( mpMenuItem->mnId, mpMenuItem->mpVCLMenu ); pFrame->CallCallback(SALEVENT_MENUCOMMAND, &aMenuEvt); } else if( mpMenuItem->mpVCLMenu ) @@ -131,3 +129,88 @@ } @end +@implementation OOStatusItemView +-(void)drawRect: (NSRect)aRect +{ + NSGraphicsContext* pContext = [NSGraphicsContext currentContext]; + [pContext saveGraphicsState]; + [SalData::getStatusItem() drawStatusBarBackgroundInRect: aRect withHighlight: NO]; + if( AquaSalMenu::pCurrentMenuBar ) + { + const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() ); + NSRect aFrame = [self frame]; + NSRect aImgRect = { { 2, 0 }, { 0, 0 } }; + for( size_t i = 0; i < rButtons.size(); ++i ) + { + NSRect aFromRect = { { 0, 0 }, + { rButtons[i].maButton.maImage.GetSizePixel().Width(), + rButtons[i].maButton.maImage.GetSizePixel().Height() } }; + aImgRect.origin.y = floor((aFrame.size.height - aFromRect.size.height)/2); + aImgRect.size = aFromRect.size; + if( rButtons[i].mpNSImage ) + [rButtons[i].mpNSImage drawInRect: aImgRect fromRect: aFromRect operation: NSCompositeSourceOver fraction: 1.0]; + aImgRect.origin.x += aFromRect.size.width + 2; + } + } + [pContext restoreGraphicsState]; +} + +-(void)mouseUp: (NSEvent *)pEvent +{ + /* check if button goes up inside one of our status buttons */ + if( AquaSalMenu::pCurrentMenuBar ) + { + const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() ); + NSRect aFrame = [self frame]; + NSRect aImgRect = { { 2, 0 }, { 0, 0 } }; + NSPoint aMousePt = [pEvent locationInWindow]; + for( size_t i = 0; i < rButtons.size(); ++i ) + { + NSRect aFromRect = { { 0, 0 }, + { rButtons[i].maButton.maImage.GetSizePixel().Width(), + rButtons[i].maButton.maImage.GetSizePixel().Height() } }; + aImgRect.origin.y = (aFrame.size.height - aFromRect.size.height)/2; + aImgRect.size = aFromRect.size; + if( aMousePt.x >= aImgRect.origin.x && aMousePt.x <= (aImgRect.origin.x+aImgRect.size.width) && + aMousePt.y >= aImgRect.origin.y && aMousePt.y <= (aImgRect.origin.y+aImgRect.size.height) ) + { + if( AquaSalMenu::pCurrentMenuBar->mpFrame && AquaSalFrame::isAlive( AquaSalMenu::pCurrentMenuBar->mpFrame ) ) + { + SalMenuEvent aMenuEvt( rButtons[i].maButton.mnId, AquaSalMenu::pCurrentMenuBar->mpVCLMenu ); + AquaSalMenu::pCurrentMenuBar->mpFrame->CallCallback(SALEVENT_MENUBUTTONCOMMAND, &aMenuEvt); + } + return; + } + + aImgRect.origin.x += aFromRect.size.width + 2; + } + } +} + +-(void)layout +{ + NSStatusBar* pStatBar = [NSStatusBar systemStatusBar]; + NSSize aSize = { 0, [pStatBar thickness] }; + [self removeAllToolTips]; + if( AquaSalMenu::pCurrentMenuBar ) + { + const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() ); + if( ! rButtons.empty() ) + { + aSize.width = 2; + for( size_t i = 0; i < rButtons.size(); ++i ) + { + NSRect aImgRect = { { aSize.width, floor((aSize.height-rButtons[i].maButton.maImage.GetSizePixel().Height())/2) }, + { rButtons[i].maButton.maImage.GetSizePixel().Width(), + rButtons[i].maButton.maImage.GetSizePixel().Height() } }; + if( rButtons[i].mpToolTipString ) + [self addToolTipRect: aImgRect owner: rButtons[i].mpToolTipString userData: NULL]; + aSize.width += 2 + aImgRect.size.width; + } + } + } + [self setFrameSize: aSize]; +} +@end + + |