2013-01-13 19:32:13 +01:00
|
|
|
// Copyright (c) 2013, Thomas Goyne <plorkyeran@aegisub.org>
|
2007-01-02 23:18:10 +01:00
|
|
|
//
|
2013-01-13 19:32:13 +01:00
|
|
|
// Permission to use, copy, modify, and distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice appear in all copies.
|
2007-01-02 23:18:10 +01:00
|
|
|
//
|
2013-01-13 19:32:13 +01:00
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
2007-01-02 23:18:10 +01:00
|
|
|
//
|
2009-07-29 07:43:02 +02:00
|
|
|
// Aegisub Project http://www.aegisub.org/
|
|
|
|
|
2013-01-13 19:32:13 +01:00
|
|
|
#include <wx/button.h>
|
2007-01-02 23:18:10 +01:00
|
|
|
|
2012-10-26 16:09:14 +02:00
|
|
|
#include <libaegisub/color.h>
|
Note: This was done using a script! it's far from perfect but 95% of the work has been done already formatting-wise.
Document all functions, class, struct, union, enum, macro, variable, typedefs. This isn't the actual document in itself but empty documentation using any old documentation if it was there.
This was done using exuberant ctags to get tag info, then a TCL script to parse/remove old comments and convert them into Doxygen-style.
Some notes:
* Anything labeled 'DOCME' needs to be documented, @param and @return have been left blank as it would be annoying to delete the 'DOCME' from every one of those.
* Some multiline comments may have been munged into single line comments
* Leave the /// comments above global variables with a space, if they're harder to read then we'll be less likey to use them.
* Enum comments can go after the enumeration itself '[value] /// comment'
* include/aegisub/*.h haven't been converted yet, this will be done in a later commit
* Some documentation blocks are in the wrong place, in the .h when it should be in the .cpp, or vice versa.
See http://devel.aegisub.org/wiki/Doxygen for some details on Doxygen and a 'style guide'.
Originally committed to SVN as r3312.
2009-07-30 00:59:22 +02:00
|
|
|
|
2015-01-01 17:12:05 +01:00
|
|
|
#include "value_event.h"
|
|
|
|
|
2013-01-13 19:32:13 +01:00
|
|
|
/// Emitted by ColourButton when the user picks a new color, with the chosen
|
|
|
|
/// color set to the event payload
|
2015-01-01 17:12:05 +01:00
|
|
|
AGI_DECLARE_EVENT(EVT_COLOR, agi::Color);
|
2013-01-13 19:32:13 +01:00
|
|
|
|
|
|
|
/// A button which displays a currently-selected color and lets the user pick
|
|
|
|
/// a new color when clicked
|
|
|
|
class ColourButton: public wxButton {
|
2013-07-02 06:34:37 +02:00
|
|
|
wxImage bmp; ///< The button's bitmap label
|
2013-01-13 19:32:13 +01:00
|
|
|
agi::Color colour; ///< The current colour
|
2012-10-26 16:09:14 +02:00
|
|
|
|
2013-01-13 19:32:13 +01:00
|
|
|
/// Update the bitmap label after the color is changed
|
|
|
|
void UpdateBitmap();
|
2007-01-02 23:18:10 +01:00
|
|
|
|
|
|
|
public:
|
2013-01-13 19:32:13 +01:00
|
|
|
/// Constructor
|
|
|
|
/// @param parent Parent window
|
|
|
|
/// @param size Size of the bitmap (note: not the size of the button)
|
2013-01-13 20:19:13 +01:00
|
|
|
/// @param alpha Let the user adjust the color's alpha
|
2013-01-13 19:32:13 +01:00
|
|
|
/// @param color Initial color to display
|
2013-01-13 20:19:13 +01:00
|
|
|
ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi::Color color = agi::Color(), wxValidator const& validator = wxDefaultValidator);
|
2007-01-02 23:18:10 +01:00
|
|
|
|
2013-01-13 19:32:13 +01:00
|
|
|
/// Get the currently selected color
|
|
|
|
agi::Color GetColor() { return colour; }
|
2007-01-02 23:18:10 +01:00
|
|
|
};
|
2013-06-12 01:32:59 +02:00
|
|
|
|
2014-03-13 02:39:07 +01:00
|
|
|
struct ColorValidator final : public wxValidator {
|
2013-06-12 01:32:59 +02:00
|
|
|
agi::Color *color;
|
|
|
|
ColorValidator(agi::Color *color) : color(color) { }
|
2013-11-21 18:13:36 +01:00
|
|
|
wxValidator *Clone() const override { return new ColorValidator(color); }
|
|
|
|
bool Validate(wxWindow*) override { return true; }
|
|
|
|
bool TransferToWindow() override { return true; }
|
2013-06-12 01:32:59 +02:00
|
|
|
|
2013-11-21 18:13:36 +01:00
|
|
|
bool TransferFromWindow() override {
|
2013-06-12 01:32:59 +02:00
|
|
|
*color = static_cast<ColourButton*>(GetWindow())->GetColor();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|