ScummVM API documentation
Graphics::MacWindow Class Reference

#include <macwindow.h>

Inheritance diagram for Graphics::MacWindow:
Graphics::BaseMacWindow Graphics::MacWidget Director::Window Graphics::MacTextWindow

Public Member Functions

 MacWindow (int id, bool scrollable, bool resizable, bool editable, MacWindowManager *wm)
 
void move (int x, int y)
 
virtual void resize (int w, int h)
 
virtual void resizeInner (int w, int h)
 
void setDimensions (const Common::Rect &r) override
 
void setInnerDimensions (const Common::Rect &r)
 
void setBackgroundPattern (int pattern)
 
bool draw (ManagedSurface *g, bool forceRedraw=false) override
 
bool draw (bool forceRedraw=false) override
 
void blit (ManagedSurface *g, Common::Rect &dest) override
 
const Common::RectgetInnerDimensions () override
 
ManagedSurfacegetBorderSurface () override
 
void center (bool toCenter=true)
 
void setActive (bool active) override
 
bool isActive () const
 
void setTitle (const Common::String &title)
 
virtual void setTitleVisible (bool visible)
 
bool isTitleVisible ()
 
const Common::StringgetTitle () const
 
void setHighlight (WindowClick highlightedPart)
 
void setScroll (float scrollPos, float scrollSize)
 
bool processEvent (Common::Event &event) override
 
bool hasAllFocus () override
 
void loadBorder (Common::SeekableReadStream &file, uint32 flags, int lo=-1, int ro=-1, int to=-1, int bo=-1)
 
void loadBorder (Common::SeekableReadStream &file, uint32 flags, BorderOffsets offsets)
 
void setBorder (Graphics::ManagedSurface *surface, uint32 flags, BorderOffsets offsets)
 
void disableBorder ()
 
void loadInternalBorder (uint32 flags)
 
void enableScrollbar (bool active)
 
void setCloseable (bool closeable)
 
void setBorderType (int borderType)
 
int getBorderType () const
 
uint32 getBorderFlags () const
 
void addDirtyRect (const Common::Rect &r)
 
void markAllDirty ()
 
void mergeDirtyRects ()
 
bool isDirty () override
 
void setBorderDirty (bool dirty)
 
void resizeBorderSurface ()
 
void setMode (uint32 mode)
 
void setBorderOffsets (BorderOffsets &offsets)
 
void updateInnerDims ()
 
- Public Member Functions inherited from Graphics::BaseMacWindow
 BaseMacWindow (int id, bool editable, MacWindowManager *wm)
 
int getId ()
 
WindowType getType ()
 
bool isEditable ()
 
virtual void setVisible (bool visible, bool silent=false)
 
bool isVisible ()
 
ManagedSurfacegetWindowSurface ()
 
void setCallback (bool(*callback)(WindowClick, Common::Event &, void *), void *data)
 
- Public Member Functions inherited from Graphics::MacWidget
 MacWidget (MacWidget *parent, int x, int y, int w, int h, MacWindowManager *wm, bool focusable, uint16 border=0, uint16 gutter=0, uint16 shadow=0, uint32 fgcolor=0, uint32 bgcolor=0xff)
 
const Common::RectgetDimensions ()
 
void setDirty (bool dirty)
 
virtual bool needsRedraw ()
 
virtual void setColors (uint32 fg, uint32 bg)
 
Common::Point getAbsolutePos ()
 
MacWidgetfindEventHandler (Common::Event &event, int dx, int dy)
 
void removeWidget (MacWidget *child, bool del=true)
 
Graphics::ManagedSurfacegetSurface ()
 

Protected Member Functions

void drawBorder ()
 
WindowClick isInBorder (int x, int y) const
 
BorderOffsets getBorderOffsets () const
 

Protected Attributes

ManagedSurface _borderSurface
 
bool _borderIsDirty
 
Common::Rect _innerDims
 
Common::List< Common::Rect_dirtyRects
 
bool _hasScrollBar
 
uint32 _mode
 
- Protected Attributes inherited from Graphics::BaseMacWindow
int _id
 
WindowType _type
 
bool _editable
 
bool(* _callback )(WindowClick, Common::Event &, void *)
 
void * _dataPtr
 
bool _visible
 
bool _draggable
 
- Protected Attributes inherited from Graphics::MacWidget
uint16 _border
 
uint16 _gutter
 
uint16 _shadow
 
uint32 _fgcolor
 
uint32 _bgcolor
 
Graphics::ManagedSurface_composeSurface
 
bool _contentIsDirty
 

Additional Inherited Members

- Public Attributes inherited from Graphics::MacWidget
bool _focusable
 
bool _active
 
bool _editable
 
uint _priority
 
Common::Rect _dims
 
MacWindowManager_wm
 
MacWidget_parent
 
Common::Array< MacWidget * > _children
 

Detailed Description

An implementation of an ordinary window in the Mac interface. It supports custom resizing, scrolling, borders, etc.

Constructor & Destructor Documentation

◆ MacWindow()

Graphics::MacWindow::MacWindow ( int  id,
bool  scrollable,
bool  resizable,
bool  editable,
MacWindowManager wm 
)

Construct a simple window, with the default settings. Note that the scroll must be implemented in the event handling, even if the scrollable flag is set to true.

Parameters
idSee BaseMacWindow.
scrollableTrue if the window can be scrolled.
resizableTrue if the window can be resized.
editableSee BaseMacWindow.
wmSee BaseMacWindow.

Member Function Documentation

◆ move()

void Graphics::MacWindow::move ( int  x,
int  y 
)

Change the window's location to fixed coordinates (not delta).

Parameters
xNew left position of the window relative to the WM's screen.
yNew top position of the window relative to the WM's screen.

◆ setDimensions()

void Graphics::MacWindow::setDimensions ( const Common::Rect r)
overridevirtual

Change the dimensions of the window ([0, 0, 0, 0] by default). Note that this can be used to update both the position and the size of the window, although move() and resize() might be more comfortable.

Parameters
rThe desired dimensions of the window.

Reimplemented from Graphics::MacWidget.

◆ setInnerDimensions()

void Graphics::MacWindow::setInnerDimensions ( const Common::Rect r)

Change the inner dimension of the window. Note that this changes the window inner dimension and calculates outer dimension (ie with border, etc)

Parameters
rThe desired dimensions of the window.

◆ setBackgroundPattern()

void Graphics::MacWindow::setBackgroundPattern ( int  pattern)

Set a background pattern for the window.

Parameters
pattern

◆ draw() [1/2]

bool Graphics::MacWindow::draw ( ManagedSurface g,
bool  forceRedraw = false 
)
overridevirtual

Similar to that described in BaseMacWindow.

Parameters
gSee BaseMacWindow.
forceRedrawIf true, the borders are guarranteed to redraw.

Implements Graphics::BaseMacWindow.

◆ draw() [2/2]

bool Graphics::MacWindow::draw ( bool  forceRedraw = false)
overridevirtual

Method called to internally draw the window. This relies on the window being marked as dirty unless otherwise specified.

Parameters
forceRedrawIts behavior depends on the subclass.

Implements Graphics::BaseMacWindow.

◆ getInnerDimensions()

const Common::Rect& Graphics::MacWindow::getInnerDimensions ( )
inlineoverridevirtual

Accessor to retrieve the dimensions of the inner surface of the window (i.e. without taking borders into account). Note that the returned dimensions' position is relative to the WM's screen, just like in getDimensions().

Returns
The inner dimensions of the window.

Implements Graphics::BaseMacWindow.

◆ getBorderSurface()

ManagedSurface* Graphics::MacWindow::getBorderSurface ( )
inlineoverridevirtual

Method to access the border surface of the window.

Returns
A pointer to the border surface of the window.

Implements Graphics::BaseMacWindow.

◆ center()

void Graphics::MacWindow::center ( bool  toCenter = true)

Centers the window using the dimensions of the parent window manager, or undoes this; does nothing if WM is null.

◆ setActive()

void Graphics::MacWindow::setActive ( bool  active)
overridevirtual

Mutator to change the active state of the window. Most often called from the WM.

Parameters
activeTarget state.

Reimplemented from Graphics::MacWidget.

◆ isActive()

bool Graphics::MacWindow::isActive ( ) const

Accessor to determine whether a window is active.

Returns
True if the window is active.

◆ setTitle()

void Graphics::MacWindow::setTitle ( const Common::String title)

Mutator to change the title of the window.

Parameters
titleTarget title.

◆ setTitleVisible()

virtual void Graphics::MacWindow::setTitleVisible ( bool  visible)
virtual

Set visibility of window title.

Parameters
visiblevisibility of window.

Reimplemented in Director::Window.

◆ isTitleVisible()

bool Graphics::MacWindow::isTitleVisible ( )

Get visibility of window title.

◆ getTitle()

const Common::String& Graphics::MacWindow::getTitle ( ) const
inline

Accessor to get the title of the window.

Returns
Title.

◆ setHighlight()

void Graphics::MacWindow::setHighlight ( WindowClick  highlightedPart)

Highlight the target part of the window. Used for the default borders.

Parameters
highlightedPartPart to be highlighted.

◆ setScroll()

void Graphics::MacWindow::setScroll ( float  scrollPos,
float  scrollSize 
)

Set the scroll poisition.

Parameters
scrollPosTarget scroll position.
scrollSizeSize of the scrolling bar.

◆ processEvent()

bool Graphics::MacWindow::processEvent ( Common::Event event)
overridevirtual

◆ loadBorder()

void Graphics::MacWindow::loadBorder ( Common::SeekableReadStream file,
uint32  flags,
int  lo = -1,
int  ro = -1,
int  to = -1,
int  bo = -1 
)

Set arbitrary border from a BMP data stream, with custom border offsets. Note that the BMP has to be 9patch compliant. For examples, go to: https://github.com/blorente/MacVenture-Extract-Guide/tree/master/borders

Parameters
fileThe BMP data stream with the desired border.
activeWhether the border corresponds with the active state of the window.
loWidth of the left side of the border, in pixels.
roWidth of the right side of the border, in pixels.
toWidth of the top side of the border, in pixels.
boWidth of the bottom side of the border, in pixels.

◆ enableScrollbar()

void Graphics::MacWindow::enableScrollbar ( bool  active)
inline

we better set this before we load the border

Parameters
scrollbarstate

◆ setCloseable()

void Graphics::MacWindow::setCloseable ( bool  closeable)

Indicate whether the window can be closed (false by default).

Parameters
closeableTrue if the window can be closed.

◆ setBorderType()

void Graphics::MacWindow::setBorderType ( int  borderType)

Mutator to change the border type.

Parameters
borderTypeBorder type.

◆ getBorderType()

int Graphics::MacWindow::getBorderType ( ) const
inline

Accessor to get the border type.

Returns
Border type.

◆ getBorderFlags()

uint32 Graphics::MacWindow::getBorderFlags ( ) const

We should call this method whenever we need border flags don't calc border flags yourself

Returns
Border flags

◆ isDirty()

bool Graphics::MacWindow::isDirty ( )
inlineoverridevirtual

Method that checks if the window is needs redrawing.

Implements Graphics::BaseMacWindow.


The documentation for this class was generated from the following file: