Support Forum       Library Source       SourceForge Page       G3D Web Page     
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
G3D::CarbonWindow Class Reference

Inherits G3D::OSWindow.

Public Member Functions

virtual ~CarbonWindow ()
 
virtual std::string _clipboardText () const override
 
virtual void _setClipboardText (const std::string &text) const override
 
virtual std::string caption ()
 The window title.
 
virtual std::string className () const
 
virtual Rect2D clientRect () const override
 Size of the inside of the window (the part that the program can render to)
 
virtual void decInputCaptureCount ()
 
virtual void decMouseHideCount ()
 
virtual void fireEvent (const GEvent &event)
 Inserts an event into the queue.
 
virtual Rect2D fullRect () const override
 Shape of the window, including borders.
 
std::string getAPIName () const
 Description of the windowing API for logging purposes (e.g.
 
std::string getAPIVersion () const
 Description of the windowing API for logging purposes (e.g.
 
virtual void getDroppedFilenames (Array< std::string > &files) override
 Clears the files array and then sets it to a list of all files that were dropped in the last GEventType::FILE_DROP event.
 
virtual void getJoystickState (unsigned int stickNum, Array< float > &axis, Array< bool > &buttons) const override
 Returns the state of the given joystick.
 
virtual void getRelativeMouseState (Vector2 &position, uint8 &mouseButtons) const
 Returns the current mouse position and the state of the mouse buttons.
 
virtual void getRelativeMouseState (int &x, int &y, uint8 &mouseButtons) const
 
virtual void getRelativeMouseState (double &x, double &y, uint8 &mouseButtons) const
 
virtual void getSettings (OSWindow::Settings &settings) const
 Return the actual properties of this window (as opposed to the desired settings from which it was initialized)
 
virtual bool hasFocus () const
 Returns true if this window currently has [keyboard] focus (i.e.
 
virtual int height () const
 
virtual void incInputCaptureCount ()
 
virtual void incMouseHideCount ()
 
virtual bool inputCapture () const
 
int inputCaptureCount () const
 If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.
 
virtual std::string joystickName (unsigned int stickNum) const
 The name by which the OS refers to this joystick (e.g.
 
void makeCurrent () const
 Makes the OpenGL context of this window current.
 
int mouseHideCount () const
 If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.
 
virtual bool mouseVisible () const
 
virtual int numJoysticks () const
 Returns 0 if there are no joysticks available.
 
virtual bool pollEvent (GEvent &e)
 Checks to see if any events are waiting.
 
virtual void popLoopBody ()
 Pops a loop body off the stack.
 
virtual void pushLoopBody (void(*body)(void *), void *arg)
 Pushes a function onto the stack of functions called by runMainLoop.
 
virtual void pushLoopBody (GApp *app)
 Invokes GApplet::beginRun after the applet is on the stack.
 
RenderDevicerenderDevice () const
 If a RenderDevice has been created and initialized for this window, returns that renderDevice.
 
virtual bool requiresMainLoop () const
 Windows for which this is true require a program to hand control of the main loop to OSWindow::startMainLoop.
 
virtual void runMainLoop ()
 Executes an event loop, invoking callback repeatedly.
 
virtual void setCaption (const std::string &title)
 
virtual void setClientPosition (int x, int y) override
 
virtual void setClientRect (const Rect2D &dims) override
 
virtual void setFullPosition (int x, int y) override
 Fails silently if unable to change the position.
 
virtual void setFullRect (const Rect2D &dims) override
 Fails silently if unable to change the dimensions.
 
virtual void setGammaRamp (const Array< uint16 > &gammaRamp)
 gammaRamp.length() = 256
 
virtual void setIcon (const Image::Ref &image)
 Set the icon (if supported).
 
virtual void setIcon (const std::string &imageFilename)
 
virtual void setInputCapture (bool c)
 Capture the keyboard and mouse focus, locking the mouse to the client area of this window.
 
void setInputCaptureCount (int c)
 
void setMouseHideCount (int c)
 
virtual void setMouseVisible (bool b)
 
virtual void setRelativeMousePosition (double x, double y)
 
virtual void setRelativeMousePosition (const Vector2 &p)
 Relative to the window origin.
 
virtual void swapGLBuffers ()
 Swap the OpenGL front and back buffers.
 
virtual int width () const
 Measured in pixels, this is the client area of the window.
 
WindowRef windowref () const
 

Static Public Member Functions

static std::string clipboardText ()
 Uses the current() OSWindow instance to obtain text from the operating system clipboard.
 
static CarbonWindowcreate (const OSWindow::Settings &settings=OSWindow::Settings())
 
static CarbonWindowcreate (const OSWindow::Settings &settings, WindowRef window)
 
static const OSWindowcurrent ()
 
static void getFullScreenResolutions (Array< Vector2int32 > &array)
 Enumerates all full-screen resolutions.
 
static int numDisplays ()
 Number of physical displays (e.g., monitors) reported by the operating system.
 
static Vector2 primaryDisplaySize ()
 Dimensions in pixels of the primary display.
 
static Vector2 primaryDisplayWindowSize ()
 Dimensions in pixels of a maximized (but not full-screen) window on the primary display.
 
static void setClipboardText (const std::string &text)
 Uses the current() OSWindow instance to put text on the operating system clipboard.
 
static Vector2 virtualDisplaySize ()
 Dimensions of the bounding rectangle of all displays.
 

Protected Member Functions

void executeLoopBody ()
 Subclasses should call from their idle function.
 
virtual void getOSEvents (Queue< GEvent > &events)
 Extract new events from the underlying operating system.
 
virtual void handleResize (int width, int height)
 Handles updating size settings and viewport for window size changes.
 
bool notDone ()
 
virtual void reallyMakeCurrent () const
 Override this with the glMakeCurrent call appropriate for your window.
 

Protected Attributes

Queue< GEventm_eventQueue
 
int m_inputCaptureCount
 
int m_mouseHideCount
 
RenderDevicem_renderDevice
 
Settings m_settings
 Use this to maintain settings in sub-classes.
 

Friends

void _internal::HIDCollectJoyElementsArrayHandler (const void *value, void *parameter)
 
pascal OSStatus _internal::OnActivation (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 
pascal OSStatus _internal::OnAppQuit (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 
pascal OSStatus _internal::OnDeactivation (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 
pascal OSStatus _internal::OnDeviceScroll (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 
pascal OSErr _internal::OnDragReceived (WindowRef theWindow, void *userData, DragRef theDrag)
 
pascal OSStatus _internal::OnWindowClosed (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 
pascal OSStatus _internal::OnWindowSized (EventHandlerCallRef handlerRef, EventRef event, void *userData)
 

Constructor & Destructor Documentation

virtual G3D::CarbonWindow::~CarbonWindow ( )
virtual

Member Function Documentation

virtual std::string G3D::CarbonWindow::_clipboardText ( ) const
overridevirtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::_setClipboardText ( const std::string text) const
overridevirtual

Implements G3D::OSWindow.

virtual std::string G3D::CarbonWindow::caption ( )
virtual

The window title.

Implements G3D::OSWindow.

virtual std::string G3D::CarbonWindow::className ( ) const
inlinevirtual

Implements G3D::OSWindow.

virtual Rect2D G3D::CarbonWindow::clientRect ( ) const
overridevirtual

Size of the inside of the window (the part that the program can render to)

Implements G3D::OSWindow.

static std::string G3D::OSWindow::clipboardText ( )
staticinherited

Uses the current() OSWindow instance to obtain text from the operating system clipboard.

Returns the empty string if no OSWindow is currently instantiated.

static CarbonWindow* G3D::CarbonWindow::create ( const OSWindow::Settings settings = OSWindow::Settings())
static
static CarbonWindow* G3D::CarbonWindow::create ( const OSWindow::Settings settings,
WindowRef  window 
)
static
static const OSWindow* G3D::OSWindow::current ( )
inlinestaticinherited
virtual void G3D::OSWindow::decInputCaptureCount ( )
inlinevirtualinherited
virtual void G3D::OSWindow::decMouseHideCount ( )
inlinevirtualinherited
void G3D::OSWindow::executeLoopBody ( )
protectedinherited

Subclasses should call from their idle function.

Referenced by G3D::OSWindow::runMainLoop().

virtual void G3D::OSWindow::fireEvent ( const GEvent event)
virtualinherited

Inserts an event into the queue.

virtual Rect2D G3D::CarbonWindow::fullRect ( ) const
inlineoverridevirtual

Shape of the window, including borders.

Implements G3D::OSWindow.

std::string G3D::CarbonWindow::getAPIName ( ) const
virtual

Description of the windowing API for logging purposes (e.g.

"SDL").

See Also
className

Implements G3D::OSWindow.

std::string G3D::CarbonWindow::getAPIVersion ( ) const
virtual

Description of the windowing API for logging purposes (e.g.

"1.2.7" for SDL 1.2.7).

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::getDroppedFilenames ( Array< std::string > &  files)
overridevirtual

Clears the files array and then sets it to a list of all files that were dropped in the last GEventType::FILE_DROP event.

Implements G3D::OSWindow.

static void G3D::OSWindow::getFullScreenResolutions ( Array< Vector2int32 > &  array)
staticinherited

Enumerates all full-screen resolutions.

virtual void G3D::CarbonWindow::getJoystickState ( unsigned int  stickNum,
Array< float > &  axis,
Array< bool > &  button 
) const
overridevirtual

Returns the state of the given joystick.

Not all sticks support all buttons and axes and frequently the state of one stick overlaps the state of another. An asserition fails if stickNum > numJoysticks(). Joystick axes are normalized to the range -1, 1. Joystick axes should be in the starting order: X, Y, Z, Slider1, Slider2, rX, rY, rZ

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::getOSEvents ( Queue< GEvent > &  events)
protectedvirtual

Extract new events from the underlying operating system.

Reimplemented from G3D::OSWindow.

virtual void G3D::CarbonWindow::getRelativeMouseState ( Vector2 position,
uint8 mouseButtons 
) const
virtual

Returns the current mouse position and the state of the mouse buttons.

It is essential to sample both simultaneously so that the mouse has not moved from the location where a click occurred.

Parameters
positionIn pixels, with y=up. Relative to the upper left corner of the window.
mouseButtonsIf button i is currently pressed then bit i is set.

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::getRelativeMouseState ( int x,
int y,
uint8 mouseButtons 
) const
virtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::getRelativeMouseState ( double &  x,
double &  y,
uint8 mouseButtons 
) const
virtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::getSettings ( OSWindow::Settings settings) const
virtual

Return the actual properties of this window (as opposed to the desired settings from which it was initialized)

Implements G3D::OSWindow.

virtual void G3D::OSWindow::handleResize ( int  width,
int  height 
)
protectedvirtualinherited

Handles updating size settings and viewport for window size changes.

virtual bool G3D::CarbonWindow::hasFocus ( ) const
virtual

Returns true if this window currently has [keyboard] focus (i.e.

is in the foreground, not minimized, recieves keystrokes.)

Implements G3D::OSWindow.

virtual int G3D::CarbonWindow::height ( ) const
virtual

Implements G3D::OSWindow.

virtual void G3D::OSWindow::incInputCaptureCount ( )
inlinevirtualinherited
virtual void G3D::OSWindow::incMouseHideCount ( )
inlinevirtualinherited
virtual bool G3D::CarbonWindow::inputCapture ( ) const
virtual
int G3D::OSWindow::inputCaptureCount ( ) const
inlineinherited

If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.

The use of a count instead of an explicit capture/release API allows multiple parts of a program to capture input without accidentally releasing and enclosing capture.

Referenced by G3D::OSWindow::decInputCaptureCount(), and G3D::OSWindow::incInputCaptureCount().

virtual std::string G3D::CarbonWindow::joystickName ( unsigned int  sticknum) const
virtual

The name by which the OS refers to this joystick (e.g.

"Gravis Gamepad")

Implements G3D::OSWindow.

void G3D::OSWindow::makeCurrent ( ) const
inlineinherited

Makes the OpenGL context of this window current.

If you have multiple windows, call this before rendering to one of them. beta

int G3D::OSWindow::mouseHideCount ( ) const
inlineinherited

If the count is 1 or greater, then the keyboard and mouse focus is captured, locking the mouse to the client area of this window.

The use of a count instead of an explicit capture/release API allows multiple parts of a program to capture input without accidentally releasing and enclosing capture.

Referenced by G3D::OSWindow::decMouseHideCount(), and G3D::OSWindow::incMouseHideCount().

virtual bool G3D::CarbonWindow::mouseVisible ( ) const
virtual
bool G3D::OSWindow::notDone ( )
inlineprotectedinherited
static int G3D::CarbonWindow::numDisplays ( )
static

Number of physical displays (e.g., monitors) reported by the operating system.

The OSWindow implementation calls the appropriate subclass override for the current operating system.

virtual int G3D::CarbonWindow::numJoysticks ( ) const
virtual

Returns 0 if there are no joysticks available.

Implements G3D::OSWindow.

virtual bool G3D::OSWindow::pollEvent ( GEvent e)
virtualinherited

Checks to see if any events are waiting.

If there is an event, returns true and fills out the GEvent structure. Otherwise returns false.

virtual void G3D::OSWindow::popLoopBody ( )
virtualinherited

Pops a loop body off the stack.

If the loop body was a GApplet, invokes GApplet::endRun on it. If the loop body was a GApp2, invokes GApp2::endRun on it.

static Vector2 G3D::CarbonWindow::primaryDisplaySize ( )
static

Dimensions in pixels of the primary display.

The OSWindow implementation calls the appropriate subclass override for the current operating system.

static Vector2 G3D::CarbonWindow::primaryDisplayWindowSize ( )
static

Dimensions in pixels of a maximized (but not full-screen) window on the primary display.

Task bars and menus may make this smaller than the primaryDisplaySize().The OSWindow implementation calls the appropriate subclass override for the current operating system.

virtual void G3D::OSWindow::pushLoopBody ( void(*)(void *)  body,
void arg 
)
inlinevirtualinherited

Pushes a function onto the stack of functions called by runMainLoop.

virtual void G3D::OSWindow::pushLoopBody ( GApp app)
virtualinherited

Invokes GApplet::beginRun after the applet is on the stack.

virtual void G3D::OSWindow::reallyMakeCurrent ( ) const
inlineprotectedvirtualinherited

Override this with the glMakeCurrent call appropriate for your window.

Reimplemented in G3D::Win32Window, and G3D::SDLWindow.

Referenced by G3D::OSWindow::makeCurrent().

RenderDevice* G3D::OSWindow::renderDevice ( ) const
inlineinherited

If a RenderDevice has been created and initialized for this window, returns that renderDevice.

Otherwise returns NULL.

virtual bool G3D::CarbonWindow::requiresMainLoop ( ) const
inlinevirtual

Windows for which this is true require a program to hand control of the main loop to OSWindow::startMainLoop.

    The program's functionality may then be implemented through
    the "loop body" function.

    That is, if requiresMainLoop returns true, you must use
    the following structure:
    <PRE>
       void doEvents() {
          GEvent e;
          while (window->pollEvent(e)) {
              ... // Event handling
          } 
       }

       void doGraphics() {
          renderDevice->beginFrame();
              renderDevice->clear(true, true, true);
              ...  // draw stuff
          renderDevice->endFrame();
       }

       void loopBody(void*) {

all per-frame code; event-handling, physics, networking, AI, etc. doEvents(); doLogic(); doNetwork(); doAI(); doGraphics();

To end the program, invoke window->popLoopBody }

window->pushLoopBody(callback, NULL); window->runMainLoop(); // doesn't return

When requiresMainLoop returns false, you may use either the above structure or the following one (which puts you in more control of when graphics vs. other code is executed):

            while (true) {
              doEvents();
              doLogic();
              doNetwork();
              doAI();
              doGraphics();
            }       
        

This design is necessary because some underlying Window APIs (e.g. ActiveX, GLUT) enforce an event-driven structure.

Reimplemented from G3D::OSWindow.

virtual void G3D::OSWindow::runMainLoop ( )
inlinevirtualinherited

Executes an event loop, invoking callback repeatedly.

Put everything that you want to execute once per frame into the callback function. It is guaranteed safe to call pollEvents and all other OSWindow methods from the callback function.

The default implementation (for requiresMainLoop() == false GWindows) just calls the callback continuously. Subclasses should use the notDone() and executeLoopBody() functions.

virtual void G3D::CarbonWindow::setCaption ( const std::string title)
virtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setClientPosition ( int  x,
int  y 
)
inlineoverridevirtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setClientRect ( const Rect2D dims)
overridevirtual

Implements G3D::OSWindow.

Referenced by setClientPosition().

static void G3D::OSWindow::setClipboardText ( const std::string text)
staticinherited

Uses the current() OSWindow instance to put text on the operating system clipboard.

Does nothing if no OSWindow is currently instantiated.

virtual void G3D::CarbonWindow::setFullPosition ( int  x,
int  y 
)
inlineoverridevirtual

Fails silently if unable to change the position.

Sets the window (not client) position.

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setFullRect ( const Rect2D dims)
inlineoverridevirtual

Fails silently if unable to change the dimensions.

The value returned by getSettings will not change immediately– it waits for a size event to update.

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setGammaRamp ( const Array< uint16 > &  gammaRamp)
virtual

gammaRamp.length() = 256

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setIcon ( const Image::Ref image)
virtual

Set the icon (if supported).

Fails silently if not supported or the window has no frame. May also fail if the OSWindow implementation's underlying GUI library is too limited.

Parameters
imageMay have any dimension supported by underlying OS.

Reimplemented from G3D::OSWindow.

virtual void G3D::OSWindow::setIcon ( const std::string imageFilename)
inlinevirtualinherited
virtual void G3D::CarbonWindow::setInputCapture ( bool  c)
virtual

Capture the keyboard and mouse focus, locking the mouse to the client area of this window.

Sets the inputCaptureCount to 1 if c is true and 0 if c is false

Implements G3D::OSWindow.

void G3D::OSWindow::setInputCaptureCount ( int  c)
inlineinherited
void G3D::OSWindow::setMouseHideCount ( int  c)
inlineinherited
virtual void G3D::CarbonWindow::setMouseVisible ( bool  b)
virtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setRelativeMousePosition ( double  x,
double  y 
)
virtual

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::setRelativeMousePosition ( const Vector2 p)
virtual

Relative to the window origin.

Implements G3D::OSWindow.

virtual void G3D::CarbonWindow::swapGLBuffers ( )
virtual

Swap the OpenGL front and back buffers.

Called by RenderDevice::endFrame.

Implements G3D::OSWindow.

static Vector2 G3D::CarbonWindow::virtualDisplaySize ( )
static

Dimensions of the bounding rectangle of all displays.

For a multi-monitor configuration, this is the net "display" size.

virtual int G3D::CarbonWindow::width ( ) const
virtual

Measured in pixels, this is the client area of the window.

Returns the same width as getSettings and clientDimensions(). Convenience method for users.

Implements G3D::OSWindow.

WindowRef G3D::CarbonWindow::windowref ( ) const
inline

Friends And Related Function Documentation

void _internal::HIDCollectJoyElementsArrayHandler ( const void value,
void parameter 
)
friend
pascal OSStatus _internal::OnActivation ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend
pascal OSStatus _internal::OnAppQuit ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend
pascal OSStatus _internal::OnDeactivation ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend
pascal OSStatus _internal::OnDeviceScroll ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend
pascal OSErr _internal::OnDragReceived ( WindowRef  theWindow,
void userData,
DragRef  theDrag 
)
friend
pascal OSStatus _internal::OnWindowClosed ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend
pascal OSStatus _internal::OnWindowSized ( EventHandlerCallRef  handlerRef,
EventRef  event,
void userData 
)
friend

Member Data Documentation

Queue<GEvent> G3D::OSWindow::m_eventQueue
protectedinherited
int G3D::OSWindow::m_inputCaptureCount
protectedinherited
int G3D::OSWindow::m_mouseHideCount
protectedinherited
RenderDevice* G3D::OSWindow::m_renderDevice
protectedinherited
Settings G3D::OSWindow::m_settings
protectedinherited

Use this to maintain settings in sub-classes.

Referenced by setClientPosition().


documentation generated on Sat Dec 29 2012 09:09:28 using doxygen 1.8.2