tsc_MenuButton (deprecated)

This class is no longer in use


A button which may be added to the list of controls on a tsc_AppMainWindow.  Such a button is not of use on a tsc_Form.

These buttons are optimised for use on a main window to provide standard behaviour expected of Survey Core applications' main menus.  They are always bitmap buttons, and will display four images to reflect the normal, selected, pressed, and disabled states.  You supply a single image with a transparent background and default backgrounds will be painted suiting the current button state.

A tsc_MenuButton is sized according to the supplied image, the recommend sizes for a main menu icon are given below. Allow room for borders to be drawn over the image.  Transparent parts should have an alpha channel value of 0. The images should be added to the plugin DLL as resources.  It's important to note that only .png images are supported and the image is saved with a bit depth of 8-bits.

The image sizes required for the General Survey Main Menu buttons are:

 

Menu buttons are identified in events by their x_Codes, and the same code also determines the displayed text.

Constructors

Construction must be by allocating the object on the heap.  Destruction occurs automatically when the containing window is destroyed, if the button is a member of the window's list of controls.

There are two constructors that allow an image to be provided.  A single transparent image must be supplied for the button to display the button in its various states. This image must be in PNG format.  The image is specified by its resource Id.

The x_Code is the button's identity used in other calls and event handlers - therefore, never use the same x_Code more than once in a window.  The x_Code is also used for the display text unless the optional text field is used to override the translation for the x_Code as the button's text.

A hotkey (alphabetic or numeric key) that simulates the button press is defined either by including an ampersand (&) in the display text or by specifying the number or letter in the hotkey parameter.  The default is zero which means use the "&" value from the text, or none.  The user can 'click' the button by typing its letter or number while the main window is displayed.  Using an '&' in the text is preferable because the hotkey character within the button text is underlined.

This overload places the button in the next available cell working from left to right and may flow into the next row.  No account is taken of the button size; the button will be centered in the cell following the previous button whether they overlap or not.  Also, no account is taken of other specifically-placed buttons (see the constructor that takes a row and column).

tsc_MenuButton (x_Code      identifier,

                int         imageResourceId,

                const char* text = NULL,

                char        hotkey = '\0');

This constructor is similar to the preceding but allows a control to be placed in a specific cell.  The center of the button is located at the centre of the cell at the specified column and row.  Column and row numbers start at zero and should be less than the column or row count respectively.

tsc_MenuButton (x_Code      identifier,

                tsc_ColRow  position,

                int         imageResourceId,

                const char* text = NULL,

                char        hotkey = '\0');

For example:  Controls.Add (tsc_ColRow(3,2), X_Measure);

Constructors for standard buttons

To avoid having to supply many bitmaps for standard buttons that SC already implements, the following constructors are provided:

This constructs a menu button with a standard set of bitmaps.  The identity parameter controls which SC bitmaps are used and must be one of the following known x-codes:

X_MenuJobs, X_MenuKeyin, X_MenuCogo, X_MenuMeasure, X_MenuStakeoutMain, X_MenuInstrument

tsc_MenuButton (x_Code      identifier,

                const char* text = NULL,

                char        hotkey = '\0');

This constructor also makes a standard button, but allows its position to be specified (see above).

tsc_MenuButton (x_Code      identifier,

                tsc_ColRow  position,

                const char* text = NULL,

                char        hotkey = '\0');

Example:

class MyMainWindow : public tsc_AppMainWindow { public:     MyMainWindow()     {     }      virtual ~MyMainWindow()     {     }      virtual void OnCreate ()     {         SetSizing (Size_Normal);         SetGridDimensions (3, 2);         SetMarginsPercent (20, 5, 20, 5);          Controls.Add (new tsc_MenuButton (X_MenuJob, IDB_MainIconNormal));     } }; 

 

Inherited from tsc_Control

void Enable();

void Disable();

bool Enabled();