Graphics

Types of Windows

SynthEdit supports three types of windows.

1 - Standard Microsoft Window (Native) [DEPRECATED]

 windowtypes1


These are the plain regular windows as used in most applications. They are always rectangular and always obscure any window 'behind' them.

Advantages

  • Fast to draw (CPU efficient).
  • Support for entire Microsoft Windows Graphics API, and for OS functions that require a real window-handle (HWND) e.g. timers.

Disadvantages

  • No transparency.
2 - SynthEdit Composited Windows [DEPRECATED]

windowtypes2

Created to support non-rectangular shapes, these are still actually rectangular but support transparent pixels. Here the red circle is partially transparent.

Advantages:

  • transparency.
  • non-rectangular shapes.
  • anti-aliased edges.

Disadvantages

  • Slower to draw (more CPU).
  • Support only basic windows messages. e.g. no scrollwheel support.

Specify which type by deriving your module class from the appropriate base class. In your graphics class header file, and also in your XML file...

3. Cross-Platform windows

These are also composited windows (supporting transparency), but also work on Mac. The API is close to Microsoft's Direct2D and is automatically translated to the Mac API for you when you build a Mac version of your module. This new addition to the SDK adds support for accessing SynthEdit skin files, can hook into the right-click menu, display cross-platform file open/save dialogs and popup menus.

The SDK download contains several examples in the folder "SubControlsXp".

 For a native window...

MyPluginGui.h

class MyGui : public SeGuiWindowsGfxBase
{

MyPlugin.xml

<Plugin id="SynthEdit Scope3" graphicsApi="HWND">

For a composited window...

class MyGui : public SeGuiCompositedGfxBase
{
<Plugin id="SynthEdit Scope3" graphicsApi="Composited">

Customizing the popup context menu

You can customize SynthEdit's right-click context menu.

popupmenu

In your .h file...

virtual int32_t MP_STDCALL onCreateContextMenu();
virtual int32_t MP_STDCALL onContextMenu( int32_t selection );

In your .cpp file...

// Add custom items to right-click menu.
int32_t MyGui::onCreateContextMenu()
{
getHost()->addContextMenuItem( L"Cat", 0, 0 );
getHost()->addContextMenuItem( L"Dog", 1, 0 );
return gmpi::MP_OK;
}


// act on user selecting right-click item.
int32_t MyGui::onContextMenu( int32_t selection )
{
switch( selection )
{
case 0:
// 'Cat' selected
break;

case 1:
// 'Dog' selected
break;
}
return gmpi::MP_OK;
}

Right-click handler

To override SynthEdit's right-click handler. NOTE: If possible please avoid doing this as it disables SynthEdit's pop up menu system.

In your .h file...

// This handles the Windows message loop.
// Add here to override right-click behavior.
virtual LRESULT MsgProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam );
int32_t onRButtonDown( UINT flags, POINT point );
int32_t onRButtonUp( UINT flags, POINT point );

In your .cpp file...

// Test overriding right-click handling.
// WARNING: This will disable SynthEdit's right-click menu. If possible please avoid taking
// right-click for your own use.
LRESULT MyGui::MsgProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
 switch (message)
 {
 case (WM_RBUTTONDOWN):
 {
 POINT p;
 p.x = MAKEPOINTS(lParam).x;
 p.y = MAKEPOINTS(lParam).y;
onRButtonDown( (UINT) wParam, p ); } return 1; break; case (WM_RBUTTONUP): { POINT p; p.x = MAKEPOINTS(lParam).x; p.y = MAKEPOINTS(lParam).y; onRButtonUp( (UINT) wParam, p ); } return 1; break; default: return SeGuiWindowsGfxBase::MsgProc( hwnd, message, wParam, lParam ); break; } }
int32_t MyGui::onRButtonDown( UINT flags, POINT point ) { return gmpi::MP_OK; }
int32_t MyGui::onRButtonUp( UINT flags, POINT point ) { return gmpi::MP_OK; }