11#import <Cocoa/Cocoa.h>
13#if defined IGRAPHICS_GL
14#import <QuartzCore/QuartzCore.h>
17#include "IGraphicsMac.h"
18#include "IGraphicsStructs.h"
21BEGIN_IGRAPHICS_NAMESPACE
26 const float x = floor(bounds.L * scale);
27 const float y = floor(bounds.T * scale);
28 const float x2 = ceil(bounds.R * scale);
29 const float y2 = ceil(bounds.B * scale);
31 return NSMakeRect(x, y, x2 - x, y2 - y);
37 const float x = pNSRect->origin.x;
38 const float y = pNSRect->origin.y;
39 const float w = pNSRect->size.width;
40 const float h = pNSRect->size.height;
42 return IRECT(x * scale, y * scale, (x + w) * scale, (y + h) * scale);
45inline NSColor* ToNSColor(
const IColor& c)
47 return [NSColor colorWithDeviceRed:(double) c.R / 255.0 green:(
double) c.G / 255.0 blue:(double) c.B / 255.0 alpha:(
double) c.A / 255.0];
50inline IColor FromNSColor(
const NSColor* c)
52 return IColor(c.alphaComponent * 255., c.redComponent* 255., c.greenComponent * 255., c.blueComponent * 255.);
57 return pGraphics->GetMouseOver();
60END_IGRAPHICS_NAMESPACE
64@interface IGRAPHICS_FORMATTER : NSFormatter
66 NSCharacterSet* filterCharacterSet;
71- (void) setAcceptableCharacterSet: (NSCharacterSet*) pCharacterSet;
72- (void) setMaximumLength:(
int) inLength;
73- (void) setMaximumValue:(
int) inValue;
77@interface IGRAPHICS_TEXTFIELDCELL : NSTextFieldCell
79 BOOL mIsEditingOrSelecting;
85using namespace igraphics;
87@interface IGRAPHICS_MENU : NSMenu
91- (id) initWithIPopupMenuAndReceiver: (
IPopupMenu*) pMenu : (NSView*) pView;
96@interface IGRAPHICS_MENU_RCVR : NSView
98 NSMenuItem* nsMenuItem;
100- (void) onMenuSelection:(
id)sender;
101- (NSMenuItem*) menuItem;
104@interface IGRAPHICS_TEXTFIELD : NSTextField
107- (bool) becomeFirstResponder;
111#define VIEW_BASE NSOpenGLView
113#define VIEW_BASE NSView
116@interface IGRAPHICS_VIEW : VIEW_BASE <NSTextFieldDelegate, NSDraggingSource>
118 CVDisplayLinkRef mDisplayLink;
119 dispatch_source_t mDisplaySource;
122 NSTrackingArea* mTrackingArea;
123 IGRAPHICS_TEXTFIELD* mTextFieldView;
124 NSCursor* mMoveCursor;
125 float mPrevX, mPrevY;
126 bool mMouseOutDuringDrag;
128 IColorPickerHandlerFunc mColorPickerFunc;
134- (BOOL) acceptsFirstResponder;
135- (BOOL) acceptsFirstMouse: (NSEvent*) pEvent;
136- (void) viewDidMoveToWindow;
137- (void) viewDidChangeBackingProperties: (NSNotification*) pNotification;
138- (void) drawRect: (NSRect) bounds;
141- (void) onTimer: (NSTimer*) pTimer;
142- (void) viewDidChangeEffectiveAppearance;
144- (void) getMouseXY: (NSEvent*) pEvent : (
float&) x : (
float&) y;
145- (
IMouseInfo) getMouseLeft: (NSEvent*) pEvent;
146- (
IMouseInfo) getMouseRight: (NSEvent*) pEvent;
147- (void) updateTrackingAreas;
148- (void) mouseEntered:(NSEvent*) pEvent;
149- (void) mouseExited:(NSEvent*) pEvent;
150- (void) mouseDown: (NSEvent*) pEvent;
151- (void) mouseUp: (NSEvent*) pEvent;
152- (void) mouseDragged: (NSEvent*) pEvent;
153- (void) rightMouseDown: (NSEvent*) pEvent;
154- (void) rightMouseUp: (NSEvent*) pEvent;
155- (void) rightMouseDragged: (NSEvent*) pEvent;
156- (void) mouseMoved: (NSEvent*) pEvent;
157- (void) scrollWheel: (NSEvent*) pEvent;
158- (void) keyDown: (NSEvent*) pEvent;
159- (void) keyUp: (NSEvent*) pEvent;
161- (void) removeFromSuperview;
162- (void) controlTextDidEndEditing: (NSNotification*) pNotification;
163- (void) createTextEntry: (
int) paramIdx : (const
IText&) text : (const
char*) str : (
int) length : (NSRect) areaRect;
164- (void) endUserInput;
168- (BOOL) promptForColor: (
IColor&) color : (IColorPickerHandlerFunc) func;
169- (void) onColorPicked: (NSColorPanel*) pColorPanel;
172- (NSString*) view: (NSView*) pView stringForToolTip: (NSToolTipTag) tag point: (NSPoint) point userData: (
void*) pData;
173- (void) registerToolTip: (
IRECT&) bounds;
175- (NSDragOperation) draggingEntered: (
id <NSDraggingInfo>) sender;
176- (BOOL) performDragOperation: (
id<NSDraggingInfo>) sender;
177- (NSDragOperation)draggingSession:(NSDraggingSession*) session sourceOperationMaskForDraggingContext:(NSDraggingContext)context;
179- (void) setMouseCursor: (ECursor) cursorType;
182- (void) activateGLContext;
183- (void) deactivateGLContext;
The lowest level base class of an IGraphics context.
float GetDrawScale() const
Gets the graphics context scaling factor.
IGraphics platform class for macOS.
Used to manage a list of rectangular areas and optimize them for drawing to the screen.
Used to group mouse coordinates with mouse modifier information.
Used to manage color data, independent of draw class/platform.
Used to manage a rectangular area, independent of draw class/platform.
IText is used to manage font and text/text entry style for a piece of text on the UI,...