// Todo: split into different interfaces

public interface HyperConstants
{
final static int BIT1  = 0x00000001,BIT2   = 0x00000002,BIT3  = 0x00000004;
final static int BIT4  = 0x00000008,BIT5   = 0x00000010,BIT6  = 0x00000020;
final static int BIT7  = 0x00000040,BIT8   = 0x00000080,BIT9  = 0x00000100;
final static int BIT10 = 0x00000200,BIT11  = 0x00000400,BIT12 = 0x00000800;
final static int BIT13 = 0x00001000,BIT14  = 0x00002000,BIT15 = 0x00004000;
final static int BIT16 = 0x00008000,BIT17  = 0x00010000,BIT18 = 0x00020000;
final static int BIT19 = 0x00040000,BIT20  = 0x00080000,BIT21 = 0x00100000;
final static int BIT22 = 0x00200000,BIT23  = 0x00400000,BIT24 = 0x00800000;
final static int BIT25 = 0x01000000,BIT26  = 0x02000000,BIT27 = 0x04000000;
final static int BIT28 = 0x08000000,BIT29  = 0x10000000,BIT30 = 0x20000000;
final static int BIT31 = 0x40000000,BIT32  = 0x80000000;

//final static String HYPERVIEWVERSION="V2.969";// <-- Jan 30,2013
//final static String HYPERVIEWVERSION="V2.970";// <-- April 18,2014
//final static String HYPERVIEWVERSION="V2.971";// <-- April 11 2015  
//final static String HYPERVIEWVERSION="V2.972"; // <-- Jan 18 2019  
//final static String HYPERVIEWVERSION="V2.973"; // <-- Nov 3 2019
final static String HYPERVIEWVERSION="V2.974";   // <-- April 11 2020
                                               //
                                               //Don't change this.
                                               // unless you do a CVS/SNV commit.
                                               // to hyperview.dev.java
                                               //and if so increment by 1
final static int UP   = 1;
final static int DOWN = 2;

// Selected Bitmap wait time
final static long SELECT_WAIT_MILLIS = 30l;

final static String DEFAULT_DATA_FILENAME = "HyperView.dat";
final static String EMPTY_STRING = "";
   //
   // HyperView() is at the base of the call stack.
   // Dispatch() will increment the stack.
   // Thus returning from a Dispatch() can only return 
   // at least there. Each stack frame has a name
   // which can be easily read to determine which 
   // stack frame died during a code autopsy :)
   //  
public final static String   BASE_STACKNAME     = "HyperView";
        // Dispatch() Control Flags
final static int INHERIT_GADGETS    = 0x00000002;  //ATM you must inherit both
final static int INHERIT_GOBS       = 0x00000004;  //gobs & Gadgets. Or neither.
        // This is Open   = 0x00000008;
final static int INHERIT_STRINGS    = 0x00000010;
final static int INHERIT_ANIMGOBS   = 0x00000020;  //
final static int INHERIT_CONBACKS   = 0x00000040;
final static int INHERIT_GETSTRINGS = 0x00000080;  //
final static int INHERIT_TITLEBAR   = 0x00000100;
final static int INHERIT_MENUS      = 0x00000200;
final static int INHERIT_BACKGROUND = 0x00000400;
final static int ABORT_ENA          = 0x00000800;
final static int INHERIT_ALL        = 0x00001000;
            
        // A gap for more
//final static int REMOTE_ON          = 0x00010000;
//final static int LOCAL_ECHO         = 0x00020000;
   
   // For Application only Applet uses Browser AppletSecurity
//final static int DISPATCH_SOCK_ENA  = 0x00200000;
   // 
final static int MAX_HYPERCOMPONENTS = 255; // Adjust as required.

final static int MAX_GOBS           = MAX_HYPERCOMPONENTS;
final static int MAX_GADGETS        = MAX_HYPERCOMPONENTS;
   //
//final static int MAX_FONT_SIZE      = 13;
final static int MAX_GETSTRINGS     = 32;
final static int MAX_KEY_MESSAGES   = 255;
final static int MAX_STRINGS        = 255;  // Same as 
final static int MAX_BACKGROUNDS    = 255;

     // HyperView main enable bits. Some of these are deprecated

final static int DISPLAY_ENA          = BIT1;    // before we overflow 32 bits
final static int CONNECT_ENA          = BIT2;    // will split some of these
final static int KEYBOARD_ENA         = BIT3;    
final static int CONSOLE_ENA          = BIT4;    // Enable stdin
final static int TEXT_ENA             = BIT5;    // Enable System Text rendering/
final static int GOB_ENA              = BIT6;    // Enable Bittable Gobs()
final static int LINE_ENA             = BIT7;    // Enable System lines buffer.
final static int MENU_ENA             = BIT8;    // Enable X style pop menu.
final static int OUTLINE_ENA          = BIT9;    // draw outline in current FG Color
final static int LAYER_SWAP_ENA       = BIT10;   // enable Component Layering.
final static int KEEP_RUNNING         = BIT11;   // Asynchronons non blocking quit signal bit.
final static int BACKGROUND_ENA       = BIT12;   // Enable background image rendering.
final static int DEBUG_ENA            = BIT13;   // Enable running under debugger
final static int MENU_ACTIVE          = BIT14;   // render pop up menu.
final static int RUN_EXCEPTION        = BIT15;   // Oh Oh! Trigger exception handler.
final static int BACKGROUND_LOADING   = BIT16;   // Background Image is still loading.
final static int IMAGE_LOADING        = BIT17;   // Will do extra rendering while loading.
final static int GOB_BOUNCED          = BIT18;   //  It bounced, invoke Spline momentum/direction instructions if enabled.
final static int TITLEBAR_ENA         = BIT19;   // Enable the titlebar at the top.
final static int CONNECTED            = BIT20;   // --  You are connected to a server.
final static int CONNECTING           = BIT21;   // you are in the process.
final static int RUNSTACK_TIMER       = BIT22;   //  How long to run the display at this display stack.
final static int GURU_ENA             = BIT23;   // OH OH! someting failed.
final static int GEM_REFRESH          = BIT24;   // Redraw the "Connect Gem" color on the titlebar when connection state changes.
final static int OBSERVER_ECHO        = BIT25;   // print all Image Obeserver messages to stdout.
final static int INIT_OVERRIDE        = BIT26;
final static int SKIP_RESTORE         = BIT27;   // flag a 1 display frame 
final static int PARENT_IS_HYPERFRAME = BIT28;   // If I know the parent Component is a HyperFrame, I can call  it's methods.
                                                 // Note: HyperFrame is deprecated for java 12.
                                                 //
// Wait for text to time out. Note this will run for(;;)
// If the text does not actually time out and does not cancel
// a regular runView timeout
final static int WAIT_TEXT            = BIT32;

//
// A note on USE_BLIT_OPTIMIZE.
//  This controls how the background clip restore blit is done.
// 1) Restore only the damaged part of the display caused by component moves and layer changes.
// 2) Stamp the entire display in one blit and then do the component render.

// #1 is generally faster as blits are small things like sprites so you are restore
// #2 However, if you have a LARGE number of gobs, it will be quicker to stamp the whole background
// than to loop through and restore a pile of individual clips.
// FTM:You will have to determine which is better for you. 
//  TODO: Make this automatic via time based calculation.
//

// Main View Flags 2

final static int BACKGROUND_UNDERLAP  = BIT1;
final static int BACKGROUND_STRETCH   = BIT2;
final static int EXTERNAL_SERVER_ENA  = BIT3;
final static int SERVER_SPAWNED_VIEW  = BIT4;
final static int GEM_UPDATE_OVERRIDE  = BIT5;
final static int ERASE_VIEW           = BIT6;  // Erase signal
final static int USE_BLIT_OPTMIZE     = BIT7; // Blit clip only bit (as opposed to whole display) What you are
final static int INITIALIZE_REFRESH   = BIT8; 

                // ******  HyperView eventFlags
final static int DISPATCH_ENA         = BIT1;  // Enable Dispatch.class Objects on Gobs.
final static int DISPATCH_MENU        = BIT2;  // Menu is active flag/ 
final static int RUN_ABORTED          = BIT3; // Abort.class Object was invoked.
final static int SELECT_SKIP          = BIT4; // wait one iteration for select image to render. ie: a selected button.
final static int REMOTE_DISPATCH      = BIT5; // Dispatch from a different host.
final static int SOUND_ENA            = BIT6;  // turn on sound

                // ****** HyperView memoryFlags
                //Note: these bits area also used by ViewMemoryConstant.OFFSET_FLAGS
final static int SERVER_BASE          = BIT1;
final static int START_SERVER_BASE    = BIT2;
final static int START_P2P_SERVER     = BIT3;
final static int P2P_BASE             = BIT4;
final static int EXTERNAL_IO_ENABLE   = BIT5;
                 
                // ****** Hyperview List Control flags
final static int LIST_REFRESH  = 0x00000001;
  // suspend Abort Gadget & CLI Command
  // till after user has replied to Popup.
  // This avoids display stack skew on asynch event handle 
  // (ie: avoids Basic you're dead so kiss your ass goodbye situation :) ) 
final static int POPUP_NOABORT = 0x00000002;
               // *****************************
final static int MAX_CONSOLES = 25; // For now
final static int MAX_REMOTE_DISPATCH = 15;

         // External/ internal IOFlags / Device Flags / Exeption etc.
         // Thank Amiga DOS for these.

final static int IO_DO               = BIT1;  // Proceed within the current thread context
final static int IO_SEND             = BIT2;  // Asynchronous; queue and return
final static int IO_WAIT             = BIT3;  // Wait for reply.
final static int IO_QUICK            = BIT4;  // Do within caller's Thread context
final static int ASYNCH_KEY_ENA      = BIT5;
final static int IMAGE_FROM_JAR_ENA  = BIT6;  // as opposed to codebase
final static int HYPEREDIT_ENA       = BIT7;
final static int HYPERVIEW_EXCEPTION = BIT8;  // It had one
final static int PORTINFO_ENA        = BIT9;




          //     // Abs Max
     //  2      6      24       150  
    // (1 * 2)(2 * 3)(4 * 6)(10 * 15)  @ 640  X 480
    //  2      6       35      216
    // (1 * 2)(2 * 3)(5 * 7)( 12 * 18) @ 800  X 600
    //  6      12      54      384
    // (2 * 3)(3 * 4)(6 * 9)(16 * 24)  @ 1024 X 768

// I have this truned off FTM but you can click click and shrik the view small.
// X/Y offsets of scaled multiple Views

 final static int xLoop[][] =
    {
    {1,2,4,10},
    {1,2,5,12},
    {2,3,6,16}
    };
 final static int yLoop[][] = 
   {
   {2,3,6,15},
   {2,3,7,18},
   {3,4,9,24}
   };        
         // Gob type flag bit are
/*
final static int GOB_IS_TEXT           = BIT1;
final static int GOB_IS_LINE           = BIT2;
final static int GOB_IS_GADGET         = BIT3;
*/
      // Flags for GOB (Graphics Objects) control
      // If you add more you must also add the appropriate string
      // to hyperView.hyperDump()
      // You are free to play with bbits marked as internal
      // BUT you really shouldnt and will probably
      //  not have anything  useful happen.

final static int GOB_IS_TEXT           = BIT1;  // internal
final static int GOB_IS_LINE           = BIT2;  // ""
final static int GOB_IS_GADGET         = BIT3;  // ""
final static int GOB_ONGOB             = BIT4;  // it's embeddd on another gob
final static int GOB_COLLISION_ON      = BIT5;  // Enable the collision Manager
//these are for splines
final static int GOB_BOUNCE            = BIT6;  // Bounce at the end of its path
final static int GOB_ORBIT             = BIT7;  // Its orbiting another Gob()
final static int GOB_NO_SELECT         = BIT8;  // Dont use a select image.
                                                
//final static int GOB_BLT_ENA           = BIT9;  // Enable stamping of the image from
                                                //A URL based getImage
final static int GOB_ON_DISPLAY        = BIT10;   // What it says
final static int GOB_LOADING           = BIT11;   //  You could check this
final static int GOB_HAS_ZBUFFER       = BIT12;   // Better not set this unless
                                                  // you have a X/Y/Z/ Spline
final static int GOB_IS_ORBITING       = BIT13;   // It's Orbiting another Gob()
final static int GOB_HAS_GRAVITY       = BIT14;  // 
final static int GOB_COLLISION_ENA     = BIT15;  //Enable a Collision detection
final static int GOB_CLICK_METHOD      = BIT16;  // Enable Gob.onClick()        
                                                 // for MouseEvents    
                                                 // Otherwise the default is a DIspatch.begin() call on MouseEvent/                                    


final static int GOB_DO_ONCLICK        = BIT17; // "internal" BUT you could set this bit 
                                                // to "Fake" a mouse click.
                                                //
final static int GOB_MULTICON          = BIT18; // The Gob can jump from Consoles
                                                //
final static int GOB_ANIM_ENA          = BIT19; //"Internal" BUT you could perhaps
                                                // turn this on and off.  
                                                // BUT if you enable animation
                                                // On a Gob() and not an AnimGob() it is an error
                                                // 
final static int GOB_ANIMATED          = BIT20;   
final static int ZBUFFER_ENA           = BIT21;    // Enable/Disable  Zbuffer
final static int GOB_ISLOADED          = BIT22;    // YOu could maybe loop aroound or check this
                           // Note: This is for Gadgets. "Select"= alternate Image enable
                           // That is displayed when you click on a Gadget.
// The handle to both is thus..
                         
final static int GOB_USE_SELECT        = BIT23;    // You couls play with this 
                                                   // BUT   
final static int GOB_ON_CONSOLE        = BIT24;   // On a Console
final static int GOB_COLLIDED          = BIT25;   
final static int GOB_GRABBED           = BIT26;
final static int GOB_NO_TIDY           = BIT27;
final static int GOB_SPLINE_ENA        = BIT28;
final static int GOB_INFO_ENA          = BIT29;
final static int GOB_ATTACHED_ENA      = BIT30;
final static int GOB_IN_SWAPBUFFER     = BIT31;
final static int GOB_IS_HYPERCOMPONENT = BIT32;
       // These are for -> Gob.gobFlags2
final static int GOB_ACTIVATE_ENA      = BIT1; // Allows shutting on and off
final static int GOB_DESTROY           = BIT2;
final static int GOB_REMOVED           = BIT3;
final static int GOB_PURGE_ENA         = BIT4;
final static int GOB_POPUP_ENA             = BIT5;
final static int GOB_RESTORE_ENA           = BIT6; // restore Background
final static int GOB_RELEASE_METHOD        = BIT7; // enable onRelease()
final static int GOB_DO_RELEASE            = BIT8; // call onRelease(); 
final static int GOB_MEMORYIMAGESOURCE     = BIT9;  // derive render blit from integer data.
final static int GOB_MEMORYIMAGE_NO_SELECT = BIT10; // error. select bit set but null select MemoryImageSource
final static int GOB_HAS_DATA              = BIT11;  // Observer flagged graphics data valid.


final static int ANIMATE_GOB = (GOB_ANIMATED|GOB_ANIM_ENA);                      
final static int DEFAULT_MOVEBUFFER_SIZE = 32;

// Gob() Event Flags
final static int GOB_DISPATCH_ENA      = BIT1;
// 
final static int CON_FLIPBACK          = BIT23;
final static int CON_RANDFLIP          = BIT24;
final static int CON_FLIPLOOP          = BIT25;
final static int CON_FLIP_XOR          = BIT26;
final static int CON_FLIP_ASCEND       = BIT27;
final static int COLLISION_START       = BIT28;
    // ************ TitleBar Flags
// Redundant use Gob flag to toggle.

//final static int TITLEBAR_ON         = 0x00000001;

final static int TITLEBAR_CLOCK      = 0x00000002; // Display a Real Time Clock.
final static int TITLEBAR_CLOSE      = 0x00000004;  // Well now... I forget :)
final static int TITLEBAR_MEMON      = 0x00000008; // Enable memory to be displayed // add video ram.
final static int TITLEBAR_DRAWSTRING = 0x00000010;  // Put default text on it.
    // ************** Gadget Flags **************
    // If you add more you must also add the appropriate string
    // to hyperView.hyperDump()   
final static int GADGETON            = BIT1;  // ENA
final static int GADGETFLASH         = BIT2;  // Flash enable
final static int GADGETCOMP          = BIT3;  // Complement Planes ^= Planes
final static int GADGETSELECT        = BIT4;  // Maybe can XOR
final static int GADGET_TOGGLE       = BIT5;  // A toggle
final static int GADGET_STRING       = BIT6;  // Its a String Gadget so 
                                              // MOST of these are internal
                                              // play with but will likely cause problems
final static int GADGET_BITMAPPED    = BIT7;
final static int GADGET_SBITMAPPED   = BIT8;   // It has a "SuperBitMap"
                          // This is a background that is larger than the
                          // visible display and scrollable.
                          //todo fix namespacew to be consistant
final static int GAD_USE_SELECT      = BIT9;   // Use BUT better have a gob.selecImage()
final static int GAD_ITEM_SELECTED   = BIT10;  // internal For menu items etc
final static int DISPATCH_GADGET     = BIT11;  // internal
final static int GAD_LOCK_ON         = BIT12;  // Hmm I forget :)
final static int GAD_IS_MENU         = BIT13;  // "internal"
final static int GAD_IS_TITLEBAR     = BIT14; // Faster to check a bit than instanceof
final static int GAD_IS_CONSOLE      = BIT15; //
final static int GAD_KEYBOARD_ENA    = BIT16; // Keyboard Meta enable.
final static int GAD_KEY_PRESSED_ENA = BIT17; // KeyPress enable
final static int GAD_KEY_RELEASE_ENA = BIT18; // Key release enable.
final static int GAD_KEY_TYPED_ENA   = BIT19; // Keyboard IO method enable.
final static int GAD_DRAW_CURSOR     = BIT20; // It wants a Cursor enable.
final static int GAD_MOUSEOVER_ENA   = BIT21; // Turn off onClick.
final static int GAD_NOCLICK         = BIT22; // Dont allow grabbing
final static int GAD_NOGRAB          = BIT23;
final static int GAD_DISPATCH_ENA    = BIT24; // Dispatch() ENA
final static int GAD_OUTLINE_ENA     = BIT25; // Draw an outline
final static int GAD_TEXT_ENA        = BIT26; 
final static int GAD_LAYER_ENA       = BIT27; // It is Layerable
                                              // IF you set this the Gadget
                                              // And any embedded ones.
                                              //will moveto the foreground when clicked on
              // There is no reason to touch these.
final static int GAD_IN_LIST         = BIT28;  // internal
final static int GAD_IS_VIEWPANE     = BIT29;
final static int GAD_WAITFOR_IMAGE   = BIT30;
final static int GAD_CURSOR_ENA      = BIT31;               
           // Another 32 bits of flags
final static int GAD_SELECT_IMAGE_RENDERED = BIT1;  // Used to force preloading
                                                    // of the image by the observer
final static int GAD_MOUSE_WHEEL_ENA       = BIT2;
           //
          //  Main initialization Flags
          // Mouse Message Flags

final static int MAX_MOUSE_MESSAGES = 255;

final static int BACKGROUND_USED       = BIT1;
//final static int MAX_EXEC              = 50;

    // Its a moving line
final static int VECTOR_LINE           = 0x00000001;

            /* WebGuru() Sub process Exception Bits */
final static int MOUSE_EXCEPTION    = 0x00000001;
final static int KEYBOARD_EXCEPTION = 0x00000002;   

   /* *** FileTransaction Flags */
    // NOT implemented yet.
final static int ENABLE     = 0x00000001;
final static int COMPLETED  = 0x00000002;
final static int BEGUN      = 0x00000004;
final static int RECORD     = 0x00000008;
final static int CONFIRMED  = 0x00000010;
final static int DENIED     = 0x00000002;

   // Scrollbar constants
   // You should never touch these.
   //
final static int SCROLLBAR_ENA        =  0x00000001;
final static int SCROLLBAR_LEFT       =  0x00000002;
final static int SCROLLBAR_TOP        =  0x00000004;
final static int SCROLLBAR_RIGHT      =  0x00000008;
final static int SCROLLBAR_BOTTOM     =  0x00000010;


final static int SCROLLBAR_HORIZONTAL = 0x00000020;
final static int SCROLLBAR_VERTICAL   = 0x00000040;
final static int SCROLLBAR_MONO_CNTL  = 0x00000080;// One Thumb for horiz & vert.

final static int SCROLLBAR_PLACEMASK  =  0x0000000e1;
final static int SCROLLBAR_PCLEARMASK = ~0x0000000e;
final static int SCROLLBAR_TYPE_MASK  = SCROLLBAR_HORIZONTAL|SCROLLBAR_VERTICAL|SCROLLBAR_MONO_CNTL;


   // Superbitmap scroll
   // I will have to show how to use these later.
   //
final static int SCROLL_ENA      = 0x00000001;
   // Values for Scroll Octant
final static int SCROLL_NONE       = 0;
final static int SCROLL_UP         = 1;
final static int SCROLL_URIGHT     = 2;
final static int SCROLL_RIGHT      = 3;
final static int SCROLL_RIGHTDOWN  = 4;
final static int SCROLL_DOWN       = 5;
final static int SCROLL_DOWNLEFT   = 6;
final static int SCROLL_LEFT       = 7;
final static int SCROLL_UPLEFT     = 8;
/* ie: 
scroll (x-,y-)(x+,y)(x-,y+)(x+,y-)(x==y) 
*/
    //"internal"
final static int HORIZONTAL_ENA = 0x00000001;
final static int VERTICAL_ENA   = 0x00000002;
final static String CURSOR_NAME = "cursor.gif";   // Change this for default cursor image. which will be scale to font size.
   // Set this to your VLC directory and it will default there.
final static String DEFAULT_VIDEO_PROGRAM = "D:\\camera\\VLC\\vlc.exe";

final static int MAINFILE_FOLDER_IMAGE_WIDTH = 18;
final static int MAINFILE_FOLDER_IMAGE_HEIGHT = 14;
// For stop lite image x/y
public final static int trafficLightOffsets [][] =
{
{0, 42,21,63},  // stop
{23,43,31,63},  // red
{34,43,42,63},  // amber
{44,43,52,63}   // green
};

// messages from the Guru.
// 
// Guru() has issues ATM
// it traps All exceptions BUT damage recovery needs work.
// todo: fix view shutdown and restart, 
//
// When funcitoning properly it SHOULD be impossible 
// to crash the HyperView()
//

String guruStr[]=
{
"",
"0x1001 Run Dispatch         ",
"0x2001 Sound NULL Ptr       ",
"0x3001 BackGround URL       ",
"0x3002 BackGround OverFlow  ",
"0x3003 SetBackGround() Index",//5
"0x3004 DrawBackGround()     ",
"0x2006 PlaySound()          ",
"0x4001 Exec Stream Overflow.",
"0x4002 Exec Unknown StreamID",
"0x3005 Out of Gob(); Memory ", //10
"0x4001 Illegal AddGadget()  ",  
"0x4002 AddGadget() OverFlow.",
"0x4003 AddGadget() Run Error",
"0x3006 SetFontSize() Error  ",
"0x4004 GadgetDisplay() Error", //15
"0xffff V1.0 Fatal UnRecoverable Error.",
"0x3007 SetBackGround() Index",
"0x4005 String Stream Overflow",
"0x4006 HYPERInit()=false;",
"0x6001 LoadCursor() Exception",      //20
"0x6002 LoadCursor() Image Null",
"0x7001 ConsoleAddGob() Runtime",
""   //23 GuruEnd
};
int guruEnd=23;

}
