# Quick Reference

## CommandObject

    //  CommandObject: "#include <v/v_defs.h>"

    typedef struct CommandObject
      {
        CmdType cmdType;    // what kind of item is this
        ItemVal cmdId;      // unique id for the item
        ItemVal retVal;     // value returned when picked
        char* title;        // string
        void* itemList;     // used when cmd needs a list
        CmdAttribute attrs; // list of attributes
        unsigned
           Sensitive : 1;   // if item is sensitive or not
        ItemVal cFrame;     // Frame used for an item
        ItemVal cRightOf;   // Item placed left of this id
        ItemVal cBelow;     // Item placed below this one
        int size;           // Optional - for size information
        char* tip;		// Optional tip string
      } CommandObject;

### CmdType

                       (with suggested prefix for id names)
        C_EndOfList:   Used to denote end of command list
        C_Blank:       filler to help RightOfs, Belows work (blk)
        C_BoxedLabel:  a label with a box (bxl)
        C_Button:      Button (btn)
        C_CheckBox:    Checked Item (chk)
        C_ColorButton: Colored button (cbt)
        C_ColorLabel:  Colored label (clb)
        C_ComboBox:    Popup combo list (cbx)
        C_Frame:       General purpose frame (frm)
        C_Icon:        a display only Icon (ico)
        C_IconButton:  a command button Icon (icb)
        C_Label:       Regular text label (lbl)
        C_List:        List of items (lst)
        C_ProgressBar: Bar to show progress (pbr)
        C_RadioButton: Radio button (rdb)
        C_Slider:      Slider to enter value (sld)
        C_Spinner:     Spinner value entry (spn)
        C_TextIn:      Text input field (txi)
        C_Text:        wrapping text out (txt)
        C_ToggleButton: a toggle button (tbt)
        C_ToggleFrame: a toggle frame (tfr)
        C_ToggleIconButton:  a toggle Icon button (tib)

### CmdAttribute

        CA_DefaultButton: Special Default Button
           [Used by: C_Button]
        CA_Hidden:        Starts out hidden
           [All controls]
        CA_Horizontal:    Horizontal orientation
           [C_ProgressBar, C_Slider]
        CA_Large:         Command larger than normal
           [C_List C_ProgressBar, C_Slider, C_Spinner, C_TextIn]
        CA_MainMsg:       Gets replacement message
           [C_Label]
        CA_NoBorder:      No border (frames, status bar)
           [C_Frame,C_ToggleFrame,C_Text,status bar]
        CA_NoLabel:       No label on progress bar
           [C_ProgressBar]
        CA_NoNotify:      Don't notify on all events
           [C_ComboBox,C_List,C_Spinner]
        CA_NoSpace:       No space between widgets
           [C_Frame,C_ToggleFrame]
        CA_None:          No special attributes
           [All controls]
        CA_Percent:       Use % on progress bar
           [C_ProgressBar]
        CA_Small:         Command smaller than normal
           [C_ProgressBar,C_TextIn]
        CA_Size:          Specify size
           [C_Button,C_List,C_Spinner]
        CA_Text:          A Text value box
           [C_Spinner]
        CA_Vertical:      Vertical orientation
           [C_ProgressBar, C_Slider]

### Useful symbolic values

        NoList:           No list used
        NoFrame:          Not a member of a frame
        isSens:           Is sensitive
        notSens:          Not sensitive
        isChk:            Is checked
        notChk:           Not checked
        notUsed:          Not used
        noIcon:           No icon

## vApp

    //  vApp:  "#include <v/vapp.h>"

        class vApp : public vBaseItem
          {
          public:  //---------------------------------------- public
            vApp(VCONST char* appName, int simSDI = 0, int frameHeight = 0,
                int frameWidth = 0);      // constructor
            virtual ~vApp();

            // Methods to override

            virtual void AppCommand(vWindow* win, ItemVal id,
                                    ItemVal retval, CmdType ctype);
            virtual int CloseAppWin(vWindow* win);
            virtual void CloseLastCmdWindow(vWindow* win, int exitcode);
            virtual void Exit(void);
            virtual void KeyIn(vWindow* win, vKey key, unsigned int shift);
            virtual vWindow* NewAppWin(vWindow* win, char* name, int w, int h,
                                   vAppWinInfo* winInfo = 0);
            // Utility methods

            vFont GetDefaultFont(void);
            void GetVVersion(int& major, int& minor);
            int DefaultHeight();
            int DefaultWidth();
            int IsRunning();
            void SendWindowCommandAll(ItemVal id, int val, CmdType ctype);
            void SetAppTitle(char* title);
            void SetValueAll(ItemVal id, int val, ItemSetType setType);
            void SetStringAll(ItemVal id, char* str);
    	void showAppWin(bool show);
            void UpdateAllViews(vWindow* sender = NULL, int hint = 0,
                   void* pHint = NULL);
            const char* name();

            vAppWinInfo *getAppWinInfo(vWindow* Win);

            // Clipboard

            int ClipboardSetText(char* text);
            char* ClipboardGetText();
            int ClipboardCheckText();
            void ClipboardClear();

            // Tasking

    	void CheckEvents();

    	int EnableWorkSlice(long slice);
    	virtual void WorkSlice();

            // X platform dependent

            Display* display();           // To get the X display
            XtAppContext appContext();    // To get the context

            // MS-Windows platform dependent
            int simSDI();
          };

        extern vApp *theApp;     // Pointer to single global instance
        extern int AppMain(int argc, char** argv);  // Pseudo main program

## vAppWinInfo

    //  vAppWinInfo:  "#include <v/vawinfo.h>"
        class V_EXPORT vAppWinInfo
          {
          public:     //---------------------------------------- public

            vAppWinInfo(VCONST char* name = "", VCONST void* ptr = 0);
            virtual ~vAppWinInfo();

            virtual VCONST char* infoName() {return _infoName;}
            virtual VCONST void* getPtr() {return _ptr;}
          };

## vBrush

    //  vBrush:  "#include <v/vbrush.h>"
        class vBrush
          {
          public:       //-------------------------------- public
            vBrush(unsigned int r = 0, unsigned int g = 0, unsigned int b = 0,
                   int style = vSolid, int fillMode = vAlternate);
            ~vBrush();

            int operator ==(vBrush b2);
            int operator !=(vBrush b2);

            vColor GetColor();
            int GetFillMode();
            int GetStyle();
            void SetColor(vColor c);
            void SetColor(unsigned int r, unsigned int g, unsigned int b);
            void SetFillMode(int fillMode);
            void SetStyle(int style);
          };

## vCanvasPane

    //  vCanvasPane:  "#include <v/vcanvas.h>"

        class vCanvasPane
          {
          public:   //---------------------------------------- public

            vCanvasPane(PaneType pt = P_Canvas);
            virtual ~vCanvasPane();

            virtual void ShowPane(int OnOrOff);

            // Cursor
            void SetCursor(VCursor id);
            VCursor GetCursor();
            void UnSetCursor(void);

            // Scrolling
            virtual void HPage(int Shown, int Top);
            virtual void VPage(int Shown, int Top);
            virtual void HScroll(int step);
            virtual void VScroll(int step);
            virtual void SetHScroll(int Shown, int Top);
            virtual void SetVScroll(int Shown, int Top);
            virtual int GetHScroll(int& Shown, int& Top);
            virtual int GetVScroll(int& Shown, int& Top);
            virtual void ShowHScroll(int OnOff);
            virtual void ShowVScroll(int OnOff);

            // Change messages
            virtual void FontChanged(vFont vf);

            // Events
            virtual void MouseDown(int x, int y, int button);
            virtual void MouseUp(int x, int y, int button);
            virtual void MouseMove(int x, int y, int button);
            virtual void EnterFocus();
            virtual void LeaveFocus();

            // Expose/redraw events
            virtual void Redraw(int x, int y, int width , int height);
            virtual void Resize(int newW, int newH);

            // Information
            virtual int GetWidth();
            virtual int GetHeight();

            // Drawing
            void Clear(void);
            virtual void ClearRect(int left, int top, int width, int height);
            virtual void DrawAttrText(int x, int y, char* text, const ChrAttr attr);
            virtual void DrawColorPoints(int x, int y, int nPoints, vColor* pts);
            virtual void DrawText(int x, int y, char* text);
            virtual void DrawEllipse(int x, int y, int width, int height);
            virtual void DrawIcon(int x, int y, vIcon& icon);
            virtual void DrawLine(int x, int y, int xend , int yend);
            virtual void DrawLines(vLine* lineList, int count);
            virtual void DrawPoint(int x, int y);
            virtual void DrawPoints(vPoint* pointList, int count);
            virtual void DrawPolygon(int n, vPoint points[], int fillStyle = vAlternate);
            virtual void DrawRectangle(int x, int y, int width, int height);
            virtual void DrawRectangles(vRect* rectList, int count);
            virtual void DrawRoundedRectangle(int x, int y, int width, int height, int radius);
            virtual void DrawRubberLine(int x, int y, int xend, int yend);
            virtual void DrawRubberEllipse(int x, int y, int width, int height);
            virtual void DrawRubberRectangle(int x, int y, int width, int height);
            virtual vBrush GetBrush(void);
            virtual void SetBrush(vBrush brush);
            virtual vFont GetFont(void);
            virtual void SetFont(vFont fnt);
            virtual int TextWidth(char* str);
            virtual int TextHeight(int& ascent, int& descent);
            vDC* GetDC();

            // Appearance
            virtual void SetScale(int mult, int div);
            virtual void GetScale(int& mult, int& div);
            virtual void SetBackground(vColor color);
            virtual void SetPen(vPen pen);
            vPen GetPen();
            void SetTranslate(int x, int y);
            void SetTransX(int x);
            void SetTransY(int y);
            void GetTranslate(int& x, int& y);
            int GetTransX();
            int GetTransY();

            // X Platform dependent
            Widget DrawingWindow();
    	// Windows Platform dependent
    	HWND DrawingWindow();
          };

## vCmdWindow

    //  vCmdWindow:  "#include <v/vcmdwin.h>"

        class vCmdWindow : public vWindow
          {
          public:           //----------------------------------- public
            vCmdWindow(char* name = "+", int width = 0, int height = 0);
            virtual ~vCmdWindow();                         // Destructor

            virtual void CloseWin(void);    // callback for close button
          };

## vColor

    //  vColor:  "#include <v/vcolor.h>"

    // Message constants for use in Color buttons (for color buttons, etc.)

            M_Black, M_Red, M_DimRed, M_Green, M_DimGreen, M_Blue, M_DimBlue,
            M_Yellow, M_DimYellow, M_Magenta, M_DimMagenta, M_Cyan, M_DimCyan,
            M_DarkGray, M_MedGray, M_White,
            M_ColorFrame

    // Index constants into V "standard" color arrays: vStdColors, vColorNames.

            vC_Black, vC_Red, vC_DimRed, vC_Green, vC_DimGreen, vC_Blue, vC_DimBlue,
            vC_Yellow, vC_DimYellow, vC_Magenta, vC_DimMagenta, vC_Cyan, vC_DimCyan,
            vC_DarkGray, vC_MedGray, vC_White

        class vColor
          {
          public:    //---------------------------------------- public
            vColor(unsigned int rd = 0, unsigned int gr = 0, unsigned int bl = 0);
            ~vColor();

            int operator ==(vColor c2);
            int operator !=(vColor c2);
            int BitsOfColor();
            ResetColor(unsigned int rd = 0, unsigned int gr = 0, unsigned int bl = 0);
            Set(unsigned int rd = 0, unsigned int gr = 0, unsigned int bl = 0);
            Set(vColor& c);
            void SetR(unsigned int rd = 0);
            void SetG(unsigned int gr = 0);
            void SetB(unsigned int bl = 0);

            unsigned int r();
            unsigned int g();
            unsigned int b();
          };

        extern vColor vStdColors[16];       // 16 "standard" colors
        extern char* vColorNames[16];       // and their names

## vDebugDialog

    //  vDebugDialog:  "#include <v/vdebug.h>"

        class vDebugDialog : public vModalDialog
          {
          public:    //---------------------------------------- public
            vDebugDialog(vBaseWindow* bw,char* title = "Debugging Options");
            vDebugDialog(vApp* aw,char* title = "Debugging Options");
            ~vDebugDialog();
            void SetDebug();
          };

### Command Line Switches

-vDebug SU < list >
  Turn on System or User (or both) debug messages in list.
c
  Command events (menu, dialog commands).
m
  Mouse events.
w
  Window events (resize, redraw).
b
  Build events.
o
  Other misc. events.
v
  Bad values.
C
  Constructors.
D
  Destructors.
123
  User items 1, 2, or 3.

## vDialog

    //  vDialog:  "#include <v/vdialog.h>"

        class vDialog
          {
          public:             //------------------------------------ public

            vDialog(vBaseWindow* creator, int modal = 0, char* title = "");
            vDialog(vApp* creator, int modal = 0, char* title = "");
            ~vDialog();

            WindowType wType();

            virtual void AddDialogCmds(CommandObject* cList);
            virtual void CancelDialog(void);
            virtual void CloseDialog(void);
            virtual void SetDialogTitle(char * title);
            virtual void DialogCommand(ItemVal id, ItemVal retval, CmdType ctype);
            virtual int GetTextIn(ItemVal id, char* strout, int maxlen);
            virtual int GetValue(ItemVal id);
            virtual void SetValue(ItemVal id, ItemVal val, ItemSetType setType);
            virtual void SetString(ItemVal id, char* str);
            int IsDisplayed(void);
            virtual void ShowDialog(const char* msg);
          };

## vFileSelect

    //  vFileSelect:  "#include <v/vfilesel.h>"

        class vFileSelect : protected vModalDialog
          {
          public:     //---------------------------------------- public
            vFileSelect(vBaseWindow* bw, char* title = "File Select");
            vFileSelect(vApp* aw, char* title = "File Select");
            ~vFileSelect();

            int FileSelect(const char* msg, char* filename,
                const int maxlen, char** filter);
            int FileSelectSave(const char* msg, char* filename,
                const int maxlen, char** filter);
          };

## vFont

    //  vFont:  "#include <v/vfont.h>"
        enum vFontID                // various font related ids
          {
            vfDefaultSystem,        // the default system font
            vfDefaultFixed,         // the system default fixed font
            vfDefaultVariable,      // the system default variable font
            vfSerif,                // serifed font - TimesRoman
            vfSansSerif,            // SansSerif - Swiss or Helvetica
            vfFixed,                // fixed font - Courier
            vfDecorative,           // decorative - dingbat
            vfOtherFont,            // for all other fonts
            vfNormal,               // normal style, weight
            vfBold,                 // boldface
            vfItalic,               // italic style
            vfEndOfList
          };

        class vFont         // make the font stuff a class to make it portable
          {
          public:           //---------------------------------------- public
            vFont(vFontID fam = vfDefaultFixed, int size = 10,
               vFontID sty = vfNormal, vFontID wt = vfNormal, int und = 0,
               int angle = 0);
            ~vFont();

            vFontID GetFamily() { return _family; }
            int GetPointSize() { return _pointSize; }
            vFontID GetStyle() { return _style; }
            vFontID GetWeight() { return _weight; }
            int GetUnderlined() { return _underlined; }
            void SetFontValues(vFontID fam = vfDefaultFixed, int size = 10,
               vFontID sty = vfNormal, vFontID wt = vfNormal, int und = 0);
          };
    #endif

## vFontSelect

    //  vFontSelect:  "#include <v/vfontsel.h>"

        class vFontSelect : protected vModalDialog
          {
          public:       //---------------------------------------- public
            vFontSelect(vBaseWindow* bw, char* title = "Select Font");
            vFontSelect(vApp* aw, char* title = "Select Font");
           ~vFontSelect();

           int FontSelect(vFont& font, const char* msg = "Select Font" );
          };
    #endif

## vIcon

        // <v/vicon.h>

        class vIcon     // an icon
          {
          public:             //---------------------------------------- public
            vIcon(unsigned char* ic, int h, int w, int d = 1);
            ~vIcon();
            int height;             // height in pixels
            int width;              // width in pixels
            int depth;              // bits per pixel
            unsigned char* icon;    // ptr to icon array

          protected:        //--------------------------------------- protected
          private:          //--------------------------------------- private
          };

## vMenu

    //  vMenu:  "#include <v/v_menu.h>"

        typedef struct vMenu
          {
            char* label;       // The label on the menu
            ItemVal menuId;    // A User assigned unique id
            unsigned
              sensitive : 1,   // If item is sensitive or not
              checked : 1;     // If item is checked or not
            char* keyLabel;    // Label for an accelerator key
            vKey accel;        // Value of accelerator key
            vMenu* SubMenu;    // Ptr to a submenu
          } MenuItem;

### Useful symbolic values

        isSens:           Is sensitive
        notSens:          Not sensitive
        noSub:            No submenu
        isChk:            Is checked
        notChk:           Not checked
        noKey:            No accelerator specified
        noKeyLbl:         No accelerator label

## vModalDialog

    //  vModalDialog:  "#include <v/vmodald.h>"

        class vModalDialog : public vDialog
          {
          public:   //---------------------------------------- public

            vModalDialog(vBaseWindow* creator, char* title = "");
            vModalDialog(vApp* creator, char* title = "");
            virtual ~vModalDialog();

            virtual ItemVal ShowModalDialog(const char* msg, ItemVal& retval);

            // rest are inherited from vDialog
          };

## vNoticeDialog

    //  vNoticeDialog:  "#include <v/vnotice.h>"

        class vNoticeDialog : protected vModalDialog
          {
          public:    //---------------------------------------- public
            vNoticeDialog(vBaseWindow* bw, char* title = "Notice");
            vNoticeDialog(vApp* aw, char* title = "Notice");
            ~vNoticeDialog();

            void Notice(char* msg);
          };

## vPen

    //  vPen:  "#include <v/vpen.h>"

        class vPen
          {
          public:    //---------------------------------------- public
            vPen(unsigned int r = 0, unsigned int g = 0,
                 unsigned int b = 0, int width = 1, int style = vSolid);
            ~vPen();

            int operator ==(vPen p2);
            int operator !=(vPen p2);

            void SetStyle(int style);
            int GetStyle(void);
            void SetWidth(int width);
            int GetWidth();
            void SetColor(vColor c);
            vColor GetColor();
          };

## vReplyDialog

    //  vReplyDialog:  "#include <v/vreply.h>"

        class vReplyDialog : protected vModalDialog
          {
          public:   //---------------------------------------- public
            vReplyDialog(vBaseWindow* bw, char* title = "Reply");
            vReplyDialog(vApp *aw, char* title = "Reply");

            int Reply(const char* msg, char* reply, const int maxlen);
          };

## vStatus

    //  vStatus:  "#include <v/v_defs.h>"

        typedef struct vStatus      // for status bars
          {
            char* label;            // text label
            ItemVal statId;         // id
            CmdAttribute attrs;     // attributes - CA_NoBorder, CA_None
            unsigned sensitive : 1; // if button is sensitive or not
            int width;              // to specify width (0 for default)
          } vButton;

### Useful symbolic values

        CA_NoBorder:      No border (frames, status bar)
        CA_None:          No special attributes
        isSens:           Is sensitive
        notSens:          Not sensitive
        noIcon:           No icon

## vTextCanvasPane

    //  vTextCanvasPane:  "#include <v/vtextcnv.h>"

        class vTextCanvasPane : public vCanvasPane
          {
          public:  //---------------------------------------- public
            vTextCanvasPane();
            virtual ~vTextCanvasPane();

            // Window management/drawing

            virtual void Clear(void);
            virtual void ClearRow(const int r, const int c);
            virtual void ClearToEnd(const int r, const int c);
            int GetCols();
            int GetRows();
    	int ColToX(int col);
    	int RowToY(int row);
            void GetRC(int& r, int& c);
            void GotoRC(const int r, const int c);
            virtual void DrawAttrText(const char* text, const ChrAttr attr);
            virtual void DrawChar(const char chr, const ChrAttr attr);
            virtual void DrawText(const char* text);
            virtual void DrawText(int x, int y, const char* text);
            void HideTextCursor(void);
            void ShowTextCursor(void);
    	void SetTextRowsCols(int rows, int cols);

            // Scrolling
            void ScrollText(const int lineCount);

            // Events
            virtual void ResizeText(const int rows, const int cols);
            virtual void TextMouseDown(int row, int col, int button);
            virtual void TextMouseUp(int row, int col, int button);
            virtual void TextMouseMove(int row, int col, int button);
          };

## vTimer

    //  vTimer:  "#include <v/vtimer.h>"

        class vTimer
          {
          public:   //---------------------------------------- public
            vTimer();
            virtual ~vTimer();

            virtual int TimerSet(long interval);
            virtual void TimerStop(void);
            virtual void TimerTick(void);
          };

## V Utilities

    //  V Utilities:  "#include <v/vutil.h>"

        extern void LongToStr(long intg, char* str);
        extern void IntToStr(int intg, char* str);
        extern void vGetLocalTime(char* tm);
        extern void vGetLocalDate(char* tm);

## vWindow

    //  vWindow:  "#include <v/vwindow.h>"

        enum WindowType
          { WINDOW, CMDWINDOW, DIALOG };  // Types of windows

        class vWindow
          {
          public:           //-------------------------------- public
            vWindow(char *name = "+", int width = 0, int height = 0,
               WindowType wintype = WINDOW);    // Constructor

            virtual ~vWindow();                 // Destructor

            // Methods to Override

            virtual void KeyIn(vKey keysym, unsigned int shift);
            virtual void MenuCommand(ItemVal id);
            virtual void WindowCommand(ItemVal id, ItemVal retval, CmdType ctype);

            // Utility Methods

            const Widget vHandle();         // X only - native handle
            const char* name();             // the name set
            virtual void ShowWindow(void);
            WindowType wType();          // what kind of window we are

            virtual void AddPane(vPane* add_pane);
            virtual void CloseWin(void);
            virtual int GetValue(ItemVal id);
            virtual void RaiseWindow(void);
            virtual void SetString(ItemVal id, char* str);
            virtual void SetStringAll(ItemVal id, char* str);
            virtual void SetTitle(char* title);
            virtual void SetValue(ItemVal id, int val, ItemSetType setType);
            virtual void SetValueAll(ItemVal id, int val, ItemSetType setType);
            void ShowPane(vPane* wpane, int OnOrOff);
          };

## vYNReplyDialog

    //  vYNReplyDialog:  "#include <v/vynreply.h>"

        class vYNReplyDialog : protected vModalDialog
          {
          public:     //---------------------------------------- public
            vYNReplyDialog(vBaseWindow* bw, char* title = "Yes or No");
            vYNReplyDialog(vApp* aw, char* title = "Yes or No");
            ~vYNReplyDialog();

            int AskYN(const char* msg);
          };