jay.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. typedef struct Jayconfig Jayconfig;
  2. typedef struct Widget Widget;
  3. typedef struct WListElement WListElement;
  4. typedef struct Panel Panel;
  5. typedef struct Label Label;
  6. typedef struct Border Border;
  7. typedef enum wtype wtype;
  8. enum wtype{
  9. PANEL,
  10. LABEL
  11. };
  12. struct Jayconfig{
  13. // Task Panel Config
  14. u32 taskPanelColor;
  15. // Main Menu Config
  16. u32 mainMenuColor;
  17. u32 mainMenuHooverColor;
  18. // Window Config
  19. u32 windowTitleColor;
  20. u32 windowTitleFontColor;
  21. u32 windowBackgroundColor;
  22. u32 windowInTopBorder;
  23. u32 windowInBottomBorder;
  24. u32 windowSelectedColor;
  25. u32 windowScrollBarFrontColor;
  26. u32 windowTextCursorColor;
  27. u32 windowBackTextColor;
  28. u32 windowFrontTextColor;
  29. //Background
  30. u32 backgroundColor;
  31. char *backgroundimgpath;
  32. //Menu
  33. u32 menuBackColor;
  34. u32 menuHighColor;
  35. u32 menuBorderColor;
  36. u32 menuTextColor;
  37. u32 menuSelTextColor;
  38. //Widgets
  39. u32 mainBackColor;
  40. u32 mainTextColor;
  41. char *fontPath;
  42. unsigned int doubleclickTime;
  43. };
  44. struct Widget {
  45. char *id;
  46. //Methods
  47. int (*addWidget)(Widget *me, Widget *new, Point pos);
  48. Widget *(*getWidget)(Widget *me, char *id);
  49. Widget *(*extractWidget)(Widget *me, char *id);
  50. int (*listWidgets)(Widget *me, char ***list);
  51. void (*deleteWidget)(Widget *me, char *id);
  52. void (*setVisible)(Widget *w, int visible);
  53. void (*freeWidget)(Widget *w);
  54. //User Events:
  55. void (*hover)(Widget *w);
  56. void (*unhover)(Widget *w);
  57. void (*draw)(Widget *w);
  58. void (*resize)(Widget *w);
  59. void (*click)(Widget *w, Mouse *);
  60. void (*dclick)(Widget *w, Mouse *);
  61. void (*mpressdown)(Widget *w, Mouse *);
  62. void (*mpressup)(Widget *w, Mouse *);
  63. void (*change)(Widget *w);
  64. //For internal use
  65. void (*_hover)(Widget *w, Mouse *m);
  66. void (*_unhover)(Widget *w);
  67. void (*_draw)(Widget *w, Image *dst);
  68. void (*_redraw)(Widget *w);
  69. void (*_resize)(Widget *w, Point d); //d is the vector that represents the displacement
  70. void (*_click)(Widget *w, Mouse *);
  71. void (*_dclick)(Widget *w, Mouse *);
  72. void (*_mpressdown)(Widget *w, Mouse *);
  73. void (*_mpressup)(Widget *w, Mouse *);
  74. void (*_change)(Widget *w);
  75. int width; //ancho
  76. int height;//alto
  77. int hovered;
  78. int autosize;
  79. Rectangle r;
  80. Point p; //Real position
  81. Point pos; //Relative position
  82. wtype t; //widget type
  83. void *w; //The widget
  84. Widget *father; //Container
  85. Image *i;
  86. int visible;
  87. Widget *lh; //last hover
  88. };
  89. struct WListElement {
  90. WListElement *next;
  91. WListElement *prev;
  92. Widget *w;
  93. };
  94. struct Border{
  95. int size;
  96. int _3d; // True if border is 3D
  97. int up; // Up or Down 3D effect
  98. };
  99. struct Panel {
  100. Widget *w;
  101. u32 backColor;
  102. WListElement *l;
  103. };
  104. struct Label {
  105. Widget *w;
  106. char *t;
  107. Font *f;
  108. Border border;
  109. u32 backColor;
  110. u32 textColor;
  111. void (*setText)(Label *l, const char *text);
  112. char * (*gettext)(Label *l);
  113. };
  114. Widget *initjayapp(char *name);
  115. void startjayapp(Widget * w);
  116. void initdefaultconfig();
  117. Border createBorder(int size, int _3D, int up);
  118. Widget *createPanel(char *id, int height, int width, Point p);
  119. Widget *createLabel(char *id, int height, int width);