Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_WindowViewCocoa.h
| Show All 19 Lines | |||||
| /* NSView subclass for drawing and handling input. | /* NSView subclass for drawing and handling input. | ||||
| * | * | ||||
| * COCOA_VIEW_BASE_CLASS will be either NSView or NSOpenGLView depending if | * COCOA_VIEW_BASE_CLASS will be either NSView or NSOpenGLView depending if | ||||
| * we use a Metal or OpenGL layer for drawing in the view. We use macros | * we use a Metal or OpenGL layer for drawing in the view. We use macros | ||||
| * to defined classes for each case, so we don't have to duplicate code as | * to defined classes for each case, so we don't have to duplicate code as | ||||
| * Objective-C does not have multiple inheritance. */ | * Objective-C does not have multiple inheritance. */ | ||||
| // We need to subclass it in order to give Cocoa the feeling key events are trapped | // We need to subclass it in order to give Cocoa the feeling key events are trapped | ||||
| @interface COCOA_VIEW_CLASS : COCOA_VIEW_BASE_CLASS <NSTextInput> | @interface COCOA_VIEW_CLASS : COCOA_VIEW_BASE_CLASS <NSTextInputClient> | ||||
| { | { | ||||
| GHOST_SystemCocoa *systemCocoa; | GHOST_SystemCocoa *systemCocoa; | ||||
| GHOST_WindowCocoa *associatedWindow; | GHOST_WindowCocoa *associatedWindow; | ||||
| bool composing; | bool composing; | ||||
| NSString *composing_text; | NSString *composing_text; | ||||
| bool immediate_draw; | bool immediate_draw; | ||||
| ▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | - (void)composing_free | ||||
| composing = NO; | composing = NO; | ||||
| if (composing_text) { | if (composing_text) { | ||||
| [composing_text release]; | [composing_text release]; | ||||
| composing_text = nil; | composing_text = nil; | ||||
| } | } | ||||
| } | } | ||||
| - (void)insertText:(id)chars | - (void)insertText:(id)chars replacementRange:(NSRange)replacementRange | ||||
| { | { | ||||
| [self composing_free]; | [self composing_free]; | ||||
| } | } | ||||
| - (void)setMarkedText:(id)chars selectedRange:(NSRange)range | - (void)setMarkedText:(id)chars selectedRange:(NSRange)range replacementRange:(NSRange)replacementRange | ||||
| { | { | ||||
| [self composing_free]; | [self composing_free]; | ||||
| if ([chars length] == 0) | if ([chars length] == 0) | ||||
| return; | return; | ||||
| // start composing | // start composing | ||||
| composing = YES; | composing = YES; | ||||
| composing_text = [chars copy]; | composing_text = [chars copy]; | ||||
| Show All 17 Lines | |||||
| { | { | ||||
| } | } | ||||
| - (BOOL)isComposing | - (BOOL)isComposing | ||||
| { | { | ||||
| return composing; | return composing; | ||||
| } | } | ||||
| - (NSInteger)conversationIdentifier | - (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)range actualRange:(NSRangePointer)actualRange | ||||
| { | |||||
| return (NSInteger)self; | |||||
| } | |||||
| - (NSAttributedString *)attributedSubstringFromRange:(NSRange)range | |||||
| { | { | ||||
| return [[[NSAttributedString alloc] init] autorelease]; | return [[[NSAttributedString alloc] init] autorelease]; | ||||
| } | } | ||||
| - (NSRange)markedRange | - (NSRange)markedRange | ||||
| { | { | ||||
| unsigned int length = (composing_text) ? [composing_text length] : 0; | unsigned int length = (composing_text) ? [composing_text length] : 0; | ||||
| if (composing) | if (composing) | ||||
| return NSMakeRange(0, length); | return NSMakeRange(0, length); | ||||
| return NSMakeRange(NSNotFound, 0); | return NSMakeRange(NSNotFound, 0); | ||||
| } | } | ||||
| - (NSRange)selectedRange | - (NSRange)selectedRange | ||||
| { | { | ||||
| unsigned int length = (composing_text) ? [composing_text length] : 0; | unsigned int length = (composing_text) ? [composing_text length] : 0; | ||||
| return NSMakeRange(0, length); | return NSMakeRange(0, length); | ||||
| } | } | ||||
| - (NSRect)firstRectForCharacterRange:(NSRange)range | - (NSRect)firstRectForCharacterRange:(NSRange)range actualRange:(NSRangePointer)actualRange | ||||
| { | { | ||||
| return NSZeroRect; | return NSZeroRect; | ||||
| } | } | ||||
| - (NSUInteger)characterIndexForPoint:(NSPoint)point | - (NSUInteger)characterIndexForPoint:(NSPoint)point | ||||
| { | { | ||||
| return NSNotFound; | return NSNotFound; | ||||
| } | } | ||||
| - (NSArray *)validAttributesForMarkedText | - (NSArray *)validAttributesForMarkedText | ||||
| { | { | ||||
| return [NSArray array]; | return [NSArray array]; | ||||
| } | } | ||||
| @end | @end | ||||