Torque3D Documentation / _generateds / guiBitmapButtonCtrl.cpp

guiBitmapButtonCtrl.cpp

Engine/source/gui/buttons/guiBitmapButtonCtrl.cpp

More...

Public Variables

Public Functions

ConsoleDocClass(GuiBitmapButtonCtrl , "@brief A button that renders its various states (mouse over, pushed, etc.) from separate <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">bitmaps.\n\n</a>" "A bitmapped button is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> push button that uses one or more texture images <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> rendering its individual <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">states.\n\n</a>" "To find the individual textures associated with the button, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> naming scheme is used. For each state " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> suffix is appended <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the texture <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> name given in the GuiBitmapButtonCtrl::bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">field:\n</a>" "- \"_n\": Normal state. This one will be active when no other state <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">applies.\n</a>" "- \"_h\": Highlighted state. This applies when the mouse is hovering over the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n</a>" "- \"_d\": Depressed state. This applies when the left mouse button has been clicked on the button but not yet <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">released.\n</a>" "- \"_i\": Inactive state. This applies when the button <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> has been deactivated (<a href="/coding/class/classguicontrol/#classguicontrol_1a364a295ca2dde03cb49cefbc67b80d24">GuiControl::setActive</a>())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "If <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular state cannot be found, the default bitmap will be used. To disable all state-based " "bitmap functionality, set useStates <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> false which will make the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> solely <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> from the bitmap specified " "in the bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">field.\n\n</a>" " @section guibitmapbutton_modifiers Per-Modifier Button <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Actions\n</a>" "If GuiBitmapButtonCtrl::useModifiers is set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true, per-modifier button actions and textures are enabled. This functionality " "allows <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> associate different images and different actions with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> button depending on which modifiers are pressed " "on the keyboard by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">user.\n\n</a>" "When enabled, this functionality alters the texture lookup above by prepending the following strings <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the " "suffixes listed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">above:\n</a>" "- \"\": Default. No modifier is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "- \"_ctrl\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when CTRL/CMD is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- \"_alt\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when ALT is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- \"_shift\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when SHIFT is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down\n\n</a>" "When this functionality is enabled, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> set of callbacks is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">used:\n</a>" "- onDefaultClick:Button was clicked without <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> modifier being <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">presssed.\n</a>" "- onCtrlClick:Button was clicked with the CTRL/CMD key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- onAltClick:Button was clicked with the ALT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- onShiftClick:Button was clicked with the SHIFT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n\n</a>" "GuiControl::command or <a href="/coding/class/classguicontrol/#classguicontrol_1a87cb040f7be0557426f9a2328dc6f65d">GuiControl::onAction</a>() still work as before when per-modifier functionality is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enabled.\n\n</a>" "Note that modifiers cannot be mixed. If two or more modifiers are pressed)
ConsoleDocClass(GuiBitmapButtonTextCtrl , "@brief An extension of <a href="/coding/class/classguibitmapbuttonctrl/">GuiBitmapButtonCtrl</a> that additionally renders <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> text label on the bitmapped <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n\n</a>" "The text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the label is taken from the GuiButtonBaseCtrl::text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">property.\n\n</a>" "For rendering, the label is placed, relative <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> 's upper left corner, at the text offset specified in the " "<a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> 's profile(GuiControlProfile::textOffset) and justified according <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the profile 's setting(GuiControlProfile::justify).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile::textOffset\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile::justify\n</a>" " @ingroup GuiButtons" )
DefineEngineMethod(GuiBitmapButtonCtrl , setBitmap , void , (const char *path) , "Set the bitmap <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n</a>" "@param path Path <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the texture <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> in any of the supported <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">formats.\n</a>" )
IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onAltClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the ALT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )
IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onCtrlClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the CTRL key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )
IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onDefaultClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button without any modifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )
IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onShiftClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the SHIFT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )
ImplementEnumType(GuiBitmapMode , "Rendering behavior when placing bitmaps in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" "@ingroup GuiImages" )

Detailed Description

Public Variables

 EndImplementEnumType 

Public Functions

ConsoleDocClass(GuiBitmapButtonCtrl , "@brief A button that renders its various states (mouse over, pushed, etc.) from separate <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">bitmaps.\n\n</a>" "A bitmapped button is <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> push button that uses one or more texture images <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> rendering its individual <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">states.\n\n</a>" "To find the individual textures associated with the button, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> naming scheme is used. For each state " "<a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> suffix is appended <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the texture <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> name given in the GuiBitmapButtonCtrl::bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">field:\n</a>" "- \"_n\": Normal state. This one will be active when no other state <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">applies.\n</a>" "- \"_h\": Highlighted state. This applies when the mouse is hovering over the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n</a>" "- \"_d\": Depressed state. This applies when the left mouse button has been clicked on the button but not yet <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">released.\n</a>" "- \"_i\": Inactive state. This applies when the button <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> has been deactivated (<a href="/coding/class/classguicontrol/#classguicontrol_1a364a295ca2dde03cb49cefbc67b80d24">GuiControl::setActive</a>())\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" "If <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> particular state cannot be found, the default bitmap will be used. To disable all state-based " "bitmap functionality, set useStates <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> false which will make the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> solely <a href="/coding/file/editortool_8cpp/#editortool_8cpp_1a4cb041169a32ea3d4cacadbb955e06b4">render</a> from the bitmap specified " "in the bitmap <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">field.\n\n</a>" " @section guibitmapbutton_modifiers Per-Modifier Button <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">Actions\n</a>" "If GuiBitmapButtonCtrl::useModifiers is set <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> true, per-modifier button actions and textures are enabled. This functionality " "allows <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> associate different images and different actions with <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> button depending on which modifiers are pressed " "on the keyboard by the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">user.\n\n</a>" "When enabled, this functionality alters the texture lookup above by prepending the following strings <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the " "suffixes listed <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">above:\n</a>" "- \"\": Default. No modifier is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "- \"_ctrl\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when CTRL/CMD is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- \"_alt\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when ALT is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- \"_shift\": Image <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> use when SHIFT is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down\n\n</a>" "When this functionality is enabled, <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> <a href="/coding/file/tmm__on_8h/#tmm__on_8h_1a1ac41480eb2e4aadd52252ee550b630a">new</a> set of callbacks is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">used:\n</a>" "- onDefaultClick:Button was clicked without <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> modifier being <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">presssed.\n</a>" "- onCtrlClick:Button was clicked with the CTRL/CMD key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- onAltClick:Button was clicked with the ALT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n</a>" "- onShiftClick:Button was clicked with the SHIFT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">down.\n\n</a>" "GuiControl::command or <a href="/coding/class/classguicontrol/#classguicontrol_1a87cb040f7be0557426f9a2328dc6f65d">GuiControl::onAction</a>() still work as before when per-modifier functionality is <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">enabled.\n\n</a>" "Note that modifiers cannot be mixed. If two or more modifiers are pressed)

ConsoleDocClass(GuiBitmapButtonTextCtrl , "@brief An extension of <a href="/coding/class/classguibitmapbuttonctrl/">GuiBitmapButtonCtrl</a> that additionally renders <a href="/coding/file/pointer_8h/#pointer_8h_1aeeddce917cf130d62c370b8f216026dd">a</a> text label on the bitmapped <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n\n</a>" "The text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a2732ab74fa0237854c2ba0f75f88a624">for</a> the label is taken from the GuiButtonBaseCtrl::text <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">property.\n\n</a>" "For rendering, the label is placed, relative <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the <a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> 's upper left corner, at the text offset specified in the " "<a href="/coding/file/guieditctrl_8cpp/#guieditctrl_8cpp_1abb04e3738c4c5a96b3ade6fa47013a6c">control</a> 's profile(GuiControlProfile::textOffset) and justified according <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the profile 's setting(GuiControlProfile::justify).\<a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">n\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile::textOffset\n</a>" " @see <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">GuiControlProfile::justify\n</a>" " @ingroup GuiButtons" )

DefineEngineMethod(GuiBitmapButtonCtrl , setBitmap , void , (const char *path) , "Set the bitmap <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> show on the <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">button.\n</a>" "@param path Path <a href="/coding/file/cmdgram_8cpp/#cmdgram_8cpp_1a5bafda9519252aa2d0fd038153f77dca">to</a> the texture <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1a702945180aa732857b380a007a7e2a21">file</a> in any of the supported <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">formats.\n</a>" )

IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onAltClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the ALT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )

IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onCtrlClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the CTRL key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )

IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onDefaultClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button without any modifier <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )

IMPLEMENT_CALLBACK(GuiBitmapButtonCtrl , onShiftClick , void , () , () , "Called when per-modifier functionality is enabled and the user clicks on the button with the SHIFT key <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">pressed.\n</a>" "@ref guibitmapbutton_modifiers" )

IMPLEMENT_CONOBJECT(GuiBitmapButtonCtrl )

IMPLEMENT_CONOBJECT(GuiBitmapButtonTextCtrl )

ImplementEnumType(GuiBitmapMode , "Rendering behavior when placing bitmaps in <a href="/coding/file/cmdscan_8cpp/#cmdscan_8cpp_1aeab71244afb687f16d8c4f5ee9d6ef0e">controls.\n\n</a>" "@ingroup GuiImages" )

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#include "platform/platform.h"
 25#include "gui/buttons/guiBitmapButtonCtrl.h"
 26#include "core/util/path.h"
 27#include "console/console.h"
 28#include "console/consoleTypes.h"
 29#include "console/engineAPI.h"
 30#include "gui/core/guiCanvas.h"
 31#include "gui/core/guiDefaultControlRender.h"
 32#include "gfx/gfxDrawUtil.h"
 33#include "gfx/gfxTextureManager.h"
 34
 35
 36ImplementEnumType( GuiBitmapMode,
 37   "Rendering behavior when placing bitmaps in controls.\n\n"
 38   "@ingroup GuiImages" )
 39   { GuiBitmapButtonCtrl::BitmapStretched, "Stretched", "Stretch bitmap to fit control extents." },
 40   { GuiBitmapButtonCtrl::BitmapCentered, "Centered", "Center bitmap in control."  },
 41EndImplementEnumType;
 42
 43
 44//=============================================================================
 45//    GuiBitmapButtonCtrl
 46//=============================================================================
 47
 48IMPLEMENT_CONOBJECT(GuiBitmapButtonCtrl);
 49
 50ConsoleDocClass( GuiBitmapButtonCtrl,
 51   "@brief A button that renders its various states (mouse over, pushed, etc.) from separate bitmaps.\n\n"
 52   
 53   "A bitmapped button is a push button that uses one or more texture images for rendering its individual states.\n\n"
 54   
 55   "To find the individual textures associated with the button, a naming scheme is used.  For each state "
 56   "a suffix is appended to the texture file name given in the GuiBitmapButtonCtrl::bitmap field:\n"
 57   
 58   "- \"_n\": Normal state.  This one will be active when no other state applies.\n"
 59   "- \"_h\": Highlighted state.  This applies when the mouse is hovering over the button.\n"
 60   "- \"_d\": Depressed state.  This applies when the left mouse button has been clicked on the button but not yet released.\n"
 61   "- \"_i\": Inactive state.  This applies when the button control has been deactivated (GuiControl::setActive())\n\n"
 62   
 63   "If a bitmap for a particular state cannot be found, the default bitmap will be used.  To disable all state-based "
 64   "bitmap functionality, set useStates to false which will make the control solely render from the bitmap specified "
 65   "in the bitmap field.\n\n"
 66
 67   "@section guibitmapbutton_modifiers Per-Modifier Button Actions\n"
 68   
 69   "If GuiBitmapButtonCtrl::useModifiers is set to true, per-modifier button actions and textures are enabled.  This functionality "
 70   "allows to associate different images and different actions with a button depending on which modifiers are pressed "
 71   "on the keyboard by the user.\n\n"
 72   
 73   "When enabled, this functionality alters the texture lookup above by prepending the following strings to the "
 74   "suffixes listed above:\n"
 75   
 76   "- \"\": Default.  No modifier is pressed.\n"
 77   "- \"_ctrl\": Image to use when CTRL/CMD is down.\n"
 78   "- \"_alt\": Image to use when ALT is down.\n"
 79   "- \"_shift\": Image to use when SHIFT is down\n\n"
 80   
 81   "When this functionality is enabled, a new set of callbacks is used:\n"
 82   
 83   "- onDefaultClick: Button was clicked without a modifier being presssed.\n"
 84   "- onCtrlClick: Button was clicked with the CTRL/CMD key down.\n"
 85   "- onAltClick: Button was clicked with the ALT key down.\n"
 86   "- onShiftClick: Button was clicked with the SHIFT key down.\n\n"
 87   
 88   "GuiControl::command or GuiControl::onAction() still work as before when per-modifier functionality is enabled.\n\n"
 89   
 90   "Note that modifiers cannot be mixed.  If two or more modifiers are pressed, a single one will take precedence over "
 91   "the remaining modifiers.  The order of precedence corresponds to the order listed above.\n\n"
 92   
 93   "@tsexample\n"
 94   "// Create an OK button that will trigger an onOk() call on its parent when clicked:\n"
 95   "%okButton = new GuiBitmapButtonCtrl()\n"
 96   "{\n"
 97   "   bitmap = \"art/gui/okButton\";\n"
 98   "   autoFitExtents = true;\n"
 99   "   command = \"$ThisControl.getParent().onOk();\";\n"
100   "};\n"
101   "@endtsexample\n\n"
102   
103   "@ingroup GuiButtons"
104);
105
106IMPLEMENT_CALLBACK( GuiBitmapButtonCtrl, onDefaultClick, void, (), (),
107   "Called when per-modifier functionality is enabled and the user clicks on the button without any modifier pressed.\n"
108   "@ref guibitmapbutton_modifiers" );
109IMPLEMENT_CALLBACK( GuiBitmapButtonCtrl, onCtrlClick, void, (), (),
110   "Called when per-modifier functionality is enabled and the user clicks on the button with the CTRL key pressed.\n"
111   "@ref guibitmapbutton_modifiers" );
112IMPLEMENT_CALLBACK( GuiBitmapButtonCtrl, onAltClick, void, (), (),
113   "Called when per-modifier functionality is enabled and the user clicks on the button with the ALT key pressed.\n"
114   "@ref guibitmapbutton_modifiers" );
115IMPLEMENT_CALLBACK( GuiBitmapButtonCtrl, onShiftClick, void, (), (),
116   "Called when per-modifier functionality is enabled and the user clicks on the button with the SHIFT key pressed.\n"
117   "@ref guibitmapbutton_modifiers" );
118
119//-----------------------------------------------------------------------------
120
121GuiBitmapButtonCtrl::GuiBitmapButtonCtrl()
122{
123   mBitmapMode = BitmapStretched;
124   mAutoFitExtents = false;
125   mUseModifiers = false;
126   mUseStates = true;
127   setExtent( 140, 30 );
128   mMasked = false;
129}
130
131//-----------------------------------------------------------------------------
132
133void GuiBitmapButtonCtrl::initPersistFields()
134{
135   addGroup( "Bitmap" );
136   
137      addProtectedField( "bitmap", TypeStringFilename, Offset( mBitmapName, GuiBitmapButtonCtrl ),
138         &_setBitmap, &defaultProtectedGetFn,
139         "Texture file to display on this button.\n"
140         "If useStates is false, this will be the file that renders on the control.  Otherwise, this will "
141         "specify the default texture name to which the various state and modifier suffixes are appended "
142         "to find the per-state and per-modifier (if enabled) textures." );
143      addField( "bitmapMode", TYPEID< BitmapMode >(), Offset( mBitmapMode, GuiBitmapButtonCtrl ),
144         "Behavior for fitting the bitmap to the control extents.\n"
145         "If set to 'Stretched', the bitmap will be stretched both verticall and horizontally to fit inside "
146         "the control's extents.\n\n"
147         "If set to 'Centered', the bitmap will stay at its original resolution centered in the control's "
148         "rectangle (getting clipped if the control is smaller than the texture)." );
149      addProtectedField( "autoFitExtents", TypeBool, Offset( mAutoFitExtents, GuiBitmapButtonCtrl ),
150         &_setAutoFitExtents, &defaultProtectedGetFn,
151         "If true, the control's extents will be set to match the bitmap's extents when setting the bitmap.\n"
152         "The bitmap extents will always be taken from the default/normal bitmap (in case the extents of the various "
153         "bitmaps do not match up.)" );
154      addField( "useModifiers", TypeBool, Offset( mUseModifiers, GuiBitmapButtonCtrl ),
155         "If true, per-modifier button functionality is enabled.\n"
156         "@ref guibitmapbutton_modifiers" );
157      addField( "useStates", TypeBool, Offset( mUseStates, GuiBitmapButtonCtrl ),
158         "If true, per-mouse state button functionality is enabled.\n"
159         "Defaults to true.\n\n"
160         "If you do not use per-state images on this button set this to false to speed up the loading process "
161         "by inhibiting searches for the individual images." );
162      addField("masked", TypeBool, Offset(mMasked, GuiBitmapButtonCtrl),"Use alpha masking for interaction.");
163         
164   endGroup( "Bitmap" );
165      
166   Parent::initPersistFields();
167}
168
169//-----------------------------------------------------------------------------
170
171bool GuiBitmapButtonCtrl::onWake()
172{
173   if (! Parent::onWake())
174      return false;
175      
176   setActive( true );
177   setBitmap( mBitmapName );
178   
179   return true;
180}
181
182//-----------------------------------------------------------------------------
183
184void GuiBitmapButtonCtrl::onSleep()
185{
186   if( dStricmp(mBitmapName, "texhandle") != 0 )
187      for( U32 i = 0; i < NumModifiers; ++ i )
188      {
189         mTextures[ i ].mTextureNormal = NULL;
190         mTextures[ i ].mTextureHilight = NULL;
191         mTextures[ i ].mTextureDepressed = NULL;
192         mTextures[ i ].mTextureInactive = NULL;
193      }
194
195   Parent::onSleep();
196}
197
198//-----------------------------------------------------------------------------
199
200bool GuiBitmapButtonCtrl::_setAutoFitExtents( void *object, const char *index, const char *data )
201{
202   GuiBitmapButtonCtrl* ctrl = reinterpret_cast< GuiBitmapButtonCtrl* >( object );
203   ctrl->setAutoFitExtents( dAtob( data ) );
204   return false;
205}
206
207//-----------------------------------------------------------------------------
208
209bool GuiBitmapButtonCtrl::_setBitmap( void *object, const char *index, const char *data )
210{
211   GuiBitmapButtonCtrl* ctrl = reinterpret_cast< GuiBitmapButtonCtrl* >( object );
212   ctrl->setBitmap( data );
213   return false;
214}
215
216//-----------------------------------------------------------------------------
217
218// Legacy method.  Can just assign to bitmap field.
219DefineEngineMethod( GuiBitmapButtonCtrl, setBitmap, void, ( const char* path ),,
220   "Set the bitmap to show on the button.\n"
221   "@param path Path to the texture file in any of the supported formats.\n" )
222{
223   object->setBitmap( path );
224}
225
226//-----------------------------------------------------------------------------
227
228void GuiBitmapButtonCtrl::inspectPostApply()
229{
230   Parent::inspectPostApply();
231
232   Torque::Path path( mBitmapName );
233   const String& fileName = path.getFileName();
234   
235   if( mUseStates )
236   {
237      // If the filename points to a single state, automatically
238      // cut off the state part.  Makes it easy to select files in
239      // the editor without having to go in and manually cut off the
240      // state parts all the time.
241      
242      static String s_n = "_n";
243      static String s_d = "_d";
244      static String s_h = "_h";
245      static String s_i = "_i";
246      
247      if(    fileName.endsWith( s_n )
248          || fileName.endsWith( s_d )
249          || fileName.endsWith( s_h )
250          || fileName.endsWith( s_i ) )
251      {
252         path.setFileName( fileName.substr( 0, fileName.length() - 2 ) );
253         path.setExtension( String::EmptyString );
254      }
255   }
256   
257   setBitmap( path.getFullPath() );
258
259   // if the extent is set to (0,0) in the gui editor and appy hit, this control will
260   // set it's extent to be exactly the size of the normal bitmap (if present)
261
262   if ((getWidth() == 0) && (getHeight() == 0) && mTextures[ 0 ].mTextureNormal)
263   {
264      setExtent( mTextures[ 0 ].mTextureNormal->getWidth(), mTextures[ 0 ].mTextureNormal->getHeight());
265   }
266}
267
268//-----------------------------------------------------------------------------
269
270void GuiBitmapButtonCtrl::setAutoFitExtents( bool state )
271{
272   mAutoFitExtents = state;
273   if( mAutoFitExtents )
274      setBitmap( mBitmapName );
275}
276
277//-----------------------------------------------------------------------------
278
279void GuiBitmapButtonCtrl::setBitmap( const String& name )
280{
281   PROFILE_SCOPE( GuiBitmapButtonCtrl_setBitmap );
282   
283   mBitmapName = name;
284   if( !isAwake() )
285      return;
286
287   if( !mBitmapName.isEmpty() )
288   {
289      if( dStricmp( mBitmapName, "texhandle" ) != 0 )
290      {
291         const U32 count = mUseModifiers ? NumModifiers : 1;
292         for( U32 i = 0; i < count; ++ i )
293         {
294            static String modifiers[] =
295            {
296               "",
297               "_ctrl",
298               "_alt",
299               "_shift"
300            };
301            
302            static String s_n = "_n";
303            static String s_d = "_d";
304            static String s_h = "_h";
305            static String s_i = "_i";
306
307            String baseName = mBitmapName;
308            if( mUseModifiers )
309               baseName += modifiers[ i ];
310
311            mTextures[ i ].mTextureNormal = GFXTexHandle( baseName, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
312            
313            if( mUseStates )
314            {
315               if( !mTextures[ i ].mTextureNormal )
316                  mTextures[ i ].mTextureNormal = GFXTexHandle( baseName + s_n, &GFXDefaultGUIProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__));
317               
318               mTextures[ i ].mTextureHilight = GFXTexHandle( baseName + s_h, &GFXDefaultGUIProfile, avar("%s() - mTextureHighlight (line %d)", __FUNCTION__, __LINE__));
319               if( !mTextures[ i ].mTextureHilight )
320                  mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
321                  
322               mTextures[ i ].mTextureDepressed = GFXTexHandle( baseName + s_d, &GFXDefaultGUIProfile, avar("%s() - mTextureDepressed (line %d)", __FUNCTION__, __LINE__));
323               if( !mTextures[ i ].mTextureDepressed )
324                  mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
325
326               mTextures[ i ].mTextureInactive = GFXTexHandle( baseName + s_i, &GFXDefaultGUIProfile, avar("%s() - mTextureInactive (line %d)", __FUNCTION__, __LINE__));
327               if( !mTextures[ i ].mTextureInactive )
328                  mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
329            }
330
331            if( i == 0 && mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull() )
332            {
333               Con::warnf( "GuiBitmapButtonCtrl::setBitmap - Unable to load texture: %s", mBitmapName.c_str() );
334               this->setBitmap( GFXTextureManager::getUnavailableTexturePath() );
335               return;
336            }
337         }
338      }
339      
340      if( mAutoFitExtents && !mTextures[ 0 ].mTextureNormal.isNull() )
341         setExtent( mTextures[ 0 ].mTextureNormal.getWidth(), mTextures[ 0 ].mTextureNormal.getHeight() );
342   }
343   else
344   {
345      for( U32 i = 0; i < NumModifiers; ++ i )
346      {
347         mTextures[ i ].mTextureNormal = NULL;
348         mTextures[ i ].mTextureHilight = NULL;
349         mTextures[ i ].mTextureDepressed = NULL;
350         mTextures[ i ].mTextureInactive = NULL;
351      }
352   }
353   
354   setUpdate();
355}
356
357//-----------------------------------------------------------------------------
358
359void GuiBitmapButtonCtrl::setBitmapHandles(GFXTexHandle normal, GFXTexHandle highlighted, GFXTexHandle depressed, GFXTexHandle inactive)
360{
361   const U32 count = mUseModifiers ? NumModifiers : 1;
362   for( U32 i = 0; i < count; ++ i )
363   {
364      mTextures[ i ].mTextureNormal = normal;
365      mTextures[ i ].mTextureHilight = highlighted;
366      mTextures[ i ].mTextureDepressed = depressed;
367      mTextures[ i ].mTextureInactive = inactive;
368
369      if (!mTextures[ i ].mTextureHilight)
370         mTextures[ i ].mTextureHilight = mTextures[ i ].mTextureNormal;
371      if (!mTextures[ i ].mTextureDepressed)
372         mTextures[ i ].mTextureDepressed = mTextures[ i ].mTextureHilight;
373      if (!mTextures[ i ].mTextureInactive)
374         mTextures[ i ].mTextureInactive = mTextures[ i ].mTextureNormal;
375
376      if (mTextures[ i ].mTextureNormal.isNull() && mTextures[ i ].mTextureHilight.isNull() && mTextures[ i ].mTextureDepressed.isNull() && mTextures[ i ].mTextureInactive.isNull())
377      {
378         Con::warnf("GuiBitmapButtonCtrl::setBitmapHandles() - Invalid texture handles");
379         setBitmap( GFXTextureManager::getUnavailableTexturePath() );
380         
381         return;
382      }
383   }
384
385   mBitmapName = "texhandle";
386}
387
388//------------------------------------------------------------------------------
389
390GuiBitmapButtonCtrl::Modifier GuiBitmapButtonCtrl::getCurrentModifier()
391{   
392   U8 modifierKeys = Input::getModifierKeys();
393
394   if( modifierKeys & SI_PRIMARY_CTRL )
395      return ModifierCtrl;
396   else if( modifierKeys & SI_PRIMARY_ALT )
397      return ModifierAlt;
398   else if( modifierKeys & SI_SHIFT )
399      return ModifierShift;
400   
401   return ModifierNone;
402}
403
404//------------------------------------------------------------------------------
405
406GFXTexHandle& GuiBitmapButtonCtrl::getTextureForCurrentState()
407{
408   U32 index = ModifierNone;
409   if( mUseModifiers )
410      index = getCurrentModifier();
411         
412   if( !mUseStates )
413   {
414      if( mTextures[ index ].mTextureNormal )
415         return mTextures[ 0 ].mTextureNormal;
416      else
417         return mTextures[ index ].mTextureNormal;
418   }
419
420   switch( getState() )
421   {
422      case NORMAL:
423         if( !mTextures[ index ].mTextureNormal )
424            return mTextures[ 0 ].mTextureNormal;
425         else
426            return mTextures[ index ].mTextureNormal;
427            
428      case HILIGHT:
429         if( !mTextures[ index ].mTextureHilight )
430            return mTextures[ 0 ].mTextureHilight;
431         else
432            return mTextures[ index ].mTextureHilight;
433            
434      case DEPRESSED:
435         if( !mTextures[ index ].mTextureDepressed )
436            return mTextures[ 0 ].mTextureDepressed;
437         else
438            return mTextures[ index ].mTextureDepressed;
439            
440      default:
441         if( !mTextures[ index ].mTextureInactive )
442            return mTextures[ 0 ].mTextureInactive;
443         else
444            return mTextures[ index ].mTextureInactive;
445   }
446}
447
448//------------------------------------------------------------------------------
449
450void GuiBitmapButtonCtrl::onAction()
451{
452   Parent::onAction();
453   
454   if( mUseModifiers )
455   {
456      switch( getCurrentModifier() )
457      {
458         case ModifierNone:
459            onDefaultClick_callback();
460            break;
461         
462         case ModifierCtrl:
463            onCtrlClick_callback();
464            break;
465         
466         case ModifierAlt:
467            onAltClick_callback();
468            break;
469         
470         case ModifierShift:
471            onShiftClick_callback();
472            break;
473            
474         default:
475            break;
476      }
477   }
478}
479
480//------------------------------------------------------------------------------
481
482void GuiBitmapButtonCtrl::onRender(Point2I offset, const RectI& updateRect)
483{
484   GFXTexHandle& texture = getTextureForCurrentState();
485   if( texture )
486   {
487      renderButton( texture, offset, updateRect );
488      renderChildControls( offset, updateRect );
489   }
490   else
491      Parent::onRender(offset, updateRect);
492}
493
494//------------------------------------------------------------------------------
495
496void GuiBitmapButtonCtrl::renderButton( GFXTexHandle &texture, const Point2I &offset, const RectI& updateRect )
497{
498   GFX->getDrawUtil()->clearBitmapModulation();
499   
500   switch( mBitmapMode )
501   {
502      case BitmapStretched:
503      {
504         RectI rect( offset, getExtent() );
505         GFX->getDrawUtil()->drawBitmapStretch( texture, rect );
506         break;
507      }
508         
509      case BitmapCentered:
510      {
511         Point2I p = offset;
512         
513         p.x += getExtent().x / 2 - texture.getWidth() / 2;
514         p.y += getExtent().y / 2 - texture.getHeight() / 2;
515         
516         GFX->getDrawUtil()->drawBitmap( texture, p );
517         break;
518      }
519   }
520}
521
522//=============================================================================
523//    GuiBitmapButtonTextCtrl.
524//=============================================================================
525
526IMPLEMENT_CONOBJECT( GuiBitmapButtonTextCtrl);
527
528ConsoleDocClass( GuiBitmapButtonTextCtrl,
529   "@brief An extension of GuiBitmapButtonCtrl that additionally renders a text label on the bitmapped button.\n\n"
530   
531   "The text for the label is taken from the GuiButtonBaseCtrl::text property.\n\n"
532   
533   "For rendering, the label is placed, relative to the control's upper left corner, at the text offset specified in the "
534   "control's profile (GuiControlProfile::textOffset) and justified according to the profile's setting (GuiControlProfile::justify).\n\n"
535   
536   "@see GuiControlProfile::textOffset\n"
537   "@see GuiControlProfile::justify\n"
538   "@ingroup GuiButtons"
539);
540
541//-----------------------------------------------------------------------------
542
543void GuiBitmapButtonTextCtrl::renderButton( GFXTexHandle &texture, const Point2I &offset, const RectI& updateRect )
544{
545   Parent::renderButton( texture, offset, updateRect );
546
547   Point2I textPos = offset;
548   if(mDepressed)
549      textPos += Point2I(1,1);
550
551   // Make sure we take the profile's textOffset into account.
552   textPos += mProfile->mTextOffset;
553
554   GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor );
555   renderJustifiedText(textPos, getExtent(), mButtonText);
556}
557
558bool GuiBitmapButtonCtrl::pointInControl(const Point2I& parentCoordPoint)
559{
560   if (mMasked && getTextureForCurrentState())
561   {
562      ColorI rColor(0, 0, 0, 0);
563      GBitmap* bmp;
564
565      const RectI &bounds = getBounds();
566      S32 xt = parentCoordPoint.x - bounds.point.x;
567      S32 yt = parentCoordPoint.y - bounds.point.y;
568
569      bmp = getTextureForCurrentState().getBitmap();
570      if (!bmp)
571      {
572         setBitmap(mBitmapName);
573         bmp = getTextureForCurrentState().getBitmap();
574      }
575
576      S32 relativeXRange = this->getExtent().x;
577      S32 relativeYRange = this->getExtent().y;
578      S32 fileXRange = bmp->getHeight(0);
579      S32 fileYRange = bmp->getWidth(0);
580      //Con::errorf("xRange:[%i -- %i],  Range:[%i -- %i]  pos:(%i,%i)",relativeXRange,fileXRange,relativeYRange,fileYRange,xt,yt);
581
582      S32 fileX = (xt*fileXRange) / relativeXRange;
583      S32 fileY = (yt*fileYRange) / relativeYRange;
584      //Con::errorf("Checking %s @ (%i,%i)",this->getName(),fileX,fileY);
585
586      bmp->getColor(fileX, fileY, rColor);
587
588      if (rColor.alpha)
589         return true;
590      else
591         return false;
592   }
593   else
594      return Parent::pointInControl(parentCoordPoint);
595}
596