CheckBox.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /******************************************************************************/
  2. const_mem_addr STRUCT(CheckBox , GuiObj) // Gui CheckBox !! must be stored in constant memory address !!
  3. //{
  4. GuiSkinPtr skin; // skin override, default=null (if set to null then current value of 'Gui.skin' is used)
  5. // manage
  6. CheckBox& del ( ); // delete
  7. CheckBox& create( Bool on=false); // create
  8. CheckBox& create(C Rect &rect, Bool on=false) {create(on).rect(rect); return T;} // create and set rectangle
  9. CheckBox& create(C CheckBox &src ); // create from 'src'
  10. // get / set
  11. CheckBox& set (Bool on, SET_MODE mode=SET_DEFAULT); Bool operator()()C {return _on;} // set/get if on
  12. CheckBox& toggle ( SET_MODE mode=SET_DEFAULT); // toggle if on
  13. CheckBox& setMulti ( ); // set visuals as both true and false, this modifies only visuals and does not modify the current value of the checkbox
  14. CheckBox& focusable(Bool on ); Bool focusable()C {return _focusable;} // set/get if can catch keyboard focus, default=false
  15. GuiSkin* getSkin()C {return skin ? skin() : Gui.skin();} // get actual skin
  16. CheckBox& func(void (*func)(Ptr ), Ptr user=null, Bool immediate=false); // set function called when checkbox state has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  17. T1(TYPE) CheckBox& func(void (*func)(TYPE *user), TYPE *user , Bool immediate=false) {return T.func((void(*)(Ptr))func, user, immediate);} // set function called when checkbox state has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  18. T1(TYPE) CheckBox& func(void (*func)(TYPE &user), TYPE &user , Bool immediate=false) {return T.func((void(*)(Ptr))func, &user, immediate);} // set function called when checkbox state has changed, with 'user' as its parameter, 'immediate'=if call the function immediately when a change occurs (this will happen inside object update function where you cannot delete any objects) if set to false then the function will get called after all objects finished updating (there you can delete objects)
  19. // main
  20. virtual void update(C GuiPC &gpc); // update object
  21. virtual void draw (C GuiPC &gpc); // draw object
  22. #if EE_PRIVATE
  23. void zero();
  24. void call(Bool sound);
  25. #endif
  26. ~CheckBox() {del();}
  27. CheckBox();
  28. #if !EE_PRIVATE
  29. private:
  30. #endif
  31. Bool _on, _multi, _func_immediate, _focusable;
  32. Flt _lit;
  33. Ptr _func_user;
  34. void (*_func)(Ptr user);
  35. protected:
  36. virtual Bool save(File &f, CChar *path=null)C;
  37. virtual Bool load(File &f, CChar *path=null) ;
  38. };
  39. /******************************************************************************/