jay.h 2.8 KB

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