xtb.h
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:5k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /*
  2.  * xtb - a mini-toolbox for X11
  3.  *
  4.  * David Harrison
  5.  * University of California, Berkeley
  6.  * 1988
  7.  */
  8. #ifndef _XTB_
  9. #define _XTB_
  10. #include "copyright.h"
  11. /* Handler function return codes */
  12. typedef enum xtb_hret_defn {
  13.     XTB_NOTDEF, XTB_HANDLED, XTB_STOP
  14. }       xtb_hret;
  15. /* If you have an ANSI compiler,  some checking will be done */
  16. #ifdef __STDC__
  17. #define DECLARE(func, rtn, args) extern rtn func args
  18. typedef void *xtb_data;
  19. #else
  20. #define DECLARE(func, rtn, args) extern rtn func ()
  21. typedef char *xtb_data;
  22. #endif
  23. /* Basic return value */
  24. typedef struct xtb_frame_defn {
  25.     Window  win;
  26.     int     x_loc,
  27.             y_loc;
  28.     unsigned int width,
  29.             height;
  30. }       xtb_frame;
  31. DECLARE(xtb_init, void, (Display * disp, int scrn,
  32.  unsigned long foreground,
  33.  unsigned long background,
  34.  XFontStruct * font));
  35.  /* Initializes mini-toolbox */
  36. /*
  37.  * Basic event handling
  38.  */
  39. DECLARE(xtb_register, void, (Window win,
  40.      xtb_hret(*func) (XEvent * evt, xtb_data info),
  41.      xtb_data info));
  42.  /* Registers call-back function */
  43. DECLARE(xtb_lookup, xtb_data, (Window win));
  44.  /* Returns data associated with window */
  45. DECLARE(xtb_dispatch, xtb_hret, (XEvent * evt));
  46.  /* Dispatches events for mini-toolbox */
  47. DECLARE(xtb_unregister, int, (Window win, xtb_data * info));
  48.  /* Unregisters a call-back function */
  49. /*
  50.  * Command button frame
  51.  */
  52. DECLARE(xtb_bt_new, void, (Window win, char *text,
  53.    xtb_hret(*func) (Window win, int state,
  54.     xtb_data val),
  55.    xtb_data val,
  56.    xtb_frame * frame));
  57.  /* Creates new button  */
  58. DECLARE(xtb_bt_get, int, (Window win, xtb_data * stuff, int *na));
  59.  /* Returns state of button */
  60. DECLARE(xtb_bt_set, int, (Window win, int val, xtb_data stuff, int na));
  61.  /* Sets state of button */
  62. DECLARE(xtb_bt_del, void, (Window win, xtb_data * info));
  63.  /* Deletes a button */
  64. /*
  65.  * Button row frame - built on top of buttons
  66.  */
  67. DECLARE(xtb_br_new, void, (Window win, int cnt, char *lbls[], int init,
  68.    xtb_hret(*func) (Window win, int prev,
  69.     int this, xtb_data val),
  70.    xtb_data val,
  71.    xtb_frame * frame));
  72.  /* Creates a new button row frame */
  73. DECLARE(xtb_br_get, int, (Window win));
  74.  /* Returns currently selected button */
  75. DECLARE(xtb_br_del, void, (Window win));
  76.  /* Deletes a button row */
  77. /*
  78.  * Text output (label) frames
  79.  */
  80. DECLARE(xtb_to_new, void, (Window win, char *text,
  81.    XFontStruct * ft, xtb_frame * frame));
  82.  /* Create new text output frame */
  83. DECLARE(xtb_to_del, void, (Window win));
  84. /*
  85.  * Text input (editable text) frames
  86.  */
  87. #define MAXCHBUF 1024
  88. DECLARE(xtb_ti_new, void, (Window win, char *text, int maxchar,
  89.    xtb_hret(*func) (Window win, int ch,
  90.     char *textcopy, xtb_data * val),
  91.    xtb_data val, xtb_frame * frame));
  92.  /* Creates a new text input frame */
  93. DECLARE(xtb_ti_get, void, (Window win, char text[MAXCHBUF], xtb_data * val));
  94.  /* Returns state of text input frame */
  95. DECLARE(xtb_ti_set, int, (Window win, char *text, xtb_data val));
  96.  /* Sets the state of text input frame */
  97. DECLARE(xtb_ti_ins, int, (Window win, int ch));
  98.  /* Inserts character onto end of text input frame */
  99. DECLARE(xtb_ti_dch, int, (Window win));
  100.  /* Deletes character from end of text input frame */
  101. DECLARE(xtb_ti_del, void, (Window win, xtb_data * info));
  102.  /* Deletes an text input frame */
  103. /*
  104.  * Block frame
  105.  */
  106. DECLARE(xtb_bk_new, void, (Window win, unsigned width, unsigned height,
  107.    xtb_frame * frame));
  108.  /* Makes a new block frame */
  109. DECLARE(xtb_bk_del, void, (Window win));
  110.  /* Deletes a block frame */
  111. /*
  112.  * Formatting support
  113.  */
  114. #define MAX_BRANCH 50
  115. typedef enum xtb_fmt_types_defn {
  116.     W_TYPE, A_TYPE
  117. }       xtb_fmt_types;
  118. typedef enum xtb_fmt_dir_defn {
  119.     HORIZONTAL, VERTICAL
  120. }       xtb_fmt_dir;
  121. typedef enum xtb_just_defn {
  122.     XTB_CENTER = 0, XTB_LEFT, XTB_RIGHT, XTB_TOP, XTB_BOTTOM
  123. }       xtb_just;
  124. typedef struct xtb_fmt_widget_defn {
  125.     xtb_fmt_types type; /* W_TYPE */
  126.     xtb_frame *w;
  127. }       xtb_fmt_widget;
  128. typedef struct xtb_fmt_align_defn {
  129.     xtb_fmt_types type; /* A_TYPE */
  130.     xtb_fmt_dir dir; /* HORIZONTAL or VERTICAL */
  131.     int     padding; /* Outside padding        */
  132.     int     interspace; /* Internal padding       */
  133.     xtb_just just; /* Justification          */
  134.     int     ni; /* Number of items */
  135.     union xtb_fmt_defn *items[MAX_BRANCH]; /* Branches themselves */
  136. }       xtb_fmt_align;
  137. typedef union xtb_fmt_defn {
  138.     xtb_fmt_types type; /* W_TYPE or A_TYPE */
  139.     xtb_fmt_widget wid;
  140.     xtb_fmt_align align;
  141. }       xtb_fmt;
  142. #define NE 0
  143. DECLARE(xtb_w, xtb_fmt *, (xtb_frame * w));
  144.  /* Returns formatting structure for frame */
  145. DECLARE(xtb_hort, xtb_fmt *, (xtb_just just, int padding, int interspace,...));
  146.  /* Varargs routine for horizontal formatting */
  147. DECLARE(xtb_vert, xtb_fmt *, (xtb_just just, int padding, int interspace,...));
  148.  /* Varargs routine for vertical formatting */
  149. DECLARE(xtb_fmt_do, xtb_fmt *, (xtb_fmt * def, unsigned *w, unsigned *h));
  150.  /* Carries out formatting */
  151. DECLARE(xtb_mv_frames, void, (int nf, xtb_frame frames[]));
  152.  /* Actually moves widgets */
  153. DECLARE(xtb_fmt_free, void, (xtb_fmt * def));
  154.  /* Frees resources claimed by xtb_w, xtb_hort, and xtb_vert */
  155. #endif /* _XTB_ */