Ide/Resource Editor

The term resource is applied to the things like dialogs, forms, icons, cursors, pens, brushes, etc. Resources can be created by one of the IDE resource editors, or just added to a project. The correspondent resource files are referenced from a project file.

During project building IDE generates binary ProjectName.res file which is provided to a linker. IDE also generates resourceIdentifiers.i file which specifies numeric constants for resource identifiers. Resource identifierd can be refered from sources codes to provide the proper resource handling. The names and values for resource identifiers can be set or changed with the help of IDE resource editors.

GUI and VPI Style Resources
Historically windowing programs - that is, programs with the graphical user interface - were developed in Visual Prolog using the VPI (Visual Programming Interface) package supplied as one of packages in Prolog Foundation Classes (PFC).

The Visual Programming Interface (VPI) is a high-level Application Programming Interface (API) and it is designed to make it easy for Prolog applications to provide sophisticated user interfaces utilizing the graphical capabilities of today's operating systems and display hardware. The resources and tools needed by such applications - windows, menus, dialogs, controls, pens, brushes, cursors, carets, pictures, etc. all appear as simple Prolog structures.

However, the VPI layer (PFC\vpi) provides an old style of handling the graphical user interface. This was the reason why the PDC has developed the modern GUI package (pfc\gui), which provides really object-oriented implementation of API handling of the main windowing system features. The GUI package presents the object-oriented windows, dialogs, forms, controls, etc., handling. This package is built on top of the VPI package and delivers a new level of abstraction and ease of use while retaining compatibility with VPI programs since both the GUI and VPI programming styles can be applied in the same program.

Currently for new GUI applications the IDE generates the default program code which use the GUI package features (but it still possible to edit old VPI style dialogs, etc.).

Notice that in VPI style programs, except for VPI style dialogs and VPI style windows you can also create GUI style forms, which, of course, are handled by GUI package predicates. From the other side, since each GUI program includes the VPI package, so some VPI features can be embedded into GUI style programs.

To understand difference of GUI and VPI style programs and difference of GUI and VPI style dialogs, windows, forms, controls, etc., we recommend to read carefully VPI and GUI programming tutorials on WEB.

IDE Designer
Editing of dialogs, windows, form, and IDE Controls on the IDE Designer are very closely related. The only real difference is that definitions of the VPI package dialogs are (normally) put into resource files, whereas GUI package dialogs, windows, and forms are always created dynamically by code.

Creating and Editing a Window
The IDE does not support the creation or editing of the old-style VPI windows. You should use instead of windows (see description of forms in the GUI package overview in the PFC part of Help for more details).

However, the IDE automatically creates for GUI applications the special resource file TaskWindow.win which is placed if the TaskWindow sub-directory of the project root directory. This resource file can be later changed by the IDE resource editor.

Toolbar Editor
The Toolbar editor allows you interactively create various kinds of toolbars.

Menu Editor
The Menu Editor can be used to create both pull-down menus (for windows), and pop-up menus (useful for object oriented user interfaces).

Editing a Menu
To edit a menu, double-click (or press Enter) the name of a file with a menu description in the project tree in the Project window. For example TaskMenu.mnu. The Menu Editor dialog appears and you can create (or modify) whatever kind of a menu you wish.



The Menu Editor dialog allows you to modify or delete existing menu items or add new ones. The main pane in this dialog contains the tree of menu items of the edited (it is TaskMenu in the picture) menu.

By pressing the New toolbar buttons it is possible to create new menu items and sub-items. You can use: - the New First Item,  - the next New Item, and  - the menu New SubItem.

Menu items can optionally be grouped by inserting separators. To insert a separator just click the New Separator toolbar button.

Cut, Copy and Paste operations for selected menu items (with all their submenu items) can be executed with Ctrl+X, Ctrl+C, and Ctrl+V keyboard accelerators.

The Menu Editor can create nested menus of any level. To enter/create a submenu for the selected menu item click the Submenu button.

By pressing the Test toolbar button you activate the test mode in which the edited menu will be displayed instead of the main IDE menu. You can open it submenus, etc. To exit the test mode, you can click somewhere in the IDE window out of the tested menu.

Customizing Menu Item Attributes
In the bottom of the menu editor dialog you see the big pane (the Menu Tree pane) in which you can see the edited menu tree. Menu items prefixed with the plus icon have submenus. Click the plus icon or press the right arrow on the keypad to expand one level of such submenu. Notice that the plus icon before expanded menu items is changed for the minus  icon.

When you select any menu item in the menu tree, the menu editor controls display attributes of this menu item. For each menu item the programmer can specify the following attributes:


 * Item Title
 * Select a menu item in the Menu Tree pane and click the menu item title. The menu item title becomes surrounded by the frame like:
 * [[Image:Ide_MenuEdit_Title.png]]
 * Here you can specify/edit the menu item title (name).
 * The menu item title may contain up to 255 characters. It may include the \t (tab) escape sequence.
 * In the menu item title the ampersand symbol & can be used for indicating that the following character is to be underlined. For example, if you type in the string &Contents, then at runtime this menu item will be displayed as C ontents. I.e. the character C will be displayed underlined (thus visually indicating that the C is an accelerator key). The underlined character should be unique on each level of a menu. If you need to display the & character, use two &&.

If you enter a symbolic constant name, then the IDE automatically places this symbolic constant into the resourceidentifiers.i file and generates an appropriate integer value for it. The Menu Editor automatically generates the default symbolic constant name (for example, id_file_exit) from the Constant Prefix id_file and names of menu items (Exit on the picture).
 * Item Constant
 * The Item Constant input box is where you can select or type in the symbolic (or integer) constant that will be used as the menu item identifier. It can be typed-in directly from the keyboard or selected from the list of available constants (by clicking the [[Image:Ide_ListButton_Button.png]] button). It must be either a legal symbolic constant (for example, id_help_contents) or an integer value.


 * Constant Prefix
 * The Constant Prefix edit control is where you can input a common prefix for all item constants of menu items on the current level of submenu.


 * Checked
 * Set the initial state of the menu item to Checked.


 * Disabled
 * Specifies that initially the menu item will be Disabled.


 * Accelerator
 * In the Accelerator group box you can set an accelerator key (hot key), which will be used to activate this menu item. The accelerator key can be defined as a combination of a basic accelerator key and of the Shift, Ctrl, and Alt keys. The basic accelerator key can be typed in or chosen from the list in the list edit control. To specify the desired Shift, Ctrl, and Alt keys check on the corresponding check box. To assign more than one accelerator key to a menu item, use the vpi::setAccelerators/1 predicate.

Notice that this possibility can be used only for MDI applications. (It is ignored for non-MDI applications since they do not have the Windows (system handling) menu item.
 * Help Constant
 * In this list button control you can select one of constants of the existing first-level menu items. The Windows (system handling) menu item (in MDI mode) will be placed just before the first-level menu item with this constant.

Editing the Window Submenu
In MDI applications Windows automatically add the Windows first-level menu item, which, by default, is placed after (the most right) all other user-created first-level menu items in each application menu. By default, it contains the Tile, Cascade, and Arrange Icons menu commands and in the bottom of this menu are listed titles of all opened MDI document windows.

To customize items of the Windows submenu, the programmer should create a new menu with the Item Constant equal to mdiwindow_menu. This menu should include only one level of menu items. Notice that since this user-designed submenu will be used instead of the default system Windows submenu, so handling of ALL its menu commands should be explicitly programmed. For instance, handling of the Tile, Cascade, and Arrange Icons menu commands should be programmed if they are included into the designed menu.

See the video: Using your own Window menu

About the Graphics Editor
The Graphics Editor is a convenient tool for creating, viewing and editing icons, cursors and small bitmaps. The images can be passed to the Windows Clipboard or saved in files.

The Graphics Editor allows you to create and edit images ranging in size from 4x4 pixels to 64x64 pixels, by using either a 16-color palette or monochrome shadow palette.

The Graphics Editor is invoked from the Project window for Icons, Cursors and Bitmaps. However, when you register large bitmaps in your project, Visual Prolog will call to edit the bitmap an external editor associated in Windows for editing files with .BMP extension.

After the Graphics Editor is started, the Graphics Editor window will appear on the screen.



When you create a new image in a project, you need to specify the Name of the image, the Constant (resource ID) which will be identify the image in the project, the name of the File, in which the image will be saved, its size, and how many colors it will have.

Graphics Editor Menus
When the Graphics Editor window is active, the Integrated Development Environment's menu bar displays the Graphics Editor sub-menus of the Resource menu and looks as follows:



Note that there are 2 menu items: Set Mirror Style, Set Cursor Hotspot and 2 sub-menus: Tools and Move. Also some menu items under the Edit menu (like the Undo, Redo, Cut, Copy, Paste) are specially tailored for the Graphics Editor, and the File menu operations refer now to the image files.

Editing Image Attributes
You can always wake up (with the Resource | Attribute task menu item or with the Attribute item from pop up menu) the Bitmap/Cursor/Icon Attributes dialog for the created bitmap, cursor or icon to view and change some image attributes.

Notice that the appeared Bitmap Attributes dialog for an existing bitmap will display less bitmap attributes then it has for created bitmaps:



You see that for existing bitmap the dialog does not contain the Width, Height, and Color attributes.

The only image attribute that you can edit is the Constant.:

Constant
 * In the Constant list edit the programmer can change the default resource constant for the image (at the picture it is idb_mybitmap).