| 1 | ///////////////////////////////////////////////////////////////////////////// |
| 2 | // Name: No names yet. |
| 3 | // Purpose: Contrib. demo |
| 4 | // Author: Aleksandras Gluchovas |
| 5 | // Modified by: Sebastian Haase (June 21, 2001) |
| 6 | // Created: 04/11/98 |
| 7 | // RCS-ID: $Id$ |
| 8 | // Copyright: (c) Aleksandras Gluchovas |
| 9 | // Licence: wxWindows license |
| 10 | ///////////////////////////////////////////////////////////////////////////// |
| 11 | |
| 12 | |
| 13 | #ifdef __GNUG__ |
| 14 | #pragma implementation "fl_demo1.h" |
| 15 | #endif |
| 16 | |
| 17 | // For compilers that support precompilation, includes "wx/wx.h". |
| 18 | #include "wx/wxprec.h" |
| 19 | |
| 20 | #ifdef __BORLANDC__ |
| 21 | #pragma hdrstop |
| 22 | #endif |
| 23 | |
| 24 | #ifndef WX_PRECOMP |
| 25 | #include "wx/wx.h" |
| 26 | #endif |
| 27 | |
| 28 | #include "wx/textctrl.h" |
| 29 | |
| 30 | // fl headers |
| 31 | #include "wx/fl/controlbar.h" // core API |
| 32 | |
| 33 | // extra plugins |
| 34 | #include "wx/fl/barhintspl.h" // beveal for bars with "X"s and grooves |
| 35 | #include "wx/fl/rowdragpl.h" // NC-look with dragable rows |
| 36 | #include "wx/fl/cbcustom.h" // customization plugin |
| 37 | #include "wx/fl/hintanimpl.h" |
| 38 | |
| 39 | // beuty-care |
| 40 | #include "wx/fl/gcupdatesmgr.h" // smooth d&d |
| 41 | #include "wx/fl/antiflickpl.h" // double-buffered repaint of decorations |
| 42 | #include "wx/fl/dyntbar.h" // auto-layouting toolbar |
| 43 | #include "wx/fl/dyntbarhnd.h" // control-bar dimension handler for it |
| 44 | |
| 45 | #include "fl_demo1.h" |
| 46 | |
| 47 | // comment it out if it breaks, (this is my workaround for MSDev 4.0 linker) |
| 48 | |
| 49 | char wxDummyChar; |
| 50 | |
| 51 | |
| 52 | IMPLEMENT_APP (MyApp) |
| 53 | |
| 54 | bool MyApp::OnInit(void) |
| 55 | { |
| 56 | MyFrame *frame = new MyFrame(NULL); |
| 57 | |
| 58 | frame->SetBackgroundColour( wxColour(192,192,192) ); |
| 59 | |
| 60 | wxMenu *file_menu = new wxMenu; |
| 61 | |
| 62 | file_menu->Append( NEW_TEST_LOAD, "&Load layouts" ); |
| 63 | file_menu->Append( NEW_TEST_SAVE, "&Store layouts" ); |
| 64 | file_menu->Append( NEW_TEST_EXIT, "E&xit" ); |
| 65 | |
| 66 | wxMenuBar *menu_bar = new wxMenuBar; |
| 67 | |
| 68 | menu_bar->Append(file_menu, "&File"); |
| 69 | |
| 70 | frame->SetMenuBar(menu_bar); |
| 71 | |
| 72 | frame->CreateStatusBar(3); |
| 73 | |
| 74 | frame->Show(TRUE); |
| 75 | |
| 76 | frame->mpClientWnd->Refresh(); |
| 77 | |
| 78 | SetTopWindow(frame); |
| 79 | |
| 80 | |
| 81 | wxMessageBox("Hello, this demo has a bunch of yet-not-fixed-bugs and misssing functionality\n" \ |
| 82 | "The ONLY purpose is to demostrate self-layouting toolbars,\nflat-bitmapped-buttons and 2-new FL-plugins" \ |
| 83 | "(cbRowDragPlugin & cbBarHintsPlugin)\n\n" \ |
| 84 | "BTW, disabled images and label-text are rendered at run-time" ); |
| 85 | |
| 86 | return TRUE; |
| 87 | } |
| 88 | |
| 89 | /***** Implementation for class MyFrame *****/ |
| 90 | |
| 91 | BEGIN_EVENT_TABLE( MyFrame, wxFrame ) |
| 92 | // EVT_CHAR_HOOK(MyFrame::OnKeyDown) |
| 93 | // EVT_PAINT( MyFrame::OnPaint ) |
| 94 | EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave ) |
| 95 | EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad ) |
| 96 | EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit ) |
| 97 | END_EVENT_TABLE() |
| 98 | |
| 99 | void MyFrame::OnLoad( wxCommandEvent& event ) |
| 100 | { |
| 101 | wxMessageBox("Hey - you found a BIG question-mark !!"); |
| 102 | } |
| 103 | |
| 104 | void MyFrame::OnSave( wxCommandEvent& event ) |
| 105 | { |
| 106 | wxMessageBox("Hey - you found another BIG question-mark !!"); |
| 107 | } |
| 108 | |
| 109 | void MyFrame::OnExit( wxCommandEvent& event ) |
| 110 | { |
| 111 | Destroy(); |
| 112 | } |
| 113 | |
| 114 | wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) |
| 115 | { |
| 116 | wxTextCtrl* pCtrl = |
| 117 | |
| 118 | new wxTextCtrl( this, -1, value, |
| 119 | wxDefaultPosition, wxSize(0,0), wxTE_MULTILINE ); |
| 120 | |
| 121 | pCtrl->SetBackgroundColour( wxColour( 255,255,255 ) ); |
| 122 | |
| 123 | return pCtrl; |
| 124 | } |
| 125 | |
| 126 | MyFrame::MyFrame(wxFrame *frame) |
| 127 | : wxFrame( frame, -1, "wxWindows 2.0 wxFrameLayout Test Application", wxDefaultPosition, |
| 128 | wxSize( 700, 500 ), |
| 129 | wxCLIP_CHILDREN | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | |
| 130 | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION, |
| 131 | "freimas" ) |
| 132 | { |
| 133 | mpClientWnd = CreateTextCtrl( "Client window" ); |
| 134 | |
| 135 | mpLayout = new wxFrameLayout( this, mpClientWnd ); |
| 136 | |
| 137 | #ifdef __WXGTK__ |
| 138 | cbCommonPaneProperties props; |
| 139 | mpLayout->GetPaneProperties( props ); |
| 140 | |
| 141 | props.mRealTimeUpdatesOn = FALSE; // real-time OFF!!! |
| 142 | |
| 143 | mpLayout->SetPaneProperties( props, wxALL_PANES ); |
| 144 | #endif |
| 145 | |
| 146 | mpLayout->SetUpdatesManager( new cbGCUpdatesMgr() ); |
| 147 | |
| 148 | // this is now default... |
| 149 | //mpLayout->SetMargins( 1,1,1,1 ); // gaps for vertical/horizontal/right/left panes |
| 150 | |
| 151 | // setup plugins for testing |
| 152 | mpLayout->PushDefaultPlugins(); |
| 153 | |
| 154 | mpLayout->AddPlugin( CLASSINFO( cbBarHintsPlugin ) ); // facny "X"es and beveal for bars |
| 155 | mpLayout->AddPlugin( CLASSINFO( cbHintAnimationPlugin ) ); |
| 156 | mpLayout->AddPlugin( CLASSINFO( cbRowDragPlugin ) ); |
| 157 | mpLayout->AddPlugin( CLASSINFO( cbAntiflickerPlugin ) ); |
| 158 | mpLayout->AddPlugin( CLASSINFO( cbSimpleCustomizationPlugin ) ); |
| 159 | |
| 160 | // drop in some bars |
| 161 | cbDimInfo sizes0( 200,45, // when docked horizontally |
| 162 | 200,85, // when docked vertically |
| 163 | 175,35, // when floated |
| 164 | FALSE, // the bar is not fixed-size |
| 165 | 4, // vertical gap (bar border) |
| 166 | 4 // horizontal gap (bar border) |
| 167 | ); |
| 168 | |
| 169 | cbDimInfo sizes1( 150,35, // when docked horizontally |
| 170 | 150,85, // when docked vertically |
| 171 | 175,35, // when floated |
| 172 | TRUE, // the bar is not fixed-size |
| 173 | 4, // vertical gap (bar border) |
| 174 | 4 // horizontal gap (bar border) |
| 175 | ); |
| 176 | |
| 177 | cbDimInfo sizes2( 175,45, // when docked horizontally |
| 178 | 175,37, // when docked vertically |
| 179 | 170,35, // when floated |
| 180 | TRUE, // the bar is not fixed-size |
| 181 | 4, // vertical gap (bar border) |
| 182 | 4, // horizontal gap (bar border) |
| 183 | new cbDynToolBarDimHandler() |
| 184 | ); |
| 185 | |
| 186 | mpLayout->AddBar( CreateTextCtrl("Hello"), // bar window |
| 187 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
| 188 | 0, // insert into 0th row (vert. position) |
| 189 | 0, // offset from the start of row (in pixels) |
| 190 | "InfoViewer1", // name to refere in customization pop-ups |
| 191 | TRUE |
| 192 | ); |
| 193 | |
| 194 | mpLayout->AddBar( CreateTextCtrl("Bye"), // bar window |
| 195 | sizes0, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
| 196 | 1, // insert into 0th row (vert. position) |
| 197 | 0, // offset from the start of row (in pixels) |
| 198 | "InfoViewer2", // name to refere in customization pop-ups |
| 199 | TRUE |
| 200 | ); |
| 201 | |
| 202 | mpLayout->AddBar( CreateTextCtrl("Fixed0"), // bar window |
| 203 | sizes1, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
| 204 | 0, // insert into 0th row (vert. position) |
| 205 | 0, // offset from the start of row (in pixels) |
| 206 | "ToolBar1", // name to refere in customization pop-ups |
| 207 | TRUE |
| 208 | ); |
| 209 | |
| 210 | wxDynamicToolBar* pToolBar = new wxDynamicToolBar(); |
| 211 | |
| 212 | pToolBar->Create( this, -1 ); |
| 213 | |
| 214 | // 1001-1006 ids of command events fired by added tool-buttons |
| 215 | |
| 216 | pToolBar->AddTool( 1001, BMP_DIR "new.bmp" ); |
| 217 | pToolBar->AddTool( 1002, BMP_DIR "open.bmp" ); |
| 218 | pToolBar->AddTool( 1003, BMP_DIR "save.bmp" ); |
| 219 | |
| 220 | pToolBar->AddTool( 1004, BMP_DIR "cut.bmp" ); |
| 221 | pToolBar->AddTool( 1005, BMP_DIR "copy.bmp" ); |
| 222 | pToolBar->AddTool( 1006, BMP_DIR "paste.bmp" ); |
| 223 | |
| 224 | |
| 225 | mpLayout->AddBar( pToolBar, // bar window (can be NULL) |
| 226 | sizes2, FL_ALIGN_TOP, // alignment ( 0-top,1-bottom, etc) |
| 227 | 0, // insert into 0th row (vert. position) |
| 228 | 0, // offset from the start of row (in pixels) |
| 229 | "ToolBar2", // name to refere in customization pop-ups |
| 230 | FALSE |
| 231 | ); |
| 232 | |
| 233 | mpLayout->EnableFloating( TRUE ); // off, thinking bout wxGtk... |
| 234 | } |
| 235 | |
| 236 | MyFrame::~MyFrame() |
| 237 | { |
| 238 | if ( mpLayout) |
| 239 | delete mpLayout; // should be destroyed manually |
| 240 | } |
| 241 | |