📄 sdllabel.h
字号:
// ============================================================================
// Data Structures For Game Programmers
// Ron Penton
// SDLLabel.h
// This is a basic SDLGUI library that I've set up for use with the game demos
// I've used in the book.
// ============================================================================
#ifndef SDLLABEL_H
#define SDLLABEL_H
#include "SDLHelpers.h"
#include "SDLGUIItem.h"
class SDLLabel : public SDLGUIItem
{
public:
// -------------------------------------------------------
// Name: SDLLabel::SDLLabel
// Description: This constructs the label
// Arguments: - p_x: x coordinate
// - p_y: y coordinate
// - p_text: the text of the label
// - p_tforecol: the foreground color of the
// text
// - p_tbackcol: the background color of the
// text
// - p_font: the font of the label.
// -------------------------------------------------------
SDLLabel( int p_x, int p_y,
const char* p_text,
SDL_Color p_tforecol,
SDL_Color p_tbackcol,
TTF_Font* p_font );
// ----------------------------------------------------------------
// Name: Draw
// Description: draws the item on a surface
// Arguments: p_dest: the destination surface
// Return Value: None
// ----------------------------------------------------------------
void Draw( SDL_Surface* p_dest );
// ----------------------------------------------------------------
// Name: ClickDown
// Description: Tells the item that it was clicked on.
// Arguments: None
// Return Value: None
// ----------------------------------------------------------------
void ClickDown();
// ----------------------------------------------------------------
// Name: ClickUp
// Description: Tells the item that it a mouse was released
// on this item
// Arguments: None
// Return Value: None
// ----------------------------------------------------------------
void ClickUp();
// ----------------------------------------------------------------
// Name: IsOver
// Description: determines if a set of coordinates is over this
// item
// Arguments: p_x, p_y: the coordinates
// Return Value: true if the coordinates are over this item
// ----------------------------------------------------------------
bool IsOver( int p_x, int p_y );
// ----------------------------------------------------------------
// Name: ResetOnUp
// Description: This tells the item to reset itself because
// the user unclicked the mouse (only valid
// for some items)
// Arguments: None
// Return Value: None
// ----------------------------------------------------------------
void ResetOnUp();
// -------------------------------------------------------
// Name: SDLLabel::CanGetFocus
// Description: determines if this object can get the
// focus of the GUI.
// Arguments: None.
// Return Value: True or False
// -------------------------------------------------------
bool CanGetFocus();
// ----------------------------------------------------------------
// Name: GetFocus
// Description: tells the item to get the focus or not.
// Arguments: p_focus: true if the item gets the focus
// Return Value: None
// ----------------------------------------------------------------
void GetFocus( bool p_focus );
// ----------------------------------------------------------------
// Name: KeyPress
// Description: tells the GUI that a key was pressed when this
// item was in focus
// Arguments: p_key: the that was pressed
// p_mod: the keyboard modifier flag (shift, alt,
// control).
// p_char: the UNICODE representation of the key
// Return Value: None
// ----------------------------------------------------------------
void KeyPress( SDLKey p_key, SDLMod p_mod, Uint16 p_char );
protected:
SDL_Surface* m_text;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -