An almost complete NSButtonCell implementation.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2192 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Scott Christley 1997-02-18 18:45:16 +00:00
parent 151bf11e2c
commit c47e7d474c
6 changed files with 39 additions and 29 deletions

View file

@ -35,7 +35,6 @@
@class NSEvent;
@interface NSCursor : NSObject <NSCoding>
{
// Attributes
NSImage *cursor_image;

View file

@ -76,7 +76,7 @@
- initTextCell:(NSString *)aString
{
[super initTextCell:aString];
altContents = @"Button";
altContents = nil;
[self setButtonType:NSMomentaryPushButton];
[self setEnabled:YES];
[self setTransparent:NO];
@ -264,9 +264,20 @@
[self setShowsStateBy:NSContentsCellMask];
break;
case NSSwitchButton:
[self setHighlightsBy:NSContentsCellMask];
[self setShowsStateBy:NSContentsCellMask];
[self setImage:[NSImage imageNamed:@"common_SwitchOff"]];
[self setAlternateImage:[NSImage imageNamed:@"common_SwitchOn"]];
[self setImagePosition:NSImageLeft];
[self setAlignment:NSLeftTextAlignment];
break;
case NSRadioButton:
[self setHighlightsBy:NSContentsCellMask];
[self setShowsStateBy:NSContentsCellMask];
[self setImage:[NSImage imageNamed:@"common_RadioOff"]];
[self setAlternateImage:[NSImage imageNamed:@"common_RadioOn"]];
[self setImagePosition:NSImageLeft];
[self setAlignment:NSLeftTextAlignment];
break;
}

View file

@ -124,7 +124,7 @@
cell_font = [[NSFont userFontOfSize:12] retain];
contents = aString;
cell_type = NSTextCellType;
text_align = NSLeftTextAlignment;
text_align = NSCenterTextAlignment;
cell_image = nil;
image_position = NSNoImage;
cell_state = NO;

View file

@ -26,11 +26,11 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <Foundation/NSArray.h>
#include <AppKit/NSCursor.h>
#include <gnustep/base/Stack.h>
// Class variables
static Stack *gnustep_gui_cursor_stack;
static NSMutableArray *gnustep_gui_cursor_stack;
static NSCursor *gnustep_gui_current_cursor;
static BOOL gnustep_gui_hidden_until_move;
@ -47,7 +47,7 @@ static BOOL gnustep_gui_hidden_until_move;
[self setVersion:1];
// Initialize class variables
gnustep_gui_cursor_stack = [[Stack alloc] initWithCapacity: 2];
gnustep_gui_cursor_stack = [[NSMutableArray alloc] initWithCapacity: 2];
gnustep_gui_hidden_until_move = YES;
gnustep_gui_current_cursor = [NSCursor arrowCursor];
}
@ -63,13 +63,15 @@ static BOOL gnustep_gui_hidden_until_move;
+ (void)pop
{
// The object we pop is the current cursor
if (![gnustep_gui_cursor_stack isEmpty])
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack popObject];
if ([gnustep_gui_cursor_stack count]) {
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
[gnustep_gui_cursor_stack removeLastObject];
}
// If the stack isn't empty then get the new current cursor
// Otherwise the cursor will stay the same
if (![gnustep_gui_cursor_stack isEmpty])
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack topObject];
if ([gnustep_gui_cursor_stack count])
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
[self currentCursorHasChanged];
}
@ -188,7 +190,7 @@ static BOOL gnustep_gui_hidden_until_move;
- (void)push
{
[gnustep_gui_cursor_stack pushObject: self];
[gnustep_gui_cursor_stack addObject: self];
gnustep_gui_current_cursor = self;
[NSCursor currentCursorHasChanged];
}
@ -214,13 +216,10 @@ static BOOL gnustep_gui_hidden_until_move;
//
- (void)encodeWithCoder:aCoder
{
[super encodeWithCoder:aCoder];
}
- initWithCoder:aDecoder
{
[super initWithCoder:aDecoder];
return self;
}

View file

@ -161,8 +161,8 @@ set_repd_for_rep(NSMutableArray *_reps, NSImageRep *rep, rep_data_t *new_repd)
main = [NSBundle mainBundle];
ext = extension(aName);
NSLog(@"search locally\n");
NSLog(@"extension is %s\n", [ext cString]);
NSDebugLog(@"search locally\n");
NSDebugLog(@"extension is %s\n", [ext cString]);
/* First search locally */
if (ext)
path = [main pathForResource: aName ofType: ext];
@ -173,11 +173,11 @@ set_repd_for_rep(NSMutableArray *_reps, NSImageRep *rep, rep_data_t *new_repd)
array = [self imageFileTypes];
if (!array)
NSLog(@"array is nil\n");
NSDebugLog(@"array is nil\n");
e = [array objectEnumerator];
while ((o = [e nextObject]))
{
NSLog(@"extension %s\n", [o cString]);
NSDebugLog(@"extension %s\n", [o cString]);
path = [main pathForResource:aName
ofType: o];
if ([path length] != 0)
@ -201,11 +201,11 @@ set_repd_for_rep(NSMutableArray *_reps, NSImageRep *rep, rep_data_t *new_repd)
array = [self imageFileTypes];
if (!array)
NSLog(@"array is nil\n");
NSDebugLog(@"array is nil\n");
e = [array objectEnumerator];
while ((o = [e nextObject]))
{
NSLog(@"extension %s, array = %@\n", [o cString], dirsArray);
NSDebugLog(@"extension %s, array = %@\n", [o cString], dirsArray);
path = [NSBundle pathForResource: aName
ofType: o
inDirectories:dirsArray];

View file

@ -55,9 +55,10 @@
*/
//#include <gnustep/base/preface.h>
#include <gnustep/gui/config.h>
#include <Foundation/NSString.h>
#include <Foundation/NSUtilities.h>
#include <gnustep/gui/config.h>
#include <gnustep/gui/LogFile.h>
#include <math.h>
#include <stdlib.h>
@ -80,7 +81,7 @@ static tsize_t
TiffHandleRead(thandle_t handle, tdata_t buf, toff_t count)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleRead\n");
NSDebugLog (@"TiffHandleRead\n");
if (chand->position >= chand->size)
return 0;
if (chand->position + count > chand->size)
@ -93,7 +94,7 @@ static tsize_t
TiffHandleWrite(thandle_t handle, tdata_t buf, toff_t count)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleWrite\n");
NSDebugLog (@"TiffHandleWrite\n");
if (chand->mode == "r")
return 0;
if (chand->position + count > chand->size)
@ -113,7 +114,7 @@ static toff_t
TiffHandleSeek(thandle_t handle, toff_t offset, int mode)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleSeek\n");
NSDebugLog (@"TiffHandleSeek\n");
switch(mode)
{
case SEEK_SET: chand->position = offset; break;
@ -132,7 +133,7 @@ TiffHandleClose(thandle_t handle)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleClose\n");
NSDebugLog (@"TiffHandleClose\n");
/* Presumably, we don't need the handle anymore */
OBJC_FREE(chand);
return 0;
@ -142,7 +143,7 @@ static toff_t
TiffHandleSize(thandle_t handle)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleSize\n");
NSDebugLog (@"TiffHandleSize\n");
return chand->size;
}
@ -151,7 +152,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
{
chandle_t* chand = (chandle_t *)handle;
printf("TiffHandleMap\n");
NSDebugLog (@"TiffHandleMap\n");
*data = chand->data;
*size = chand->size;
@ -161,7 +162,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
static void
TiffHandleUnmap(thandle_t handle, tdata_t data, toff_t size)
{
printf("TiffHandleUnmap\n");
NSDebugLog (@"TiffHandleUnmap\n");
/* Nothing to unmap. */
}
@ -171,7 +172,7 @@ NSTiffOpenData(char* data, long size, const char* mode,
realloc_data_callback* realloc_data)
{
chandle_t* handle;
printf("NSTiffOpenData\n");
NSDebugLog (@"NSTiffOpenData\n");
OBJC_MALLOC(handle, chandle_t, 1);
handle->data = data;
handle->position = 0;