Functions providing a way to integrate the Add-On into the menu structure of Archicad.
More...
|
MenuManager | ACAPI::UI::Menu::CreateMenuManager () |
| A function to create menu manager instance, that lets you query and manipulate menu related data.
|
|
GSErrCode | ACAPI_MenuItem_GetMenuItemFlags (const API_MenuItemRef *menuItemRef, GSFlags *itemFlags, GS::UniString *menuItemText=nullptr) |
| Returns the flag values of the specified menu item mounted by API tool add-on.
|
|
GSErrCode | ACAPI_MenuItem_SetMenuItemFlags (const API_MenuItemRef *menuItemRef, GSFlags *itemFlags, GS::UniString *menuItemText=nullptr) |
| Sets the flag values of the specified menu item.
|
|
GSErrCode | ACAPI_MenuItem_GetMenuItemText (const API_MenuItemRef *menuItemRef, char *itemText, GS::UniString *itemUniText=nullptr) |
| Returns the text of the specified menu item.
|
|
GSErrCode | ACAPI_MenuItem_SetMenuItemText (const API_MenuItemRef *menuItemRef, char *itemText, GS::UniString *itemUniText=nullptr) |
| Sets the text of the specified menu item.
|
|
GSErrCode | ACAPI_MenuItem_AddMenuItemText (const API_MenuItemRef *menuItemRef, char *weText, GS::UniString *weUniText=nullptr) |
| Sets the text of a specified menu item that will appear in the Work Environment dialog.
|
|
GSErrCode | ACAPI_MenuItem_RegisterMenu (short menuStrResID, short promptStrResID, APIMenuCodeID menuPosCode, GSFlags menuFlags) |
| Registers the menu items of the add-on.
|
|
GSErrCode | ACAPI_MenuItem_InstallMenuHandler (short menuStrResID, APIMenuCommandProc *handlerProc) |
| Installs a callback procedure for handling the add-on's menu commands.
|
|
Functions providing a way to integrate the Add-On into the menu structure of Archicad.
◆ ACAPI_MenuItem_AddMenuItemText()
GSErrCode ACAPI_MenuItem_AddMenuItemText |
( |
const API_MenuItemRef * | menuItemRef, |
|
|
char * | weText, |
|
|
GS::UniString * | weUniText = nullptr ) |
Sets the text of a specified menu item that will appear in the Work Environment dialog.
- Parameters
-
menuItemRef | [in] The referenced menu item. |
weText | [in] The text (if you don't pass weUniText) that will appear as the name of the menu item in the menu customization part of the work environment dialog. |
weUniText | [in] The Unicode text that will appear as the name of the menu item in the menu customization part of the work environment dialog. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - menuItemRef or both itemText and itemUniText are nullptr
◆ ACAPI_MenuItem_GetMenuItemFlags()
GSErrCode ACAPI_MenuItem_GetMenuItemFlags |
( |
const API_MenuItemRef * | menuItemRef, |
|
|
GSFlags * | itemFlags, |
|
|
GS::UniString * | menuItemText = nullptr ) |
Returns the flag values of the specified menu item mounted by API tool add-on.
- Parameters
-
menuItemRef | [in] Identifies the menu item. |
itemFlags | [out] Menu item flags.
Flag Value | Meaning |
API_MenuItemDisabled | The menu item is currently disabled |
API_MenuItemChecked | The menu item is currently checked |
|
menuItemText | [out] Optional Unicode menu item text to get. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - any of the parameters are nullptr
- APIERR_BADINDEX - the specified menu item does not belong to the caller add-on
- Example
void EnableACMenuItem (short itemInd, bool enable)
{
GSFlags itemFlags;
itemRef.itemIndex = itemInd;
itemFlags = 0;
if (enable)
itemFlags &= ~API_MenuItemDisabled;
else
itemFlags |= API_MenuItemDisabled;
}
◆ ACAPI_MenuItem_GetMenuItemText()
GSErrCode ACAPI_MenuItem_GetMenuItemText |
( |
const API_MenuItemRef * | menuItemRef, |
|
|
char * | itemText, |
|
|
GS::UniString * | itemUniText = nullptr ) |
Returns the text of the specified menu item.
- Parameters
-
menuItemRef | [in] Identifies the menu item. |
itemText | [out] Menu item text (if you don't pass itemUniText). |
itemUniText | [out] Optional Unicode menu item text to set. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - menuItemRef or both itemText and itemUniText are nullptr
- APIERR_BADINDEX - the specified menu item does not belong to the caller add-on
- Example
void ReportChosenCommand (short menuResID, short itemInd)
{
char itemStr [256], message [256];
itemRef.itemIndex = itemInd;
sprintf (message, "You have chosen the %s command", itemStr);
}
}
◆ ACAPI_MenuItem_InstallMenuHandler()
GSErrCode ACAPI_MenuItem_InstallMenuHandler |
( |
short | menuStrResID, |
|
|
APIMenuCommandProc * | handlerProc ) |
Installs a callback procedure for handling the add-on's menu commands.
- Parameters
-
menuStrResID | [in] An identifier of the menu to install the callback procedure for. This should be the same what you used in the ACAPI_MenuItem_RegisterMenu as a menu string resource number in the RegisterInterface function. |
handlerProc | [in] The callback function to handle the menu commands. |
- Returns
- NoError - The function has completed with success.
- Example
{
GSErrCode err = NoError;
return err;
}
◆ ACAPI_MenuItem_RegisterMenu()
GSErrCode ACAPI_MenuItem_RegisterMenu |
( |
short | menuStrResID, |
|
|
short | promptStrResID, |
|
|
APIMenuCodeID | menuPosCode, |
|
|
GSFlags | menuFlags ) |
Registers the menu items of the add-on.
- Parameters
-
menuStrResID | [in] The resource ID of the menu resource, which should be in the resource fork of the add-on. |
promptStrResID | [in] The resource ID of the propmt string resource, which should be in the resource fork of the add-on. These strings appear in the status bar. |
menuPosCode | [in] Defines the server application's menu to insert the command into. |
menuFlags | [in] Flags describing whether you would like to see any separator item in the menu before or after the registered menu item. Its possible values are: MenuFlag_Default, MenuFlag_SeparatorBefore, and MenuFlag_SeparatorAfter |
- Returns
- NoError - The function has completed with success.
As you see, the add-on may define its own main menu, if it uses MenuCode_UserDef and the menu position. In this case the first item in the STR# resource will be the title of the main menu, and the other items correspond to the menu items in the non-main menu case. If this first item is the same as one of the server application's main menu titles, then the API won't open a new main menu, rather it inserts the add-on's menu into the original main menu, as defined by the rules for that menu. This also means if you use an already existing menu title (e.g. Window) which doesn't have an insertion place for add-ons, your add-on's menu won't appear. This implies that the location of the add-on within the Add-Ons folder doesn't have any impact on the menu position of your add-on's commands. The appearance of menu items can be controlled by control codes appended to the menu item string resource as described in the Required Resources section.
- Example
- In the GRC file:
'STR#' 32800 "Menu strings" {
/* [ 1] */ "Show Selections^ES^E3^ED^32800"
}
'STR#' 32620 "Status bar prompt strings" {
/* [ 1] */ "Show Selections palette"
}
/* Toolbar icon resource ("RFIX\Images\TB_show_selections.png") */
'GICN' 32600 "TB_show_selections" {
"TB_show_selections"
}
In the RegisterInterface function:
◆ ACAPI_MenuItem_SetMenuItemFlags()
GSErrCode ACAPI_MenuItem_SetMenuItemFlags |
( |
const API_MenuItemRef * | menuItemRef, |
|
|
GSFlags * | itemFlags, |
|
|
GS::UniString * | menuItemText = nullptr ) |
Sets the flag values of the specified menu item.
- Parameters
-
menuItemRef | [in] Identifies the menu item. |
itemFlags | [in] Menu item flags.
Flag Value | Meaning |
API_MenuItemDisabled | Disable the menu item |
API_MenuItemChecked | Check the menu item |
|
menuItemText | [in] Optional Unicode menu item text to set. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - any of the parameters are nullptr
- APIERR_BADINDEX - the specified menu item does not belong to the caller add-on
- Example
void CheckACMenuItem (short itemInd, bool checked)
{
GSFlags itemFlags;
itemRef.itemIndex = itemInd;
itemFlags = 0;
if (checked)
itemFlags |= API_MenuItemChecked;
else
itemFlags &= ~API_MenuItemChecked;
}
◆ ACAPI_MenuItem_SetMenuItemText()
GSErrCode ACAPI_MenuItem_SetMenuItemText |
( |
const API_MenuItemRef * | menuItemRef, |
|
|
char * | itemText, |
|
|
GS::UniString * | itemUniText = nullptr ) |
Sets the text of the specified menu item.
- Parameters
-
menuItemRef | [in] Identifies the menu item. |
itemText | [in] Menu item text to set (if you don't pass itemUniText). |
itemUniText | [in] Optional Unicode menu item text to set. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - menuItemRef or both itemText and itemUniText are nullptr
- APIERR_BADINDEX - the specified menu item does not belong to the caller add-on
- Example
void SetPaletteMenuText (short paletteItemInd, bool paletteIsVisible)
{
GS::UniString itemStr;
if (paletteIsVisible)
itemStr.Append ("Hide Palette");
else
itemStr.Append ("Show Palette");
itemRef.itemIndex = paletteItemInd;
}
◆ CreateMenuManager()
A function to create menu manager instance, that lets you query and manipulate menu related data.
- Returns
- The menu manager instance.