2005-11-22 10:03:32 +00:00
|
|
|
/* GdkQuartzView.m
|
|
|
|
*
|
2007-06-30 08:56:50 +00:00
|
|
|
* Copyright (C) 2005-2007 Imendio AB
|
2013-05-20 17:48:32 +00:00
|
|
|
* Copyright (C) 2011 Hiroyuki Yamamoto
|
2005-11-22 10:03:32 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2005-11-22 10:03:32 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#import "GdkQuartzView.h"
|
2010-12-23 11:59:26 +00:00
|
|
|
#include "gdkquartzwindow.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
#include "gdkprivate-quartz.h"
|
2010-06-27 08:32:12 +00:00
|
|
|
#include "gdkquartz.h"
|
2005-11-22 10:03:32 +00:00
|
|
|
|
|
|
|
@implementation GdkQuartzView
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(id)initWithFrame: (NSRect)frameRect
|
|
|
|
{
|
|
|
|
if ((self = [super initWithFrame: frameRect]))
|
|
|
|
{
|
|
|
|
markedRange = NSMakeRange (NSNotFound, 0);
|
|
|
|
selectedRange = NSMakeRange (NSNotFound, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)acceptsFirstResponder
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("acceptsFirstResponder"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)becomeFirstResponder
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("becomeFirstResponder"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)resignFirstResponder
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("resignFirstResponder"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void) keyDown: (NSEvent *) theEvent
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("keyDown"));
|
2013-05-20 17:48:32 +00:00
|
|
|
[self interpretKeyEvents: [NSArray arrayWithObject: theEvent]];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)flagsChanged: (NSEvent *) theEvent
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSUInteger)characterIndexForPoint: (NSPoint)aPoint
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("characterIndexForPoint"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSRect)firstRectForCharacterRange: (NSRange)aRange actualRange: (NSRangePointer)actualRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("firstRectForCharacterRange"));
|
2013-05-20 17:48:32 +00:00
|
|
|
gint ns_x, ns_y;
|
|
|
|
GdkRectangle *rect;
|
|
|
|
|
|
|
|
rect = g_object_get_data (G_OBJECT (gdk_window), GIC_CURSOR_RECT);
|
|
|
|
if (rect)
|
|
|
|
{
|
|
|
|
_gdk_quartz_window_gdk_xy_to_xy (rect->x, rect->y + rect->height,
|
|
|
|
&ns_x, &ns_y);
|
|
|
|
|
|
|
|
return NSMakeRect (ns_x, ns_y, rect->width, rect->height);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NSMakeRect (0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSArray *)validAttributesForMarkedText
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("validAttributesForMarkedText"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return [NSArray arrayWithObjects: NSUnderlineStyleAttributeName, nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSAttributedString *)attributedSubstringForProposedRange: (NSRange)aRange actualRange: (NSRangePointer)actualRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("attributedSubstringForProposedRange"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)hasMarkedText
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("hasMarkedText"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return markedRange.location != NSNotFound && markedRange.length != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSRange)markedRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("markedRange"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return markedRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(NSRange)selectedRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("selectedRange"));
|
2013-05-20 17:48:32 +00:00
|
|
|
return selectedRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)unmarkText
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("unmarkText"));
|
2013-07-27 20:55:39 +00:00
|
|
|
gchar *prev_str;
|
2013-05-20 17:48:32 +00:00
|
|
|
markedRange = selectedRange = NSMakeRange (NSNotFound, 0);
|
2013-07-27 20:55:39 +00:00
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (gdk_window), TIC_MARKED_TEXT, NULL, g_free);
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)setMarkedText: (id)aString selectedRange: (NSRange)newSelection replacementRange: (NSRange)replacementRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("setMarkedText"));
|
2013-05-20 17:48:32 +00:00
|
|
|
const char *str;
|
2013-07-27 20:55:39 +00:00
|
|
|
gchar *prev_str;
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
if (replacementRange.location == NSNotFound)
|
|
|
|
{
|
|
|
|
markedRange = NSMakeRange (newSelection.location, [aString length]);
|
|
|
|
selectedRange = NSMakeRange (newSelection.location, newSelection.length);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
markedRange = NSMakeRange (replacementRange.location, [aString length]);
|
|
|
|
selectedRange = NSMakeRange (replacementRange.location + newSelection.location, newSelection.length);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ([aString isKindOfClass: [NSAttributedString class]])
|
|
|
|
{
|
|
|
|
str = [[aString string] UTF8String];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
str = [aString UTF8String];
|
|
|
|
}
|
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (gdk_window), TIC_MARKED_TEXT, g_strdup (str), g_free);
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), TIC_SELECTED_POS,
|
|
|
|
GUINT_TO_POINTER (selectedRange.location));
|
|
|
|
g_object_set_data (G_OBJECT (gdk_window), TIC_SELECTED_LEN,
|
|
|
|
GUINT_TO_POINTER (selectedRange.length));
|
|
|
|
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("setMarkedText: set %s (%p, nsview %p): %s",
|
|
|
|
TIC_MARKED_TEXT, gdk_window, self,
|
|
|
|
str ? str : "(empty)"));
|
2013-08-16 16:54:34 +00:00
|
|
|
|
|
|
|
/* handle text input changes by mouse events */
|
|
|
|
if (!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (gdk_window),
|
|
|
|
TIC_IN_KEY_DOWN)))
|
|
|
|
{
|
|
|
|
_gdk_quartz_synthesize_null_key_event(gdk_window);
|
|
|
|
}
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)doCommandBySelector: (SEL)aSelector
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("doCommandBySelector"));
|
2013-08-13 18:14:29 +00:00
|
|
|
if ([self respondsToSelector: aSelector])
|
|
|
|
[self performSelector: aSelector];
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)insertText: (id)aString replacementRange: (NSRange)replacementRange
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("insertText"));
|
2013-05-20 17:48:32 +00:00
|
|
|
const char *str;
|
2013-08-16 16:54:34 +00:00
|
|
|
NSString *string;
|
2013-07-27 20:55:39 +00:00
|
|
|
gchar *prev_str;
|
2013-05-20 17:48:32 +00:00
|
|
|
|
|
|
|
if ([self hasMarkedText])
|
|
|
|
[self unmarkText];
|
|
|
|
|
|
|
|
if ([aString isKindOfClass: [NSAttributedString class]])
|
2013-08-16 16:54:34 +00:00
|
|
|
string = [aString string];
|
2013-05-20 17:48:32 +00:00
|
|
|
else
|
2013-08-16 16:54:34 +00:00
|
|
|
string = aString;
|
|
|
|
|
|
|
|
NSCharacterSet *ctrlChars = [NSCharacterSet controlCharacterSet];
|
|
|
|
NSCharacterSet *wsnlChars = [NSCharacterSet whitespaceAndNewlineCharacterSet];
|
|
|
|
if ([string rangeOfCharacterFromSet:ctrlChars].length &&
|
|
|
|
[string rangeOfCharacterFromSet:wsnlChars].length == 0)
|
2013-05-20 17:48:32 +00:00
|
|
|
{
|
2013-08-16 16:54:34 +00:00
|
|
|
/* discard invalid text input with Chinese input methods */
|
|
|
|
str = "";
|
|
|
|
[self unmarkText];
|
|
|
|
NSInputManager *currentInputManager = [NSInputManager currentInputManager];
|
|
|
|
[currentInputManager markedTextAbandoned:self];
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
2013-08-16 16:54:34 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
str = [string UTF8String];
|
|
|
|
}
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2014-07-14 15:02:13 +00:00
|
|
|
g_object_set_data_full (G_OBJECT (gdk_window), TIC_INSERT_TEXT, g_strdup (str), g_free);
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("insertText: set %s (%p, nsview %p): %s",
|
2013-05-20 17:48:32 +00:00
|
|
|
TIC_INSERT_TEXT, gdk_window, self,
|
|
|
|
str ? str : "(empty)"));
|
|
|
|
|
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_FILTERED));
|
2013-08-16 16:54:34 +00:00
|
|
|
|
|
|
|
/* handle text input changes by mouse events */
|
|
|
|
if (!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (gdk_window),
|
|
|
|
TIC_IN_KEY_DOWN)))
|
|
|
|
{
|
|
|
|
_gdk_quartz_synthesize_null_key_event(gdk_window);
|
|
|
|
}
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteBackward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteBackward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteForward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteForward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteToBeginningOfLine: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteToBeginningOfLine"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteToEndOfLine: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteToEndOfLine"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteWordBackward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteWordBackward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)deleteWordForward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("deleteWordForward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)insertBacktab: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("insertBacktab"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)insertNewline: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("insertNewline"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY, GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)insertTab: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("insertTab"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveBackward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveBackward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveBackwardAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveBackwardAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveDown: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveDown"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveDownAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveDownAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveForward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveForward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveForwardAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveForwardAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveLeft: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveLeft"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveLeftAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveLeftAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveRight: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveRight"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveRightAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveRightAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToBeginningOfDocument: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToBeginningOfDocument"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToBeginningOfDocumentAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToBeginningOfDocumentAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToBeginningOfLine: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToBeginningOfLine"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToBeginningOfLineAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToBeginningOfLineAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToEndOfDocument: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToEndOfDocument"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToEndOfDocumentAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToEndOfDocumentAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToEndOfLine: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToEndOfLine"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveToEndOfLineAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveToEndOfLineAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveUp: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveUp"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveUpAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveUpAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordBackward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordBackward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordBackwardAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordBackwardAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordForward: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordForward"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordForwardAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordForwardAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordLeft: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordLeft"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordLeftAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordLeftAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordRight: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordRight"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)moveWordRightAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("moveWordRightAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)pageDown: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("pageDown"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)pageDownAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("pageDownAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)pageUp: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("pageUp"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)pageUpAndModifySelection: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("pageUpAndModifySelection"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)selectAll: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("selectAll"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)selectLine: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("selectLine"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)selectWord: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("selectWord"));
|
2013-05-20 17:48:32 +00:00
|
|
|
g_object_set_data (G_OBJECT (gdk_window), GIC_FILTER_KEY,
|
|
|
|
GUINT_TO_POINTER (GIC_FILTER_PASSTHRU));
|
|
|
|
}
|
|
|
|
|
|
|
|
-(void)noop: (id)sender
|
|
|
|
{
|
2016-02-29 02:26:26 +00:00
|
|
|
GDK_NOTE (EVENTS, g_message ("noop"));
|
2013-05-20 17:48:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */
|
|
|
|
|
2009-12-30 13:11:14 +00:00
|
|
|
-(void)dealloc
|
|
|
|
{
|
|
|
|
if (trackingRect)
|
|
|
|
{
|
2013-05-20 17:48:32 +00:00
|
|
|
[self removeTrackingRect: trackingRect];
|
2009-12-30 13:11:14 +00:00
|
|
|
trackingRect = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[super dealloc];
|
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(void)setGdkWindow: (GdkWindow *)window
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
gdk_window = window;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(GdkWindow *)gdkWindow
|
|
|
|
{
|
|
|
|
return gdk_window;
|
|
|
|
}
|
|
|
|
|
2009-02-03 15:01:31 +00:00
|
|
|
-(NSTrackingRectTag)trackingRect
|
|
|
|
{
|
|
|
|
return trackingRect;
|
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
-(BOOL)isFlipped
|
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
-(BOOL)isOpaque
|
|
|
|
{
|
2006-09-03 10:46:32 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (gdk_window))
|
|
|
|
return YES;
|
|
|
|
|
2010-08-29 00:16:27 +00:00
|
|
|
/* A view is opaque if its GdkWindow doesn't have the RGBA visual */
|
2013-05-20 17:48:32 +00:00
|
|
|
return gdk_window_get_visual (gdk_window) !=
|
|
|
|
gdk_screen_get_rgba_visual (_gdk_screen);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(void)drawRect: (NSRect)rect
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
|
|
|
GdkRectangle gdk_rect;
|
2010-12-06 13:13:40 +00:00
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (gdk_window->impl);
|
2006-08-08 20:53:09 +00:00
|
|
|
const NSRect *drawn_rects;
|
2009-12-27 16:01:25 +00:00
|
|
|
NSInteger count;
|
|
|
|
int i;
|
2010-06-28 12:44:12 +00:00
|
|
|
cairo_region_t *region;
|
2005-11-22 10:03:32 +00:00
|
|
|
|
2006-09-03 10:46:32 +00:00
|
|
|
if (GDK_WINDOW_DESTROYED (gdk_window))
|
|
|
|
return;
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
if (! (gdk_window->event_mask & GDK_EXPOSURE_MASK))
|
2006-09-03 10:46:32 +00:00
|
|
|
return;
|
|
|
|
|
2008-04-30 17:50:14 +00:00
|
|
|
if (NSEqualRects (rect, NSZeroRect))
|
|
|
|
return;
|
2007-12-10 19:38:47 +00:00
|
|
|
|
2012-09-28 04:50:13 +00:00
|
|
|
if (!GDK_WINDOW_IS_MAPPED (gdk_window))
|
|
|
|
{
|
|
|
|
/* If the window is not yet mapped, clip_region_with_children
|
|
|
|
* will be empty causing the usual code below to draw nothing.
|
|
|
|
* To not see garbage on the screen, we draw an aesthetic color
|
|
|
|
* here. The garbage would be visible if any widget enabled
|
|
|
|
* the NSView's CALayer in order to add sublayers for custom
|
|
|
|
* native rendering.
|
|
|
|
*/
|
|
|
|
[NSGraphicsContext saveGraphicsState];
|
|
|
|
|
2012-10-04 07:06:01 +00:00
|
|
|
[[NSColor windowBackgroundColor] setFill];
|
2013-05-20 17:48:32 +00:00
|
|
|
[NSBezierPath fillRect: rect];
|
2012-09-28 04:50:13 +00:00
|
|
|
|
|
|
|
[NSGraphicsContext restoreGraphicsState];
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-20 13:27:14 +00:00
|
|
|
/* Clear our own bookkeeping of regions that need display */
|
|
|
|
if (impl->needs_display_region)
|
|
|
|
{
|
2010-06-28 12:44:12 +00:00
|
|
|
cairo_region_destroy (impl->needs_display_region);
|
2009-09-20 13:27:14 +00:00
|
|
|
impl->needs_display_region = NULL;
|
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
[self getRectsBeingDrawn: &drawn_rects count: &count];
|
2010-06-28 12:44:12 +00:00
|
|
|
region = cairo_region_create ();
|
2013-05-20 17:48:32 +00:00
|
|
|
|
2010-05-12 10:11:40 +00:00
|
|
|
for (i = 0; i < count; i++)
|
2005-11-22 10:03:32 +00:00
|
|
|
{
|
2010-05-12 10:11:40 +00:00
|
|
|
gdk_rect.x = drawn_rects[i].origin.x;
|
|
|
|
gdk_rect.y = drawn_rects[i].origin.y;
|
|
|
|
gdk_rect.width = drawn_rects[i].size.width;
|
|
|
|
gdk_rect.height = drawn_rects[i].size.height;
|
2010-06-28 12:44:12 +00:00
|
|
|
|
|
|
|
cairo_region_union_rectangle (region, &gdk_rect);
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2009-01-26 19:29:51 +00:00
|
|
|
impl->in_paint_rect_count++;
|
|
|
|
_gdk_window_process_updates_recurse (gdk_window, region);
|
|
|
|
impl->in_paint_rect_count--;
|
|
|
|
|
2010-06-28 12:44:12 +00:00
|
|
|
cairo_region_destroy (region);
|
2006-09-03 10:46:32 +00:00
|
|
|
|
2008-02-27 10:49:22 +00:00
|
|
|
if (needsInvalidateShadow)
|
|
|
|
{
|
|
|
|
[[self window] invalidateShadow];
|
|
|
|
needsInvalidateShadow = NO;
|
|
|
|
}
|
2005-11-22 10:03:32 +00:00
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(void)setNeedsInvalidateShadow: (BOOL)invalidate
|
2008-02-27 10:49:22 +00:00
|
|
|
{
|
|
|
|
needsInvalidateShadow = invalidate;
|
|
|
|
}
|
|
|
|
|
2007-06-19 22:42:51 +00:00
|
|
|
/* For information on setting up tracking rects properly, see here:
|
2007-06-19 22:09:56 +00:00
|
|
|
* http://developer.apple.com/documentation/Cocoa/Conceptual/EventOverview/EventOverview.pdf
|
|
|
|
*/
|
|
|
|
-(void)updateTrackingRect
|
|
|
|
{
|
2010-12-06 13:13:40 +00:00
|
|
|
GdkWindowImplQuartz *impl = GDK_WINDOW_IMPL_QUARTZ (gdk_window->impl);
|
2007-06-30 08:56:50 +00:00
|
|
|
NSRect rect;
|
2007-06-19 22:09:56 +00:00
|
|
|
|
2016-02-22 00:22:27 +00:00
|
|
|
if (!impl || !impl->toplevel)
|
2009-01-20 13:06:39 +00:00
|
|
|
return;
|
|
|
|
|
2007-06-19 22:09:56 +00:00
|
|
|
if (trackingRect)
|
|
|
|
{
|
2013-05-20 17:48:32 +00:00
|
|
|
[self removeTrackingRect: trackingRect];
|
2007-10-31 10:07:47 +00:00
|
|
|
trackingRect = 0;
|
2007-06-19 22:09:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!impl->toplevel)
|
|
|
|
return;
|
|
|
|
|
2007-06-30 08:56:50 +00:00
|
|
|
/* Note, if we want to set assumeInside we can use:
|
|
|
|
* NSPointInRect ([[self window] convertScreenToBase:[NSEvent mouseLocation]], rect)
|
|
|
|
*/
|
|
|
|
|
2008-01-31 14:05:47 +00:00
|
|
|
rect = [self bounds];
|
2013-05-20 17:48:32 +00:00
|
|
|
trackingRect = [self addTrackingRect: rect
|
|
|
|
owner: self
|
|
|
|
userData: nil
|
|
|
|
assumeInside: NO];
|
2007-06-19 22:09:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
-(void)viewDidMoveToWindow
|
|
|
|
{
|
|
|
|
if (![self window]) /* We are destroyed already */
|
2013-05-20 17:48:32 +00:00
|
|
|
return;
|
2007-06-19 22:09:56 +00:00
|
|
|
|
|
|
|
[self updateTrackingRect];
|
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(void)viewWillMoveToWindow: (NSWindow *)newWindow
|
2007-06-19 22:09:56 +00:00
|
|
|
{
|
2007-06-30 08:56:50 +00:00
|
|
|
if (newWindow == nil && trackingRect)
|
2007-06-19 22:09:56 +00:00
|
|
|
{
|
2013-05-20 17:48:32 +00:00
|
|
|
[self removeTrackingRect: trackingRect];
|
2007-10-31 10:07:47 +00:00
|
|
|
trackingRect = 0;
|
2007-06-19 22:09:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-20 17:48:32 +00:00
|
|
|
-(void)setFrame: (NSRect)frame
|
2007-06-19 22:09:56 +00:00
|
|
|
{
|
2013-05-20 17:48:32 +00:00
|
|
|
[super setFrame: frame];
|
2008-03-31 13:15:15 +00:00
|
|
|
|
|
|
|
if ([self window])
|
|
|
|
[self updateTrackingRect];
|
2007-06-19 22:09:56 +00:00
|
|
|
}
|
|
|
|
|
2005-11-22 10:03:32 +00:00
|
|
|
@end
|