Add caret
This commit is contained in:
parent
5ccb17a263
commit
5954f9280b
|
@ -24,8 +24,8 @@ Works for basic use, can navigate to, and browse websites.
|
|||
|
||||
What still needs doing
|
||||
----------------
|
||||
Cursor, tabs, iframes(for some reason),
|
||||
downloads, bookmarks, history, other bits and bobs probably.
|
||||
Tabs, iframes(for some reason), downloads, bookmarks, history,
|
||||
other bits and bobs probably.
|
||||
|
||||
|
||||
This has only been tested on OpenBSD macppc, there's probably issues with
|
||||
|
|
|
@ -13,6 +13,7 @@ struct browser_window;
|
|||
id plotView;
|
||||
id scrollView;
|
||||
id refreshButton;
|
||||
id caretView;
|
||||
enum gui_pointer_shape lastRequestedPointer;
|
||||
}
|
||||
|
||||
|
@ -28,7 +29,7 @@ struct browser_window;
|
|||
-(void)invalidateBrowser;
|
||||
-(void)invalidateBrowser: (NSRect)rect;
|
||||
-(void)updateBrowserExtent;
|
||||
-(void)placeCaretAt: (NSPoint)point withHeight: (int)height clipTo: (NSRect)clip;
|
||||
-(void)placeCaretAtX: (int)x y: (int)y height: (int)height;
|
||||
-(void)removeCaret;
|
||||
-(void)setPointerToShape: (enum gui_pointer_shape)shape;
|
||||
-(void)newContent;
|
||||
|
|
|
@ -88,11 +88,11 @@
|
|||
NSLog(@"set frame to size: %d, %d", width, height);
|
||||
[plotView setFrame: NSMakeRect(0, 0, width, height)];
|
||||
}
|
||||
-(void)placeCaretAt: (NSPoint)point withHeight: (int)height clipTo: (NSRect)clip {
|
||||
|
||||
-(void)placeCaretAtX: (int)x y: (int)y height: (int)height {
|
||||
[plotView placeCaretAtX: x y: y height: height];
|
||||
}
|
||||
-(void)removeCaret {
|
||||
|
||||
[plotView removeCaret];
|
||||
}
|
||||
-(void)setPointerToShape: (enum gui_pointer_shape)shape {
|
||||
if (shape == lastRequestedPointer)
|
||||
|
|
|
@ -6,8 +6,11 @@
|
|||
BOOL isDragging;
|
||||
NSPoint dragStart;
|
||||
NSSize lastSize;
|
||||
BOOL showCaret;
|
||||
NSRect caretRect;
|
||||
}
|
||||
|
||||
-(void)setBrowser: (void*)aBrowser;
|
||||
|
||||
-(void)placeCaretAtX: (int)x y: (int)y height: (int)height;
|
||||
-(void)removeCaret;
|
||||
@end
|
||||
|
|
|
@ -258,17 +258,37 @@ static const struct plotter_table gnustep_plotters = {
|
|||
|
||||
@implementation PlotView
|
||||
|
||||
-(id)init {
|
||||
if ((self = [super init])) {
|
||||
reallyDraw = NO;
|
||||
}
|
||||
return self;
|
||||
-(void)awakeFromNib {
|
||||
reallyDraw = NO;
|
||||
caretRect = NSMakeRect(0, 0, 1, 0);
|
||||
}
|
||||
|
||||
-(BOOL)resignFirstResponder {
|
||||
[self removeCaret];
|
||||
return [super resignFirstResponder];
|
||||
}
|
||||
|
||||
-(void)setBrowser: (void*)aBrowser {
|
||||
browser = aBrowser;
|
||||
}
|
||||
|
||||
-(void)placeCaretAtX: (int)x y: (int)y height: (int)height {
|
||||
if (showCaret) {
|
||||
[self setNeedsDisplayInRect: caretRect];
|
||||
}
|
||||
showCaret = YES;
|
||||
caretRect.origin.x = x;
|
||||
caretRect.origin.y = y;
|
||||
caretRect.size.height = height;
|
||||
NSLog(@"Caret: %@", NSStringFromRect(caretRect));
|
||||
[self setNeedsDisplayInRect: caretRect];
|
||||
}
|
||||
|
||||
-(void)removeCaret {
|
||||
showCaret = NO;
|
||||
[self setNeedsDisplayInRect: caretRect];
|
||||
}
|
||||
|
||||
/*
|
||||
* inLiveRedraw doesn't seem to be implemented so this works around it by only triggering a
|
||||
* redraw after a 0.01 sec delay. So if we're in the middle of a resize it won't do the
|
||||
|
@ -297,6 +317,10 @@ static const struct plotter_table gnustep_plotters = {
|
|||
.y1 = NSMaxY(rect)
|
||||
};
|
||||
browser_window_redraw(browser, 0, 0, &clip, &ctx);
|
||||
if (showCaret && NSIntersectsRect(rect, caretRect)) {
|
||||
[[NSColor blackColor] set];
|
||||
[NSBezierPath fillRect: caretRect];
|
||||
}
|
||||
lastSize = newSize;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,10 +112,7 @@ static void gnustep_window_set_pointer(struct gui_window *gw, enum gui_pointer_s
|
|||
}
|
||||
|
||||
static void gnustep_window_place_caret(struct gui_window *gw, int x, int y, int height, const struct rect *clip) {
|
||||
[(id)gw placeCaretAt: NSMakePoint(x, y) withHeight: height clipTo: NSMakeRect(
|
||||
clip->x0, clip->y0,
|
||||
clip->x1 - clip->x0,
|
||||
clip->y1 - clip->y0)];
|
||||
[(id)gw placeCaretAtX: x y: y height: height];
|
||||
}
|
||||
|
||||
struct gui_window_table gnustep_window_table = {
|
||||
|
|
Loading…
Reference in New Issue