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#ifdef IGRAPHICS_ACCESSKIT
119BEGIN_IGRAPHICS_NAMESPACE
122class IGraphicsAccessibilityMac :
public IGraphicsAccessibility
125 IGraphicsAccessibilityMac(
IGraphics& graphics, NSView* pView);
126 ~IGraphicsAccessibilityMac();
129 void SetViewFocused(
bool focused);
130 NSArray* GetChildren();
132 id HitTest(NSPoint point);
135 void UpdateIfActive(accesskit_tree_update_factory factory,
void* pUserData)
override;
138 accesskit_macos_adapter* mAdapter =
nullptr;
139 bool mViewFocused =
false;
142END_IGRAPHICS_NAMESPACE
146#if defined IGRAPHICS_GL2 || defined IGRAPHICS_GL3
147#define VIEW_BASE NSOpenGLView
149#define VIEW_BASE NSView
152@interface IGRAPHICS_VIEW : VIEW_BASE <NSTextFieldDelegate, NSDraggingSource>
154 CVDisplayLinkRef mDisplayLink;
155 dispatch_source_t mDisplaySource;
158 NSTrackingArea* mTrackingArea;
159 IGRAPHICS_TEXTFIELD* mTextFieldView;
160 NSCursor* mMoveCursor;
161 float mPrevX, mPrevY;
162 bool mMouseOutDuringDrag;
164 IColorPickerHandlerFunc mColorPickerFunc;
166#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
167 EGLDisplay mEGLDisplay;
168 EGLSurface mEGLSurface;
169 EGLContext mEGLContext;
174#ifdef IGRAPHICS_ACCESSKIT
175 IGraphicsAccessibilityMac* mAccessibility;
179#ifdef IGRAPHICS_ACCESSKIT
180- (void) updateAccessibilityFocus;
183- (BOOL) acceptsFirstResponder;
184- (BOOL) acceptsFirstMouse: (NSEvent*) pEvent;
185- (void) viewDidMoveToWindow;
186- (void) viewDidChangeBackingProperties: (NSNotification*) pNotification;
187- (void) drawRect: (NSRect) bounds;
190- (void) onTimer: (NSTimer*) pTimer;
191- (void) viewDidChangeEffectiveAppearance;
193- (void) getMouseXY: (NSEvent*) pEvent : (
float&) x : (
float&) y;
194- (
IMouseInfo) getMouseLeft: (NSEvent*) pEvent;
195- (
IMouseInfo) getMouseRight: (NSEvent*) pEvent;
196- (void) updateTrackingAreas;
197- (void) mouseEntered:(NSEvent*) pEvent;
198- (void) mouseExited:(NSEvent*) pEvent;
199- (void) mouseDown: (NSEvent*) pEvent;
200- (void) mouseUp: (NSEvent*) pEvent;
201- (void) mouseDragged: (NSEvent*) pEvent;
202- (void) rightMouseDown: (NSEvent*) pEvent;
203- (void) rightMouseUp: (NSEvent*) pEvent;
204- (void) rightMouseDragged: (NSEvent*) pEvent;
205- (void) mouseMoved: (NSEvent*) pEvent;
206- (void) scrollWheel: (NSEvent*) pEvent;
207- (void) keyDown: (NSEvent*) pEvent;
208- (void) keyUp: (NSEvent*) pEvent;
210- (void) removeFromSuperview;
211- (void) controlTextDidEndEditing: (NSNotification*) pNotification;
212- (void) createTextEntry: (
int) paramIdx : (const
IText&) text : (const
char*) str : (
int) length : (NSRect) areaRect;
213- (void) endUserInput;
217- (BOOL) promptForColor: (
IColor&) color : (IColorPickerHandlerFunc) func;
218- (void) onColorPicked: (NSColorPanel*) pColorPanel;
221- (NSString*) view: (NSView*) pView stringForToolTip: (NSToolTipTag) tag point: (NSPoint) point userData: (
void*) pData;
222- (void) registerToolTip: (
IRECT&) bounds;
224- (NSDragOperation) draggingEntered: (
id <NSDraggingInfo>) sender;
225- (BOOL) performDragOperation: (
id<NSDraggingInfo>) sender;
226- (NSDragOperation)draggingSession:(NSDraggingSession*) session sourceOperationMaskForDraggingContext:(NSDraggingContext)context;
228- (void) setMouseCursor: (ECursor) cursorType;
231- (void) activateGLContext;
232- (void) deactivateGLContext;
234#if defined IGRAPHICS_GLES2 || defined IGRAPHICS_GLES3
235- (EGLDisplay) getEGLDisplay;
236- (EGLSurface) getEGLSurface;
237- (EGLContext) getEGLContext;
Bridges the IGraphics control hierarchy to platform accessibility APIs, via AccessKit (https://access...
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,...