clanlib.i 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. %include "std_string.i"
  2. class CL_Component
  3. {
  4. public:
  5. CL_Component(CL_Component* parent, CL_StyleManager* style = NULL);
  6. ~CL_Component();
  7. void show(bool show = true);
  8. bool is_visible(bool check_parents = true);
  9. void set_focus();
  10. void set_size(int new_width, int new_height);
  11. void set_position(int new_x, int new_y);
  12. const CL_Rect& get_position();
  13. int get_width() const;
  14. int get_height() const;
  15. int get_screen_x() const;
  16. int get_screen_y() const;
  17. };
  18. class CL_Size
  19. {
  20. public:
  21. CL_Size(int w, int h);
  22. int width;
  23. int height;
  24. };
  25. class CL_Sizef
  26. {
  27. public:
  28. CL_Sizef(float w, float h);
  29. float width;
  30. float height;
  31. };
  32. class CL_Pointf
  33. {
  34. public:
  35. CL_Pointf(float x, float y)
  36. : x(x), y(y) { }
  37. float x;
  38. float y;
  39. };
  40. class CL_Point
  41. {
  42. public:
  43. CL_Point(int x, int y)
  44. : x(x), y(y) { }
  45. int x;
  46. int y;
  47. };
  48. class CL_Rect
  49. {
  50. public:
  51. int left;
  52. int top;
  53. int right;
  54. int bottom;
  55. CL_Rect(int, int, int, int);
  56. CL_Rect(const CL_Point&, const CL_Size&);
  57. int get_width() const;
  58. int get_height() const;
  59. CL_Size get_size();
  60. };
  61. class CL_Rectf
  62. {
  63. public:
  64. float left;
  65. float top;
  66. float right;
  67. float bottom;
  68. CL_Rectf(float, float, float, float);
  69. CL_Rectf(const CL_Pointf&, const CL_Sizef&);
  70. float get_width() const;
  71. float get_height() const;
  72. CL_Sizef get_size();
  73. };
  74. class CL_Colorf
  75. {
  76. public:
  77. CL_Colorf(float r, float g, float b, float a);
  78. float red;
  79. float green;
  80. float blue;
  81. float alpha;
  82. };
  83. class CL_Color
  84. {
  85. public:
  86. CL_Color(unsigned int, unsigned int, unsigned int, unsigned int = 255);
  87. void set_red (unsigned int);
  88. void set_blue (unsigned int);
  89. void set_green(unsigned int);
  90. void set_alpha(unsigned int);
  91. unsigned int get_red ();
  92. unsigned int get_blue ();
  93. unsigned int get_green();
  94. unsigned int get_alpha();
  95. };
  96. class CL_Sprite
  97. {
  98. public:
  99. CL_Sprite(
  100. const std::string &resource_id, CL_ResourceManager *manager);
  101. void set_scale(float x, float y);
  102. CL_Point get_frame_offset(int frame);
  103. void set_frame_offset(int frame, CL_Point offset);
  104. };
  105. class CL_Window : public CL_Component
  106. {
  107. private:
  108. ~CL_Window();
  109. public:
  110. CL_Window(
  111. const CL_Rect &pos,
  112. const std::string &title,
  113. CL_Component *parent,
  114. CL_StyleManager *style = NULL);
  115. CL_Component* get_client_area();
  116. };
  117. class CL_Button : public CL_Component
  118. {
  119. private:
  120. ~CL_Button();
  121. public:
  122. CL_Button(
  123. const CL_Rect &pos,
  124. const std::string &text,
  125. CL_Component *parent,
  126. CL_StyleManager *style = NULL);
  127. CL_Signal_v0 &sig_clicked();
  128. const std::string &get_text() const;
  129. };
  130. class CL_Menu : public CL_Component
  131. {
  132. private:
  133. ~CL_Menu();
  134. public:
  135. CL_Menu(
  136. const CL_Rect &rect,
  137. CL_Component *parent,
  138. CL_StyleManager *style = NULL,
  139. bool vertical=false);
  140. CL_Menu(
  141. CL_Component *parent,
  142. CL_StyleManager *style = NULL,
  143. bool vertical=false);
  144. CL_MenuNode *create_item( const std::string &path, const std::string &labels=std::string());
  145. };
  146. class CL_MenuNode : public CL_Component
  147. {
  148. private:
  149. ~CL_MenuNode();
  150. //! Construction:
  151. public:
  152. //: CL_MenuNode Constructor
  153. CL_MenuNode(
  154. CL_Menu *parent_menu,
  155. CL_StyleManager *style = NULL);
  156. CL_Signal_v0 &sig_clicked();
  157. };
  158. class CL_InputBox : public CL_Component
  159. {
  160. public:
  161. CL_InputBox(
  162. const CL_Rect &pos,
  163. CL_Component *parent,
  164. CL_StyleManager *style = NULL);
  165. CL_Signal_v0& sig_return_pressed();
  166. void set_text(const std::string &text);
  167. const std::string &get_text() const;
  168. };
  169. class CL_Label : public CL_Component
  170. {
  171. public:
  172. //: Label Constructor
  173. CL_Label(
  174. const CL_Point &pos,
  175. const std::string &text,
  176. CL_Component *parent,
  177. CL_StyleManager *style = NULL);
  178. };
  179. class CL_ListBox : public CL_Component
  180. {
  181. public:
  182. CL_ListBox(
  183. const CL_Rect& pos, CL_Component* parent, CL_StyleManager* style = NULL);
  184. CL_Signal_v1<int>& sig_highlighted();
  185. int insert_item(
  186. const std::string& text, int index = -1);
  187. };
  188. class CL_ResourceManager
  189. {
  190. public:
  191. CL_ResourceManager();
  192. CL_ResourceManager(
  193. const std::string &config_file,
  194. CL_InputSourceProvider *provider = 0,
  195. bool delete_inputsource_provider = false);
  196. ~CL_ResourceManager();
  197. std::vector<std::string> get_all_resources(const std::string &section_name);
  198. std::vector<std::string> get_all_sections();
  199. std::vector<std::string> get_resources_of_type(const std::string &type_id);
  200. std::vector<std::string> get_resources_of_type(const std::string &type_id, const std::string &section_name);
  201. void add_resources(const CL_ResourceManager &additional_resources);
  202. void remove_resources(const CL_ResourceManager &additional_resources);
  203. };
  204. class CL_RadioButton : public CL_Button
  205. {
  206. public:
  207. CL_RadioButton(
  208. const CL_Point &pos,
  209. const std::string &text,
  210. CL_Component *parent,
  211. CL_StyleManager *style = NULL);
  212. bool is_checked() const;
  213. void set_checked(bool check);
  214. };
  215. class CL_RadioGroup
  216. {
  217. public:
  218. CL_RadioGroup();
  219. ~CL_RadioGroup();
  220. const std::vector<CL_RadioButton *> &get_buttons() const;
  221. void add(CL_RadioButton *button, bool delete_component = false);
  222. };
  223. class CL_CheckBox : public CL_Button
  224. {
  225. public:
  226. CL_CheckBox(
  227. const CL_Point &pos,
  228. const std::string &text,
  229. CL_Component *parent,
  230. CL_StyleManager *style = NULL);
  231. bool is_checked() const;
  232. void set_checked(bool check = true);
  233. };
  234. class CL_ProviderFactory
  235. {
  236. public:
  237. static CL_PixelBuffer load(
  238. const std::string &filename,
  239. const std::string &type = "",
  240. CL_InputSourceProvider *input_provider = 0);
  241. static void save(
  242. CL_PixelBuffer buffer,
  243. const std::string &filename,
  244. const std::string &type = "",
  245. CL_OutputSourceProvider *output_provider = 0);
  246. };
  247. /* EOF */