mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
return back horizontal menu code
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@16396 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6d9afde0d7
commit
1dfaefe6bd
3 changed files with 203 additions and 94 deletions
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
|||
2003-04-09 Serg Stoyan <stoyan@hologr.com>
|
||||
|
||||
* Source/NSMenuView.m: return back horizontal menu code.
|
||||
(sizeToFit): ditto.
|
||||
(innerRect): ditto.
|
||||
(rectOfItemAtIndex:): ditto.
|
||||
(locationForSubmenu:): ditto.
|
||||
(setWindowFrameForAttachingToRect:): ditto.
|
||||
(encodeWithCoder:): ditto.
|
||||
(initWithCoder:): ditto.
|
||||
(setHorizontal:): added.
|
||||
(isHorizontal): added.
|
||||
|
||||
* Headers/NSMenuView.h:
|
||||
(setHorizontal:): added.
|
||||
(isHorizontal): added.
|
||||
|
||||
2003-04-09 00:38 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
* Source/NSView.m (-setNeedsDisplay:, -setNeedsDisplayInRect:):
|
||||
|
|
|
@ -67,7 +67,8 @@
|
|||
</item>
|
||||
<item>
|
||||
Vertically stacked menus with the WindowMaker submenu placement. This
|
||||
behaviour is selected by choosing the <strong>GSWindowMakerInterfaceStyle</strong>.
|
||||
behaviour is selected by choosing the
|
||||
<strong>GSWindowMakerInterfaceStyle</strong>.
|
||||
</item>
|
||||
<item>
|
||||
PopupButtons are actually menus. This class implements also the
|
||||
|
@ -127,6 +128,19 @@
|
|||
*/
|
||||
- (NSMenu *) menu;
|
||||
|
||||
/**
|
||||
Sets menu orientation. If YES menu items are displayed from left
|
||||
to right, if NO from top to bottom (vertically). By default, menu
|
||||
items are displayed vertically.
|
||||
*/
|
||||
- (void) setHorizontal: (BOOL)flag;
|
||||
|
||||
/**
|
||||
Returns YES if menu items are displayed horizontally, NO if
|
||||
vertically.
|
||||
*/
|
||||
- (BOOL) isHorizontal;
|
||||
|
||||
/**
|
||||
Sets the default font to use when drawing the menu text.
|
||||
*/
|
||||
|
|
|
@ -216,6 +216,18 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
return _menu;
|
||||
}
|
||||
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
- (void) setHorizontal: (BOOL)flag
|
||||
{
|
||||
_horizontal = flag;
|
||||
}
|
||||
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
- (BOOL) isHorizontal
|
||||
{
|
||||
return _horizontal;
|
||||
}
|
||||
|
||||
- (void) setFont: (NSFont*)font
|
||||
{
|
||||
ASSIGN(_font, font);
|
||||
|
@ -633,11 +645,22 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
_keyEqOffset = _cellSize.width - _keyEqWidth - popupImageWidth;
|
||||
}
|
||||
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
[self setFrameSize: NSMakeSize(_cellSize.width + _leftBorderOffset,
|
||||
(howMany * _cellSize.height)
|
||||
+ menuBarHeight)];
|
||||
[_titleView setFrame: NSMakeRect (0, howMany * _cellSize.height,
|
||||
NSWidth (_bounds), menuBarHeight)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setFrameSize: NSMakeSize((howMany * _cellSize.width),
|
||||
_cellSize.height + _leftBorderOffset)];
|
||||
[_titleView setFrame: NSMakeRect (0, 0,
|
||||
_cellSize.width, _cellSize.height + 1)];
|
||||
}
|
||||
|
||||
_needsSizing = NO;
|
||||
}
|
||||
|
@ -691,12 +714,23 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
}
|
||||
|
||||
- (NSRect) innerRect
|
||||
{
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
return NSMakeRect (_bounds.origin.x + _leftBorderOffset,
|
||||
_bounds.origin.y,
|
||||
_bounds.size.width - _leftBorderOffset,
|
||||
_bounds.size.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSMakeRect (_bounds.origin.x,
|
||||
_bounds.origin.y + _leftBorderOffset,
|
||||
_bounds.size.width,
|
||||
_bounds.size.height - _leftBorderOffset);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSRect) rectOfItemAtIndex: (int)index
|
||||
{
|
||||
|
@ -710,8 +744,17 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
/* Fiddle with the origin so that the item rect is shifted 1 pixel over
|
||||
* so we do not draw on the heavy line at origin.x = 0.
|
||||
*/
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
theRect.origin.y = _cellSize.height * ([_itemCells count] - index - 1);
|
||||
theRect.origin.x = _leftBorderOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
theRect.origin.x = _cellSize.width * index;
|
||||
theRect.origin.y = 0;
|
||||
}
|
||||
theRect.size = _cellSize;
|
||||
|
||||
/* NOTE: This returns the correct NSRect for drawing cells, but nothing
|
||||
|
@ -763,6 +806,9 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
else
|
||||
submenuFrame = NSZeroRect;
|
||||
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
if (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil)
|
||||
== GSWindowMakerInterfaceStyle)
|
||||
{
|
||||
|
@ -781,6 +827,17 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
NSMaxY(frame) - NSHeight(submenuFrame));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSRect aRect = [self rectOfItemAtIndex:
|
||||
[_menu indexOfItemWithSubmenu: aSubmenu]];
|
||||
NSPoint subOrigin = [_window convertBaseToScreen:
|
||||
NSMakePoint(NSMinX(aRect),
|
||||
NSMinY(aRect))];
|
||||
|
||||
return NSMakePoint(subOrigin.x, subOrigin.y - NSHeight(submenuFrame));
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resizeWindowWithMaxHeight: (float)maxHeight
|
||||
{
|
||||
|
@ -817,18 +874,35 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
{
|
||||
float f;
|
||||
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
f = screenRect.size.height * (items - 1);
|
||||
screenFrame.size.height += f + _leftBorderOffset;
|
||||
screenFrame.origin.y -= f;
|
||||
screenFrame.size.width += _leftBorderOffset;
|
||||
screenFrame.origin.x -= _leftBorderOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = screenRect.size.width * (items - 1);
|
||||
screenFrame.size.width += f;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute position for popups, if needed
|
||||
if (selectedItemIndex != -1)
|
||||
{
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
if (_horizontal == NO)
|
||||
{
|
||||
screenFrame.origin.y += screenRect.size.height * selectedItemIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenFrame.origin.x -= screenRect.size.width * selectedItemIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the frameRect
|
||||
r = [NSWindow frameRectForContentRect: screenFrame
|
||||
|
@ -1276,6 +1350,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
|
||||
[encoder encodeObject: _itemCells];
|
||||
[encoder encodeObject: _font];
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
[encoder encodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[encoder encodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[encoder encodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
}
|
||||
|
@ -1290,6 +1366,8 @@ _addLeftBorderOffsetToRect(NSRect aRect)
|
|||
withObject: self];
|
||||
|
||||
[decoder decodeValueOfObjCType: @encode(id) at: &_font];
|
||||
// FIXME: horizontal orientation related code shoul be removed
|
||||
[decoder decodeValueOfObjCType: @encode(BOOL) at: &_horizontal];
|
||||
[decoder decodeValueOfObjCType: @encode(float) at: &_horizontalEdgePad];
|
||||
[decoder decodeValueOfObjCType: @encode(NSSize) at: &_cellSize];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue