Manages MFD button pages. More...
#include <MFDButtonPage.hpp>
Classes | |
struct | Page |
Represents button page. |
Public Member Functions | |
MFDButtonPage () | |
Ctor. | |
virtual | ~MFDButtonPage () |
Dtor. | |
void | SwitchPage (MFDClass *mfdInstance) const |
Switches between button pages. | |
void | SelectPage (MFDClass *mfdInstance, int pageIndex) const |
Selects a specific buttons page. | |
bool | ConsumeButton (MFDClass *mfdInstance, int button, int event) const |
Reacts on mouse clicks on buttons. | |
bool | ConsumeKeyBuffered (MFDClass *mfdInstance, DWORD key) const |
Reacts on keyboard presses. | |
bool | ConsumeKeyImmediate (MFDClass *mfdInstance, char *kstate) const |
Reacts on continuous keyboard presses. | |
int | ButtonMenu (const MFDBUTTONMENU **menu) const |
Returns button menu of the current page. | |
char * | ButtonLabel (int button) const |
Returns button labels of the current page. |
Protected Types | |
typedef void(MFDClass::* | MFDFunctionPtr )(void) |
Function pointers of the MFDClass. |
Protected Member Functions | |
virtual bool | SearchForKeysInOtherPages () const =0 |
Should other pages be searched for when pressing a key? | |
void | RegisterFunction (const std::string &label, DWORD key, MFDFunctionPtr funLClick, MFDFunctionPtr funRClick=NULL) |
Registeres handler in MFD scope for buttons. | |
void | RegisterFunctionCont (const std::string &label, DWORD key, MFDFunctionPtr funLClick, MFDFunctionPtr funRClick=NULL) |
Registeres handler in MFD scope for buttons that should have a continous reaction. | |
void | RegisterPage (const MFDBUTTONMENU *menu, int size) |
Registeres button page, and buttons menu. |
Manages MFD button pages.
Allows to register many switchable MFD button pages of the MFDClass and associates handlers for the buttons. The handlers must reside in the MFDClass, and they must not have any arguments.
<MFDClass> | Your MFD class that should contain handlers |
char * EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::ButtonLabel | ( | int | button | ) | const |
Returns button labels of the current page.
Call from MFD::ButtonLabel(). Example:
button | - button number |
int EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::ButtonMenu | ( | const MFDBUTTONMENU ** | menu | ) | const |
Returns button menu of the current page.
Call from MFD::ButtonMenu(). Example:
menu | - this will be initialised by internal structure |
bool EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::ConsumeButton | ( | MFDClass * | mfdInstance, |
int | button, | ||
int | event | ||
) | const |
Reacts on mouse clicks on buttons.
Call from MFD::ConsumeButton(). Example:
mfdInstance | - Instance of your MFD class (this) |
button | - button number |
event | - Windows event |
bool EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::ConsumeKeyBuffered | ( | MFDClass * | mfdInstance, |
DWORD | key | ||
) | const |
Reacts on keyboard presses.
Searches for the provided key in a map for the selected page and fires associated function. If SearchForKeysInOtherPages() returns true, then other pages are searched for as well. Call from MFD::ConsumeKeyBuffered(). Example:
mfdInstance | - Instance of your MFD class (this) |
key | - key designation, like OAPI_KEY_T |
bool EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::ConsumeKeyImmediate | ( | MFDClass * | mfdInstance, |
char * | kstate | ||
) | const |
Reacts on continuous keyboard presses.
Searches for the provided key in a map for the selected page and fires associated function. If SearchForKeysInOtherPages() returns true, then other pages are searched for as well. The function's execution is continuous. Call from MFD::ConsumeKeyImmediate(). Example:
mfdInstance | - Instance of your MFD class (this) |
kstate | - key state from Orbiter |
|
protected |
Registeres handler in MFD scope for buttons.
Before this method has any effect, a button page needs to be registered first with RegisterPage(). The keys may be repeated in different pages.
label | - max 3 char long label of button. Example: "TGT" |
key | - associated key on keyboard, one of OAPI_KEY_*. Example: OAPI_KEY_T |
funLClick | - on left click MFD function pointer (handler). Example: & MyMFD::OpenDialogTarget. The handler can"t take any arguments. |
funRClick | - on right click MFD function pointer (handler). Optional |
|
protected |
Registeres handler in MFD scope for buttons that should have a continous reaction.
Same as RegisterFunction(), but allows for continuous reaction on the keys, like for example, when you want to continuously modify a variable.
label | - max 3 char long label of button. Example: "TGT" |
key | - associated key on keyboard, one of OAPI_KEY_*. Example: OAPI_KEY_T |
funLClick | - on left click MFD function pointer (handler). Example: & MyMFD::OpenDialogTarget. The handler can"t take any arguments. |
funRClick | - on right click MFD function pointer (handler). Optional |
|
protected |
Registeres button page, and buttons menu.
Must be called before RegisterFunction() is called. The menu must be STATICALLY declared. For example:
menu | - STATICALLY declared button menu |
size | - menu size. Use sizeof(menu) / sizeof(MFDBUTTONMENU) |
|
protectedpure virtual |
Should other pages be searched for when pressing a key?
Normally the system reacts only keys on the current page. If this method returns true, then other pages are searched for as well.
Implemented in MyMFDButtonsPage.
void EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::SelectPage | ( | MFDClass * | mfdInstance, |
int | pageIndex | ||
) | const |
Selects a specific buttons page.
Could be used instead of SwitchPage(). Example:
mfdInstance | - Instance of your MFD class |
pageIndex | - Index of page to switch to. |
void EnjoLib::MFDGoodies::MFDButtonPage< MFDClass >::SwitchPage | ( | MFDClass * | mfdInstance | ) | const |
Switches between button pages.
A button for this method needs to be registered through RegisterFunction(), which should call MFDClass' method, which then calls this method. Example:
mfdInstance | - Instance of your MFD class |