home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Enlightenment / enl14.tgz / enl14.tar / enl14 / enl.h < prev    next >
C/C++ Source or Header  |  1997-11-21  |  13KB  |  452 lines

  1. #include <X11/Xlib.h>
  2. #include <X11/Xutil.h>
  3. #include <X11/Xproto.h>
  4. #include <X11/extensions/shape.h>
  5. #include <X11/extensions/XTest.h>
  6. #include <X11/extensions/XShm.h>
  7. #include <X11/imlib.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <unistd.h>
  11. #include <stdarg.h>
  12. #include <string.h>
  13. #include <fcntl.h>
  14. #include <dirent.h>
  15. #include <signal.h>
  16. #include <time.h>
  17. #include <sys/stat.h>
  18. #include <sys/types.h>
  19. #include <sys/wait.h>
  20. #include <sys/stat.h>
  21.  
  22. #define EERR_NONE               0
  23. #define EERR_OUT_OF_MEMORY      1
  24. #define EERR_FILE_NOT_EXIST     2
  25. #define EERR_PERMISSION_DENIED  3
  26. #define EERR_FILING_SYSTEM_FULL 4
  27.  
  28. #define ENLIGHTENMENT_ROOT           "/usr/local/enlightenment"
  29. #define ENLIGHTENMENT_SYSTEM_CONFIG  ENLIGHTENMENT_ROOT"/system_config"
  30. #define ENLIGHTENMENT_SYSTEM_THEMES  ENLIGHTENMENT_ROOT"/themes"
  31.  
  32. #define CFG_CONTEXT_NONE             0
  33. #define CFG_CONTEXT_IMAGES           1
  34. #define CFG_CONTEXT_CLASS            2
  35. #define CFG_CONTEXT_BUTTONS          3
  36. #define CFG_CONTEXT_STRIP            4
  37. #define CFG_CONTEXT_BUTTON           5
  38. #define CFG_CONTEXT_GEOMETRY         6
  39. #define CFG_CONTEXT_ACTIONS          7
  40. #define CFG_CONTEXT_SLIDERS          8
  41.  
  42. #define STRIP_LOCATION_START         0
  43. #define STRIP_LOCATION_END           1
  44.  
  45. #define STRIP_ORIENTATION_VERTICAL   0
  46. #define STRIP_ORIENTATION_HORIZONTAL 1
  47.  
  48. #define EVENT_MOUSE_DOWN  0
  49. #define EVENT_MOUSE_UP    1
  50. #define EVENT_MOUSE_ENTER 2
  51. #define EVENT_MOUSE_LEAVE 3
  52. #define EVENT_KEY_DOWN    4
  53. #define EVENT_KEY_UP      5
  54.  
  55. #define ACTION_NONE                  0
  56. #define ACTION_EXEC                  1
  57. #define ACTION_ALERT                 2
  58. #define ACTION_ROTATE_STRIP          3
  59. #define ACTION_MOVE_STRIP            4
  60. #define ACTION_SAVE_STRIP            5
  61. #define ACTION_JUSTIFY_STRIP         6
  62. #define ACTION_DELETE_STRIP          7
  63. #define ACTION_SHOW_STRIP            8
  64. #define ACTION_HIDE_STRIP            9
  65. #define ACTION_SHOW_STRIP_TOGGLE     10
  66. #define ACTION_LOCATE_STRIP          11
  67. #define ACTION_DISABLE_BUTTON        12
  68. #define ACTION_ENABLE_BUTTON         13
  69. #define ACTION_DISABLE_BUTTON_TOGGLE 14
  70. #define ACTION_MOVE_BUTTON           15
  71. #define ACTION_SAVE_BUTTON           16
  72. #define ACTION_SHOW_BUTTON           17
  73. #define ACTION_HIDE_BUTTON           18
  74. #define ACTION_DELETE_BUTTON         19
  75. #define ACTION_SHOW_BUTTON_TOGGLE    20
  76. #define ACTION_LOCATE_BUTTON         21
  77. #define ACTION_CALLBACK              22
  78. #define ACTION_SLIDER_STRIP_JUSTIFY  23
  79. #define ACTION_FLIP_STRIP            24
  80.  
  81. #define STATE_NORMAL   0
  82. #define STATE_HILITED  1
  83. #define STATE_CLICKED  2
  84. #define STATE_DISABLED 3
  85.  
  86. #define COORD_MACRO_CUSTOM      0
  87. #define COORD_MACRO_TOPLEFT     1
  88. #define COORD_MACRO_TOPRIGHT    2
  89. #define COORD_MACRO_BOTTOMLEFT  3
  90. #define COORD_MACRO_BOTTOMRIGHT 4
  91. #define COORD_MACRO_MIDDLE      5
  92.  
  93. #define LIST_TYPE_ANY           0
  94. #define LIST_TYPE_ROOT          1
  95. #define LIST_TYPE_IMAGECLASS    2
  96. #define LIST_TYPE_BUTTON        3
  97. #define LIST_TYPE_STRIP         4
  98. #define LIST_TYPE_SLIDERCLASS   5
  99. #define LIST_TYPE_SLIDER        6
  100.  
  101. #define MODE_NONE               0
  102. #define MODE_MOVE_STRIP         1
  103. #define MODE_MOVE_BUTTON        2
  104. #define MODE_MOVE_SLIDER        3
  105.  
  106. typedef struct _list
  107. {
  108.    int  type;
  109.    char *name;
  110.    void *item;
  111.    struct _list *next;
  112. } List;
  113.  
  114. typedef struct _size
  115. {
  116.    int x,x_at;
  117.    int y,y_at;
  118. } Size;
  119.  
  120. typedef struct _coord
  121. {
  122.    char handle_macro;
  123.    int  x_handle,x_handle_at;
  124.    int  y_handle,y_handle_at;
  125.    char from_macro;
  126.    int  x_from,x_from_at;
  127.    int  y_from,y_from_at;
  128.    int  x,y;
  129. } Coord;
  130.  
  131. typedef struct _constrain
  132. {
  133.    int min;
  134.    int max;
  135. } Constrain;
  136.  
  137. typedef struct _imageentry
  138. {
  139.    char    *name;
  140.    Image   *im;
  141.    ImColor *icl;
  142.    Border  *bd;
  143.    int     width,height;
  144.    Pixmap  pmap;
  145.    Pixmap  mask;
  146. } ImageEntry;
  147.  
  148. typedef struct _imageclass
  149. {
  150.    char       *name;
  151.    char       unloadable;
  152.    ImageEntry *normal;
  153.    ImageEntry *hilited;
  154.    ImageEntry *clicked;
  155.    ImageEntry *disabled;
  156. } ImageClass;
  157.  
  158. typedef struct _action
  159. {
  160.    int    id;
  161.    char   *params;
  162. } Action;
  163.  
  164. typedef struct _actioninit
  165. {
  166.    char    event;
  167.    char    any;
  168.    char    anykey;
  169.    int     modifiers;
  170.    int     button;
  171.    KeyCode key;
  172.    Action  action;
  173. } ActionInit;
  174.  
  175. typedef struct _scrbit
  176. {
  177.    Window win;
  178.    int    x,y;
  179.    int    width,height;
  180.    Pixmap pmap,mask;
  181. } ScrBit;
  182.  
  183. typedef struct _button
  184. {
  185.    Coord         loc;
  186.    Size          size;
  187.    Constrain     width,height;
  188.    char          *name;
  189.    ImageClass    *iclass;
  190.    char          state,pstate;
  191.    struct _strip *strip;
  192.    char          strip_loc;
  193.    char          visible;
  194.    int           num;
  195.    ActionInit    *actions;
  196.    ScrBit        X,pX;
  197. } Button;
  198.  
  199. typedef struct _item
  200. {
  201.    int  type;
  202.    void *item;
  203. } Item;
  204.  
  205. typedef struct _strip
  206. {
  207.    Coord         loc;
  208.    char          *name;
  209.    char          orientation;
  210.    int           justification;
  211.    char          visible;
  212.    struct _strip *strip;
  213.    int           strip_loc;
  214.    int           num;
  215.    Item          *list;
  216.    ScrBit        X;
  217. } Strip;
  218.  
  219. typedef struct _sliderbase
  220. {
  221.    ImageClass *iclass;
  222.    int        thickness;
  223.    int        start_inset;
  224.    int        end_inset;
  225. } SliderBase;
  226.  
  227. typedef struct _sliderknob
  228. {
  229.    ImageClass *iclass;
  230.    int        x,y;
  231.    int        width,height;
  232. } SliderKnob;
  233.  
  234. typedef struct _sliderorient 
  235.    SliderBase base;
  236.    SliderKnob knob;
  237. } SliderOrient;
  238.  
  239. typedef struct _sliderclass
  240. {
  241.    char         *name;
  242.    SliderOrient horizontal,vertical;
  243. } SliderClass;
  244.  
  245. typedef struct _slider
  246. {
  247.    char        *name;
  248.    SliderClass *sclass;
  249.    char        orientation;
  250.    int         length;
  251.    int         divisions;
  252.    int         value;
  253.    char        state,pstate;
  254.    char        visible;
  255.    ScrBit      baseX,pbaseX;
  256.    ScrBit      knobX,pknobX;
  257.    Action      action;
  258. } Slider;
  259.  
  260. typedef struct _mode
  261. {
  262.    int     mode;
  263.    Strip   *strip;
  264.    Button  *button;
  265.    Slider  *slider;
  266.    int     px,py;
  267. } Mode;
  268.  
  269. typedef struct _root
  270. {
  271.    char     *name;
  272.    Display  *display;
  273.    char     *displayname;
  274.    Window   win;
  275.    Visual   *visual;
  276.    int      width;
  277.    int      height;
  278.    int      depth;
  279. } Root;
  280.  
  281. void         md(char *s);
  282. int          exists(char *s);
  283. int          isfile(char *s);
  284. int          isdir(char *s);
  285. char       **ls(char *dir, int *num);
  286. void         freestrlist(char **l, int num);
  287. void         rm(char *s);
  288. void         mv(char *s, char *ss);
  289. void         cp(char *s, char *ss);
  290. time_t       moddate(char *s);
  291. int          filesize(char *s);
  292. void         cd(char *s);
  293. char        *cwd(void);
  294. int          permissions(char *s);
  295. int          owner(char *s);
  296. int          group(char *s);
  297. char        *username(int uid);
  298. char        *homedir(int uid);
  299. char        *usershell(int uid);
  300. char        *duplicate(char *s);
  301. char        *atword(char *s, int num);
  302. char        *atchar(char *s, char c);
  303. void         word(char *s, int num, char *wd);
  304. int          canread(char *s);
  305. int          canwrite(char *s);
  306. int          canexec(char *s);
  307.  
  308. void         Alert(char *fmt,...);
  309. void         ShowAlert(char *text);
  310. void         AlertHandleClick(int button);
  311. void         ErrAlert(int erno);
  312.  
  313. void         CfgLoad(char *file);
  314. char        *CfgGetLine(char *file);
  315.  
  316. void         EExit(int code);
  317. void        *Emalloc(int size);
  318. void        *Erealloc(void *ptr, int size);
  319. void         Efree(void *ptr);
  320.  
  321. Image       *LoadImage(char *file);
  322. void         FreeImageClass(ImageClass *item);
  323. void         GetPixmaps(ImageClass *ic, char state, int width, int height, Pixmap *pmap, Pixmap *mask);
  324. void         FreeImageEntry(ImageEntry *item);
  325. ImageEntry  *CfgReadImageEntry(char *type);
  326. void         CfgLoadImageClass();
  327.  
  328. void         FreeStrip(Strip *item);
  329. Strip       *CfgReadStrip();
  330. void         CfgLoadStrip();
  331. void         FreeButton(Button *item);
  332. Button      *MakeButton(char *name, char *iclass, int x, int y, int width, int height);
  333. Button      *CfgReadButton();
  334. void         CfgLoadButton();
  335. void         CfgReadGeometry(Button *b);
  336. void         CfgReadActions(ActionInit **a, int *num);
  337. void         AddButtonAction(Button *b, char *line);
  338. void         AddButtonActionCallback(Button *b, char *line, void (*cb)());
  339. void         CfgParseMouseAction(char *lin, ActionInit *a);
  340. void         CfgParseKeyAction(char *lin, ActionInit *a);
  341. void         AddButtonToStrip(Button *b, Strip *s, int loc);
  342. void         DelButtonFromStrip(Button *b, Strip *s);
  343. void         AddStripToStrip(Strip *b, Strip *s, int loc);
  344. void         DelStripFromStrip(Strip *b, Strip *s);
  345. void         CalculateSize(Size *size, ScrBit *X, Constrain *width, Constrain *height);
  346. void         CalculateLoc(Coord *loc, int width, int height, ScrBit *X);
  347. void         CalcButton(Button *b);
  348. void         DrawButton(Button *b);
  349. void         ShowButton(Button *b);
  350. void         HideButton(Button *b);
  351. void         MoveButtonTo(Button *b, int x, int y);
  352. void         MoveButtonBy(Button *b, int x, int y);
  353. void         ButtonHilite(Button *b, char onoff);
  354. void         ButtonClick(Button *b, char onoff);
  355. void         ButtonDisable(Button *b, char onoff);
  356. void         SetButtonImageClass(Button *b, char *name);
  357. void         SetButtonLocation(Button *b, Coord *loc);
  358. void         SetButtonSize(Button *b, Size *siz);
  359. void         DrawStrip(Strip *s);
  360. void         HideStrip(Strip *s);
  361. void         ShowStrip(Strip *s);
  362. void         RotateStrip(Strip *s);
  363. void         FlipStrip(Strip *s);
  364. void         SetStripJustification(Strip *s, int just);
  365. void         MoveStripTo(Strip *s, int x, int y);
  366. void         MoveStripBy(Strip *s, int x, int y);
  367. void         SetStripLocation(Strip *s, Coord *loc);
  368. void         CfgParseLocLine(char *line, Coord *loc);
  369. void         CfgParseSizeLine(char *line, Size *size);
  370. void         CfgParseConstrain(char *line, Constrain *c);
  371.  
  372. void        *FindItem(char *name, int type);
  373. void         AddItem(void *item, char *name, int type);
  374. void        *DelItem(char *name, int type);
  375. char       **ListItems(int *num, int type);
  376. void        *FindWindowID(Window win, int type, int *type_ret);
  377.  
  378. void         HandleEvent(XEvent *ev);
  379. void         HandlePress(XEvent *ev);
  380. void         HandleRelease(XEvent *ev);
  381. void         HandleIn(XEvent *ev);
  382. void         HandleOut(XEvent *ev);
  383. void         HandleMotion(XEvent *ev);
  384.  
  385. void         DoSimpleAction(Action *a);
  386. void         DoAction(XEvent *ev, ActionInit *a, int num);
  387. void         ActionExec(char *p);
  388. void         ActionAlert(char *p);
  389. void         ActionRotateStrip(char *p);
  390. void         ActionMoveStrip(char *p);
  391. void         ActionSaveStrip(char *p);
  392. void         ActionJustifyStrip(char *p);
  393. void         ActionDeleteStrip(char *p);
  394. void         ActionShowStrip(char *p);
  395. void         ActionHideStrip(char *p);
  396. void         ActionShowStripToggle(char *p);
  397. void         ActionLocateStrip(char *p);
  398. void         ActionDisableButton(char *p);
  399. void         ActionEnableButton(char *p);
  400. void         ActionDisableButtonToggle(char *p);
  401. void         ActionMoveButton(char *p);
  402. void         ActionSaveButton(char *p);
  403. void         ActionShowButton(char *p);
  404. void         ActionHideButton(char *p);
  405. void         ActionDeleteButton(char *p);
  406. void         ActionShowButtonToggle(char *p);
  407. void         ActionLocateButton(char *p);
  408. void         ActionCallback(char *p);
  409. void         ActionSliderJustiyStrip(char *p);
  410. void         ActionFlipStrip(char *p);
  411.  
  412. void         FreeSliderClass(SliderClass *item);
  413. void         CfgReadSliderOrient();
  414. void         CfgLoadSliderClass();
  415. Slider      *CreateSlider(char *name, char *classname, char orientation, int len, int divisions);
  416. void         DrawSlider(Slider *s);
  417. void         FreeSlider(Slider *item);
  418. void         MoveSliderBy(Slider *s, int x, int y);
  419. void         MoveSliderTo(Slider *s, int x, int y);
  420. void         SetSliderValue(Slider *s, int value);
  421. void         SetSliderAction(Slider *s, Action *a);
  422. int          GetSliderValue(Slider *s);
  423. void         HandleSliderMouse(Slider *s, int dx, int dy);
  424. void         ShowSlider(Slider *s);
  425. void         HideSlider(Slider *s);
  426. void         SliderClick(Slider *s, int onoff);
  427. void         SliderHilite(Slider *s, int onoff);
  428. void         SliderDisable(Slider *s, int onoff);
  429.  
  430. Root        *SetupRoot();
  431.  
  432. void         SetupVars();
  433. void         SetupSignals();
  434. void         SetupX();
  435.  
  436. void         HandleSigChild(int num);
  437. void         HandleXError(Display *d, XErrorEvent *ev);
  438. void         HandleXIOError(Display *d);
  439.  
  440. extern Display      *disp;
  441. extern FILE         *cfgfile;
  442. extern ImlibData    *imd;
  443. extern int          Eerr;
  444. extern char         ThemeIsTmp;
  445. extern char         *ThemeDir;
  446. extern List         lists;
  447. extern char         line[2048];
  448. extern Mode         mode;
  449. extern int          event_base_shape;
  450.  
  451.