Contents Up << >>

FL concepts

These are typical steps when adding FL functionality to your application.

The following is taken from fl_demo1 and shows the main code implementing the user interface as illustrated in What is FL?.

// fl headers
#include "wx/fl/controlbar.h"     // core API

// extra plugins
#include "wx/fl/barhintspl.h"    // bevel for bars with "X"s and grooves
#include "wx/fl/rowdragpl.h"     // NC-look with draggable rows
#include "wx/fl/cbcustom.h"      // customization plugin
#include "wx/fl/hintanimpl.h"

// beauty-care
#include "wx/fl/gcupdatesmgr.h"  // smooth d&d
#include "wx/fl/antiflickpl.h"   // double-buffered repaint of decorations
#include "wx/fl/dyntbar.h"       // auto-layout toolbar
#include "wx/fl/dyntbarhnd.h"    // control-bar dimension handler for it

MyFrame::MyFrame(wxFrame *frame)
    : wxFrame( frame, wxID_ANY, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition,
          wxSize( 700, 500 ),
          wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX |
          wxRESIZE_BORDER | wxSYSTEM_MENU  | wxCAPTION,
          "freimas" )
{
    mpClientWnd = CreateTextCtrl( "Client window" );

    mpLayout = new wxFrameLayout( this, mpClientWnd );

    mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() );

    // setup plugins for testing
    mpLayout->PushDefaultPlugins();

    mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // fancy "X"es and bevel for bars
    mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) );
    mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin  ) );
    mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) );
    mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) );

    // drop in some bars
    cbDimInfo sizes0( 200,45, // when docked horizontally
                      200,85, // when docked vertically
                      175,35, // when floated
                      FALSE,  // the bar is not fixed-size
                      4,      // vertical gap (bar border)
                      4       // horizontal gap (bar border)
                    );

    cbDimInfo sizes1( 150,35, // when docked horizontally
                      150,85, // when docked vertically
                      175,35, // when floated
                      TRUE,   // the bar is not fixed-size
                      4,      // vertical gap (bar border)
                      4       // horizontal gap (bar border)
                    );

    cbDimInfo sizes2( 175,45, // when docked horizontally
                      175,37, // when docked vertically
                      170,35, // when floated
                      TRUE,   // the bar is not fixed-size
                      4,      // vertical gap (bar border)
                      4,      // horizontal gap (bar border)
                      new cbDynToolBarDimHandler()
                    );

    mpLayout->AddBar( CreateTextCtrl("Hello"),  // bar window
                      sizes0, FL_ALIGN_TOP,     // alignment ( 0-top,1-bottom, etc)
                      0,                        // insert into 0th row (vert. position)
                      0,                        // offset from the start of row (in pixels)
                      "InfoViewer1",            // name for reference in customization pop-ups
                      TRUE
                    );

    mpLayout->AddBar( CreateTextCtrl("Bye"),    // bar window
                      sizes0, FL_ALIGN_TOP,     // alignment ( 0-top,1-bottom, etc)
                      1,                        // insert into 0th row (vert. position)
                      0,                        // offset from the start of row (in pixels)
                      "InfoViewer2",            // name for reference in customization pop-ups
                      TRUE
                    );

    mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window
                      sizes1, FL_ALIGN_TOP,     // alignment ( 0-top,1-bottom, etc)
                      0,                        // insert into 0th row (vert. position)
                      0,                        // offset from the start of row (in pixels)
                      "ToolBar1",               // name for reference in customization pop-ups
                      TRUE
                    );

    wxDynamicToolBar* pToolBar = new wxDynamicToolBar();

    pToolBar->Create( this, -1 );

    // 1001-1006 ids of command events fired by added tool-buttons

    pToolBar->AddTool( 1001, BMP_DIR "new.bmp" );
    pToolBar->AddTool( 1002, BMP_DIR "open.bmp" );
    pToolBar->AddTool( 1003, BMP_DIR "save.bmp" );

    pToolBar->AddTool( 1004, BMP_DIR "cut.bmp" );
    pToolBar->AddTool( 1005, BMP_DIR "copy.bmp" );
    pToolBar->AddTool( 1006, BMP_DIR "paste.bmp" );

    mpLayout->AddBar( pToolBar,             // bar window (can be NULL)
                      sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc)
                      0,                    // insert into 0th row (vert. position)
                      0,                    // offset from the start of row (in pixels)
                      "ToolBar2",           // name for reference in customization pop-ups
                      FALSE
                    );

    mpLayout->EnableFloating( TRUE ); // off, thinking about wxGtk...
}

MyFrame::~MyFrame()
{
    if ( mpLayout)
        delete mpLayout; // should be destroyed manually
}