Laxkit  0.0.7.1
Public Member Functions | Public Attributes | Protected Attributes
Laxkit::ShortcutHandler Class Reference

A kind of event filter windows can use to help process keyboard shortcuts. More...

Inheritance diagram for Laxkit::ShortcutHandler:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 ShortcutHandler (const char *areaname=NULL, ShortcutDefs *cuts=NULL, WindowActions *wactions=NULL)
virtual ShortcutHandlerduplicate ()
 Return a new ShortcutHandler object. The action and shortcut lists are refcounted, not duplicated.
virtual int NumActions ()
virtual WindowActionAction (int i)
 Return the WindowAction object at index i.
virtual WindowActionsActions ()
virtual WindowActionFindAction (unsigned int key, unsigned int state, int mode)
 Return the WindowAction object corresponding to a matching key, state, and mode if mode>=0.
virtual int FindActionNumber (unsigned int key, unsigned int state, int mode)
 Return action number listed in shortcuts stack. Does not read from actions stack.
virtual int FindActionNumber (const char *actionname, int len=-1)
 From the actions stack, return the action number corresponding to actionname.
virtual int NumShortcuts ()
virtual ShortcutDefShortcut (int i)
 Return the ShortcutDef object at index i.
virtual ShortcutDefsShortcuts ()
virtual int FindShortcutIndex (unsigned int key, unsigned int state, int mode)
 Return the index of a shortcut (in shortcuts stack) matching key, state, and mode if mode>=0.
virtual int FindShortcutFromAction (int action, int startingfrom)
virtual int InstallShortcuts (ShortcutDefs *cuts)
virtual int AddMode (int mode, const char *modestr, const char *name, const char *desc)
virtual int AddShortcut (unsigned int key, unsigned int state, unsigned int mode, unsigned int action)
 Add a shortcut. Assumes action is in actions, does not check. Return index of shortcut.
virtual unsigned int AddAction (unsigned int action, const char *nname, const char *desc, const char *icon, unsigned int mode, int assign)
 Add a window action.
virtual unsigned int Add (unsigned int action, unsigned int key, unsigned int state, unsigned int mode, const char *nname, const char *desc, const char *icon, int assign)
 Add an action with a default shortcut.
virtual int RemoveAction (int action)
 Remove action from actions stack, and remove any shortcuts bound to that action number.
virtual int ClearShortcut (unsigned int key, unsigned int state, int mode)
virtual int ClearShortcut (int i)
virtual int UpdateKey (unsigned int key, unsigned int state, unsigned int mode, unsigned int newaction)
 Update which action is triggered by the specified key.
virtual int ReassignKey (unsigned int newkey, unsigned int newstate, unsigned int oldkey, unsigned int oldstate, unsigned int mode, unsigned int action)
- Public Member Functions inherited from Laxkit::anObject
 anObject ()
 Set object_id=getUniqueNumber().
virtual ~anObject ()
 Empty virtual destructor.
virtual const charwhattype ()
 Returns the type of anObject.
virtual anObjectduplicate (anObject *ref=NULL)
virtual int inc_count ()
 Increment the data's count by 1. Returns count.
virtual int dec_count ()
 Decrement the count of the data, deleting if count is less than or equal to 0.
virtual int the_count ()

Public Attributes

chararea
- Public Attributes inherited from Laxkit::anObject
int suppress_debug
DeleteRefCountedFunc deleteMe
 Called when the count is decremented to 0.
unsigned long object_id
charobject_idstr

Protected Attributes

ShortcutDefsshortcuts
WindowActionsactions
int index
int keyindex
int deviceid
- Protected Attributes inherited from Laxkit::anObject
int _count
 The reference count of the object.

Detailed Description

A kind of event filter windows can use to help process keyboard shortcuts.

Windows and interfaces would have one ShortcutHandler object, that points to action and shortcut stacks elsewhere. ShortcutHandler objects can keep info related to tracking shortcut chain input.

This class stores lists of actions and shortcut definitions, and can return an action based on sequences of key presses.

Todo:
maybe have name/file tags, to help loading and saving sets of shortcuts? for loading and saving, the actions stay the same, but key sets change. How to clarify what saves? At some point, would need access to mode names too. either that or have on ShortcutHandler per window mode? then shortcut manager keys could be "name-mode"

Member Function Documentation

int Laxkit::ShortcutHandler::AddShortcut ( unsigned int  key,
unsigned int  state,
unsigned int  mode,
unsigned int  action 
)
virtual

Add a shortcut. Assumes action is in actions, does not check. Return index of shortcut.

If shortcut key+state+mode existed already, then assign the action to that one.

References Laxkit::PtrStack< T >::e, FindShortcutIndex(), Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::push().

Referenced by Add(), Laxkit::ShortcutManager::dump_in_atts(), ReassignKey(), and UpdateKey().

int Laxkit::ShortcutHandler::ClearShortcut ( int  index)
virtual

Return 0 for success, nonzero for error.

References Laxkit::PtrStack< T >::n, and Laxkit::PtrStack< T >::remove().

int Laxkit::ShortcutHandler::FindActionNumber ( unsigned int  key,
unsigned int  state,
int  mode 
)
virtual

Return action number listed in shortcuts stack. Does not read from actions stack.

If mode>0, then the key must have that mode. Return -1 for not found, else the action number.

References Laxkit::PtrStack< T >::e, and FindShortcutIndex().

Referenced by LaxInterfaces::ViewerWindow::CharInput(), LaxInterfaces::ViewportWindow::CharInput(), LaxInterfaces::PatchInterface::CharInput(), and Laxkit::ShortcutManager::dump_in_atts().

int Laxkit::ShortcutHandler::FindActionNumber ( const char actionname,
int  len = -1 
)
virtual

From the actions stack, return the action number corresponding to actionname.

-1 is returned if not found.

If len<0 then use strlen(actionname). Otherwise, use len number of characters of actionname.

References Laxkit::PtrStack< T >::e, and Laxkit::PtrStack< T >::n.

int Laxkit::ShortcutHandler::ReassignKey ( unsigned int  newkey,
unsigned int  newstate,
unsigned int  oldkey,
unsigned int  oldstate,
unsigned int  mode,
unsigned int  action 
)
virtual

When you overwrite a key in a ShortcutWindow, you need to syncronize which keys are mapped to which actions. This will try to preserve the order of the shortcuts.

Return -1 for old equals new, so nothing done.

References AddShortcut(), Laxkit::PtrStack< T >::e, FindShortcutIndex(), and Laxkit::PtrStack< T >::remove().

int Laxkit::ShortcutHandler::UpdateKey ( unsigned int  key,
unsigned int  state,
unsigned int  mode,
unsigned int  newaction 
)
virtual

Update which action is triggered by the specified key.

If key didn't exist, then install new shortcut.

Return 0 for sucess, or nonzero for error.

References AddShortcut(), Laxkit::PtrStack< T >::e, and FindShortcutIndex().

Referenced by Laxkit::ShortcutManager::UpdateKey().


The documentation for this class was generated from the following files:

Mon Feb 17 2014 11:53:00, Laxkit