Improved combo box look with other minor changes

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19487 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
qmathe 2004-06-09 10:34:33 +00:00
parent 2e5ad2655d
commit 31234d376f
3 changed files with 45 additions and 19 deletions

View file

@ -1,3 +1,10 @@
2004-06-09 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSComboBoxCell.m: Improved look, added constrained height and
minor documentation change.
* Source/NSComboBox.m: Added constrained height and minor documentation
change.
2004-06-08 Fred Kiefer <FredKiefer@gmx.de> 2004-06-08 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m: (-drawWithFrame:inView:) * Source/NSCell.m: (-drawWithFrame:inView:)
@ -11,15 +18,17 @@
* Source/GSTitleView.m: (-drawRect:) * Source/GSTitleView.m: (-drawRect:)
* Source/NSBrowser.m: (-drawRect:, [GSBrowserTitleCell drawWithFrame:inView:]) * Source/NSBrowser.m: (-drawRect:, [GSBrowserTitleCell drawWithFrame:inView:])
Use GSDrawingFunction methods instead of NS functions. Also Use GSDrawingFunction methods instead of NS functions. Also
changed colour of progress indicatore. Patch by Nicholas Roard changed colour of progress indicatore. Patch by Nicolas Roard
<nicolas@roard.com>. <nicolas@roard.com>.
2004-06-07 Quentin Mathe <qmathe@club-internet.fr> 2004-06-07 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSComboBoxCell.m: Added complete documentation.
* Source/NSComboBoxCell.m: Added complete documentation.
* Source/NSComboBox.m: Minor documentation corrections. * Source/NSComboBox.m: Minor documentation corrections.
2004-06-06 Quentin Mathe <qmathe@club-internet.fr> 2004-06-06 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSComboBox.m: Added complete documentation.
* Source/NSComboBox.m: Added complete documentation.
2004-06-04 Fred Kiefer <FredKiefer@gmx.de> 2004-06-04 Fred Kiefer <FredKiefer@gmx.de>

View file

@ -42,7 +42,7 @@ static NSNotificationCenter *nc;
An NSComboBox is what we can call a completion/choices box, derived from An NSComboBox is what we can call a completion/choices box, derived from
NSTextField, it allows you to enter text like in a text field but also to click NSTextField, it allows you to enter text like in a text field but also to click
in the ellipsis button (indicating the fact other user inputs are possible) on in the ellipsis button (indicating the fact other user inputs are possible) on
the right of it to obtain a list of choices whose you can use as the text field the right of it to obtain a list of choices, you can use them as the text field
value by selecting a row in this list. You can also obtain direct completion value by selecting a row in this list. You can also obtain direct completion
when it is enabled via <code>setCompletes:</code> to get a suggested text when it is enabled via <code>setCompletes:</code> to get a suggested text
field value updated as you type. field value updated as you type.
@ -463,4 +463,12 @@ static NSNotificationCenter *nc;
[super mouseDown: theEvent]; [super mouseDown: theEvent];
} }
- (void) setFrame: (NSRect)frame
{
NSRect rect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.width, 21);
// FIX ME: We shouldn't harcode the height value
[super setFrame: rect];
}
@end @end

View file

@ -33,6 +33,7 @@
#include <Foundation/NSAutoreleasePool.h> #include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSValue.h> #include <Foundation/NSValue.h>
#include "AppKit/NSApplication.h" #include "AppKit/NSApplication.h"
#include "AppKit/NSBezierPath.h"
#include "AppKit/NSBox.h" #include "AppKit/NSBox.h"
#include "AppKit/NSBrowser.h" #include "AppKit/NSBrowser.h"
#include "AppKit/NSBrowserCell.h" #include "AppKit/NSBrowserCell.h"
@ -49,6 +50,7 @@
#include "AppKit/NSTableColumn.h" #include "AppKit/NSTableColumn.h"
#include "AppKit/NSTableView.h" #include "AppKit/NSTableView.h"
#include "AppKit/NSTextView.h" #include "AppKit/NSTextView.h"
#include "GNUstepGUI/GSDrawFunctions.h"
static NSNotificationCenter *nc; static NSNotificationCenter *nc;
static const BOOL ForceBrowser = NO; static const BOOL ForceBrowser = NO;
@ -707,7 +709,7 @@ numberOfRowsInColumn: (int)column
An NSComboBoxCell is what we can call a completion/choices box cell, derived from An NSComboBoxCell is what we can call a completion/choices box cell, derived from
NSTextFieldCell, it allows you to enter text like in a text field but also to click NSTextFieldCell, it allows you to enter text like in a text field but also to click
in the ellipsis button (indicating the fact other user inputs are possible) on in the ellipsis button (indicating the fact other user inputs are possible) on
the right of it to obtain a list of choices whose you can use as the text field the right of it to obtain a list of choices, you can use them as the text field
value by selecting a row in this list. You can also obtain direct completion value by selecting a row in this list. You can also obtain direct completion
when it is enabled via <code>setCompletes:</code> to get a suggested text when it is enabled via <code>setCompletes:</code> to get a suggested text
field value updated as you type. field value updated as you type.
@ -1301,25 +1303,28 @@ numberOfRowsInColumn: (int)column
_completes = completes; _completes = completes;
} }
#define ComboBoxHeight 21 // FIX ME: All this stuff shouldn't be hardcoded
// Inlined methods // Inlined methods
#define ButtonWidth 18 #define ButtonWidth 17
#define BorderWidth 2 #define ButtonHeight 17
#define BorderSize 2
// the inset border for the top and the bottom of the button // the inset border for the top and the bottom of the button
static inline NSRect textCellFrameFromRect(NSRect cellRect) static inline NSRect textCellFrameFromRect(NSRect cellRect)
// Not the drawed part, precises just the part which receives events
{ {
return NSMakeRect(NSMinX(cellRect), return NSMakeRect(NSMinX(cellRect),
NSMinY(cellRect), NSMinY(cellRect),
NSWidth(cellRect) - ButtonWidth, NSWidth(cellRect) - ButtonWidth - BorderSize,
NSHeight(cellRect)); NSHeight(cellRect));
} }
static inline NSRect buttonCellFrameFromRect(NSRect cellRect) static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
{ {
return NSMakeRect(NSMaxX(cellRect) - ButtonWidth, return NSMakeRect(NSMaxX(cellRect) - ButtonWidth - BorderSize,
NSMinY(cellRect) + BorderWidth, NSMaxY(cellRect) - ButtonHeight - BorderSize,
ButtonWidth, ButtonWidth,
NSHeight(cellRect) - (BorderWidth * 2.0)); ButtonHeight);
} }
// Overridden // Overridden
@ -1336,17 +1341,19 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView - (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{ {
NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight);
// FIX ME: Is this test case below with the method call really needed ? // FIX ME: Is this test case below with the method call really needed ?
if ([GSCurrentContext() isDrawingToScreen]) if ([GSCurrentContext() isDrawingToScreen])
{ {
[super drawWithFrame: textCellFrameFromRect(cellFrame) [super drawWithFrame: rect
inView: controlView]; inView: controlView];
[_buttonCell drawWithFrame: buttonCellFrameFromRect(cellFrame) [_buttonCell drawWithFrame: buttonCellFrameFromRect(rect)
inView: controlView]; inView: controlView];
} }
else else
{ {
[super drawWithFrame: cellFrame inView: controlView]; [super drawWithFrame: rect inView: controlView];
} }
_lastValidFrame = cellFrame; // Used by GSComboWindow to appear in the right position _lastValidFrame = cellFrame; // Used by GSComboWindow to appear in the right position
@ -1356,19 +1363,21 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
withFrame: (NSRect)cellFrame withFrame: (NSRect)cellFrame
inView: (NSView *)controlView inView: (NSView *)controlView
{ {
NSRect rect = NSMakeRect(cellFrame.origin.x, cellFrame.origin.y, cellFrame.size.width, ComboBoxHeight);
// FIX ME: Is this test case below with the method call really needed ? // FIX ME: Is this test case below with the method call really needed ?
if ([GSCurrentContext() isDrawingToScreen]) if ([GSCurrentContext() isDrawingToScreen])
{ {
[super highlight: flag [super highlight: flag
withFrame: textCellFrameFromRect(cellFrame) withFrame: textCellFrameFromRect(rect)
inView: controlView]; inView: controlView];
[_buttonCell highlight: flag [_buttonCell highlight: flag
withFrame: buttonCellFrameFromRect(cellFrame) withFrame: buttonCellFrameFromRect(rect)
inView: controlView]; inView: controlView];
} }
else else
{ {
[super highlight: flag withFrame: cellFrame inView: controlView]; [super highlight: flag withFrame: rect inView: controlView];
} }
} }