mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-13 10:13:50 +00:00
Various nib2cib conversion improvements (sizes, autoresize, button/window styles, etc)
This commit is contained in:
1 parent
cfbdb1ce76
commit
f6b3afa75c
3 files changed
+86
-25
No files matched your search
+56
-23
@@ -28,6 +28,10 @@
|
||||
@import "NSCell.j"
|
||||
@import "NSControl.j"
|
||||
|
||||
var _CPButtonBezelStyleHeights = {};
|
||||
_CPButtonBezelStyleHeights[CPRoundedBezelStyle] = 18;
|
||||
_CPButtonBezelStyleHeights[CPTexturedRoundedBezelStyle] = 20;
|
||||
_CPButtonBezelStyleHeights[CPHUDBezelStyle] = 20;
|
||||
|
||||
@implementation CPButton (NSCoding)
|
||||
|
||||
@@ -41,10 +45,54 @@
|
||||
|
||||
var cell = [aCoder decodeObjectForKey:@"NSCell"];
|
||||
|
||||
[self setTitle:[cell title]];
|
||||
|
||||
[self setBezelStyle:[cell bezelStyle]];
|
||||
[self setBordered:[cell isBordered]];
|
||||
_title = [cell title];
|
||||
_isBordered = [cell isBordered];
|
||||
_bezelStyle = [cell bezelStyle];
|
||||
|
||||
// clean up:
|
||||
|
||||
switch (_bezelStyle)
|
||||
{
|
||||
// implemented:
|
||||
case CPRoundedBezelStyle:
|
||||
case CPTexturedRoundedBezelStyle:
|
||||
case CPHUDBezelStyle:
|
||||
break;
|
||||
// approximations:
|
||||
case CPRoundRectBezelStyle:
|
||||
_bezelStyle = CPRoundedBezelStyle;
|
||||
break;
|
||||
case CPSmallSquareBezelStyle:
|
||||
case CPThickSquareBezelStyle:
|
||||
case CPThickerSquareBezelStyle:
|
||||
case CPRegularSquareBezelStyle:
|
||||
case CPTexturedSquareBezelStyle:
|
||||
case CPShadowlessSquareBezelStyle:
|
||||
_bezelStyle = CPTexturedRoundedBezelStyle;
|
||||
break;
|
||||
case CPRecessedBezelStyle:
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// unsupported
|
||||
case CPRoundedDisclosureBezelStyle:
|
||||
case CPHelpButtonBezelStyle:
|
||||
case CPCircularBezelStyle:
|
||||
case CPDisclosureBezelStyle:
|
||||
CPLog.warn("Unsupported bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
break;
|
||||
// error:
|
||||
default:
|
||||
CPLog.error("Unknown bezel style: " + _bezelStyle);
|
||||
_bezelStyle = CPHUDBezelStyle;
|
||||
}
|
||||
|
||||
if (_CPButtonBezelStyleHeights[_bezelStyle] != undefined)
|
||||
{
|
||||
CPLog.warn("Adjusting CPButton height from " +_frame.size.height+ " / " + _bounds.size.height+" to " + _CPButtonBezelStyleHeights[_bezelStyle]);
|
||||
_frame.size.height = _CPButtonBezelStyleHeights[_bezelStyle];
|
||||
_bounds.size.height = _CPButtonBezelStyleHeights[_bezelStyle];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -68,12 +116,12 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSButtonCell : NSCell
|
||||
@implementation NSButtonCell : NSActionCell
|
||||
{
|
||||
BOOL _isBordered;
|
||||
unsigned _bezelStyle;
|
||||
BOOL _isBordered @accessors(readonly, getter=isBordered);
|
||||
int _bezelStyle @accessors(readonly, getter=bezelStyle);
|
||||
|
||||
CPString _title;
|
||||
CPString _title @accessors(readonly, getter=title);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
@@ -95,19 +143,4 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isBordered
|
||||
{
|
||||
return _isBordered;
|
||||
}
|
||||
|
||||
- (int)bezelStyle
|
||||
{
|
||||
return _bezelStyle;
|
||||
}
|
||||
|
||||
- (CPString)title
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
@end
|
||||
+16
-1
@@ -57,7 +57,22 @@
|
||||
|
||||
var vFlags = [aCoder decodeIntForKey:@"NSvFlags"];
|
||||
|
||||
_autoresizingMask = vFlags & (0x3F << 1);
|
||||
var autoresizingMaskNS = vFlags & 0x3F;
|
||||
|
||||
// swap Y coordinate flags:
|
||||
_autoresizingMask = autoresizingMaskNS & ~(CPViewMaxYMargin | CPViewMinYMargin)
|
||||
if (!(autoresizingMaskNS & (CPViewMaxYMargin | CPViewMinYMargin | CPViewHeightSizable)))
|
||||
{
|
||||
_autoresizingMask |= CPViewMinYMargin;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (autoresizingMaskNS & CPViewMaxYMargin)
|
||||
_autoresizingMask |= CPViewMinYMargin;
|
||||
if (autoresizingMaskNS & CPViewMinYMargin)
|
||||
_autoresizingMask |= CPViewMaxYMargin;
|
||||
}
|
||||
|
||||
_autoresizesSubviews = vFlags & (1 << 8);
|
||||
|
||||
_hitTests = YES;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
_maxSize = [aCoder decodeSizeForKey:@"NSMaxSize"];
|
||||
|
||||
_screenRect = [aCoder decodeRectForKey:@"NSScreenRect"]; // screen created on
|
||||
_viewClass = [aCoder decodeObjectForKey:@"NSViewClass"];
|
||||
_viewClass = [aCoder decodeObjectForKey:@"NSViewClass"]; // references the toolbar if present (anything else?)
|
||||
_wtFlags = [aCoder decodeIntForKey:@"NSWTFlags"];
|
||||
_windowBacking = [aCoder decodeIntForKey:@"NSWindowBacking"];
|
||||
|
||||
@@ -52,6 +52,19 @@
|
||||
// Flip Y coordinate
|
||||
_windowRect.origin.y = _screenRect.size.height - _windowRect.origin.y - _windowRect.size.height;
|
||||
|
||||
// Only window style so far is CPHUDBackgroundWindowMask
|
||||
_windowStyleMask |= CPHUDBackgroundWindowMask;
|
||||
|
||||
// Adjust size for HUD window - FIXME: in CPWindow.j
|
||||
if (_windowStyleMask & CPHUDBackgroundWindowMask)
|
||||
{
|
||||
CPLog.warn("Adjusting window rect.");
|
||||
_windowRect.origin.x -= 7.0;
|
||||
_windowRect.origin.y -= 30.0;
|
||||
_windowRect.size.width += 14.0;
|
||||
_windowRect.size.height += 40.0;
|
||||
}
|
||||
|
||||
/*if (![_windowClass isEqualToString:@"NSPanel"])
|
||||
_windowRect.origin.y -= [NSMainMenuView menuHeight]; // compensation for the additional menu bar
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user