salnsmenu.mm (79aad27f) salnsmenu.mm (cd426cce)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 123 unchanged lines hidden (view full) ---

132 [SalData::getStatusItem() drawStatusBarBackgroundInRect: aRect withHighlight: NO];
133 if( AquaSalMenu::pCurrentMenuBar )
134 {
135 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
136 NSRect aFrame = [self frame];
137 NSRect aImgRect = { { 2, 0 }, { 0, 0 } };
138 for( size_t i = 0; i < rButtons.size(); ++i )
139 {
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 123 unchanged lines hidden (view full) ---

132 [SalData::getStatusItem() drawStatusBarBackgroundInRect: aRect withHighlight: NO];
133 if( AquaSalMenu::pCurrentMenuBar )
134 {
135 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
136 NSRect aFrame = [self frame];
137 NSRect aImgRect = { { 2, 0 }, { 0, 0 } };
138 for( size_t i = 0; i < rButtons.size(); ++i )
139 {
140 NSRect aFromRect = { { 0, 0 },
141 { rButtons[i].maButton.maImage.GetSizePixel().Width(),
142 rButtons[i].maButton.maImage.GetSizePixel().Height() } };
140 const Size aPixSize = rButtons[i].maButton.maImage.GetSizePixel();
141 const NSRect aFromRect = NSMakeRect( 0, 0, aPixSize.Width(), aPixSize.Height());
143 aImgRect.origin.y = floor((aFrame.size.height - aFromRect.size.height)/2);
144 aImgRect.size = aFromRect.size;
145 if( rButtons[i].mpNSImage )
146 [rButtons[i].mpNSImage drawInRect: aImgRect fromRect: aFromRect operation: NSCompositeSourceOver fraction: 1.0];
147 aImgRect.origin.x += aFromRect.size.width + 2;
148 }
149 }
150 [pContext restoreGraphicsState];

--- 5 unchanged lines hidden (view full) ---

156 if( AquaSalMenu::pCurrentMenuBar )
157 {
158 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
159 NSRect aFrame = [self frame];
160 NSRect aImgRect = { { 2, 0 }, { 0, 0 } };
161 NSPoint aMousePt = [pEvent locationInWindow];
162 for( size_t i = 0; i < rButtons.size(); ++i )
163 {
142 aImgRect.origin.y = floor((aFrame.size.height - aFromRect.size.height)/2);
143 aImgRect.size = aFromRect.size;
144 if( rButtons[i].mpNSImage )
145 [rButtons[i].mpNSImage drawInRect: aImgRect fromRect: aFromRect operation: NSCompositeSourceOver fraction: 1.0];
146 aImgRect.origin.x += aFromRect.size.width + 2;
147 }
148 }
149 [pContext restoreGraphicsState];

--- 5 unchanged lines hidden (view full) ---

155 if( AquaSalMenu::pCurrentMenuBar )
156 {
157 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
158 NSRect aFrame = [self frame];
159 NSRect aImgRect = { { 2, 0 }, { 0, 0 } };
160 NSPoint aMousePt = [pEvent locationInWindow];
161 for( size_t i = 0; i < rButtons.size(); ++i )
162 {
164 NSRect aFromRect = { { 0, 0 },
165 { rButtons[i].maButton.maImage.GetSizePixel().Width(),
166 rButtons[i].maButton.maImage.GetSizePixel().Height() } };
163 const Size aPixSize = rButtons[i].maButton.maImage.GetSizePixel();
164 const NSRect aFromRect = NSMakeRect( 0, 0, aPixSize.Width(), aPixSize.Height());
167 aImgRect.origin.y = (aFrame.size.height - aFromRect.size.height)/2;
168 aImgRect.size = aFromRect.size;
169 if( aMousePt.x >= aImgRect.origin.x && aMousePt.x <= (aImgRect.origin.x+aImgRect.size.width) &&
170 aMousePt.y >= aImgRect.origin.y && aMousePt.y <= (aImgRect.origin.y+aImgRect.size.height) )
171 {
172 if( AquaSalMenu::pCurrentMenuBar->mpFrame && AquaSalFrame::isAlive( AquaSalMenu::pCurrentMenuBar->mpFrame ) )
173 {
174 SalMenuEvent aMenuEvt( rButtons[i].maButton.mnId, AquaSalMenu::pCurrentMenuBar->mpVCLMenu );

--- 15 unchanged lines hidden (view full) ---

190 if( AquaSalMenu::pCurrentMenuBar )
191 {
192 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
193 if( ! rButtons.empty() )
194 {
195 aSize.width = 2;
196 for( size_t i = 0; i < rButtons.size(); ++i )
197 {
165 aImgRect.origin.y = (aFrame.size.height - aFromRect.size.height)/2;
166 aImgRect.size = aFromRect.size;
167 if( aMousePt.x >= aImgRect.origin.x && aMousePt.x <= (aImgRect.origin.x+aImgRect.size.width) &&
168 aMousePt.y >= aImgRect.origin.y && aMousePt.y <= (aImgRect.origin.y+aImgRect.size.height) )
169 {
170 if( AquaSalMenu::pCurrentMenuBar->mpFrame && AquaSalFrame::isAlive( AquaSalMenu::pCurrentMenuBar->mpFrame ) )
171 {
172 SalMenuEvent aMenuEvt( rButtons[i].maButton.mnId, AquaSalMenu::pCurrentMenuBar->mpVCLMenu );

--- 15 unchanged lines hidden (view full) ---

188 if( AquaSalMenu::pCurrentMenuBar )
189 {
190 const std::vector< AquaSalMenu::MenuBarButtonEntry >& rButtons( AquaSalMenu::pCurrentMenuBar->getButtons() );
191 if( ! rButtons.empty() )
192 {
193 aSize.width = 2;
194 for( size_t i = 0; i < rButtons.size(); ++i )
195 {
198 NSRect aImgRect = { { aSize.width, floor((aSize.height-rButtons[i].maButton.maImage.GetSizePixel().Height())/2) },
199 { rButtons[i].maButton.maImage.GetSizePixel().Width(),
200 rButtons[i].maButton.maImage.GetSizePixel().Height() } };
196 const Size aPixSize = rButtons[i].maButton.maImage.GetSizePixel();
197 const int nY = floor( aSize.height - aPixSize.Height() ) / 2;
198 NSRect aImgRect = NSMakeRect( aSize.width, nY, aPixSize.Width(), aPixSize.Height());
201 if( rButtons[i].mpToolTipString )
202 [self addToolTipRect: aImgRect owner: rButtons[i].mpToolTipString userData: NULL];
203 aSize.width += 2 + aImgRect.size.width;
204 }
205 }
206 }
207 [self setFrameSize: aSize];
208}
209@end
210
211
199 if( rButtons[i].mpToolTipString )
200 [self addToolTipRect: aImgRect owner: rButtons[i].mpToolTipString userData: NULL];
201 aSize.width += 2 + aImgRect.size.width;
202 }
203 }
204 }
205 [self setFrameSize: aSize];
206}
207@end
208
209