home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / calc / showcaseui.h < prev   
Encoding:
C/C++ Source or Header  |  1994-08-02  |  18.0 KB  |  588 lines

  1. /*
  2.  * Copyright 1990, 1991, 1992, 1993, 1994, Silicon Graphics, Inc.
  3.  * All Rights Reserved.
  4.  *
  5.  * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6.  * the contents of this file may not be disclosed to third parties, copied or
  7.  * duplicated in any form, in whole or in part, without the prior written
  8.  * permission of Silicon Graphics, Inc.
  9.  *
  10.  * RESTRICTED RIGHTS LEGEND:
  11.  * Use, duplication or disclosure by the Government is subject to restrictions
  12.  * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13.  * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14.  * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15.  * rights reserved under the Copyright Laws of the United States.
  16.  */
  17.  
  18. #ifndef __SHOWCASEUI_H__
  19. #define __SHOWCASEUI_H__
  20.  
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24.  
  25. #define UILEFT          100
  26. #define UIRIGHT         101
  27. #define UILRCENTER      102
  28. #define UITBCENTER      103
  29. #define UITOP           104
  30. #define UIBOTTOM        105
  31.  
  32. #define UIBUTTONUP    0
  33. #define UIBUTTONDOWN    1
  34. #define UIBUTTONCLICK    2
  35. #define UIBUTTONDOUBLE    3
  36.  
  37. #define P_UISHADOW      343
  38. #define P_UILINESHADOW     344
  39.  
  40. #define MENUBARHEIGHT   26
  41. #define SHADOWOFFSET    6
  42. #define MENUXGAP        9
  43.  
  44. #define TEXTHEIGHT      20
  45. #define DEFAULTFONT    0
  46.  
  47. #define CHECKBUTTON     1
  48. #define PALETTEBUTTON   2
  49. #define PUSHBUTTON      3
  50. #define RADIOBUTTON     4
  51. #define TOGGLEBUTTON    5
  52. #define TINYTOGGLE      6
  53. #define ICONBUTTON      7
  54. #define ICON            8
  55. #define INDICATOR       9
  56. #define BED             10
  57. #define GENERICBUTTON   11
  58. #define PTRBUTTON       12
  59. #define CUSTOMBUTTON    13
  60. #define TINYRADIO       14
  61. #define VSLIDER         15
  62. #define HSLIDER         16
  63. #define VALUATOR    17
  64. #define TEXTBOX        18
  65. #define TEXTLIST    19
  66. #define MENUBAR        20
  67. #define PULLDOWNMENU    21
  68. #define POPUPMENU    22
  69. #define TEXTLABEL    23
  70. #define BOLDTEXTLABEL    24
  71.  
  72. #define TROUGH          3
  73. #define THUMB           2
  74. #define SCROLLDOWN      -1
  75. #define SCROLLUP        1
  76. #define SLIDERWIDTH     20
  77. #define ARROWHEIGHT     20
  78. #define MINSHALF        13
  79.  
  80. /* Buttons */
  81.  
  82. #define BUTSTRLEN       200
  83. #define BUTHEIGHT       28
  84. #define BUTWIDTH        75
  85. #define TINYTOGGLEHEIGHT 16
  86. #define TINYTOGGLEWIDTH 16
  87. #define TINYRADIOHEIGHT 16
  88. #define TINYRADIOWIDTH  16
  89. #define PALETTEHEIGHT   35
  90. #define PALETTEWIDTH    40
  91. #define ICONHEIGHT      32
  92. #define ICONWIDTH       32
  93. #define CHECKHEIGHT     20
  94. #define CHECKWIDTH      20
  95. #define RADIOHEIGHT     24
  96. #define RADIOWIDTH      24
  97. #define INDICATORHEIGHT 28
  98. #define INDICATORWIDTH  10
  99. #define LABELFONTHEIGHT 11
  100.  
  101. #define BUTTONICONFONT  5600
  102. #define BUTTONFONT1     5601
  103. #define BUTTONFONT2     5602
  104. #define BUTTONFONT3     5603
  105.  
  106. typedef struct AButton {
  107.     long xmin,xmax,ymin,ymax;
  108.     long number;        /* the button number--used internally */
  109.     char str[BUTSTRLEN+1];      /* the label on or next to the button */
  110.     short active;               /* the button is on (menu option label #) */
  111.     short enable;               /* the button is able to be pressed */
  112.     short locate;               /* the button is locate highlighted */
  113.     short select;               /* the button is pressed */
  114.     short invisible;        /* the button is not visible */
  115.     short type;                 /* checkbutton, indicator, etc. */
  116.     short thedefault;           /* the button is the default button */
  117.     short sticky;               /* stays pressed until an unpress is called */
  118.     void  (*butcolor)();        /* color of the text or icon on the button */
  119.     void  (*drawbutton)();      /* color of the text or icon on the button */
  120.     struct AButton **links;    /* used mainly for radio buttons to connect */
  121.     long numlinks;        /* the number of button links */
  122. } Button;
  123.  
  124. Button *newbut(long, long, long, long);
  125. Button *newcheckbut(long, long);
  126. Button *newpushbut(long, long);
  127. Button *newtogglebut(long, long, long);
  128. Button *newradiobut(long, long);
  129. Button *newindicator(long, long);
  130. Button *newtinyradio(long, long);
  131. Button *newtinytoggle(long, long);
  132. Button *newpalettebut(long, long);
  133. Button *newiconbut(long, long);
  134. Button *newptrbut(long, long);
  135. Button *newicon(long, long);
  136. Button *newcustombut(long, long, long, long, void (*drawbutton)());
  137. Button *newbed(long, long, long, long);
  138. Button *handlebutchar(long);
  139.  
  140. void    drawcheckbut(Button *b);
  141. void    drawindicatorbut(Button *b);
  142. void    drawpushbut(Button *b);
  143. void    drawbed(Button *b);
  144. void    drawtogglebut(Button *b);
  145. void    drawradiobut(Button *b);
  146. void    drawindicator(Button *b);
  147. void    drawtinyradio(Button *b);
  148. void    drawtinytoggle(Button *b);
  149. void    drawpalettebut(Button *b);
  150. void    drawiconbut(Button *b);
  151. void    drawicon(Button *b);
  152. void    drawptrbut(Button *b);
  153.  
  154. void    freebut(Button *);
  155. void    activatebut(Button *);
  156. void    deactivatebut(Button *);
  157. void    lockbut(Button *);
  158. void    flipactive(Button *);
  159. void    highlightbut(Button *);
  160. void    unhighlightbut(Button *);
  161. void    defaultbut(Button *);
  162. void    undefaultbut(Button *);
  163. void    setcolorbut(Button *, void (*butcolor)());
  164. void    linkbuttons(Button *, Button *);
  165. void    unlinkbutton(Button *);
  166. void    disablebut(Button *);
  167. void    enablebut(Button *);
  168. void    selectbut(Button *);
  169. void    unselectbut(Button *);
  170. void    makevisiblebut(Button *);
  171. void    makeinvisiblebut(Button *);
  172. void    stickbut(Button *);
  173. void    unstickbut(Button *);
  174. void    loadbut(Button *, char *);
  175. void    unpressbut(Button *);
  176. void    initbut();
  177. void    initiconbut();
  178. void    drawbut(Button *);
  179. void    drawbutnow(Button *);
  180. void    drawborder(Button *);
  181. void    drawaborder(long, long, long, long);
  182. void    positionbut(Button *, short, long);
  183. void    drawlabel(char *, long, long);
  184. void    drawboldlabel(char *, long, long);
  185. void    clearlabel(char *, long, long);
  186. void    drawiconlabel(Button *);
  187. void    unpresslinkbuts(Button *);
  188. void    UIdrawbuttons();
  189. void    UIlocatebuttons();
  190.  
  191. short    gethighlightbut(Button *);
  192. short    getdefaultbut(Button *);
  193. short    locatebut(Button *, long, long);
  194. short    valuebut(Button *);
  195. short    getenablebut(Button *);
  196. short    getselectbut(Button *);
  197. short    getvisiblebut(Button *);
  198. short    getstickbut(Button *);
  199. short    inbut(Button *, long, long);
  200. short    pressbut(Button *, long, long);
  201. short    selectedpressbut(Button *, long, long, long);
  202.  
  203. /* Horizontal Sliders */
  204.  
  205. typedef struct {
  206.     long        xmin, ymin, xmax, ymax;
  207.     long        scenter;        /* the center of the thumb */
  208.     long    shalf;            /* half of the thumb length */
  209.     long    oldpos;            /* old scenter    */
  210.     long    arrowdelta;        /* arrow delta    */
  211.     short       locate;         /* locate highlight */
  212.     short    select;            /* selected or not */
  213.     short     invisible;        /* the slider is not visible */
  214.     short       enable;            /* the slider is enabled */
  215.     short    thumb;            /* whether the thumb should show */
  216. } Slider;
  217.  
  218. typedef    Slider HSlider;
  219.  
  220. HSlider    *newhs(long, long, long, long, long);
  221.  
  222. void     movehs(HSlider *, long, long, long);
  223. void    setarrowdeltahs(HSlider *, long);
  224. void    freehs(HSlider *);
  225. void    disablehs(HSlider *);
  226. void    enablehs(HSlider *);
  227. void    highlighths(HSlider *, short);
  228. void    unhighlighths(HSlider *);
  229. void    selecths(HSlider *, short);
  230. void    unselecths(HSlider *);
  231. void    makevisiblehs(HSlider *);
  232. void    makeinvisiblehs(HSlider *);
  233. void    presshsarrow(HSlider *, short);
  234. void    sethshalf(HSlider *, long);
  235. void    sethscenter(HSlider *, long);
  236. void    sethsval(HSlider *, float);
  237. void    movehsval(HSlider *, float);
  238. void    reseths(HSlider *);
  239. void    drawhs(HSlider *);
  240. void    drawhsnow(HSlider *);
  241. void    drawhsarrows(HSlider *);
  242.  
  243. short     locatehs(HSlider *, long, long);
  244. short     getenablehs(HSlider *);
  245. short     gethighlighths(HSlider *);
  246. short     getselecths(HSlider *);
  247. short     getenablehs(HSlider *);
  248. short    getvisiblehs(HSlider *);
  249. short     inhs(HSlider *, long, long);
  250. short     handlehs(HSlider *, long, long);
  251.  
  252. short     selectedhs(HSlider *, long, long, long, long *, void (*adjust)());
  253.  
  254. long     gethstrough(HSlider *);
  255.  
  256. float     gethsval(HSlider *);
  257.  
  258. /* Pull-down menus  and MenuBars */
  259.  
  260. typedef int (*PFI)();
  261.  
  262. typedef struct MenuItem {
  263.     struct MenuItem     *next;          /* next entry in pulldown       */
  264.     PFI                 func;           /* executed by entry chosen %f  */
  265.     PFI                 itemfunc;
  266.     PFI                 draw;           /* custom drawing on entry %d   */
  267.     struct PullDown     *pd;            /* pulldown for rollover menu %m*/
  268.     char                *text;          /* text in entry                */
  269.     short               width;          /* required width for this entry*/
  270.     short               yoffset;        /* offset from pd->yorg         */
  271.     short               select;         /* selected or not              */
  272.     short               no;             /* number of entry              */
  273.     long                retno;          /* return value %x              */
  274.     short               underline;      /* separator under this entry %l*/
  275.     short               active;         /* check mark or not            */
  276.     short               enable;         /* able to be picked            */
  277.     char                *altkey;        /* alt key equivalent %a        */
  278. } MenuItem;
  279.  
  280. typedef struct PullDown {
  281.     struct MenuItem     *entries;       /* menu entries on pulldown     */
  282.     struct PullDown     *subpd;
  283.     PFI                 func;           /* exec. by any choice on pd %F */
  284.     short               nentries;       /* number of menu entries on pd */
  285.     short               slide;          /* any entries have a rollover? */
  286.     short               active;         /* any entries have a check mark*/
  287.     short               width;          /* max. width of all entries    */
  288.     short               height;         /* height of pulldown           */
  289.     char                *title;         /* title on menubar & pulldown  */
  290.     short               twidth;         /* pixel width of title         */
  291.     short               xorg;           /* screen coordinates of right  */
  292.     short               yorg;           /* screen coordinates of top    */
  293.     short               txorg;          /* screen coords. of title xorg */
  294.     short               orglocked;
  295.     short               enable;         /* able to be picked            */
  296.     struct menubar    *mb;        /* the menu bar where this pd is*/
  297. } PullDown;
  298.  
  299. typedef struct menubar {
  300.     long        xorg, yorg;             /* origin of window             */
  301.     long        xmin, ymin, xmax, ymax; /* screen coordinates           */
  302.     long        count;                  /* number of pulldown menus     */
  303.     short       locate;                 /* locate highlight (# of pd)   */
  304.     short     invisible;        /* the menu bar is not visible     */
  305.     short    enable;            /* the menu bar is enables    */
  306.     PullDown    **pds;                  /* pulldown menus               */
  307. } MenuBar;
  308.  
  309. PullDown        *newpd(MenuBar *, char *);
  310. PullDown        *createmenu(MenuBar *, char **, long, long);
  311.  
  312. void    freepd(register PullDown *);
  313. void    initpd();
  314. #ifdef __cplusplus
  315. void    loadpd(...);
  316. #else
  317. void    loadpd();
  318. #endif
  319. void    deactivatepdentry(PullDown *, char *);
  320. void    activatepdentry(PullDown *, char *);
  321. void    disablepdentry(PullDown *, char *);
  322. void    enablepdentry(PullDown *, char *);
  323. void    disablepd(PullDown *);
  324. void    enablepd(PullDown *);
  325. void    changepdtitle(PullDown *, char *);
  326. void    addtopd(PullDown *, MenuItem *);
  327.  
  328. short    getenablepd(PullDown *);
  329. short    changepd(PullDown *, char *, char *);
  330. short    valuepdentry(PullDown *, char *);
  331.  
  332. MenuItem        *getpdentry(PullDown *, char *);
  333. MenuBar        *newmenubar();
  334.  
  335. void    loadmenubar(MenuBar *, long, PullDown **);
  336. void    addtomenubar(MenuBar *, PullDown *);
  337. void    removefrommenubar(MenuBar *, PullDown *);
  338. void    movemenubar(MenuBar *);
  339. void    highlightmb(MenuBar *, long);
  340. void    unhighlightmb(MenuBar *);
  341. void    makevisiblemb(MenuBar *);
  342. void    makeinvisiblemb(MenuBar *);
  343. void    enablemb(MenuBar *);
  344. void    disablemb(MenuBar *);
  345. void    drawmenubar(MenuBar *);
  346. void    drawmenubarnow(MenuBar *);
  347.  
  348. long    dopulldown(MenuBar *);
  349. long    inmenubar(MenuBar *, long, long);
  350.  
  351. short    gethighlightmb(MenuBar *);
  352. short    getvisiblemb(MenuBar *);
  353. short    getenablemb(MenuBar *);
  354. short    locatemenubar(MenuBar *, long, long);
  355.  
  356. /* Text Boxes */
  357.  
  358. #define LABELSTRLEN     50
  359. #define TBSTRLEN        200
  360. #define TEXTBOXHEIGHT   28
  361.  
  362. /* Define for the settbtype() and gettypein() flag */
  363. #define TYPEIN_STRING   0
  364. #define TYPEIN_INT      1
  365. #define TYPEIN_FILE     2
  366. #define TYPEIN_FLOAT    3
  367. #define TYPEIN_HEX      4
  368. #define TYPEIN_WHOLE    5
  369.  
  370. typedef struct {
  371.     long    xmin, xmax, ymin;
  372.     long     number;            /* the tb number--used internally */
  373.     char        str[TBSTRLEN+1];        /* contents of text box         */
  374.     char        label[LABELSTRLEN+1];   /* label to left of text box    */
  375.     long        tp1, tp2;               /* textpointers                 */
  376.     long        charWidth;              /* width of box in # of characters */
  377.     short       active;
  378.     short       enable;
  379.     short     invisible;        /* the text box is not visible     */
  380.     short       type;                   /* for type-checking            */
  381.     long        index;          /* index into leftmost visible character */
  382. } TextBox;
  383.  
  384. TextBox    *newtb(long, long, long);
  385. TextBox *getactivetb();
  386.  
  387. void    inittb();
  388. void    freetb(TextBox *);
  389. void    labeltb(TextBox *, char *);
  390. void    settbtype(TextBox *, long);
  391. void    movetb(TextBox *, long, long, long);
  392. void    activatetb(TextBox *);
  393. void    deactivatetb(TextBox *);
  394. void    enabletb(TextBox *);
  395. void    disabletb(TextBox *);
  396. void    makevisibletb(TextBox *);
  397. void    makeinvisibletb(TextBox *);
  398. void    cleartb(TextBox *);
  399. void    adjusttb(TextBox *, long);
  400. void    loadtb(TextBox *, char *);
  401. void    backspacetb(TextBox *);
  402. void    inserttbchar(TextBox *, char);
  403. void    drawtb(TextBox *);
  404. void    drawtbnow(TextBox *);
  405.  
  406. char    *gettbstr(TextBox *);
  407.  
  408. short    intb(TextBox *, long, long);
  409. short    handletb(TextBox *, long, long, long, long);
  410. short    findtp(TextBox *, long);
  411. short    getenabletb(TextBox *);
  412. short   getvisibletb(TextBox *);
  413.  
  414. int     tilde(char *, char *);
  415.  
  416. /* Vertical Sliders */
  417.  
  418. typedef    Slider VSlider;
  419.  
  420. VSlider *newvs(long, long, long, long, long);
  421.  
  422. void     movevs(VSlider *, long, long, long);
  423. void    setarrowdelta(VSlider *, long);
  424. void    freevs(VSlider *);
  425. void    disablevs(VSlider *);
  426. void    enablevs(VSlider *);
  427. void    highlightvs(VSlider *, short);
  428. void    unhighlightvs(VSlider *);
  429. void    selectvs(VSlider *, short);
  430. void    unselectvs(VSlider *);
  431. void    makevisiblevs(VSlider *);
  432. void    makeinvisiblevs(VSlider *);
  433. void    pressvsarrow(VSlider *, short);
  434. void    setvshalf(VSlider *, long);
  435. void    setvscenter(VSlider *, long);
  436. void    setvsval(VSlider *, float);
  437. void    movevsval(VSlider *, float);
  438. void    resetvs(VSlider *);
  439. void    drawvs(VSlider *);
  440. void    drawvsnow(VSlider *);
  441. void    drawvsarrows(VSlider *);
  442.  
  443. short   locatevs(VSlider *, long, long);
  444. short   getenablevs(VSlider *);
  445. short   gethighlightvs(VSlider *);
  446. short   getselectvs(VSlider *);
  447. short   getenablevs(VSlider *);
  448. short    getvisiblevs(VSlider *);
  449. short   invs(VSlider *, long, long);
  450. short   handlevs(VSlider *, long, long);
  451.  
  452.  
  453. long    getvstrough(VSlider *);
  454.  
  455. float   getvsval(VSlider *);
  456.  
  457. /* Text Lists */
  458.  
  459. #define TEXTLISTFONT            5601
  460.  
  461. typedef struct {
  462.     long        xmin, xmax, ymin, ymax;
  463.     long        listheight;         /* in lines of text */
  464.     char        **strs;            /* text    */
  465.     long        top;            /* index into strs */
  466.     long        count;          /* total number of strings */
  467.     long        selecteditem;        /* index into selecteditem or -1 */
  468.     long        locateditem;        /* index into locateditem or -1 */
  469.     short     invisible;        /* the text list is not visible    */
  470.     VSlider     *vs;            /* the associated slider if one */
  471. } TextList;
  472.  
  473. short   selectedvs(VSlider *, TextList *, long, long, long);
  474.  
  475. TextList *newtl(long, long, long, long);
  476.  
  477. void     movetl(TextList *, long, long, long, long);
  478. void    inittl();
  479. void    resettl(TextList *);
  480. void    unselecttl(TextList *);
  481. void    selecttlitem(TextList *, long);
  482. void    highlighttl(TextList *, long);
  483. void    unhighlighttl(TextList *);
  484. void    makevisibletl(TextList *);
  485. void    makeinvisibletl(TextList *);
  486. void    settltop(TextList *, long);
  487. void    settlstrings(TextList *, char **);
  488. void    adjusttop(TextList *, float);
  489. void    drawtl(TextList *);
  490. void    drawtlnow(TextList *);
  491. void    settlstrslinkhandle(char **, TextList *);
  492. void    adjustslider(TextList *, VSlider *);
  493.  
  494. short    getselectedtlitem(TextList *);
  495. short    gethighlighttl(TextList *);
  496. short    getvisibletl(TextList *);
  497. short    getitemvisibletl(TextList *, long);
  498. short    locatetl(TextList *, long, long);
  499. short    intl(TextList *, long, long);
  500. short    handletl(TextList *, long, long);
  501. short    selectedtl(TextList *, long, long, long);
  502.  
  503. long    gettextlistheight(long);
  504. long    gettlheightcount(long, long);
  505.  
  506. char    *selectedstring(TextList *);
  507.  
  508. /* Valuators */
  509.  
  510. #define VALUATORWIDTH   22
  511.  
  512. typedef    Slider Valuator;
  513.  
  514. Valuator *newval(long, long, long, long, long, short);
  515.  
  516. void     moveval(Valuator *, long, long, long);
  517. void    setvalarrowdelta(Valuator *, long);
  518. void    freeval(Valuator *);
  519. void    disableval(Valuator *);
  520. void    enableval(Valuator *);
  521. void    highlightval(Valuator *, short);
  522. void    unhighlightval(Valuator *);
  523. void    selectval(Valuator *, short);
  524. void    unselectval(Valuator *);
  525. void    makevisibleval(Valuator *);
  526. void    makeinvisibleval(Valuator *);
  527. void    pressvalarrow(Valuator *, short);
  528. void    setvalhalf(Valuator *, long);
  529. void    setvalcenter(Valuator *, long);
  530. void    setvalval(Valuator *, float);
  531. void    movevalval(Valuator *, float);
  532. void    resetval(Valuator *);
  533. void    drawval(Valuator *);
  534. void    drawvalnow(Valuator *);
  535. void    drawvalarrows(Valuator *);
  536.  
  537. short    getarrowsval(Valuator *);
  538. short    getenableval(Valuator *);
  539. short    gethighlightval(Valuator *);
  540. short    getselectval(Valuator *);
  541. short    getvisibleval(Valuator *);
  542. short    locateval(Valuator *, long, long);
  543. short    inval(Valuator *, long, long);
  544. short    handleval(Valuator *, long, long);
  545. short    selectedval(Valuator *, long, long, long);
  546.  
  547. float    getvalval(Valuator *);
  548.  
  549. /* Misc.    */
  550. void    backgrounddraw(long, long, long, long);
  551. void    backgroundclear();
  552. void    windowborderdraw();
  553. void    initui();
  554. void    uiokdraw();
  555. void    uinodraw();
  556. void    defglfont(char *, long, long);
  557. void    unlocateall();
  558.  
  559. short    uiswapbuffers();
  560.  
  561. void uiWhite();
  562. void uiVyLtGray();
  563. void uiBlack();
  564.  
  565. #ifdef NOTDEF
  566. typedef struct {
  567.     short    type;
  568.     short       active;
  569.     short       enable;
  570.     short     invisible;
  571.     short    select;            /* selected or not */
  572.     long        xmin, ymin, xmax, ymax;
  573.     widget_t    *(*createme)();
  574.     void    (*deleteme)();
  575.     void    (*drawme)();
  576.     long    (*editme)();
  577.     void    (*inme)();
  578.     void    (*loadme)();
  579.     short    (*locateme)();
  580.     void    (*positionme)();
  581. } Widget;
  582. #endif
  583. #ifdef __cplusplus
  584. }
  585. #endif
  586.  
  587. #endif    /* !__SHOWCASEUI_H__ */
  588.