enable control size management on CPButton, CPPopUpButton, CPCheckbox, CPDatePicker, CPTexteField, CPStepper
@@ -199,6 +199,19 @@ CPButtonImageOffset = 3.0;
|
||||
[self setButtonType:CPMomentaryPushInButton];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
[super setControlSize:aControlSize];
|
||||
[self sizeToControlSize];
|
||||
[self setFont:[CPFont systemFontForControlSize:[self controlSize]]];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
// Setting the state
|
||||
/*!
|
||||
Returns a Boolean value indicating whether the button allows a mixed state.
|
||||
|
||||
@@ -198,8 +198,12 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
return self;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
|
||||
/*!
|
||||
Returns the scroller's control size
|
||||
Returns the control's control size
|
||||
*/
|
||||
- (CPControlSize)controlSize
|
||||
{
|
||||
@@ -207,8 +211,8 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the scroller's size.
|
||||
@param aControlSize the scroller's size
|
||||
Sets the control's size.
|
||||
@param aControlSize the control's size
|
||||
*/
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
@@ -223,6 +227,10 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
[self setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Gets the current theme state according to the current controlSize.
|
||||
@return a CPThemeState
|
||||
*/
|
||||
- (CPThemeState)controlSizeThemeState
|
||||
{
|
||||
switch(_controlSize)
|
||||
@@ -239,6 +247,29 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ignore
|
||||
Change frame size according to the theme control size theme constraints
|
||||
Basically for height to min-size.
|
||||
*/
|
||||
- (void)sizeToControlSize
|
||||
{
|
||||
var frameSize = [self frameSize],
|
||||
minSize = [self currentValueForThemeAttribute:@"min-size"],
|
||||
maxSize = [self currentValueForThemeAttribute:@"max-size"];
|
||||
|
||||
if (minSize.width > 0)
|
||||
frameSize.width = MAX(minSize.width, frameSize.width);
|
||||
|
||||
if (minSize.height > 0)
|
||||
frameSize.height = minSize.height;
|
||||
|
||||
[super setFrameSize:frameSize];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
|
||||
/*!
|
||||
Sets the receiver's target action.
|
||||
|
||||
|
||||
@@ -224,6 +224,16 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
[super setControlSize:aControlSize];
|
||||
[self sizeToControlSize];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Delegate methods
|
||||
|
||||
@@ -253,16 +263,6 @@ CPEraDatePickerElementFlag = 0x0100;
|
||||
|
||||
if (_datePickerStyle == CPTextFieldAndStepperDatePickerStyle || _datePickerStyle == CPTextFieldDatePickerStyle)
|
||||
{
|
||||
var frameSize = [self frameSize],
|
||||
minSize = [self currentValueForThemeAttribute:@"min-size"];
|
||||
|
||||
if (minSize.height > 0.0)
|
||||
{
|
||||
// Force height
|
||||
frameSize.height = minSize.height;
|
||||
[self setFrameSize:frameSize];
|
||||
}
|
||||
|
||||
[_datePickerTextfield setHidden:NO];
|
||||
[_datePickerCalendar setHidden:YES];
|
||||
[_datePickerTextfield setControlSize:[self controlSize]];
|
||||
|
||||
@@ -227,21 +227,19 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Control Size
|
||||
|
||||
- (void)setControlSize:(CPControlSize)aControlSize
|
||||
{
|
||||
[super setControlSize:aControlSize];
|
||||
|
||||
var frameSize = [self frameSize],
|
||||
maxSize = [self currentValueForThemeAttribute:@"max-size"],
|
||||
font = [self currentValueForThemeAttribute:@"font"];
|
||||
|
||||
if (maxSize.height > 0)
|
||||
frameSize.height = maxSize.height;
|
||||
|
||||
[self setFrameSize:frameSize];
|
||||
[self sizeToControlSize];
|
||||
[self setFont:[CPFont systemFontForControlSize:[self controlSize]]];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
- (DOMElement)_inputElement
|
||||
|
||||
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 3.6 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 3.2 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.4 KiB |