Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christophe Berbizier (dbdl)
committed
Feb 12, 2014
1 parent
0a1b772
commit 53337dd
Showing
6 changed files
with
451 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/************************************************************ | ||
LHyperlinkButton.cpp | ||
@author Christophe Berbizier (cberbizier@peersuasive.com) | ||
@license GPLv3 | ||
@copyright | ||
(c) 2014, Peersuasive Technologies | ||
*************************************************************/ | ||
|
||
#include "LHyperlinkButton_inh.h" | ||
|
||
const char LHyperlinkButton::className[] = "LHyperlinkButton"; | ||
const Luna<LHyperlinkButton>::PropertyType LHyperlinkButton::properties[] = { | ||
{"url", &LHyperlinkButton::getURL, &LHyperlinkButton::setURL}, | ||
{"font", &LBase::writeOnly, &LHyperlinkButton::setFont}, | ||
|
||
{0,0} | ||
}; | ||
const Luna<LHyperlinkButton>::FunctionType LHyperlinkButton::methods[] = { | ||
method( LHyperlinkButton, getURL ), | ||
method( LHyperlinkButton, setURL ), | ||
method( LHyperlinkButton, setFont ), | ||
method( LHyperlinkButton, changeWidthToFitText ), | ||
{0,0} | ||
}; | ||
|
||
const Luna<LHyperlinkButton>::StaticType LHyperlinkButton::statics[] = { | ||
{0,0} | ||
}; | ||
|
||
LHyperlinkButton::LHyperlinkButton(lua_State *L) | ||
: LButton(L, this), | ||
HyperlinkButton() | ||
{ | ||
HyperlinkButton::setName(myName()); | ||
HyperlinkButton::addListener(this); | ||
|
||
REGISTER_CLASS(LHyperlinkButton); | ||
} | ||
|
||
LHyperlinkButton::~LHyperlinkButton() {} | ||
|
||
// callbacks | ||
int LHyperlinkButton::addListener(lua_State*) { | ||
HyperlinkButton::addListener(this); | ||
return 0; | ||
} | ||
|
||
int LHyperlinkButton::removeListener(lua_State*) { | ||
HyperlinkButton::removeListener(this); | ||
return 0; | ||
} | ||
|
||
void LHyperlinkButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) { | ||
if(hasCallback("paintButton")) | ||
LButton::lpaintButton(g, isMouseOver, isButtonDown); | ||
else | ||
HyperlinkButton::paintButton(g, isMouseOver, isButtonDown); | ||
} | ||
|
||
void LHyperlinkButton::buttonStateChanged() { | ||
LButton::lbuttonStateChanged(); | ||
} | ||
|
||
void LHyperlinkButton::buttonClicked (Button* buttonThatWasClicked) { | ||
LButton::lbuttonClicked(buttonThatWasClicked); | ||
} | ||
|
||
/////// getters/setters | ||
int LHyperlinkButton::getURL ( lua_State *L ) { | ||
return LUA::returnString( HyperlinkButton::getURL().toString(true) ); | ||
} | ||
int LHyperlinkButton::setURL ( lua_State* ) { | ||
HyperlinkButton::setURL( URL( LUA::getString() ) ); | ||
return 0; | ||
} | ||
|
||
/////// setters | ||
int LHyperlinkButton::setFont ( lua_State* ) { | ||
Font newFont = *LUA::from_luce<LFont>(2); | ||
bool resizeToMatchComponentHeight = LUA::checkAndGetBoolean(2, false); | ||
Justification justificationType ( | ||
(Justification)LUA::checkAndGetNumber<int>(2, Justification::horizontallyCentred ) ); | ||
HyperlinkButton::setFont( newFont, resizeToMatchComponentHeight, justificationType ); | ||
return 0; | ||
} | ||
|
||
int LHyperlinkButton::changeWidthToFitText ( lua_State* ) { | ||
HyperlinkButton::changeWidthToFitText(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/************************************************************ | ||
LHyperlinkButton.h | ||
@author Christophe Berbizier (cberbizier@peersuasive.com) | ||
@license GPLv3 | ||
@copyright | ||
(c) 2014, Peersuasive Technologies | ||
*************************************************************/ | ||
|
||
#ifndef __LUCE_LHYPERLINKBUTTON_H | ||
#define __LUCE_LHYPERLINKBUTTON_H | ||
|
||
class LHyperlinkButton | ||
: public LButton, | ||
public HyperlinkButton, | ||
public Button::Listener | ||
|
||
{ | ||
public: | ||
LHyperlinkButton(lua_State*); | ||
~LHyperlinkButton(); | ||
|
||
//============================================================================== | ||
int addListener(lua_State*); | ||
int removeListener(lua_State*); | ||
|
||
//============================================================================== | ||
int setURL(lua_State*); | ||
int getURL(lua_State*); | ||
|
||
//============================================================================== | ||
int setFont(lua_State*); | ||
int changeWidthToFitText(lua_State*); | ||
|
||
//============================================================================== | ||
static const char className[]; | ||
static const Luna<LHyperlinkButton>::Inheritence inherits[]; | ||
static const Luna<LHyperlinkButton>::InheritenceF inheritsF[]; | ||
static const Luna<LHyperlinkButton>::PropertyType properties[]; | ||
static const Luna<LHyperlinkButton>::FunctionType methods[]; | ||
static const Luna<LHyperlinkButton>::StaticType statics[]; | ||
static const Luna<LHyperlinkButton>::Enum enums[]; | ||
|
||
private: | ||
//============================================================================== | ||
// callbacks | ||
virtual void paintButton(Graphics&, bool, bool) override; | ||
virtual void buttonStateChanged() override; | ||
virtual void buttonClicked (Button* buttonThatWasClicked) override; | ||
|
||
//============================================================================== | ||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (LHyperlinkButton) | ||
}; | ||
|
||
#endif // __LUCE_LHYPERLINKBUTTON_H |
Oops, something went wrong.