Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

virtualevent(3w)  —  OLIT Widget Set

NAMES

OlClassSearchIEDB, OlClassSearchTextDB, OlCreateInputEventDB, OlLookupInputEvent, OlWidgetSearchIEDB, OlWidgetSearchTextDB

SYNOPSIS AND DESCRIPTION

Note:

For all functions discussed here the registration order determines the search order when doing a lookup. 

OlClassSearchIEDB

Synopsis:

#include <Xol/OpenLook.h>
 . . .
voidOlClassSearchIEDB(

WidgetClass wc;
OlVirtualEventTable db);

The OlClassSearchIEDB procedure is used to register a given database on a specific widget class. The db value was returned from a call to OlCreateInputEventDB(). 

Once a database is registered with a given widget class, the OlLookupInputEvent() procedure (if db_flag is OL_DEFAULT_IE or db) will include this database in the search stack if the given widget id is a subclass of this widget class. 

EXAMPLE

/∗ To create a client application database ∗/
#include <Xol/OpenLook.h>
#include <Xol/Stub.h>
     /∗ start with a big value to avoid ∗/
     /∗ the "virtual_name" collision    ∗/
#define OL_MY_BASE            1000
#define OL_MY_DRAWLINEBTN     OL_MY_BASE+0
#define OL_MY_DRAWARCBTN      OL_MY_BASE+1
#define OL_MY_REDISPLAYKEY    OL_MY_BASE+2
#define OL_MY_SAVEPARTKEY     OL_MY_BASE+3
 #define XtNmyDrawLineBtn      "myDrawLineBtn"
#define XtNmyDrawArcBtn       "myDrawArcBtn"
#define XtNmyRedisplayKey     "myRedisplayKey"
#define XtNmySavePartKey      "mySavePartKey"
 static OlKeyOrBtnRec     OlMyBtnInfo[] = {
     /∗name         default_value    virtual_name        ∗/
      { XtNmyDrawLineBtn,  "c<Button1>",       OL_MY_DRAWLINEBTN  },
     { XtNmyDrawArcBtn,   "s<myDrawLineBtn>", OL_MY_DRAWARCBTN   },
};
 static OlKeyOrBtnRec     OlMyKeyInfo[] = {
     /∗name               default_value      virtual_name        ∗/
      { XtNmyRedisplayKey, "c<F5>",           OL_MY_REDISPLAYKEY },
     { XtNmySavePartKey,  "c<F5>",           OL_MY_SAVEPARTKEY  },
};
 static OlVirtualEventTable     OlMyDB;
 OlMyDB = OlCreateInputEventDB(
               w,
               OlMyKeyInfo, XtNumber(OlMyKeyInfo),
               OlMyBtnInfo, XtNumber(OlMyBtnInfo)
     );
     /∗ assume: all stub widgets are interested in OlMyDB ∗/
OlClassSearchIEDB(stubWidgetClass, OlMyDB);
     /∗ once this step is done, all stub widget instances ∗/
     /∗ will receive the OlMyDB commands after a call to  ∗/
     /∗ OlLookupInputEvent(), or in the XtNconsumeEvent   ∗/
     /∗ callback’s OlVirtualEvent structure supplied with ∗/
     /∗ the call_data field.                              ∗/
 

OlClassSearchTextDB

Synopsis:

#include <Xol/OpenLook.h>
 . . .
voidOlClassSearchTextDB(

WidgetClasswc);

The OlClassSearchTextDB procedure is used to register the OPEN LOOK TEXT database on a specific widget class. 

Once the OPEN LOOK TEXT database is registered with a given widget class, the OlLookupInputEvent() procedure (if db_flag is OL_DEFAULT_IE or OL_TEXT_IE) will include this database in the search stack if the given widget id is a subclass of this widget class. 

EXAMPLE

    ...
#include <Xol/OpenLook.h>
#include <Xol/Stub.h>
    ...
      /∗ assume: all stub widgets are interested in the    ∗/
     /∗          OPEN LOOK TEXT database                  ∗/
OlClassSearchTextDB(stubWidgetClass);
     /∗ once this step is done, all stub widget instances ∗/
     /∗ will receive OPEN LOOK TEXT commands after a      ∗/
     /∗ call to OlLookupInputEvent(), or in the           ∗/
     /∗ XtNconsumeEvent callback’s OlVirtualEvent         ∗/
     /∗ structure supplied with the call_data field.      ∗/
   ...

OlCreateInputEventDB

Synopsis:

#include <Xol/OpenLook.h>
 . . .
OlVirtualEventTableOlCreateInputEventDB(

Widget w,
OlKeyOrBtnInfo key_info,
int num_key_info,
OlKeyBtnInfo btn_info,
int num_btn_info);

The OlCreateInputEventDB function is used to create a client specific Key and/or Button database. This function returns a database pointer if the call to this function is successful otherwise a NULL pointer is returned. 

Mapping for a new virtual command can be composed from the mappings of a previously defined virtual command. 

The returned value from this function is an opaque pointer (
 
OlVirtualEventTable).  A client application should use this pointer when registering and/or looking up this database. 

typedef struct _OlVirtualEventInfo ∗OlVirtualEventTable;

The key_info and btn_info parameters are a pointer to an OlKeyOrBtnRec structure. 

typedef struct {
Stringname;
Stringdefault_value; /∗ "," separate string ∗/
OlVirtualNamevirtual_name;
} OlKeyOrBtnRec, ∗OlKeyOrBtnInfo;

Caveat

A client application can create a Key–only database by having the NULL btn_info. The same applies to a Button only database.

Each virtual command can have two different bindings because the OPEN LOOK toolkit allows the alternate key or button sequence. 

The OPEN LOOK toolkit already has a set of predefined OPEN LOOK virtual names. It is important that the virtual_name value of a client application database starts with a big value to avoid the virtual_name collision.

EXAMPLE

     /∗ To create a client application database ∗/
     ...
#include <Xol/OpenLook.h>
     ...
     /∗ start with a big value to avoid ∗/
     /∗ the "virtual_name" collision    ∗/
#define OL_MY_BASE            1000
#define OL_MY_DRAWLINEBTN     OL_MY_BASE+0
#define OL_MY_DRAWARCBTN      OL_MY_BASE+1
#define OL_MY_REDISPLAYKEY    OL_MY_BASE+2
#define OL_MY_SAVEPARTKEY     OL_MY_BASE+3
 #define XtNmyDrawLineBtn     "myDrawLineBtn"
#define XtNmyDrawArcBtn      "myDrawArcBtn"
#define XtNmyRedisplayKey    "myRedisplayKey"
#define XtNmySavePartKey     "mySavePartKey"
 static OlKeyOrBtnRec     OlMyBtnInfo[] = {
     /∗name             default_value      virtual_name        ∗/
      { XtNmyDrawLineBtn,  "c<Button1>",       OL_MY_DRAWLINEBTN  },
     { XtNmyDrawArcBtn,   "s<myDrawLineBtn>", OL_MY_DRAWARCBTN   },
};
 static OlKeyOrBtnRec     OlMyKeyInfo[] = {
     /∗name               default_value      virtual_name        ∗/
      { XtNmyRedisplayKey, "c<F5>",           OL_MY_REDISPLAYKEY },
     { XtNmySavePartKey,  "c<F5>",           OL_MY_SAVEPARTKEY  },
};
 static OlVirtualEventTable     OlMyDB;
       ...
OlMyDB = OlCreateInputEventDB(
               w,
               OlMyKeyInfo, XtNumber(OlMyKeyInfo),
               OlMyBtnInfo, XtNumber(OlMyBtnInfo)
     );
    ...

OlLookupInputEvent

Synopsis:

#include <Xol/OpenLook.h>
 . . .
OlVirtualEventTableOlLookupInputEvent(

Widget w,
XEvent ∗xevent,
OlVirtualEvent virtual_event_ret,
XtPointer db_flag);

The .JL OlLookupInputEvent procedure is used to translate a X event to an OPEN LOOK virtual event. The X event ( xevent) could be a KeyPress, ButtonPress, ButtonRelease, EnterNotify, or event. The procedure attempts to translate this event based on the setting of the OPEN LOOK defined dynamic databases. 

The virtual_event_ret parameter is a pointer to an OlVirtualEventRec structure:

typedef struct {
     Boolean         consumed;
     XEvent ∗        xevent;
     Modifiers       dont_care;
     OlVirtualName   virtual_name;
     KeySym          keysym;
     String          buffer;
     Cardinal     length;
     Cardinal        item_index;
} OlVirtualEventRec, ∗OlVirtualEvent;

(Note that this structure is also used by the callbacks to the XtNconsumeEvent resource.) 

If the X event is a KeyPress, the keysym, buffer, and length information will be included in virtual_event_ret.  The information was returned from a call to XLookupString(). 

The db_flag parameter is an XtPointer type.  The valid values are OL_DEFAULT_IE, or the return value from a OlCreateInputEventDB() call. 

The ( w, db_flag) pair determines the searching database(s). If the db_flag value is not OL_DEFAULT_IE then only the given database (for example, OL_TEXT_IE means: search the OPEN LOOK TEXT database) will be searched, otherwise a search stack will be built. This stack is based on the widget information (w) and the registering order to determine the searching database(s). Once this stack is built, the procedure searches in a LIFO (Last In First Out) manner. 

All widgets have an callback.  When this callback is called, the call_data field is a pointer to an OlVirtualEventRec structure which is filled in with the results of calling with the db_flag set to OL_DEFAULT_IE. 

Virtual Event Databases

The following abbreviations are used to shorten the “Default Bindings” column of the two tables that follow. 

  Table 1 Virtual Event Abbreviations

 KeyAbbreviation
_
Alt keya
Ctrl keyc
no modifiern
Shift keys

  Table 2 Core Virtual Event Key Bindings

Core Database (OL_CORE_IE)
_
Command NameVirtual Expression Virtual Event Default Binding
_
 
ADJUSTadjustBtn OL_ADJUST n<Button2>
ADJUSTKEYadjustKey OL_ADJUSTKEY a<Insert>
CANCELcancelKey OL_CANCEL n<Escape>
CONSTRAINconstrainBtn OL_CONSTRAIN c<Button1>
COPYcopyKey OL_COPY n<F16>
CUTcutKey OL_CUT n<F20>
DEFAULTACTIONdefaultActionKey OL_DEFAULTACTION <Return>,c<Return>
DRAGdragKey OL_DRAG n<F5>
DROPdropKey OL_DROP n<F2>
DUPLICATEduplicateBtn OL_DUPLICATE s<Button1>
DUPLICATEKEYduplicateKey OL_DUPLICATEKEY s<space>
HELPhelpKey OL_HELP n<Help>
HSBMENUhorizSBMenuKey OL_HSBMENU a<h>
MENUmenuBtn OL_MENU n<Button3>
MENUDEFAULTmenuDefaultBtn OL_MENUDEFAULT s<Button3>
MENUDEFAULTKEYmenuDefaultKey OL_MENUDEFAULTKEY c<space>
MENUKEYmenuKey OL_MENUKEY a<space>
MOVEDOWNdownKey OL_MOVEDOWN <Down>
MOVELEFTleftKey OL_MOVELEFT <Left>
MOVERIGHTrightKey OL_MOVERIGHT <Right>
MOVEUPupKey OL_MOVEUP <Up>
MULTIDOWNmultiDownKey OL_MULTIDOWN c<Down>
MULTILEFTmultiLeftKey OL_MULTILEFT c<Left>
MULTIRIGHTmultiRightKey OL_MULTIRIGHT c<Right>
MULTIUPmultiUpKey OL_MULTIUP c<Up>
NEXTAPPnextAppKey OL_NEXTAPP a<n>
NEXT_FIELDnextFieldKey OL_NEXT_FIELD n<Tab>,c<Tab>
NEXTWINDOWnextWinKey OL_NEXTWINDOW a<w>
PAGEDOWNpageDownKey OL_PAGEDOWN a<R15>
PAGELEFTpageLeftKey OL_PAGELEFT a c<R9>
PAGERIGHTpageRightKey OL_PAGERIGHT a c<R15>
PAGEUPpageUpKey OL_PAGEUP a<R9>
PANpanBtn OL_PAN a<Button1>
PASTEpasteKey OL_PASTE n<F18>
PREVAPPprevAppKey OL_PREVAPP a s<n>
PREV_FIELDprevFieldKey OL_PREV_FIELD s<Tab>,c s<Tab>
PROPERTYpropertiesKey OL_PROPERTY n<F13>
SCROLLBOTTOMscrollBottomKey OL_SCROLLBOTTOM a c<R13>
SCROLLDOWNscrollDownKey OL_SCROLLDOWN a<Down>
SCROLLLEFTscrollLeftKey OL_SCROLLLEFT a<Left>
SCROLLLEFTEDGEscrollLeftEdgeKey OL_SCROLLLEFTEDGE a <R7>
SCROLLRIGHTscrollRightKey OL_SCROLLRIGHT a<Right>
SCROLLRIGHTEDGEscrollRightEdgeKey OL_SCROLLRIGHTEDGE a <R13>
SCROLLTOPscrollTopKey OL_SCROLLTOP a c<R7>
SCROLLUPscrollUpKey OL_SCROLLUP a<up>
SELCHARBAKselCharBakKey OL_SELCHARBAK s<Left>
SELCHARFWDselCharFwdKey OL_SELCHARFWD s<Right>
SELECTselectBtn OL_SELECT n<Button1>
SELECTKEYselectKey OL_SELECTKEY n<space>
SELFLIPENDSselFlipEndsKey OL_SELFLIPENDS a<Insert>
SELLINEselLineKey OL_SELLINE c a<Left>
SELLINEBAKselLineBakKey OL_SELLINEBAK s<R7>
SELLINEFWDselLineFwdKey OL_SELLINEFWD s<R13>
SELWORDBAKselWordBakKey OL_SELWORDBAK c s<Left>
SELWORDFWDselWordFwdKey OL_SELWORDFWD c s<Right>
STOPstopKey OL_STOP n<F11>
TOGGLEPUSHPINtogglePushpinKey OL_TOGGLEPUSHPIN c<t>
UNDOundoKey OL_UNDO n<F14>
VSBMENUvertSBMenuKey OL_VSBMENU a<v>
WINDOWMENUwindowMenuKey OL_WINDOWMENU a<m>
WORKSPACEMENUworkspaceMenuKey OL_WORKSPACEMENU a s<m>

  Table 3 Text Virtual Event Key Bindings

 Text Database (OL_TEXT_IE)
_
 Command NameVirtual Expression Virtual Event Default Button
_
  Utilities
CHARBAKcharBakKey OL_CHARBAK <Left>
CHARFWDcharFwdKey OL_CHARFWD <Right>
DELCHARBAKdelCharBakKey OL_DELCHARBAK <BackSpace>,<Delete>
DELCHARFWDdelCharFwdKey OL_DELCHARFWD s<BackSpace>,s<Delete>
DELLINEdelLineKey OL_DELLINE m<BackSpace>,m<Delete>
DELLINEBAKdelLineBakKey OL_DELLINEBAK c<BackSpace>
DELLINEFWDdelLineFwdKey OL_DELLINEFWD c<Delete>
DELWORDBAKdelWordBakKey OL_DELWORDBAK c s<BackSpace>
DELWORDFWDdelWordFwdKey OL_DELWORDFWD c s<Delete>
DOCENDdocEndKey OL_DOCEND c<R13>
DOCSTARTdocStartKey OL_DOCSTART c<R7>
LINEENDlineEndKey OL_LINEEND n<R13>
LINESTARTlineStartKey OL_LINESTART n<R7>
PANEENDpaneEndKey OL_PANEEND c s<R13>
PANESTARTpaneStartKey OL_PANESTART c s<R7>
RETURNreturnKey OL_RETURN <Return>
ROWDOWNrowDownKey OL_ROWDOWN <Down>
ROWUProwUpKey OL_ROWUP <Up>
WORDBAKwordBakKey OL_WORDBAK c<Left>
WORDFWDwordFwdKey OL_WORDFWD c<Right>

EXAMPLE

         ...
#include <Xol/OpenLook.h>
         ...
OlVirtualEventRec    ve;
      /∗ To look up the OPEN LOOK CORE database ∗/
OlLookupInputEvent(w, xevent, &ve, OL_CORE_IE);
switch (ve.virtual_name)
{
     case OL_UNKNOWN_INPUT:
         ...
          break;
     case OL_UNKNOWN_BTN_INPUT:
         ...
          break;
     case OL_UNKNOW_KEY_INPUT:
         ...
          break;
     case OL_ADJUST:
          printf ("pressed the adjustBtn\n");
         ...
          break;
     case OL_ADJUSTKEY:
          printf ("pressed the adjustKey\n");
         ...
          break;
         ...
}
         ...
         ...
#include <Xol/OpenLook.h>
         ...
OlVirtualEventRec     ve;
     /∗ To look up the OPEN LOOK TEXT database ∗/
OlLookupInputEvent(w, xevent, &ve, OL_TEXT_IE);
switch (ve.virtual_name)
{
         ...
     case OL_DOCEND:
          printf ("pressed the docEndKey\n");
         ...
          break;
     case OL_LINEEND:
          printf ("pressed the lineEndKey\n");
         ...
          break;
         ...
}
         ...
#include <Xol/OpenLook.h>
         ...
OlVirtualEventRec     ve;
     /∗ To look up all possible databases ∗/
     /∗ assume: "w" is a textfield widget ∗/
OlLookupInputEvent(w, xevent, &ve, OL_DEFAULT_IE);
switch (ve.virtual_name)
{
         ...
case OL_ADJUST:
     printf ("pressed the adjustBtn\n");
         ...
          break;
     case OL_ADJUSTKEY:
          printf ("pressed the adjustKey\n");
        ...
          break;
         ...
     case OL_DOCEND:
          printf ("pressed the docEndKey\n");
         ...
          break;
     case OL_LINEEND:
          printf ("pressed the lineEndKey\n");
         ...
          break;
         ...
}

OlWidgetSearchIEDB

Synopsis:

#include <Xol/OpenLook.h>
 . . .
void OlWidgetSearchIEDB(

Widget w,
OlVirtualEventTable db);

The OlWidgetSearchIEDB procedure is used to register a given database on a specific widget instance. The db value was returned from a call to

Once a database is registered with a given widget instance, the OlLookupInputEvent() procedure (if db_flag is OL_DEFAULT_IE or db) will include this database in the search stack if the given widget id is this widget instance.

EXAMPLE

      /∗ To create a client application database ∗/
   ...
#include <Xol/OpenLook.h>
     ...
      /∗ start with a big value to avoid ∗/
      /∗ the "virtual_name" collision    ∗/
#define OL_MY_BASE            1000
#define OL_MY_DRAWLINEBTN     OL_MY_BASE+0
#define OL_MY_DRAWARCBTN      OL_MY_BASE+1
#define OL_MY_REDISPLAYKEY    OL_MY_BASE+2
#define OL_MY_SAVEPARTKEY     OL_MY_BASE+3
 #define XtNmyDrawLineBtn      "myDrawLineBtn"
#define XtNmyDrawArcBtn       "myDrawArcBtn"
#define XtNmyRedisplayKey     "myRedisplayKey"
#define XtNmySavePartKey      "mySavePartKey"
 static OlKeyOrBtnRec     OlMyBtnInfo[] = {
     /∗name             default_value      virtual_name        ∗/
      { XtNmyDrawLineBtn,  "c<Button1>",       OL_MY_DRAWLINEBTN  },
     { XtNmyDrawArcBtn,   "s<myDrawLineBtn>", OL_MY_DRAWARCBTN   },
};
static OlKeyOrBtnRec     OlMyKeyInfo[] = {
    /∗name               default_value      virtual_name        ∗/
      { XtNmyRedisplayKey, "c<F5>",           OL_MY_REDISPLAYKEY },
     { XtNmySavePartKey,  "c<F5>",           OL_MY_SAVEPARTKEY  },
};
 static OlVirtualEventTable     OlMyDB;
    ...
OlMyDB = OlCreateInputEventDB(
               w,
               OlMyKeyInfo, XtNumber(OlMyKeyInfo),
               OlMyBtnInfo, XtNumber(OlMyBtnInfo)
     );
     ...
     /∗ assume: "w" is a stub widget that is interested in ∗/
     /∗          OlMyDB                                    ∗/
OlWidgetSearchIEDB(w, OlMyDB);
     /∗ once this step is done, this widget instance will  ∗/
     /∗ receive OlMyDB commands after a call to            ∗/
     /∗ OlLookupInputEvent(), or in the XtNconsumeEvent    ∗/
     /∗ callback’s OlVirtualEvent structure supplied with  ∗/
     /∗ the call_data field.                               ∗/
     ...

OlWidgetSearchTextDB

Synopsis:

#include <Xol/OpenLook.h>
 . . .
voidOlWidgetSearchTextDB(

OlVirtualEventTable w);

The OlWidgetSearchTextDB procedure is used to register the OPEN LOOK TEXT database on a specific widget instance. 

Once the OPEN LOOK TEXT database is registered with a given widget instance, the OlLookupInputEvent() procedure (if db_flag is OL_DEFAULT_IE or OL_TEXT_IE) will include this database in the search stack if the given widget id is this widget instance. 

EXAMPLE

 ...
#include <Xol/OpenLook.h>
 ...
      /∗ assume: "w" is a stub widget that is interested in ∗/
     /∗          the OPEN LOOK TEXT database               ∗/
OlWidgetSearchTextDB(w);
     /∗ once this step is done, this widget instance will  ∗/
     /∗ receive OPEN LOOK TEXT commands after a call       ∗/
     /∗ to OlLookupInputEvent(), or in the XtNconsumeEvent ∗/
     /∗ callback’s OlVirtualEvent structure supplied with  ∗/
     /∗ the call_data field.                               ∗/
  ...

 

Version 3.0  —  Last change: 19 July 91

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026