The Hot Views Graphics Library

by David P. Heddle



Listing One

Hv_VaInitialize(argc,         argv, 

        Hv_NORAINBOW,         True, 

        Hv_USEWELCOMEVIEW,    True, 

        Hv_VERSIONNUMBER,     101, 

        Hv_USEEXTENDEDCOLORS, True, 

        NULL); 

Init(); 

Hv_Go(); 



Listing Two

void Hv_GetAttributes(va_list ap,

              Hv_AttributeArray attributes,

              char **optlist,

              int *tags,

              int *fonts,

              int *colors,

              short *numopt)

{

  int              argflag = -1;

  int              prevargflag;

  /*give defaults for all attributes */

  Hv_SetDefaultAttributes(attributes);

/* now get the attributes */

  while (argflag != 0) {

    prevargflag = argflag;

/* the argflag is the keyword, #defined as a set of sequential ints such as 

#define Hv_BACKGROUND 22, etc. the NULL terminator will produce a zero 

argflag */

    argflag = va_arg(ap, int);  /* should be >= zero & < some max */

    if ((argflag < 0) || (argflag >= Hv_NUMATTRIBUTES)) {

    /* unintersting error handling omitted */

    }

    else if (argflag > 0) {

/* group according to type, place in the attribute array which is an array of 

unions. We need insider information about what type is associated with each 

attribute. */

      if ((argflag == Hv_DRAWCONTROL)

      || (argflag == Hv_USERDRAWCONTROL)

       /* or many integer attributes omitted */

      || (argflag == Hv_RELATIVEPLACEMENT))

         attributes[argflag].i = va_arg(ap, int);

      else if ((argflag == Hv_STATE)

      || (argflag == Hv_USEWELCOMEVIEW)

       /* or many short attributes omitted */

      || (argflag == Hv_PLACEMENTGAP))

          attributes[argflag].s = (short)va_arg(ap, int);

/* omitting code for other types: chars, strings, floats, etc. */

      else  /* only thing left are the pointers */

    attributes[argflag].v = va_arg(ap, void *);

    } /* end argflag > 0 */

  }

  va_end(ap); /* terminate the processing */

}



Listing Three

void Init() {

   Hv_canvasColor = Hv_lightSeaGreen; /*Change BG color */ 

   WindowTile();    /* tile the window with propaganda */ 

   MakeMenus();     /* modify the main menu */ 

   InitControls();  /* Initialize controls */ 

   AddLogo();       /* add a logo */ 

   InitQuickZoom(); /* initialize quick zooms */ 

   FinalInit();    /* final initialization */ 

}



Listing Four

     void MakeMenus() {

    Hv_Widget item; 

    char *text; 

/* create the menu items for the Help menu */

    text = (char *)Hv_Malloc(strlen(Hv_programName) + 20);

    strcpy(text, "About "); 

    strcat(text, Hv_programName); 

    strcat(text, "..."); 

    item = Hv_VaCreateMenuItem(Hv_helpMenu, Hv_LABEL, text, 

                  Hv_CALLBACK, DoAboutDlog, NULL) 

   Hv_Free(text);

/* add a "new view" item to the action menu */ 

    item = Hv_VaCreateMenuItem(Hv_actionMenu, 

                   Hv_LABEL,     "New View", 

                   Hv_CALLBACK,  GetNewView, 

                   NULL);

/* add a plot canvas option to the action menu */ 

    item = Hv_VaCreateMenuItem(Hv_actionMenu, Hv_LABEL, "New Plot Canvas", 

                   Hv_CALLBACK, NewPlotView, NULL); 

     }



Listing Five

static void FinalInit() {

  Hv_View view; 

  Hv_AddPath("./mapmaker");   /* add to search path */ 

  Hv_InitMaps("hv.maps");     /* initialize maps */ 

  view = NewView(MAPVIEW); }  /* create one initial view*/ 

}



Listing Six

Hv_VaCreateView(&View, 

    Hv_TAG, tag, 

    Hv_DRAWCONTROL,

    Hv_STANDARDDRAWCONTROL+Hv_SAVEBACKGROUND,

    Hv_POPUPCONTROL, popupcontrol, 

    Hv_TITLE, tchr, 

    Hv_INITIALIZE, ViewSetup, 

    Hv_CUSTOMIZE, ViewCustomize, 

    Hv_USERDRAW, ViewDraw, 

    Hv_OFFSCREENUSERDRAW, OffScreenViewDraw, 

    Hv_FEEDBACK, ViewFeedback, 

    Hv_LEFT, left, 

    Hv_TOP, top, 

    Hv_XMIN, xmin, 

    Hv_XMAX, xmax, 

    Hv_YMIN, ymin, 

    Hv_YMAX, ymax, 

    Hv_HOTRECTWIDTH, width, 

    Hv_HOTRECTHEIGHT, height, 

    Hv_MINZOOMWIDTH, minw, 

    Hv_MAXZOOMWIDTH, maxw, 

    Hv_MINZOOMHEIGHT, minh, 

    Hv_MAXZOOMHEIGHT, maxh, 

    Hv_SIMPROC, (Hv_FunctionPtr)SimulationCB, 

    Hv_SIMINTERVAL, 2000, 

    Hv_HOTRECTVMARGIN, 7, 

    Hv_HOTRECTCOLOR, Hv_blue-2, 

    Hv_MOTIONLESSFB, True, 

    Hv_MOTIONLESSFBINTERVAL, 500, 

    NULL); 



Listing Seven



Choice = Hv_VaCreateItem(View, 

    Hv_TYPE, Hv_CHOICESETITEM, 

    Hv_RELATIVEPLACEMENT, Hv_POSITIONBELOW, 

    Hv_PLACEMENTITEM, Box2, 

    Hv_PLACEMENTGAP, 1, 

    Hv_NOWON, mdata->projection, 

    Hv_FILLCOLOR, Hv_powderBlue, 

    Hv_ARMCOLOR, Hv_navyBlue, 

    Hv_COLOR, Hv_gray10, 

    Hv_FONT, Hv_fixed2, 

    Hv_OPTION, "Mercator", 

    Hv_OPTION, "Orthographic", 

    Hv_SINGLECLICK, ProjectionChoiceCB, 

    Hv_TITLE, "Map Projection", 

    NULL); 



Listing Eight

Item = Hv_VaCreateItem(View, 

    Hv_TYPE, Hv_WORLDPOLYGONITEM, 

    Hv_TAG, DCITEM, 

    Hv_NUMPOINTS, np, 

    Hv_DATA, fpts, 

    Hv_NUMROWS, 1, 

    Hv_NUMCOLUMNS, 1, 

    Hv_DOMAIN, Hv_INSIDEHOTRECT, 

    Hv_DOUBLECLICK, EditDCItem, 

    Hv_DRAWCONTROL, Hv_ZOOMABLE + Hv_INBACKGROUND,

    Hv_AFTEROFFSET, DCAfterOffset, 

    Hv_USER1, (int)superlayer, 

    Hv_USER2, (int)sect, 

    Hv_BALLOON, (void *)text, 

    Hv_FIXREGION, FixDCSuperLayerRegion, 

    NULL);

Item->type = Hv_USERITEM;        /* redefine as user item */ 

Item->standarddraw = DrawDCItem; /* redirect std. drawing */ 





4



