mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 05:20:59 +00:00
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:
parent
d5fd123408
commit
85e186ecd2
6 changed files with 39 additions and 29 deletions
|
@ -35,7 +35,6 @@
|
||||||
@class NSEvent;
|
@class NSEvent;
|
||||||
|
|
||||||
@interface NSCursor : NSObject <NSCoding>
|
@interface NSCursor : NSObject <NSCoding>
|
||||||
|
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
NSImage *cursor_image;
|
NSImage *cursor_image;
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
- initTextCell:(NSString *)aString
|
- initTextCell:(NSString *)aString
|
||||||
{
|
{
|
||||||
[super initTextCell:aString];
|
[super initTextCell:aString];
|
||||||
altContents = @"Button";
|
altContents = nil;
|
||||||
[self setButtonType:NSMomentaryPushButton];
|
[self setButtonType:NSMomentaryPushButton];
|
||||||
[self setEnabled:YES];
|
[self setEnabled:YES];
|
||||||
[self setTransparent:NO];
|
[self setTransparent:NO];
|
||||||
|
@ -264,9 +264,20 @@
|
||||||
[self setShowsStateBy:NSContentsCellMask];
|
[self setShowsStateBy:NSContentsCellMask];
|
||||||
break;
|
break;
|
||||||
case NSSwitchButton:
|
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:
|
case NSRadioButton:
|
||||||
[self setHighlightsBy:NSContentsCellMask];
|
[self setHighlightsBy:NSContentsCellMask];
|
||||||
[self setShowsStateBy:NSContentsCellMask];
|
[self setShowsStateBy:NSContentsCellMask];
|
||||||
|
[self setImage:[NSImage imageNamed:@"common_RadioOff"]];
|
||||||
|
[self setAlternateImage:[NSImage imageNamed:@"common_RadioOn"]];
|
||||||
|
[self setImagePosition:NSImageLeft];
|
||||||
|
[self setAlignment:NSLeftTextAlignment];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@
|
||||||
cell_font = [[NSFont userFontOfSize:12] retain];
|
cell_font = [[NSFont userFontOfSize:12] retain];
|
||||||
contents = aString;
|
contents = aString;
|
||||||
cell_type = NSTextCellType;
|
cell_type = NSTextCellType;
|
||||||
text_align = NSLeftTextAlignment;
|
text_align = NSCenterTextAlignment;
|
||||||
cell_image = nil;
|
cell_image = nil;
|
||||||
image_position = NSNoImage;
|
image_position = NSNoImage;
|
||||||
cell_state = NO;
|
cell_state = NO;
|
||||||
|
|
|
@ -26,11 +26,11 @@
|
||||||
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <Foundation/NSArray.h>
|
||||||
#include <AppKit/NSCursor.h>
|
#include <AppKit/NSCursor.h>
|
||||||
#include <gnustep/base/Stack.h>
|
|
||||||
|
|
||||||
// Class variables
|
// Class variables
|
||||||
static Stack *gnustep_gui_cursor_stack;
|
static NSMutableArray *gnustep_gui_cursor_stack;
|
||||||
static NSCursor *gnustep_gui_current_cursor;
|
static NSCursor *gnustep_gui_current_cursor;
|
||||||
static BOOL gnustep_gui_hidden_until_move;
|
static BOOL gnustep_gui_hidden_until_move;
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ static BOOL gnustep_gui_hidden_until_move;
|
||||||
[self setVersion:1];
|
[self setVersion:1];
|
||||||
|
|
||||||
// Initialize class variables
|
// 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_hidden_until_move = YES;
|
||||||
gnustep_gui_current_cursor = [NSCursor arrowCursor];
|
gnustep_gui_current_cursor = [NSCursor arrowCursor];
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,15 @@ static BOOL gnustep_gui_hidden_until_move;
|
||||||
+ (void)pop
|
+ (void)pop
|
||||||
{
|
{
|
||||||
// The object we pop is the current cursor
|
// The object we pop is the current cursor
|
||||||
if (![gnustep_gui_cursor_stack isEmpty])
|
if ([gnustep_gui_cursor_stack count]) {
|
||||||
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack popObject];
|
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
|
// If the stack isn't empty then get the new current cursor
|
||||||
// Otherwise the cursor will stay the same
|
// Otherwise the cursor will stay the same
|
||||||
if (![gnustep_gui_cursor_stack isEmpty])
|
if ([gnustep_gui_cursor_stack count])
|
||||||
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack topObject];
|
gnustep_gui_current_cursor = [gnustep_gui_cursor_stack lastObject];
|
||||||
|
|
||||||
[self currentCursorHasChanged];
|
[self currentCursorHasChanged];
|
||||||
}
|
}
|
||||||
|
@ -188,7 +190,7 @@ static BOOL gnustep_gui_hidden_until_move;
|
||||||
|
|
||||||
- (void)push
|
- (void)push
|
||||||
{
|
{
|
||||||
[gnustep_gui_cursor_stack pushObject: self];
|
[gnustep_gui_cursor_stack addObject: self];
|
||||||
gnustep_gui_current_cursor = self;
|
gnustep_gui_current_cursor = self;
|
||||||
[NSCursor currentCursorHasChanged];
|
[NSCursor currentCursorHasChanged];
|
||||||
}
|
}
|
||||||
|
@ -214,13 +216,10 @@ static BOOL gnustep_gui_hidden_until_move;
|
||||||
//
|
//
|
||||||
- (void)encodeWithCoder:aCoder
|
- (void)encodeWithCoder:aCoder
|
||||||
{
|
{
|
||||||
[super encodeWithCoder:aCoder];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- initWithCoder:aDecoder
|
- initWithCoder:aDecoder
|
||||||
{
|
{
|
||||||
[super initWithCoder:aDecoder];
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,8 +161,8 @@ set_repd_for_rep(NSMutableArray *_reps, NSImageRep *rep, rep_data_t *new_repd)
|
||||||
main = [NSBundle mainBundle];
|
main = [NSBundle mainBundle];
|
||||||
ext = extension(aName);
|
ext = extension(aName);
|
||||||
|
|
||||||
NSLog(@"search locally\n");
|
NSDebugLog(@"search locally\n");
|
||||||
NSLog(@"extension is %s\n", [ext cString]);
|
NSDebugLog(@"extension is %s\n", [ext cString]);
|
||||||
/* First search locally */
|
/* First search locally */
|
||||||
if (ext)
|
if (ext)
|
||||||
path = [main pathForResource: aName ofType: 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];
|
array = [self imageFileTypes];
|
||||||
if (!array)
|
if (!array)
|
||||||
NSLog(@"array is nil\n");
|
NSDebugLog(@"array is nil\n");
|
||||||
e = [array objectEnumerator];
|
e = [array objectEnumerator];
|
||||||
while ((o = [e nextObject]))
|
while ((o = [e nextObject]))
|
||||||
{
|
{
|
||||||
NSLog(@"extension %s\n", [o cString]);
|
NSDebugLog(@"extension %s\n", [o cString]);
|
||||||
path = [main pathForResource:aName
|
path = [main pathForResource:aName
|
||||||
ofType: o];
|
ofType: o];
|
||||||
if ([path length] != 0)
|
if ([path length] != 0)
|
||||||
|
@ -201,11 +201,11 @@ set_repd_for_rep(NSMutableArray *_reps, NSImageRep *rep, rep_data_t *new_repd)
|
||||||
|
|
||||||
array = [self imageFileTypes];
|
array = [self imageFileTypes];
|
||||||
if (!array)
|
if (!array)
|
||||||
NSLog(@"array is nil\n");
|
NSDebugLog(@"array is nil\n");
|
||||||
e = [array objectEnumerator];
|
e = [array objectEnumerator];
|
||||||
while ((o = [e nextObject]))
|
while ((o = [e nextObject]))
|
||||||
{
|
{
|
||||||
NSLog(@"extension %s, array = %@\n", [o cString], dirsArray);
|
NSDebugLog(@"extension %s, array = %@\n", [o cString], dirsArray);
|
||||||
path = [NSBundle pathForResource: aName
|
path = [NSBundle pathForResource: aName
|
||||||
ofType: o
|
ofType: o
|
||||||
inDirectories:dirsArray];
|
inDirectories:dirsArray];
|
||||||
|
|
|
@ -55,9 +55,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#include <gnustep/base/preface.h>
|
//#include <gnustep/base/preface.h>
|
||||||
#include <gnustep/gui/config.h>
|
|
||||||
#include <Foundation/NSString.h>
|
#include <Foundation/NSString.h>
|
||||||
#include <Foundation/NSUtilities.h>
|
#include <Foundation/NSUtilities.h>
|
||||||
|
#include <gnustep/gui/config.h>
|
||||||
|
#include <gnustep/gui/LogFile.h>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -80,7 +81,7 @@ static tsize_t
|
||||||
TiffHandleRead(thandle_t handle, tdata_t buf, toff_t count)
|
TiffHandleRead(thandle_t handle, tdata_t buf, toff_t count)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
printf("TiffHandleRead\n");
|
NSDebugLog (@"TiffHandleRead\n");
|
||||||
if (chand->position >= chand->size)
|
if (chand->position >= chand->size)
|
||||||
return 0;
|
return 0;
|
||||||
if (chand->position + count > chand->size)
|
if (chand->position + count > chand->size)
|
||||||
|
@ -93,7 +94,7 @@ static tsize_t
|
||||||
TiffHandleWrite(thandle_t handle, tdata_t buf, toff_t count)
|
TiffHandleWrite(thandle_t handle, tdata_t buf, toff_t count)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
printf("TiffHandleWrite\n");
|
NSDebugLog (@"TiffHandleWrite\n");
|
||||||
if (chand->mode == "r")
|
if (chand->mode == "r")
|
||||||
return 0;
|
return 0;
|
||||||
if (chand->position + count > chand->size)
|
if (chand->position + count > chand->size)
|
||||||
|
@ -113,7 +114,7 @@ static toff_t
|
||||||
TiffHandleSeek(thandle_t handle, toff_t offset, int mode)
|
TiffHandleSeek(thandle_t handle, toff_t offset, int mode)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
printf("TiffHandleSeek\n");
|
NSDebugLog (@"TiffHandleSeek\n");
|
||||||
switch(mode)
|
switch(mode)
|
||||||
{
|
{
|
||||||
case SEEK_SET: chand->position = offset; break;
|
case SEEK_SET: chand->position = offset; break;
|
||||||
|
@ -132,7 +133,7 @@ TiffHandleClose(thandle_t handle)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
|
|
||||||
printf("TiffHandleClose\n");
|
NSDebugLog (@"TiffHandleClose\n");
|
||||||
/* Presumably, we don't need the handle anymore */
|
/* Presumably, we don't need the handle anymore */
|
||||||
OBJC_FREE(chand);
|
OBJC_FREE(chand);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -142,7 +143,7 @@ static toff_t
|
||||||
TiffHandleSize(thandle_t handle)
|
TiffHandleSize(thandle_t handle)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
printf("TiffHandleSize\n");
|
NSDebugLog (@"TiffHandleSize\n");
|
||||||
return chand->size;
|
return chand->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +152,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
|
||||||
{
|
{
|
||||||
chandle_t* chand = (chandle_t *)handle;
|
chandle_t* chand = (chandle_t *)handle;
|
||||||
|
|
||||||
printf("TiffHandleMap\n");
|
NSDebugLog (@"TiffHandleMap\n");
|
||||||
*data = chand->data;
|
*data = chand->data;
|
||||||
*size = chand->size;
|
*size = chand->size;
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ TiffHandleMap(thandle_t handle, tdata_t* data, toff_t* size)
|
||||||
static void
|
static void
|
||||||
TiffHandleUnmap(thandle_t handle, tdata_t data, toff_t size)
|
TiffHandleUnmap(thandle_t handle, tdata_t data, toff_t size)
|
||||||
{
|
{
|
||||||
printf("TiffHandleUnmap\n");
|
NSDebugLog (@"TiffHandleUnmap\n");
|
||||||
/* Nothing to unmap. */
|
/* Nothing to unmap. */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,7 +172,7 @@ NSTiffOpenData(char* data, long size, const char* mode,
|
||||||
realloc_data_callback* realloc_data)
|
realloc_data_callback* realloc_data)
|
||||||
{
|
{
|
||||||
chandle_t* handle;
|
chandle_t* handle;
|
||||||
printf("NSTiffOpenData\n");
|
NSDebugLog (@"NSTiffOpenData\n");
|
||||||
OBJC_MALLOC(handle, chandle_t, 1);
|
OBJC_MALLOC(handle, chandle_t, 1);
|
||||||
handle->data = data;
|
handle->data = data;
|
||||||
handle->position = 0;
|
handle->position = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue