Semi-broken support for colour buttons in auto4-lua

Originally committed to SVN as r2026.
This commit is contained in:
Alysson Souza 2008-03-12 07:04:07 +00:00
parent 0a931d3f45
commit e9004aa0f9
1 changed files with 52 additions and 2 deletions

View File

@ -55,6 +55,7 @@
#include <wx/validate.h>
#include <wx/tokenzr.h>
#include <assert.h>
#include "colour_button.h"
namespace Automation4 {
@ -208,6 +209,56 @@ namespace Automation4 {
};
class Color : public LuaConfigDialogControl {
public:
wxString text;
Color(lua_State *L)
: LuaConfigDialogControl(L)
{
lua_getfield(L, -1, "value");
text = wxString(lua_tostring(L, -1), wxConvUTF8);
lua_pop(L, 1);
}
virtual ~Color() { }
bool CanSerialiseValue()
{
return true;
}
wxString SerialiseValue()
{
return inline_string_encode(text);
}
void UnserialiseValue(const wxString &serialised)
{
text = inline_string_decode(serialised);
}
wxControl *Create(wxWindow *parent)
{
cw = new ColourButton(parent, -1, wxSize(50*width,10*height), wxColour(text));
cw->SetToolTip(hint);
return cw;
}
void ControlReadBack()
{
text = ((ColourButton*)cw)->GetColour().GetAsString(wxC2S_HTML_SYNTAX);
}
void LuaReadBack(lua_State *L)
{
lua_pushstring(L, text.mb_str(wxConvUTF8));
}
};
// Multiline edit
@ -573,8 +624,7 @@ skipbuttons:
} else if (controlclass == _T("checkbox")) {
ctl = new LuaControl::Checkbox(L);
} else if (controlclass == _T("color")) {
// FIXME
ctl = new LuaControl::Edit(L);
ctl = new LuaControl::Color(L);
} else if (controlclass == _T("coloralpha")) {
// FIXME
ctl = new LuaControl::Edit(L);