GlistEngine
Loading...
Searching...
No Matches
gGUIContextMenuItem Class Reference

#include <gGUIContextMenu.h>

Inheritance diagram for gGUIContextMenuItem:
Collaboration diagram for gGUIContextMenuItem:

Public Member Functions

 gGUIContextMenuItem (std::string text, gImage *menuIcon, bool seperatorAdded)
virtual ~gGUIContextMenuItem () override
virtual void drawMenuItem ()
void mouseMoved (int x, int y) override
void mousePressed (int x, int y, int button) override
void mouseReleased (int x, int y, int button) override
int getItemId ()
void setParentItemId (int itemId)
int getParentItemId ()
gGUIContextMenuItem * getItem (int itemNo)
int getContextMenuLeftMargin ()
void setContextMenuLeftMargin (int leftMargin)
int getContextMenuSize ()
bool getContextMenuShown ()
bool isPressed ()
std::string getItemTitle (int itemNo)
void addItem (std::string text, gImage *menuIcon, bool seperatorAdded)
Public Member Functions inherited from gGUIControl
 gGUIControl ()
virtual ~gGUIControl () override
virtual void set (gBaseApp *root, gBaseGUIObject *topParentGUIObject, gBaseGUIObject *parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h)
int getCursor (int x, int y) override
void update () override
void draw () override
virtual int calculateContentHeight ()
virtual bool countAsSpace ()
void setCountAsSpace (bool isSpace)
void setFont (gFont *font)
gFont * getFont ()
Public Member Functions inherited from gBaseGUIObject
 gBaseGUIObject ()
virtual ~gBaseGUIObject ()
int getId ()
int getType ()
void setEnabled (bool isEnabled)
bool isEnabled ()
void setVisible (bool isVisible)
bool isVisible ()
void setTitleOn (bool isTitleOn)
bool isTitleOn ()
virtual void setTopParent (gBaseGUIObject *parentGUIObject)
gBaseGUIObject * getTopParent ()
virtual void setParent (gBaseGUIObject *parentGUIObject)
gBaseGUIObject * getParent ()
void setParentSlotNo (int parentSlotLineNo, int parentSlotColumnNo)
int getParentSlotLineNo ()
int getParentSlotColumnNo ()
void setTitle (std::string title)
std::string getTitle ()
virtual void keyPressed (int key)
virtual void keyReleased (int key)
virtual void charPressed (unsigned int codepoint)
virtual void mouseDragged (int x, int y, int button)
virtual void mouseScrolled (int x, int y)
virtual void mouseEntered ()
virtual void mouseExited ()
virtual void windowResized (int w, int h)
virtual void onGUIEvent (int guiObjectId, int eventType, int sourceEventType, std::string value1="", std::string value2="")
void setRootApp (gBaseApp *root)
virtual void setCursorOn (bool isOn)
virtual void unfocus ()
Public Member Functions inherited from gRenderObject
 gRenderObject ()
int getScreenWidth ()
int getScreenHeight ()
void pushMatrix ()
void popMatrix ()
Public Member Functions inherited from gObject
 gObject ()
void logi (std::string message)
void logd (std::string message)
void logw (std::string message)
void loge (std::string message)
void logi (std::string tag, std::string message)
void logd (std::string tag, std::string message)
void logw (std::string tag, std::string message)
void loge (std::string tag, std::string message)

Public Attributes

int contextmenux
int contextmenuy
int contextmenudefaultw
int contextmenuh
Public Attributes inherited from gBaseGUIObject
int id
int type
int left
int top
int right
int bottom
int width
int height
int titlex
int titley
int titleheight
bool isfocused
bool iscursoron
bool issizer
bool iscontainer
bool isresizable

Additional Inherited Members

Public Types inherited from gBaseGUIObject
enum  { TEXTALIGNMENT_LEFT , TEXTALIGNMENT_MIDDLE , TEXTALIGNMENT_RIGHT }
Static Public Member Functions inherited from gBaseGUIObject
static void setBackgroundColor (gColor *backgroundColor)
static gColor * getBackgroundColor ()
static void setMiddlegroundColor (gColor *middlegroundColor)
static gColor * getMiddlegroundColor ()
static void setForegroundColor (gColor *foregroundColor)
static gColor * getForegroundColor ()
static void setTextBackgroundColor (gColor *textBackgroundColor)
static gColor * getTextBackgroundColor ()
static void setNavigationBackgroundColor (gColor *navigationBackgroundColor)
static gColor * getNavigationBackgroundColor ()
static void setFont (gFont *font)
static gFont * getFont ()
static void setFontColor (gColor *fontColor)
static gColor * getFontColor ()
static void setNavigationFontColor (gColor *navigationFontColor)
static gColor * getNavigationFontColor ()
static void setButtonColor (gColor *color)
static gColor * getButtonColor ()
static void setPressedButtonColor (gColor *color)
static gColor * getPressedButtonColor ()
static void setDisabledButtonColor (gColor *color)
static gColor * getDisabledButtonColor ()
static void setButtonFontColor (gColor *color)
static gColor * getButtonFontColor ()
static void setPressedButtonFontColor (gColor *color)
static gColor * getPressedButtonFontColor ()
static void setDisabledButtonFontColor (gColor *color)
static gColor * getDisabledButtonFontColor ()
Static Public Member Functions inherited from gRenderObject
static void setScreenSize (int screenWidth, int screenHeight)
static void setUnitScreenSize (int unitWidth, int unitHeight)
static void setScreenScaling (int screenScaling)
static void enableShadowMapping ()
static void disableShadowMapping ()
static bool isShadowMappingEnabled ()
static void enableExtraShaders (bool isEnabled=true)
static void disableExtraShaders ()
static bool isExtraShadersEnabled ()
static gRenderer * getRenderer ()
static void destroyRenderer ()
static void createRenderer (int renderEngine=G_RENDERER_GL)
Static Public Member Functions inherited from gObject
static std::string gGetAppDir ()
static std::string gGetAssetsDir ()
static void gSetAssetsDir (std::string assetsDir)
static std::string gGetFilesDir ()
static std::string gGetImagesDir ()
static std::string gGetFontsDir ()
static std::string gGetModelsDir ()
static std::string gGetTexturesDir ()
static std::string gGetShadersDir ()
static std::string gGetSoundsDir ()
static std::string gGetDatabasesDir ()
static std::string gGetVideosDir ()
static void setCurrentResolution (int scalingNo, int currentResolutionNo)
Static Public Attributes inherited from gBaseGUIObject
static const int GUIEVENT_FOCUSED = -1
static const int GUIEVENT_UNFOCUSED = -2
static const int CURSOR_ARROW = 0
static const int CURSOR_IBEAM = 1
static const int CURSOR_CROSSHAIR = 2
static const int CURSOR_HAND = 3
static const int CURSOR_HRESIZE = 4
static const int CURSOR_VRESIZE = 5
static int focusid
static int previousfocusid
Static Public Attributes inherited from gObject
static const int LOGLEVEL_SILENT
static const int LOGLEVEL_DEBUG
static const int LOGLEVEL_INFO
static const int LOGLEVEL_WARNING
static const int LOGLEVEL_ERROR
Protected Attributes inherited from gGUIControl
bool countasspace
int oldwidth
int oldheight
gFont * localfont
Protected Attributes inherited from gBaseGUIObject
std::string title
gBaseApp * root
gBaseGUIObject * topparent
gBaseGUIObject * parent
bool isenabled
bool isvisible
bool istitleon
int parentslotlineno
int parentslotcolumnno
Static Protected Attributes inherited from gBaseGUIObject
static gColor * backgroundcolor
static gColor * middlegroundcolor
static gColor * foregroundcolor
static gColor * textbackgroundcolor
static gColor * navigationbackgroundcolor
static gFont * font
static gColor * fontcolor
static gColor * navigationfontcolor
static gColor * buttoncolor
static gColor * pressedbuttoncolor
static gColor * disabledbuttoncolor
static gColor * buttonfontcolor
static gColor * pressedbuttonfontcolor
static gColor * disabledbuttonfontcolor
static gGUIActionManager actionmanager
static gGUIResources res
Static Protected Attributes inherited from gRenderObject
static bool isshadowmappingenabled
static bool isextrashadersenabled
Static Protected Attributes inherited from gObject
static int renderpassnum
static int renderpassno
static int releasescaling
static int releaseresolution

Detailed Description

Beggining of gGUIContextMenuItem class which creates a menu item according to given parameters. Without any parameters the class will give an error. You can add menu items, seperators, change both menu width and left margin width. You can directly change menu width (Ex: menu.contextmenudefaultw = 100;) but you have to use setter function to change left margin width. (Ex: menu.setContextMenuLeftMargin(20);)

HOW TO USE

  • First, create an object from gGUIContextMenu class (Ex: gGUIContextMenu menu;) and use addContextMenu method to add your menu into the frame. (Ex: frame.addContextMenu(&menu);)
  • Second, add menu items with addItem method. (Ex: menu.addItem("item name", nullptr, false);) You can also add sub-menu items with this function. (Ex: menu.getItem(0)->addItem("item name", &menuicon, false); or menu.getItem(0)->getItem(0)->addItem("item name", nullptr, false);) Parameter explanations can be found below.
  • To add an icon to menu you can load your own images or use the icons provided by GlistEngine.
  • To use your own image create a gImage object (Ex: gImage icon;) and load it with loadImage method. Then, you can send this object to add item. (Ex: menu.addItem("item name", &icon, false);)
  • To use icons provided by GlistEngine create a gGUIResources object. (Ex: gGUIResources resource;) Initialize it by initialize method. (Ex: resource.initialize();) then you can send it to addItem by getIconImage method. (Ex: menu.addItem("item name", icon.getIconImage(gGUIResources::ICON_FILE), false);)
  • There are many different icons in GlistEngine you can see them all in gGUIResources.h
  • In order to add functionality to menu options you can use isPressed method in GameCanvas' mousePressed method. (Ex: if(menu.getItem(0)->isPressed()) { // your code })
  • Lastly, run your program. When you right click on the screen you will see the context menu, then you can close it with a left click.

Constructor & Destructor Documentation

◆ gGUIContextMenuItem()

gGUIContextMenuItem::gGUIContextMenuItem ( std::string text,
gImage * menuIcon,
bool seperatorAdded )

◆ ~gGUIContextMenuItem()

virtual gGUIContextMenuItem::~gGUIContextMenuItem ( )
overridevirtual

Member Function Documentation

◆ addItem()

void gGUIContextMenuItem::addItem ( std::string text,
gImage * menuIcon,
bool seperatorAdded )

Adds an item to the gGUIContextMenuItem vector

Parameters
std::stringtext is the title of menu item
gImage*menuIcon is the icon of menu item, if nullptr is sent an item without any icons will be added to the vector.
boolseperatorAdded determines if there will be a seperator under a menu item or not.

◆ drawMenuItem()

virtual void gGUIContextMenuItem::drawMenuItem ( )
virtual

◆ getContextMenuLeftMargin()

int gGUIContextMenuItem::getContextMenuLeftMargin ( )

Returns the width of context menu item's left margin.

Returns
the current width of left margin.

◆ getContextMenuShown()

bool gGUIContextMenuItem::getContextMenuShown ( )

Returns the visibility of context menu

Returns
the visibility information for menu.

◆ getContextMenuSize()

int gGUIContextMenuItem::getContextMenuSize ( )

◆ getItem()

gGUIContextMenuItem * gGUIContextMenuItem::getItem ( int itemNo)

Returns selected menu item.

Parameters
itemNois the number of the gGUIMenuItem object to return
Returns
selected item as an gGUIMenuItem object.

◆ getItemId()

int gGUIContextMenuItem::getItemId ( )

Returns item id.

Returns
the value of a menu items id.

◆ getItemTitle()

std::string gGUIContextMenuItem::getItemTitle ( int itemNo)

◆ getParentItemId()

int gGUIContextMenuItem::getParentItemId ( )

Returns parent item's id.

Returns
the value of parent item's id.

◆ isPressed()

bool gGUIContextMenuItem::isPressed ( )

◆ mouseMoved()

void gGUIContextMenuItem::mouseMoved ( int x,
int y )
overridevirtual

Reimplemented from gBaseGUIObject.

◆ mousePressed()

void gGUIContextMenuItem::mousePressed ( int x,
int y,
int button )
overridevirtual

Reimplemented from gBaseGUIObject.

◆ mouseReleased()

void gGUIContextMenuItem::mouseReleased ( int x,
int y,
int button )
overridevirtual

Reimplemented from gBaseGUIObject.

◆ setContextMenuLeftMargin()

void gGUIContextMenuItem::setContextMenuLeftMargin ( int leftMargin)

Sets context menu item's left margin to given number.

Parameters
leftMarginis the new margin width to be set.

◆ setParentItemId()

void gGUIContextMenuItem::setParentItemId ( int itemId)

Sets parent item id of an item.

Parameters
itemIdis the menu item's parent id to be set.

Member Data Documentation

◆ contextmenudefaultw

int gGUIContextMenuItem::contextmenudefaultw

◆ contextmenuh

int gGUIContextMenuItem::contextmenuh

◆ contextmenux

int gGUIContextMenuItem::contextmenux

◆ contextmenuy

int gGUIContextMenuItem::contextmenuy

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