forked from mojbro/gocoa
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imageview: Allow adding
image.Image
s
- Loading branch information
1 parent
0fbdd13
commit 101ca94
Showing
3 changed files
with
87 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
#import "image.h" | ||
#import <Cocoa/Cocoa.h> | ||
|
||
// typedef void (*callback)(void); | ||
typedef void *ImageViewPtr; | ||
|
||
typedef void* ImageViewPtr; | ||
|
||
ImageViewPtr ImageView_New(int goImageViewID, int x, int y, int w, int h, const char* url); | ||
ImageViewPtr ImageView_New(int goImageViewID, int x, int y, int w, int h); | ||
ImageViewPtr ImageView_NewWithContentsOfURL(int goImageViewID, int x, int y, | ||
int w, int h, const char *url); | ||
void ImageView_SetAnimates(ImageViewPtr imageViewPtr, int animates); | ||
void ImageView_SetContentTintColor(ImageViewPtr imageViewPtr, int r, int g, int b, int a); | ||
void ImageView_SetContentTintColor(ImageViewPtr imageViewPtr, int r, int g, | ||
int b, int a); | ||
void ImageView_SetEditable(ImageViewPtr imageViewPtr, int editable); | ||
void ImageView_SetFrameStyle(ImageViewPtr imageViewPtr, int frameStyle); | ||
void ImageView_SetImageAlignment(ImageViewPtr imageViewPtr, int imageAlignment); | ||
void ImageView_SetImageScaling(ImageViewPtr imageViewPtr, int imageScaling); | ||
void ImageView_Remove(ImageViewPtr imageViewPtr); | ||
|
||
void ImageView_SetImage(ImageViewPtr imageViewPtr, ImagePtr imagePtr); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,70 @@ | ||
#import "imageview.h" | ||
#include "_cgo_export.h" | ||
#import "image.h" | ||
|
||
ButtonPtr ImageView_New(int goButtonID, int x, int y, int w, int h, const char* url) { | ||
NSImage *theImage = [[NSImage alloc] initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithUTF8String:url]]]; | ||
ImageViewPtr ImageView_New(int goButtonID, int x, int y, int w, int h) { | ||
id nsImageView = | ||
[[[NSImageView alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease]; | ||
|
||
id nsImageView = [[[NSImageView alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease]; | ||
[nsImageView setImage:theImage]; | ||
return (ImageViewPtr)nsImageView; | ||
} | ||
|
||
ImageViewPtr ImageView_NewWithContentsOfURL(int goButtonID, int x, int y, int w, | ||
int h, const char *url) { | ||
NSImage *theImage = [[NSImage alloc] | ||
initWithContentsOfURL:[NSURL | ||
URLWithString:[NSString | ||
stringWithUTF8String:url]]]; | ||
|
||
id nsImageView = | ||
[[[NSImageView alloc] initWithFrame:NSMakeRect(x, y, w, h)] autorelease]; | ||
[nsImageView setImage:theImage]; | ||
|
||
return (ImageViewPtr)nsImageView; | ||
return (ImageViewPtr)nsImageView; | ||
} | ||
|
||
void ImageView_SetFrameStyle(ImageViewPtr imageViewPtr, int frameStyle) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setImageFrameStyle:frameStyle]; | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setImageFrameStyle:frameStyle]; | ||
} | ||
|
||
void ImageView_SetImageAlignment(ImageViewPtr imageViewPtr, int imageAlignment) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setImageAlignment:imageAlignment]; | ||
void ImageView_SetImageAlignment(ImageViewPtr imageViewPtr, | ||
int imageAlignment) { | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setImageAlignment:imageAlignment]; | ||
} | ||
|
||
void ImageView_SetImageScaling(ImageViewPtr imageViewPtr, int imageScaling) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setImageScaling:imageScaling]; | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setImageScaling:imageScaling]; | ||
} | ||
|
||
void ImageView_SetAnimates(ImageViewPtr imageViewPtr, int animates) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setAnimates:animates]; | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setAnimates:animates]; | ||
} | ||
|
||
void ImageView_SetContentTintColor(ImageViewPtr imageViewPtr, int r, int g, int b, int a) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setContentTintColor:[NSColor colorWithCalibratedRed:r/255.f green:g/255.f blue:b/255.f alpha:a/255.f]]; | ||
void ImageView_SetContentTintColor(ImageViewPtr imageViewPtr, int r, int g, | ||
int b, int a) { | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setContentTintColor:[NSColor colorWithCalibratedRed:r / 255.f | ||
green:g / 255.f | ||
blue:b / 255.f | ||
alpha:a / 255.f]]; | ||
} | ||
|
||
void ImageView_SetEditable(ImageViewPtr imageViewPtr, int editable) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView setEditable:editable]; | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setEditable:editable]; | ||
} | ||
|
||
void ImageView_Remove(ImageViewPtr imageViewPtr) { | ||
NSImageView* nsImageView = (NSImageView*)imageViewPtr; | ||
[nsImageView removeFromSuperview]; | ||
} | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView removeFromSuperview]; | ||
} | ||
|
||
void ImageView_SetImage(ImageViewPtr imageViewPtr, ImagePtr imagePtr) { | ||
NSImage *theImage = (NSImage *)imagePtr; | ||
NSImageView *nsImageView = (NSImageView *)imageViewPtr; | ||
[nsImageView setImage:theImage]; | ||
} |