11#import <Cocoa/Cocoa.h>
13#if defined IGRAPHICS_GL
14#import <QuartzCore/QuartzCore.h>
17#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
18#import <libEGL/libEGL.h>
19#import <libGLESv2/angle_gl.h>
22#include "IGraphicsMac.h"
23#include "IGraphicsStructs.h"
26BEGIN_IGRAPHICS_NAMESPACE
31 const float x = floor(bounds.L * scale);
32 const float y = floor(bounds.T * scale);
33 const float x2 = ceil(bounds.R * scale);
34 const float y2 = ceil(bounds.B * scale);
36 return NSMakeRect(x, y, x2 - x, y2 - y);
42 const float x = pNSRect->origin.x;
43 const float y = pNSRect->origin.y;
44 const float w = pNSRect->size.width;
45 const float h = pNSRect->size.height;
47 return IRECT(x * scale, y * scale, (x + w) * scale, (y + h) * scale);
50inline NSColor* ToNSColor(
const IColor& c)
52 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];
55inline IColor FromNSColor(
const NSColor* c)
57 return IColor(c.alphaComponent * 255., c.redComponent* 255., c.greenComponent * 255., c.blueComponent * 255.);
62 return pGraphics->GetMouseOver();
65END_IGRAPHICS_NAMESPACE
69@interface IGRAPHICS_FORMATTER : NSFormatter
71 NSCharacterSet* filterCharacterSet;
76- (void) setAcceptableCharacterSet: (NSCharacterSet*) pCharacterSet;
77- (void) setMaximumLength:(
int) inLength;
78- (void) setMaximumValue:(
int) inValue;
82@interface IGRAPHICS_TEXTFIELDCELL : NSTextFieldCell
84 BOOL mIsEditingOrSelecting;
90using namespace igraphics;
92@interface IGRAPHICS_MENU : NSMenu
96- (id) initWithIPopupMenuAndReceiver: (
IPopupMenu*) pMenu : (NSView*) pView;
101@interface IGRAPHICS_MENU_RCVR : NSView
103 NSMenuItem* nsMenuItem;
105- (void) onMenuSelection:(
id)sender;
106- (NSMenuItem*) menuItem;
109@interface IGRAPHICS_TEXTFIELD : NSTextField
112- (bool) becomeFirstResponder;
115#if defined IGRAPHICS_GL2 || defined IGRAPHICS_GL3
116#define VIEW_BASE NSOpenGLView
118#define VIEW_BASE NSView
121@interface IGRAPHICS_VIEW : VIEW_BASE <NSTextFieldDelegate, NSDraggingSource>
123 CVDisplayLinkRef mDisplayLink;
124 dispatch_source_t mDisplaySource;
127 NSTrackingArea* mTrackingArea;
128 IGRAPHICS_TEXTFIELD* mTextFieldView;
129 NSCursor* mMoveCursor;
130 float mPrevX, mPrevY;
131 bool mMouseOutDuringDrag;
133 IColorPickerHandlerFunc mColorPickerFunc;
135#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
136 EGLDisplay mEGLDisplay;
137 EGLSurface mEGLSurface;
138 EGLContext mEGLContext;
146- (BOOL) acceptsFirstResponder;
147- (BOOL) acceptsFirstMouse: (NSEvent*) pEvent;
148- (void) viewDidMoveToWindow;
149- (void) viewDidChangeBackingProperties: (NSNotification*) pNotification;
150- (void) drawRect: (NSRect) bounds;
153- (void) onTimer: (NSTimer*) pTimer;
154- (void) viewDidChangeEffectiveAppearance;
156- (void) getMouseXY: (NSEvent*) pEvent : (
float&) x : (
float&) y;
157- (
IMouseInfo) getMouseLeft: (NSEvent*) pEvent;
158- (
IMouseInfo) getMouseRight: (NSEvent*) pEvent;
159- (void) updateTrackingAreas;
160- (void) mouseEntered:(NSEvent*) pEvent;
161- (void) mouseExited:(NSEvent*) pEvent;
162- (void) mouseDown: (NSEvent*) pEvent;
163- (void) mouseUp: (NSEvent*) pEvent;
164- (void) mouseDragged: (NSEvent*) pEvent;
165- (void) rightMouseDown: (NSEvent*) pEvent;
166- (void) rightMouseUp: (NSEvent*) pEvent;
167- (void) rightMouseDragged: (NSEvent*) pEvent;
168- (void) mouseMoved: (NSEvent*) pEvent;
169- (void) scrollWheel: (NSEvent*) pEvent;
170- (void) keyDown: (NSEvent*) pEvent;
171- (void) keyUp: (NSEvent*) pEvent;
173- (void) removeFromSuperview;
174- (void) controlTextDidEndEditing: (NSNotification*) pNotification;
175- (void) createTextEntry: (
int) paramIdx : (const
IText&) text : (const
char*) str : (
int) length : (NSRect) areaRect;
176- (void) endUserInput;
180- (BOOL) promptForColor: (
IColor&) color : (IColorPickerHandlerFunc) func;
181- (void) onColorPicked: (NSColorPanel*) pColorPanel;
184- (NSString*) view: (NSView*) pView stringForToolTip: (NSToolTipTag) tag point: (NSPoint) point userData: (
void*) pData;
185- (void) registerToolTip: (
IRECT&) bounds;
187- (NSDragOperation) draggingEntered: (
id <NSDraggingInfo>) sender;
188- (BOOL) performDragOperation: (
id<NSDraggingInfo>) sender;
189- (NSDragOperation)draggingSession:(NSDraggingSession*) session sourceOperationMaskForDraggingContext:(NSDraggingContext)context;
191- (void) setMouseCursor: (ECursor) cursorType;
194- (void) activateGLContext;
195- (void) deactivateGLContext;
197#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
198- (EGLDisplay) getEGLDisplay;
199- (EGLSurface) getEGLSurface;
200- (EGLContext) getEGLContext;
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,...