VCL.EditorViewAPI Sample

From RAD Studio XE3 Code Examples
Jump to: navigation, search

Language:

This sample shows how to extend the Delphi IDE editor including graphics control, tab insertion, and options settings.

Location

You can find the EditorViewAPI sample project at:

Contents

Description

The package adds the following:

  • A new IDE menu item, View > Bouncy Ball, which will create a new editor tab with a bouncing ball, and an associated View > Close Bouncy Ball item.
  • A new lower tab called OS File Information holding file data related to the units represented by currently shown edit tabs.

How to Use the Sample

  1. Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open TestEditorViewAPI.dproj.
  2. Build TestEditorViewAPI.bpl.
  3. Install TestEditorViewAPI.bpl.
  4. Select View > Bouncy Ball to run the Bouncy Ball wizard.
  5. Select the OS File Information tab next to the History tab to see additional information about the current file.

Files

File Contains

BouncyBallDataMod

The bouncy ball data module class.

BouncyBallOptions

The frame for the bouncy ball options.

EditorTabFrame

The form with the bouncy ball.

FileInfoFrame

The frame for the OS file information display.

TestEditorViewAPIUnit

The wizard classes for the bouncy ball component and the OS File Information tab.

Classes

  • TBouncyBallDataModule contains an image list component to store the icon for the new Bouncy Ball option in the View menu.
  • TBouncyBallOptionsFrame represents the bouncy ball options dialog box. It allows the user to choose the color of the ball and how quickly the ball should move vertically or horizontally.
  • TEditorTab represents the frame where the ball will be bouncing.
  • TEditorTabHandler adds the tab with the bouncy ball next to the other tabs in the editor.
  • TBouncyBallOptions is the class that stores the properties of the bouncy ball such as color, vertical and horizontal step.
  • TFileInfoFrame represents the frame with the OS file information. This frame is shown when the user chooses the OS File Information tab from the bottom of the editor.
  • TFileInfoEditorSubView adds a lower tab in the editor. This class adds the OS File Information next to the History tab at the bottom of the editor.
  • TBouncyBallAddinOptions adds the bouncy ball options to the Tools > Options dialog under the Third party node.

Implementation

Bouncy Ball

Bouncy Ball Options

  • TBouncyBallOptionsFrame is the frame displayed when the user chooses Tools > Options > Third Party > Bouncy Ball. It contains a combo box for color selection, a spin edit to set the horizontal and vertical step and two check boxes.
  • TBouncyBallAddinOptions is the wizard that adds the bouncy ball options to the Tools > Options dialog. It contains a TBallOptionsFrame private member that represents the frame displayed in the Options dialog. However, this member is only used to retrieve the user input. To make sure that TBouncyBallOptionsFrame is added in the Options dialog, TBouncyBallAddinOptions.GetFrameClass must return TBouncyBallOptionsFrame.
  • TBouncyBallOptions stores the bouncy ball properties. It is instantiated to BouncyBallOpts global variable. The TBouncyBallOptions.Create constructor retrieves the bouncy ball properties from the system registry using a TRegistryIniFile object.

Bouncy Ball tab

  • TEditorTabHandler
    • Is a wizard that handles adding a new tab with the ball bouncing, next to the other editor tabs. It returns TEditorTab from GetFrameClass method to indicate which frame will be displayed when the user chooses View > Bouncy Ball.
    • It derives from INTACustomEditorView, INTACustomEditorView150, INTACustomEditorViewStatusPanel, INTACustomEditorViewState. INTACustomEditorView is implemented to add another tab, INTACustomEditorViewStatusPanel to have access to the status bar, and INTACustomEditorViewState to save the current view state to the project desktop file.
    • It is a singleton. OnViewMenuClick and OnCloseMenuClick are both class procedures that create, respectively free the TEditorTabHandler instance.
  • TEditorTab
    • Is the frame class displayed when the user chooses View > Bouncy Ball. It contains a TShape for the ball, a timer for the animation and a popup menu.

OS File Information

  • TFileEditorSubView
    • Is the wizard class that implements INTACustomEditorSubView and is responsible for adding a new bottom tag, OS File Information.
    • It must have associated a frame class that will be shown when the tag is accessed. This is achieved by returning TFileInfoFrame in GetFrameClass method.
    • It retrieves the module services to have access to the open files and the editor services to access the source code:
Supports(BorlandIDEServices, IOTAModuleServices, FModuleServices);
Supports(BorlandIDEServices, IOTAEditorViewServices, FEditorViewServices);
  • TFileInfoFrame
    • The frame displayed when the user chooses OS File Information bottom tag. It contains: Creation Time, Modified Time and File Size.
    • It is a notifier class and implements IOTAModuleNotifier and IOTANotifier methods. Most of these methods have no implementation, but AfterSave for instance refreshes the frame so it can update the modification time and, if necessary, the file size.
    • Has a IOTAModule private member that stores the file for which the information are displayed.

Uses

See Also

Personal tools