ScummVM
Glk::Screen Class Reference

Screen surface class. More...

#include <screen.h>

Inheritance diagram for Glk::Screen:
Collaboration diagram for Glk::Screen:

Public Member Functions

 Screen ()
 Constructor. More...
 
virtual ~Screen ()
 Destructor. More...
 
void initialize ()
 Initialize the screen. More...
 
void fill (uint color)
 Fills the screen with a given color. More...
 
void fillRect (const Rect &box, uint color)
 Fill a given area of the screen with a given color. More...
 
int drawString (const Point &pos, int fontIdx, uint color, const Common::String &text, int spw=0)
 Draws a string using the specified font at the given co-ordinates. More...
 
int drawStringUni (const Point &pos, int fontIdx, uint color, const Common::U32String &text, int spw=0)
 Draws a unicode string using the specified font at the given co-ordinates. More...
 
size_t stringWidth (int fontIdx, const Common::String &text, int spw=0)
 Get the width in pixels of a string. More...
 
size_t stringWidthUni (int fontIdx, const Common::U32String &text, int spw=0)
 Get the width in pixels of a unicode string. More...
 
- Public Member Functions inherited from Graphics::Screen
 Screen ()
 
 Screen (int width, int height)
 
 Screen (int width, int height, PixelFormat pixelFormat)
 
bool isDirty () const
 Returns true if there are any pending screen updates (dirty areas) More...
 
void makeAllDirty ()
 Marks the whole screen as dirty. More...
 
virtual void clearDirtyRects ()
 Clear the current dirty rects list. More...
 
virtual void update ()
 Updates the screen by copying any affected areas to the system. More...
 
void getPalette (byte palette[PALETTE_SIZE])
 Return the currently active palette. More...
 
void getPalette (byte *palette, uint start, uint num)
 Return a portion of the currently active palette. More...
 
void setPalette (const byte palette[PALETTE_SIZE])
 Set the palette. More...
 
void setPalette (const byte *palette, uint start, uint num)
 Set a subsection of the palette. More...
 
void clearPalette ()
 Clears the current palette, setting all entries to black. More...
 
- Public Member Functions inherited from Graphics::ManagedSurface
 ManagedSurface ()
 Create the managed surface. More...
 
 ManagedSurface (ManagedSurface &surf)
 Create a managed surface from another one. More...
 
 ManagedSurface (int width, int height)
 Create the managed surface. More...
 
 ManagedSurface (int width, int height, const Graphics::PixelFormat &pixelFormat)
 Create the managed surface. More...
 
 ManagedSurface (ManagedSurface &surf, const Common::Rect &bounds)
 Create the managed surface. More...
 
virtual ~ManagedSurface ()
 Destroy the managed surface. More...
 
 operator const Surface & () const
 Implements automatic conversion to a Graphics::Surface by simply returning the inner surface. More...
 
const SurfacerawSurface () const
 
ManagedSurfaceoperator= (ManagedSurface &surf)
 Reassign one managed surface to another one Note that if the source has a managed surface, it will be duplicated. More...
 
bool empty () const
 Returns true if the surface has not yet been allocated. More...
 
DisposeAfterUse::Flag disposeAfterUse () const
 Returns true if the surface is managing its own pixels. More...
 
const voidgetBasePtr (int x, int y) const
 Return a pointer to the pixel at the specified point. More...
 
voidgetBasePtr (int x, int y)
 Return a pointer to the pixel at the specified point. More...
 
voidgetPixels ()
 Get a reference to the pixel data. More...
 
const voidgetPixels () const
 
virtual void setPixels (void *newPixels)
 Sets the pixel data. More...
 
virtual void create (uint16 width, uint16 height)
 Allocate memory for the pixel data of the surface. More...
 
virtual void create (uint16 width, uint16 height, const PixelFormat &pixelFormat)
 Allocate memory for the pixel data of the surface. More...
 
virtual void create (ManagedSurface &surf, const Common::Rect &bounds)
 Sets up the surface as a sub-section of another passed parent surface. More...
 
virtual void free ()
 Release the memory used by the pixels memory of this surface. More...
 
const Common::Point getOffsetFromOwner () const
 When the managed surface is a sub-section of a parent surface, returns the the offset in the parent surface that the surface starts at. More...
 
const Common::Rect getBounds () const
 Return a rect giving the bounds of the surface. More...
 
void blitFrom (const Surface &src)
 Copies another surface into this one. More...
 
void blitFrom (const Surface &src, const Common::Point &destPos)
 Copies another surface into this one at a given destination position. More...
 
void blitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos)
 Copies another surface into this one at a given destination position. More...
 
void transBlitFrom (const Surface &src, uint transColor=0, bool flipped=false, uint overrideColor=0, uint srcAlpha=0xff)
 Copies another surface into this one ignoring pixels of a designated transparent color. More...
 
void transBlitFrom (const Surface &src, const Common::Point &destPos, uint transColor=0, bool flipped=false, uint overrideColor=0, uint srcAlpha=0xff)
 Copies another surface into this one ignoring pixels of a designated transparent color. More...
 
void transBlitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Point &destPos, uint transColor=0, bool flipped=false, uint overrideColor=0, uint srcAlpha=0xff)
 Copies another surface into this one ignoring pixels of a designated transparent color. More...
 
void transBlitFrom (const Surface &src, const Common::Rect &srcRect, const Common::Rect &destRect, uint transColor=0, bool flipped=false, uint overrideColor=0, uint srcAlpha=0xff)
 Copies another surface into this one ignoring pixels of a designated transparent color. More...
 
void clear (uint color=0)
 Clear the entire surface. More...
 
void markAllDirty ()
 Mark the entire surface as dirty. More...
 
void copyRectToSurface (const void *buffer, int srcPitch, int destX, int destY, int width, int height)
 Copies a bitmap to the Surface internal buffer. More...
 
void copyRectToSurface (const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect)
 Copies a bitmap to the Surface internal buffer. More...
 
void copyFrom (const ManagedSurface &surf)
 Copy the data from another Surface, reinitializing the surface to match the dimensions of the passed surface. More...
 
void drawLine (int x0, int y0, int x1, int y1, uint32 color)
 Draw a line. More...
 
void drawThickLine (int x0, int y0, int x1, int y1, int penX, int penY, uint32 color)
 Draw a thick line. More...
 
void hLine (int x, int y, int x2, uint32 color)
 Draw a horizontal line. More...
 
void vLine (int x, int y, int y2, uint32 color)
 Draw a vertical line. More...
 
void fillRect (Common::Rect r, uint32 color)
 Fill a rect with a given color. More...
 
void frameRect (const Common::Rect &r, uint32 color)
 Draw a frame around a specified rect. More...
 
Surface getSubArea (const Common::Rect &area)
 Returns a sub-area of the screen, but only adds a single initial dirty rect for the retrieved area. More...
 
void convertToInPlace (const PixelFormat &dstFormat, const byte *palette=0)
 Convert the data to another pixel format. More...
 

Static Public Member Functions

static FACES getFontId (const Common::String &name)
 Return the font Id for a given name. More...
 

Protected Member Functions

virtual void loadFonts (Common::Archive *archive)
 Load the fonts. More...
 
- Protected Member Functions inherited from Graphics::Screen
virtual void addDirtyRect (const Common::Rect &r)
 Adds a rectangle to the list of modified areas of the screen during the current frame. More...
 
- Protected Member Functions inherited from Graphics::ManagedSurface
bool clip (Common::Rect &srcBounds, Common::Rect &destBounds)
 Clips the given source bounds so the passed destBounds will be entirely on-screen. More...
 

Protected Attributes

Common::Array< const Graphics::Font * > _fonts
 

Private Member Functions

void loadFonts ()
 Open the fonts archive and load all the fonts. More...
 
const Graphics::FontloadFont (FACES face, Common::Archive *archive, double size, double aspect, int style)
 Load a single font. More...
 

Additional Inherited Members

- Public Attributes inherited from Graphics::ManagedSurface
uint16w
 
uint16h
 
uint16pitch
 
PixelFormatformat
 

Detailed Description

Screen surface class.

Definition at line 44 of file screen.h.

Constructor & Destructor Documentation

◆ Screen()

Glk::Screen::Screen ( )
inline

Constructor.

Definition at line 72 of file screen.h.

◆ ~Screen()

Screen::~Screen ( )
virtual

Destructor.

Definition at line 36 of file screen.cpp.

Member Function Documentation

◆ drawString()

int Screen::drawString ( const Point pos,
int  fontIdx,
uint  color,
const Common::String text,
int  spw = 0 
)

Draws a string using the specified font at the given co-ordinates.

Parameters
posPosition for the bottom-left corner the text will be drawn with
fontIdxWhich font to use
colorText color
textThe text to draw
spw??

Definition at line 148 of file screen.cpp.

◆ drawStringUni()

int Screen::drawStringUni ( const Point pos,
int  fontIdx,
uint  color,
const Common::U32String text,
int  spw = 0 
)

Draws a unicode string using the specified font at the given co-ordinates.

Parameters
posPosition for the bottom-left corner the text will be drawn with
fontIdxWhich font to use
colorText color
textThe text to draw
spw??

Definition at line 158 of file screen.cpp.

◆ fill()

void Screen::fill ( uint  color)

Fills the screen with a given color.

Definition at line 61 of file screen.cpp.

◆ fillRect()

void Screen::fillRect ( const Rect box,
uint  color 
)

Fill a given area of the screen with a given color.

Definition at line 65 of file screen.cpp.

◆ getFontId()

FACES Screen::getFontId ( const Common::String name)
static

Return the font Id for a given name.

Definition at line 136 of file screen.cpp.

◆ initialize()

void Screen::initialize ( )

Initialize the screen.

Definition at line 41 of file screen.cpp.

◆ loadFont()

const Graphics::Font * Screen::loadFont ( FACES  face,
Common::Archive archive,
double  size,
double  aspect,
int  style 
)
private

Load a single font.

Definition at line 123 of file screen.cpp.

◆ loadFonts() [1/2]

void Screen::loadFonts ( )
private

Open the fonts archive and load all the fonts.

Definition at line 70 of file screen.cpp.

◆ loadFonts() [2/2]

void Screen::loadFonts ( Common::Archive archive)
protectedvirtual

Load the fonts.

Reimplemented in Glk::Frotz::FrotzScreen.

Definition at line 104 of file screen.cpp.

◆ stringWidth()

size_t Screen::stringWidth ( int  fontIdx,
const Common::String text,
int  spw = 0 
)

Get the width in pixels of a string.

Parameters
fontIdxWhich font to use
textText to get the width of
spwDelta X
Returns
Width of string multiplied by GLI_SUBPIX

Definition at line 168 of file screen.cpp.

◆ stringWidthUni()

size_t Screen::stringWidthUni ( int  fontIdx,
const Common::U32String text,
int  spw = 0 
)

Get the width in pixels of a unicode string.

Parameters
fontIdxWhich font to use
textText to get the width of
spwDelta X
Returns
Width of string multiplied by GLI_SUBPIX

Definition at line 173 of file screen.cpp.

Member Data Documentation

◆ _fonts

Common::Array<const Graphics::Font *> Glk::Screen::_fonts
protected

Definition at line 57 of file screen.h.


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