jay.h 3.1 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. uint32_t taskPanelColor;
  15. // Main Menu Config
  16. uint32_t mainMenuColor;
  17. uint32_t mainMenuHooverColor;
  18. // Window Config
  19. uint32_t windowTitleColor;
  20. uint32_t windowTitleFontColor;
  21. uint32_t windowBackgroundColor;
  22. uint32_t windowInTopBorder;
  23. uint32_t windowInBottomBorder;
  24. uint32_t windowSelectedColor;
  25. uint32_t windowScrollBarFrontColor;
  26. uint32_t windowTextCursorColor;
  27. uint32_t windowBackTextColor;
  28. uint32_t windowFrontTextColor;
  29. //Background
  30. uint32_t backgroundColor;
  31. char *backgroundimgpath;
  32. //Menu
  33. uint32_t menuBackColor;
  34. uint32_t menuHighColor;
  35. uint32_t menuBorderColor;
  36. uint32_t menuTextColor;
  37. uint32_t menuSelTextColor;
  38. //Widgets
  39. uint32_t mainBackColor;
  40. uint32_t 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. uint32_t backColor;
  102. WListElement *l;
  103. };
  104. struct Label {
  105. Widget *w;
  106. char *t;
  107. Font *f;
  108. Border border;
  109. uint32_t backColor;
  110. uint32_t 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);