Search
Creating Custom Shape Libraries

( a feature of FlowChartX Pro edition)

The professional edition of FlowChartX provides you with the ultimate customization of shapes of diagram elements. You can create dynamic load libraries that define new types of box shapes. Every single library may contain one or more shape definitions. Shape libraries are loaded as plug-ins into the FlowChartX engine, to provide painting and user-interaction code. These libraries should conform to a certain interface, specified by the FlowChartX plug-in manager.

Every shape library must implement and export the following functions:

1) A function that returns a unique class identifier of the library. This identifier is used to associate diagram objects with the library that defines their shape. Use the guidgen.exe tool that comes with Visual Studio to generate the class id for your library.

C++  Copy Code

extern "C" FCPLUGIN_API void GetLibCLSID(CLSID* clsid);

2) A function that returns a user-friendly name for the shape library. This name should give descriptive information about the shapes that are available in the library. For example the name might be "Collection of network design symbols".

C++  Copy Code

extern "C" FCPLUGIN_API void GetLibName(WCHAR* libName);

3) A function that returns the number of shapes contained in the library:

C++  Copy Code

extern "C" FCPLUGIN_API LONG GetShapeCount();

4) This function returns a Windows GDI region object that defines the outline of the shape. This region actually defines a clipping region, in which the text and picture of a box are rendered. The first argument of the function specifies the position of the diagram element, and the second - the zero-based index of the shape.

C++  Copy Code

extern "C" FCPLUGIN_API HRGN CreateRegion(const RECT& rc, LONG shape);

5) This function should draw a shape at the specified position. It is used to draw both shapes and their shadows, depending on the value of the last parameter.

C++  Copy Code

extern "C" FCPLUGIN_API void Draw(HDC dc, const RECT& rc, LONG shape, bool shadow);

6) This function should print a shape at the specified position. It is used to print both shapes and their shadows, depending on the value of the last parameter.

C++  Copy Code

extern "C" FCPLUGIN_API void Print(PRINTINFO* ppi, const RECT& rc, LONG shape, bool shadow);

7) This method determines if a shape contains the point that is specified as parameter.

C++  Copy Code

extern "C" FCPLUGIN_API BOOL ContainsPoint(const RECT& rc, const POINT& pt, LONG shape);

8) This method finds the intersection of a line segment and the outline of a shape. It is used for finding the connection point of an arrow and a diagram element from the library.

C++  Copy Code

extern "C" FCPLUGIN_API POINT GetIntersection(const RECT& rc, const POINT& ptOrg, const POINT& ptDest, LONG shape);

Shape libraries can be created in any language as long as it has a compiler that can produce standard Windows DLLs.

You can find a template library project in the "FCPluginAPI" directory in the FlowChartX installation folder.