mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 22:40:48 +00:00
* Source/NSSearchField.m,
* Source/NSSearchFieldCell.m: Small cleanups in formatting and int types.
This commit is contained in:
parent
4004f549d7
commit
a0f0b8b147
3 changed files with 117 additions and 121 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2020-12-12 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSSearchField.m,
|
||||||
|
* Source/NSSearchFieldCell.m: Small cleanups in formatting and
|
||||||
|
int types.
|
||||||
|
|
||||||
2020-12-11 Riccardo Mottola <rm@gnu.org>
|
2020-12-11 Riccardo Mottola <rm@gnu.org>
|
||||||
|
|
||||||
* Source/GSToolbarView.m,
|
* Source/GSToolbarView.m,
|
||||||
|
|
|
@ -46,6 +46,10 @@
|
||||||
#import "AppKit/NSSearchFieldCell.h"
|
#import "AppKit/NSSearchFieldCell.h"
|
||||||
#import "AppKit/NSWindow.h"
|
#import "AppKit/NSWindow.h"
|
||||||
|
|
||||||
|
#import "GSGuiPrivate.h"
|
||||||
|
|
||||||
|
#define ICON_WIDTH 16
|
||||||
|
|
||||||
@interface NSSearchFieldCell (Private)
|
@interface NSSearchFieldCell (Private)
|
||||||
|
|
||||||
- (NSMenu *) _buildTemplate;
|
- (NSMenu *) _buildTemplate;
|
||||||
|
@ -59,18 +63,6 @@
|
||||||
|
|
||||||
@implementation NSSearchFieldCell
|
@implementation NSSearchFieldCell
|
||||||
|
|
||||||
#define ICON_WIDTH 16
|
|
||||||
|
|
||||||
// Inlined method
|
|
||||||
|
|
||||||
static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
|
||||||
// Not the drawed part, precises just the part which receives events
|
|
||||||
{
|
|
||||||
return NSMakeRect(cellRect.origin.x + ICON_WIDTH,
|
|
||||||
NSMinY(cellRect),
|
|
||||||
NSWidth(cellRect) - 2*ICON_WIDTH,
|
|
||||||
NSHeight(cellRect));
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initTextCell: (NSString*)aString
|
- (id) initTextCell: (NSString*)aString
|
||||||
{
|
{
|
||||||
|
@ -93,7 +85,6 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
/* Don't set the searchMenuTemplate unless it is explicitly set in code or by a nib connection
|
/* Don't set the searchMenuTemplate unless it is explicitly set in code or by a nib connection
|
||||||
template = [self _buildTemplate];
|
template = [self _buildTemplate];
|
||||||
[self setSearchMenuTemplate: template];
|
[self setSearchMenuTemplate: template];
|
||||||
RELEASE(template);
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//_recent_searches = [[NSMutableArray alloc] init];
|
//_recent_searches = [[NSMutableArray alloc] init];
|
||||||
|
@ -204,7 +195,7 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
|
|
||||||
- (void) setRecentSearches: (NSArray*)searches
|
- (void) setRecentSearches: (NSArray*)searches
|
||||||
{
|
{
|
||||||
int max;
|
NSInteger max;
|
||||||
NSMutableArray *mutableSearches;
|
NSMutableArray *mutableSearches;
|
||||||
|
|
||||||
max = [self maximumRecents];
|
max = [self maximumRecents];
|
||||||
|
@ -310,8 +301,6 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
[c setEditable: NO];
|
[c setEditable: NO];
|
||||||
[c setImagePosition: NSImageOnly];
|
[c setImagePosition: NSImageOnly];
|
||||||
[c setImage: [NSImage imageNamed: @"GSSearch"]];
|
[c setImage: [NSImage imageNamed: @"GSSearch"]];
|
||||||
// [c setAction: [self action]];
|
|
||||||
// [c setTarget: [self target]];
|
|
||||||
[c setAction: @selector(performClick:)];
|
[c setAction: @selector(performClick:)];
|
||||||
[c setTarget: self];
|
[c setTarget: self];
|
||||||
[c sendActionOn: NSLeftMouseUpMask];
|
[c sendActionOn: NSLeftMouseUpMask];
|
||||||
|
@ -455,13 +444,14 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
|
|
||||||
- (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView
|
- (void) resetCursorRect: (NSRect)cellFrame inView: (NSView *)controlView
|
||||||
{
|
{
|
||||||
[super resetCursorRect: textCellFrameFromRect(cellFrame)
|
[super resetCursorRect: [self searchTextRectForBounds: cellFrame]
|
||||||
inView: controlView];
|
inView: controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textDidChange: (NSNotification *)notification
|
- (void) textDidChange: (NSNotification *)notification
|
||||||
{
|
{
|
||||||
NSText *textObject;
|
NSText *textObject;
|
||||||
|
|
||||||
[_control_view setNeedsDisplay: YES];
|
[_control_view setNeedsDisplay: YES];
|
||||||
|
|
||||||
// make textChanged send action (unless disabled)
|
// make textChanged send action (unless disabled)
|
||||||
|
@ -560,36 +550,36 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
|
|
||||||
template = [[NSMenu alloc] init];
|
template = [[NSMenu alloc] init];
|
||||||
|
|
||||||
item = [[NSMenuItem alloc] initWithTitle: @"Recent searches"
|
item = [[NSMenuItem alloc] initWithTitle: _(@"Recent searches")
|
||||||
action: NULL
|
action: NULL
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[item setTag: NSSearchFieldRecentsTitleMenuItemTag];
|
[item setTag: NSSearchFieldRecentsTitleMenuItemTag];
|
||||||
[template addItem: item];
|
[template addItem: item];
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
|
|
||||||
item = [[NSMenuItem alloc] initWithTitle: @"Recent search item"
|
item = [[NSMenuItem alloc] initWithTitle: _(@"Recent search item")
|
||||||
action: @selector(search:)
|
action: @selector(search:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[item setTag: NSSearchFieldRecentsMenuItemTag];
|
[item setTag: NSSearchFieldRecentsMenuItemTag];
|
||||||
[template addItem: item];
|
[template addItem: item];
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
|
|
||||||
item = [[NSMenuItem alloc] initWithTitle: @"Clear recent searches"
|
item = [[NSMenuItem alloc] initWithTitle: _(@"Clear recent searches")
|
||||||
action: @selector(_clearSearches:)
|
action: @selector(_clearSearches:)
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[item setTag: NSSearchFieldClearRecentsMenuItemTag];
|
[item setTag: NSSearchFieldClearRecentsMenuItemTag];
|
||||||
[item setTarget: self];
|
[item setTarget: self];
|
||||||
[template addItem: item];
|
[template addItem: item];
|
||||||
|
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
item = [[NSMenuItem alloc] initWithTitle: @"No recent searches"
|
|
||||||
|
item = [[NSMenuItem alloc] initWithTitle: _(@"No recent searches")
|
||||||
action: NULL
|
action: NULL
|
||||||
keyEquivalent: @""];
|
keyEquivalent: @""];
|
||||||
[item setTag: NSSearchFieldNoRecentsMenuItemTag];
|
[item setTag: NSSearchFieldNoRecentsMenuItemTag];
|
||||||
[template addItem: item];
|
[template addItem: item];
|
||||||
RELEASE(item);
|
RELEASE(item);
|
||||||
|
|
||||||
return template;
|
return AUTORELEASE(template);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _openPopup: (id)sender
|
- (void) _openPopup: (id)sender
|
||||||
|
@ -599,10 +589,10 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
NSMenuView *mr;
|
NSMenuView *mr;
|
||||||
NSWindow *cvWin;
|
NSWindow *cvWin;
|
||||||
NSRect cellFrame;
|
NSRect cellFrame;
|
||||||
int i;
|
NSInteger i;
|
||||||
int recentCount = [_recent_searches count];
|
NSInteger recentCount = [_recent_searches count];
|
||||||
NSPopUpButtonCell *pbcell = [[NSPopUpButtonCell alloc] initTextCell: nil pullsDown: NO];
|
NSPopUpButtonCell *pbcell = [[NSPopUpButtonCell alloc] initTextCell: nil pullsDown: NO];
|
||||||
int selectedItemIndex = -1, newSelectedItemIndex;
|
NSInteger selectedItemIndex = -1, newSelectedItemIndex;
|
||||||
|
|
||||||
template = [self searchMenuTemplate];
|
template = [self searchMenuTemplate];
|
||||||
popupmenu = [[NSMenu alloc] init];
|
popupmenu = [[NSMenu alloc] init];
|
||||||
|
@ -610,7 +600,7 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
// Fill the popup menu
|
// Fill the popup menu
|
||||||
for (i = 0; i < [template numberOfItems]; i++)
|
for (i = 0; i < [template numberOfItems]; i++)
|
||||||
{
|
{
|
||||||
int tag;
|
NSInteger tag;
|
||||||
NSMenuItem *item, *newItem = nil;
|
NSMenuItem *item, *newItem = nil;
|
||||||
|
|
||||||
item = (NSMenuItem*)[template itemAtIndex: i];
|
item = (NSMenuItem*)[template itemAtIndex: i];
|
||||||
|
@ -642,7 +632,7 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
}
|
}
|
||||||
else if (tag == NSSearchFieldRecentsMenuItemTag)
|
else if (tag == NSSearchFieldRecentsMenuItemTag)
|
||||||
{
|
{
|
||||||
int j;
|
NSInteger j;
|
||||||
|
|
||||||
for (j = 0; j < recentCount; j++)
|
for (j = 0; j < recentCount; j++)
|
||||||
{
|
{
|
||||||
|
@ -692,7 +682,7 @@ static inline NSRect textCellFrameFromRect(NSRect cellRect)
|
||||||
if (newSelectedItemIndex != selectedItemIndex && newSelectedItemIndex != -1
|
if (newSelectedItemIndex != selectedItemIndex && newSelectedItemIndex != -1
|
||||||
&& newSelectedItemIndex < [template numberOfItems])
|
&& newSelectedItemIndex < [template numberOfItems])
|
||||||
{
|
{
|
||||||
int tag = [[template itemAtIndex:newSelectedItemIndex] tag];
|
NSInteger tag = [[template itemAtIndex:newSelectedItemIndex] tag];
|
||||||
if (tag != NSSearchFieldRecentsTitleMenuItemTag && tag != NSSearchFieldClearRecentsMenuItemTag
|
if (tag != NSSearchFieldRecentsTitleMenuItemTag && tag != NSSearchFieldClearRecentsMenuItemTag
|
||||||
&& tag != NSSearchFieldNoRecentsMenuItemTag && tag != NSSearchFieldRecentsMenuItemTag
|
&& tag != NSSearchFieldNoRecentsMenuItemTag && tag != NSSearchFieldRecentsMenuItemTag
|
||||||
&& ![[template itemAtIndex:newSelectedItemIndex] isSeparatorItem])
|
&& ![[template itemAtIndex:newSelectedItemIndex] isSeparatorItem])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue