diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/skin/widgets/checkbox.h | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Wasabi/api/skin/widgets/checkbox.h')
-rw-r--r-- | Src/Wasabi/api/skin/widgets/checkbox.h | 246 |
1 files changed, 246 insertions, 0 deletions
diff --git a/Src/Wasabi/api/skin/widgets/checkbox.h b/Src/Wasabi/api/skin/widgets/checkbox.h new file mode 100644 index 00000000..213d25a0 --- /dev/null +++ b/Src/Wasabi/api/skin/widgets/checkbox.h @@ -0,0 +1,246 @@ +#ifndef __CHECKBOX_H +#define __CHECKBOX_H + +#include <api/wnd/wndclass/guiobjwnd.h> +#include <api/script/objects/c_script/h_guiobject.h> +#include <api/script/objects/c_script/h_button.h> + +#define CHECKBOX_PARENT GuiObjectWnd + +class TextClicks; +class ToggleClicks; + + +/** + Class + + @short + @author Nullsoft + @ver 1.0 + @see +*/ +class CheckBox : public CHECKBOX_PARENT { + + public: + + CheckBox(const wchar_t *_text = L"ERROR", const wchar_t *_radioid = NULL); + virtual ~CheckBox(); + + + /** + Method + + @see + @ret + @param + */ + virtual int onInit(); + + + /** + Method + + @see + @ret + @param + */ + virtual int getPreferences(int what); + + + /** + Method + + @see + @ret + @param + */ + void toggle(int self_switch); // this is called by the click catchers. + + /** + Method + + @see + @ret + @param + */ + void setActivated(int activated, int writetocfg=1); + + /** + Method + + @see + @ret + @param + */ + int isActivated(); + + + /** + Method + + @see + @ret + @param + */ + void setText(const wchar_t *_text); + const wchar_t *getText(); + void setRadioid(const wchar_t *_radioid); + const wchar_t *getRadioid() { return radioid; } + void setRadioVal(const wchar_t *val, int use_radioval=TRUE); + const wchar_t *getRadioVal() { return radioval; } + + +#ifdef WASABI_COMPILE_CONFIG + /** + Method + + @see + @ret + @param + */ + virtual int onReloadConfig(); +#endif + + /** + Method + + @see + @ret + @param + */ + virtual void onNewContent(); + + virtual int wantFocus() { return 1; } + virtual int onChar(unsigned int c); + + virtual void setAction(const wchar_t *str); + virtual void setActionTarget(const wchar_t *target); + virtual void setActionParam(const wchar_t *param); + virtual const wchar_t *getActionParam(); + + protected: + virtual void onToggle(); //override to catch toggles + + private: + + void doAction(); + + /** + Method + + @see + @ret + @param + */ + void updateText(); + + TextClicks *textclicks; + ToggleClicks *toggleclicks; + StringW text; + StringW radioid; + GuiObject *buttonGuiObj; + StringW radioval; + int use_radioval; + StringW action, action_target, action_param; +}; + + +/** + Class + + @short + @author Nullsoft + @ver 1.0 + @see +*/ +class TextClicks : public H_GuiObject { + public: + + /** + Method + + @see + @ret + @param + */ + TextClicks(ScriptObject *textobj, CheckBox *_callback) : + + /** + Method + + @see + @ret + @param + */ + callback(_callback), H_GuiObject(textobj) { + } + + + /** + Method + + @see + @ret + @param + */ + virtual void hook_onLeftButtonDown(int x, int y) { + callback->toggle(0); + } + private: + CheckBox *callback; +}; + + +/** + Class + + @short + @author Nullsoft + @ver 1.0 + @see +*/ +class ToggleClicks : public H_Button { + public: + + /** + Method + + @see + @ret + @param + */ + ToggleClicks(ScriptObject *button, CheckBox *_callback) : + + /** + Method + + @see + @ret + @param + */ + callback(_callback), H_Button(button) { + inhere=0; + } + + + /** + Method + + @see + @ret + @param + */ + virtual void hook_onActivate(int activate) { + if (inhere) return; + inhere=1; + callback->toggle(1); + inhere=0; + } + + private: + CheckBox *callback; + int inhere; +}; + + +#endif |