home *** CD-ROM | disk | FTP | other *** search
-
-
-
- /*⌐ Copyright 1988-1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
- #include <applet.h>
-
-
- /*
- these are the IAC messages that BarChart can receive from Frontier scripts.
-
- for the other side of this interface, check out system.verbs.apps.BarChart in
- frontier.root.
- */
- #define setbarvaluetoken 'sval'
- #define getbarvaluetoken 'gval'
- #define setbarlabeltoken 'slab'
- #define getbarlabeltoken 'glab'
- #define setbartoken 'sbar'
- #define addbartoken 'abar'
- #define setunitstoken 'sunt'
- #define setbarcounttoken 'scnt'
- #define getbarcounttoken 'gcnt'
-
-
-
- #define maxbars 25
-
- typedef long tyvalues [maxbars]; /*holds an array worth of values*/
-
- #define maxlabelchars 32
-
-
- typedef struct tybarrecord {
-
- boolean flhasbeenset: 1; /*avoid displaying if it's never been assigned to*/
-
- long value;
-
- char label [maxlabelchars];
- } tybarrecord;
-
-
- typedef struct tybarchartrecord {
-
- short versionnumber; /*this structure is saved on disk*/
-
- boolean flactive: 1; /*true if our window is active, false otherwise*/
-
- boolean flbitmapactive: 1; /*if false use bitmaps in drawing*/
-
- bigstring barunits; /*concatenated at the end of every displayed value*/
-
- short ctbars; /*number of bars in the chart*/
-
- long minvalue, maxvalue; /*the range of values*/
-
- short pixelsbetweenbars; /*how much space between the bars?*/
-
- short onebarwidth; /*how wide is one of the bars?*/
-
- short maxbarheight; /*max height in pixels of a bar*/
-
- short horizbaseline; /*the bottom edge of all the bars*/
-
- short vertbaseline; /*the left edge of the first bar*/
-
- short labelfont, labelsize, labelstyle; /*how are labels drawn?*/
-
- short labelbaseline; /*the horiz baseline for bar labels*/
-
- short labellineheight; /*vertical pixels for a label*/
-
- tybarrecord bars [maxbars];
- } tybarchartrecord, *ptrbarchartrecord, **hdlbarchartrecord;
-
-
- bigstring bsbarchartsearch; /*see selectbarchartwindow*/
-
- #define pictmargin 20 /*leave this much room on all sides of chart*/
-
-
-
-
-
- static boolean setchartconsts (void) {
-
- /*
- set values for the computed and constant fields of the barchart record.
-
- assume non-computed fields have been set and are accurate.
- */
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register hdlappwindow ha = app.appwindow;
- register short totalwidth;
- register short ctbars = (**hb).ctbars;
- Rect r;
-
- (**hb).pixelsbetweenbars = 10;
-
- (**hb).labelfont = (**ha).defaultfont;
-
- (**hb).labelsize = (**ha).defaultsize;
-
- (**hb).labelstyle = (**ha).defaultstyle;
-
- (**hb).labellineheight = (**ha).fontheight;
-
- r = (**ha).windowrect;
-
- totalwidth = (**ha).windowhorizpixels - (2 * pictmargin);
-
- totalwidth -= (ctbars + 1) * (**hb).pixelsbetweenbars;
-
- if (ctbars <= 0)
- (**hb).onebarwidth = 0; /*defensive driving*/
- else
- (**hb).onebarwidth = totalwidth / ctbars;
-
- (**hb).labelbaseline = r.bottom - pictmargin;
-
- (**hb).horizbaseline = r.bottom - pictmargin - (2 * (**hb).labellineheight);
-
- (**hb).maxbarheight = (**hb).horizbaseline - r.top - pictmargin;
-
- (**hb).vertbaseline = r.left + pictmargin;
-
- return (true);
- } /*setchartconsts*/
-
-
- static short getbarleftedge (short barnum) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- return (
- (**hb).vertbaseline +
-
- ((**hb).pixelsbetweenbars * (barnum + 1)) +
-
- ((**hb).onebarwidth * barnum));
- } /*getbarleftedge*/
-
-
- static boolean drawbar (short barnumber) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register hdlappwindow ha = app.appwindow;
- register short barnum = barnumber;
- register short maxbarheight = (**hb).maxbarheight;
- register long value = (**hb).bars [barnum].value;
- register long maxvalue = (**hb).maxvalue;
- register short whitearea;
- Rect rbar, rwindow, rbitmap;
-
- if (!(**hb).bars [barnum].flhasbeenset)
- return (true);
-
- rwindow = (**ha).windowrect;
-
- apppushwindow (ha);
-
- rbar.left = getbarleftedge (barnum);
-
- rbar.right = rbar.left + (**hb).onebarwidth;
-
- rbar.bottom = (**hb).horizbaseline;
-
- rbar.top = rbar.bottom - maxbarheight;
-
- rbitmap = rbar;
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appopenbitmap (rbitmap, ha);
-
- EraseRect (&rbar);
-
- if (maxvalue == 0) /*avoid divide by zero error*/
- whitearea = 0;
-
- else { /*do arithmetic with longs*/
-
- register long l1 = maxvalue - value;
- register long l2 = maxbarheight;
- register long l3 = maxvalue;
- register long l4 = (l1 * l2) / l3;
-
- whitearea = (short) l4;
- }
-
- if (whitearea > 0)
- rbar.top += whitearea;
-
- pushpen ();
-
- if ((**hb).flactive) {
-
- FillRect (&rbar, quickdrawglobal (gray));
-
- PenPat (quickdrawglobal (black));
- }
- else {
-
- FillRect (&rbar, quickdrawglobal (ltGray));
-
- PenPat (quickdrawglobal (black));
- }
-
- FrameRect (&rbar);
-
- poppen ();
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appclosebitmap (ha);
-
- apppopwindow ();
-
- return (true);
- } /*drawbar*/
-
-
- static boolean drawlabel (short barnumber) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register hdlappwindow ha = app.appwindow;
- register hdlstring hstring;
- register short lh = (**hb).labellineheight;
- bigstring bs;
- Rect r;
-
- if (ha == nil)
- return (false);
-
- if (!(**hb).bars [barnumber].flhasbeenset)
- return (true);
-
- apppushwindow (ha);
-
- pushclip ((**ha).windowrect);
-
- r.left = getbarleftedge (barnumber);
-
- r.right = r.left + (**hb).onebarwidth;
-
- r.bottom = (**hb).labelbaseline - lh;
-
- r.top = r.bottom - lh;
-
- copystring ((**hb).bars [barnumber].label, bs);
-
- pushstyle ((**hb).labelfont, (**hb).labelsize, (**hb).labelstyle);
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appopenbitmap (r, ha);
-
- EraseRect (&r);
-
- centerstring (r, bs);
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appclosebitmap (ha);
-
- r.bottom += lh;
-
- r.top += lh;
-
- NumToString ((**hb).bars [barnumber].value, bs);
-
- pushstring ((**hb).barunits, bs);
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appopenbitmap (r, ha);
-
- EraseRect (&r);
-
- centerstring (r, bs);
-
- if (!(**hb).flbitmapactive) /*you can't nest bitmaps*/
- appclosebitmap (ha);
-
- popstyle ();
-
- popclip ();
-
- apppopwindow ();
-
- return (true);
- } /*drawlabel*/
-
-
- static void drawbarchart (void) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register short i;
-
- for (i = 0; i < (**hb).ctbars; i++) {
-
- drawbar (i);
-
- drawlabel (i);
- } /*for*/
- } /*drawbarchart*/
-
-
- static void drawfreemem (void) {
-
- Rect r;
- Str255 s;
-
- r = (*thePort).portRect;
-
- r.top = r.bottom - 15;
-
- r.right -= 20;
-
- EraseRect (&r);
-
- NumToString (FreeMem () / 1024, s);
-
- MoveTo (r.left + 3, r.bottom - 3);
-
- setfontsizestyle (geneva, 9, 0);
-
- DrawString (s);
-
- DrawString ("\pK");
- } /*drawfreemem*/
-
-
- static void drawusername (void) {
-
- /*
- use this to test out the FrontierDoScript functionality.
- */
-
- Rect r;
- Str255 s;
-
- if (!FrontierDoScript ("\puser.name", s))
- copystring ("\punknown user", s);
-
- r = (*thePort).portRect;
-
- r.top = r.bottom - 15;
-
- r.right -= 20;
-
- EraseRect (&r);
-
- MoveTo (r.left + 3, r.bottom - 3);
-
- setfontsizestyle (geneva, 9, 0);
-
- DrawString (s);
- } /*drawusername*/
-
-
- static void updatebarchart (void) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register hdlappwindow ha = app.appwindow;
-
- if (hb == nil) /*no data, it can't be our window*/
- return;
-
- apppushwindow (ha);
-
- drawfreemem ();
-
- /*drawusername ();*/
-
- (**hb).flbitmapactive = true; /*block lower-level bitmaps*/
-
- appopenbitmap ((**ha).windowrect, ha);
-
- drawbarchart ();
-
- appclosebitmap (ha);
-
- (**hb).flbitmapactive = false; /*unblock lower-level bitmaps*/
-
- apppopwindow ();
- } /*updatebarchart*/
-
-
- static boolean activatebarchart (boolean flactive) {
-
- /*
- activate or deactivate the indicated BarChart window. we can't depend
- on the BC globals being properly set because we may be working with a
- window that's not the frontmost window.
-
- returns true if we consumed the activate.
- */
-
- register hdlappwindow ha = app.appwindow;
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- if (hb == nil) /*no data, it can't be our window*/
- return (false);
-
- invalappwindow (ha, false);
-
- (**hb).flactive = flactive;
-
- return (true);
- } /*activatebarchart*/
-
-
- static boolean setminmax (void) {
-
- /*
- examine the values array, and reset the min and max, if necessary.
-
- return true if at least one changed, false otherwise.
- */
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register long newmax, newmin;
- register long val;
- register short i;
-
- newmax = intminusinfinity; /*assume only short values*/
-
- for (i = 0; i < (**hb).ctbars; i++) {
-
- val = (**hb).bars [i].value;
-
- if (val > newmax)
- newmax = val;
- } /*for*/
-
- newmin = intinfinity; /*assume only short values*/
-
- for (i = 0; i < (**hb).ctbars; i++) {
-
- val = (**hb).bars [i].value;
-
- if (val < newmin)
- newmin = val;
- } /*for*/
-
- if ((newmax != (**hb).maxvalue) || (newmin != (**hb).minvalue)) {
-
- (**hb).maxvalue = newmax;
-
- (**hb).minvalue = newmin;
-
- return (true);
- }
-
- return (false); /*no change*/
- } /*setminmax*/
-
-
- static void smashchartdisplay (boolean flerase) {
-
- register hdlappwindow ha = app.appwindow;
- Rect r;
-
- setchartconsts (); /*reset all the drawing parameters*/
-
- setminmax (); /*min and max might have changed*/
-
- invalappwindow (ha, flerase);
-
- updateappwindow (ha);
- } /*smashchartdisplay*/
-
-
- static boolean setbarunits (bigstring bs) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- copystring (bs, (**hb).barunits);
-
- smashchartdisplay (false); /*redraw the whole thing*/
-
- (**app.appwindow).flmadechanges = true;
-
- return (true);
- } /*setbarunits*/
-
-
- static boolean setbarvalue (short barnumber, long barvalue) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- if ((barnumber < 0) || (barnumber >= (**hb).ctbars)) /*defensive driving*/
- return (false);
-
- (**hb).bars [barnumber].value = barvalue;
-
- (**hb).bars [barnumber].flhasbeenset = true;
-
- if (setminmax ())
- smashchartdisplay (false); /*redraw the whole thing*/
-
- else {
- drawbar (barnumber);
-
- drawlabel (barnumber);
- }
-
- (**app.appwindow).flmadechanges = true;
-
- return (true);
- } /*setbarvalue*/
-
-
- static boolean getbarvalue (short barnumber, long *barvalue) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- *barvalue = 0; /*default returned value*/
-
- if ((barnumber < 0) || (barnumber >= (**hb).ctbars)) /*defensive driving*/
- return (false);
-
- *barvalue = (**hb).bars [barnumber].value;
-
- return (true);
- } /*getbarvalue*/
-
-
- static boolean setallvalues (short ct, tyvalues vals) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register short i;
-
- for (i = 0; i < ct; i++) {
-
- (**hb).bars [i].value = vals [i];
-
- (**hb).bars [i].flhasbeenset = true;
- } /*for*/
-
- setminmax ();
-
- smashchartdisplay (false); /*redraw the whole thing*/
-
- (**app.appwindow).flmadechanges = true;
-
- return (true);
- } /*setallvalues*/
-
-
- static boolean setbarlabel (short barnumber, bigstring bslabel) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- if ((barnumber < 0) || (barnumber >= (**hb).ctbars)) /*defensive driving*/
- return (false);
-
- copystring (bslabel, (**hb).bars [barnumber].label);
-
- (**hb).bars [barnumber].flhasbeenset = true;
-
- drawlabel (barnumber);
-
- (**app.appwindow).flmadechanges = true;
-
- return (true);
- } /*setbarlabel*/
-
-
- static boolean setbar (short barnumber, bigstring bslabel, long barvalue) {
-
- /*
- sets both the label and the value for the indicated bar.
-
- this is provided so that a single IAC call can set both.
- */
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- if ((barnumber < 0) || (barnumber >= (**hb).ctbars)) /*defensive driving*/
- return (false);
-
- if (!setbarlabel (barnumber, bslabel))
- return (false);
-
- return (setbarvalue (barnumber, barvalue));
- } /*setbar*/
-
-
- static short addbar (bigstring bslabel, long barvalue) {
-
- /*
- returns the number of the new bar, -1 if it failed.
- */
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register short barnumber = (**hb).ctbars;
-
- (**hb).ctbars++;
-
- setbarvalue (barnumber, barvalue);
-
- if (!setbarlabel (barnumber, bslabel)) {
-
- (**hb).ctbars--;
-
- return (-1);
- }
-
- smashchartdisplay (true);
-
- (**app.appwindow).flmadechanges = true;
-
- return (barnumber);
- } /*addbar*/
-
-
- static boolean getbarlabel (short barnumber, bigstring bslabel) {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
-
- setemptystring (bslabel); /*default returned value*/
-
- if ((barnumber < 0) || (barnumber >= (**hb).ctbars)) /*defensive driving*/
- return (false);
-
- copystring ((**hb).bars [barnumber].label, bslabel);
-
- return (true);
- } /*getbarlabel*/
-
-
- static boolean resetbarchartwindow (short ctbars) {
-
- (**(hdlbarchartrecord) app.appdata).ctbars = ctbars;
-
- smashchartdisplay (false);
-
- (**app.appwindow).flmadechanges = true;
-
- return (true);
- } /*resetbarchartwindow*/
-
-
- static boolean bcnewrecord (void) {
-
- register hdlbarchartrecord hb;
- register short i;
-
- if (!newclearhandle (longsizeof (tybarchartrecord), (Handle *) &app.appdata))
- return (false);
-
- hb = (hdlbarchartrecord) app.appdata;
-
- (**hb).versionnumber = 1;
-
- (**hb).ctbars = 0;
-
- (**hb).minvalue = 0;
-
- (**hb).maxvalue = 0;
-
- (**hb).pixelsbetweenbars = 10;
-
- for (i = 0; i < maxbars; i++) {
-
- (**hb).bars [i].value = 0;
-
- setstringlength ((**hb).bars [i].label, 0);
- } /*for*/
-
- setchartconsts ();
-
- return (true);
- } /*bcnewrecord*/
-
-
- static boolean bcdisposerecord (void) {
-
- disposehandle ((Handle) app.appdata);
-
- return (true);
- } /*bcdisposerecord*/
-
-
- static boolean bcadjustcursor (void) {
-
- arrowcursor (); /*BarChart's "adjust cursor" is pretty simple*/
-
- return (true);
- } /*bcadjustcursor*/
-
-
- static boolean bcwindowresize (void) {
-
- setchartconsts (); /*reset all computed values*/
-
- return (true);
- } /*bcwindowresize*/
-
-
- static boolean bcactivate (flactivate) boolean flactivate; {
-
- activatebarchart (flactivate);
-
- return (true);
- } /*bcactivate*/
-
-
- static boolean bcupdate (void) {
-
- updatebarchart ();
-
- return (true);
- } /*bcupdate*/
-
-
- static boolean setbarvalueverb (void) {
-
- /*
- verb that sets the value of one of the bars in the target window.
- */
-
- short barnumber;
- long barvalue;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &barnumber))
- return (false);
-
- barnumber--; /*our IAC interface is 1-based, internally we're 0-based*/
-
- if (!IACgetlongparam ('vbar', &barvalue))
- return (false);
-
- return (IACreturnboolean (setbarvalue (barnumber, barvalue)));
- } /*setbarvalueverb*/
-
-
- static boolean getbarvalueverb (void) {
-
- /*
- verb that returns the value of one of the bars in the target window.
- */
-
- short barnumber;
- long barvalue;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &barnumber))
- return (false);
-
- barnumber--; /*our IAC interface is 1-based, internally we're 0-based*/
-
- getbarvalue (barnumber, &barvalue);
-
- return (IACreturnlong (barvalue));
- } /*getbarvalueverb*/
-
-
- static boolean setbarverb (void) {
-
- /*
- verb that sets both the value and label of one of the bars in the
- target window.
- */
-
- short barnumber;
- bigstring bslabel;
- long barvalue;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &barnumber))
- return (false);
-
- barnumber--; /*our IAC interface is 1-based, internally we're 0-based*/
-
- if (!IACgetstringparam ('lbar', bslabel))
- return (false);
-
- if (!IACgetlongparam ('vbar', &barvalue))
- return (false);
-
- return (IACreturnboolean (setbar (barnumber, bslabel, barvalue)));
- } /*setbarverb*/
-
-
- static boolean setbarlabelverb (void) {
-
- /*
- verb that sets the label of one of the bars in the target window.
- */
-
- short barnumber;
- bigstring bslabel;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &barnumber))
- return (false);
-
- barnumber--; /*our IAC interface is 1-based, internally we're 0-based*/
-
- if (!IACgetstringparam ('lbar', bslabel))
- return (false);
-
- return (IACreturnboolean (setbarlabel (barnumber, bslabel)));
- } /*setbarlabelverb*/
-
-
- static boolean addbarverb (void) {
-
- /*
- verb that adds a new bar to the target window with indicated label and
- value.
- */
-
- bigstring bslabel;
- long barvalue;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetstringparam (keyDirectObject, bslabel))
- return (false);
-
- if (!IACgetlongparam ('vbar', &barvalue))
- return (false);
-
- return (IACreturnshort (addbar (bslabel, barvalue) + 1));
- } /*addbarverb*/
-
-
- static boolean setbarcountverb (void) {
-
- /*
- changes the number of bars in the target window.
- */
-
- short ctbars;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &ctbars))
- return (false);
-
- return (IACreturnboolean (resetbarchartwindow (ctbars)));
- } /*setbarcountverb*/
-
-
- static boolean getbarcountverb (void) {
-
- /*
- returns the number of bars in the target window.
- */
-
- register hdlbarchartrecord hb;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- return (IACreturnshort ((**(hdlbarchartrecord) app.appdata).ctbars));
- } /*getbarcountverb*/
-
-
- static boolean setunitsverb (void) {
-
- /*
- sets the units string of the target window. this string is displayed
- with the value of each of the bars.
- */
-
- bigstring bs;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetstringparam (keyDirectObject, bs))
- return (false);
-
- setbarunits (bs);
-
- return (IACreturnboolean (true));
- } /*setunitsverb*/
-
-
- static boolean getbarlabelverb (void) {
-
- /*
- returns the label of one of the bars in the target window. you provide
- us with a bar number.
- */
-
- short barnumber;
- bigstring barlabel;
-
- if (!settargetglobals ()) /*this verb requires an open barchart window*/
- return (false);
-
- if (!IACgetshortparam (keyDirectObject, &barnumber))
- return (false);
-
- barnumber--; /*our IAC interface is 1-based, internally we're 0-based*/
-
- getbarlabel (barnumber, barlabel);
-
- return (IACreturnstring (barlabel));
- } /*getbarlabelverb*/
-
-
- static boolean bciacmessage (void) {
-
- switch (IACgetverbtoken ()) {
-
- case setbarvaluetoken:
- setbarvalueverb (); break;
-
- case getbarvaluetoken:
- getbarvalueverb (); break;
-
- case setbarlabeltoken:
- setbarlabelverb (); break;
-
- case setbartoken:
- setbarverb (); break;
-
- case getbarlabeltoken:
- getbarlabelverb (); break;
-
- case addbartoken:
- addbarverb (); break;
-
- case setunitstoken:
- setunitsverb (); break;
-
- case setbarcounttoken:
- setbarcountverb (); break;
-
- case getbarcounttoken:
- getbarcountverb (); break;
-
- default:
- IACnothandlederror (); break;
- } /*switch*/
-
- return (false);
- } /*bciacmessage*/
-
-
- static boolean bcpack (hpacked) Handle *hpacked; {
-
- register hdlbarchartrecord hb;
-
- if (!copyhandle (app.appdata, hpacked))
- return (false);
-
- hb = (hdlbarchartrecord) *hpacked;
-
- return (true);
- } /*bcpack*/
-
-
- static boolean bcunpack (hpacked) Handle hpacked; {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) hpacked;
- hdlbarchartrecord hcopy;
-
- if ((**hb).versionnumber != 1)
- return (false);
-
- if (!copyhandle ((Handle) hb, (Handle *) &hcopy))
- return (false);
-
- disposehandle (app.appdata);
-
- app.appdata = (Handle) hcopy;
-
- setchartconsts (); /*reset all computed values*/
-
- return (true);
- } /*bcunpack*/
-
-
- static boolean bcgetpicture (hpicture) PicHandle *hpicture; {
-
- register hdlbarchartrecord hb = (hdlbarchartrecord) app.appdata;
- register hdlappwindow ha = app.appwindow;
- register WindowPtr w = (**ha).macwindow;
- Rect r = (*w).portRect;
- register PicHandle hp;
-
- *hpicture = nil; /*return value if error*/
-
- if (hb == nil) /*no data, it can't be our window*/
- return (false);
-
- pushmacport (w);
-
- pushclip (r);
-
- *hpicture = OpenPicture (&r);
-
- (**hb).flbitmapactive = true; /*block lower-level bitmaps*/
-
- drawbarchart ();
-
- (**hb).flbitmapactive = false; /*unblock lower-level bitmaps*/
-
- ClosePicture ();
-
- popclip ();
-
- popmacport ();
-
- return (true);
- } /*bcgetpicture*/
-
-
- static boolean bcresetscrollbars (void) {
-
- return (true);
- } /*bcresetscrollbars*/
-
-
- static boolean bcscroll (void) {
-
- return (true);
- } /*bcscroll*/
-
-
- static boolean bcopenprint (void) {
-
- app.printinfo.ctpages = 1;
-
- return (true);
- } /*bcopenprint*/
-
-
- static boolean bcpagesetup (void) {
-
- return (true);
- } /*bcpagesetup*/
-
-
- static boolean bcprintpage (pagenumber) short pagenumber; {
-
- PicHandle hpict;
- Rect rpict, rpaper;
- short hindent, vindent;
-
- if (!bcgetpicture (&hpict))
- return (false);
-
- rpict = (**hpict).picFrame;
-
- rpaper = app.printinfo.paperrect;
-
- hindent = ((rpaper.right - rpaper.left) - (rpict.right - rpict.left)) / 2;
-
- vindent = ((rpaper.bottom - rpaper.top) - (rpict.bottom - rpict.top)) / 2;
-
- OffsetRect (&rpict, hindent, vindent);
-
- DrawPicture (hpict, &rpict);
-
- KillPicture (hpict);
-
- return (true);
- } /*bcprintpage*/
-
-
- static boolean bccloseprint (void) {
-
- return (true);
- } /*bccloseprint*/
-
-
- static boolean bchaveselection (void) {
-
- return (false); /*no selection in BarChart*/
- } /*bchaveselection*/
-
-
- static boolean bcselectall (void) {
-
- return (false); /*no selection in BarChart*/
- } /*bcselectall*/
-
-
- void main (void) {
-
- clearbytes (&app, longsizeof (app)); /*init all fields to 0*/
-
- app.creator = 'BARC';
-
- app.filetype = 'CHRT';
-
- app.statswindow = true;
-
- app.newrecordcallback = &bcnewrecord;
-
- app.disposerecordcallback = &bcdisposerecord;
-
- app.adjustcursorcallback = &bcadjustcursor;
-
- app.activatecallback = (tyappbooleancallback) &bcactivate;
-
- app.updatecallback = &bcupdate;
-
- app.windowresizecallback = &bcwindowresize;
-
- app.iacmessagecallback = &bciacmessage;
-
- app.packcallback = &bcpack;
-
- app.unpackcallback = &bcunpack;
-
- app.getpictcallback = (tyapphandleptrcallback) &bcgetpicture;
-
- app.resetscrollbarscallback = &bcresetscrollbars;
-
- app.scrollcallback = (tyappsscrollcallback) &bcscroll;
-
- app.openprintcallback = &bcopenprint;
-
- app.pagesetupcallback = &bcpagesetup;
-
- app.printpagecallback = (tyappshortcallback) &bcprintpage;
-
- app.closeprintcallback = &bccloseprint;
-
- app.haveselectioncallback = &bchaveselection;
-
- app.selectallcallback = &bcselectall;
-
- runapplet ();
- } /*main*/