void MyFrame::Test_AbsoluteLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "AbsoluteLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new AbsoluteLayout() ); Component* c1 = CreateComp( "Hello1" ); c1->setLocation( 100, 30 ); Component* c2 = CreateComp( "Hello2" ); c2->setLocation( 30, 120 ); Component* c3 = CreateComp( "Hello3" ); c3->setLocation( 230, 200 ); parent->add( c1 ); parent->add( c2 ); parent->add( c3 ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void MyFrame::Test_GridBagLayout_2( wxCommandEvent& event ) { RemoveAll(); SetTestName( "GridBagLayout-2" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; c.fill = GridBagConstraints::BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridwidth = GridBagConstraints::REMAINDER; parent->add( MakeButton( "Hi" ), &c ); Container* panel = new Container(); c.weighty = 0.0; parent->add( panel, &c ); panel->setLayout( new FlowLayout() ); for( int i = 0;i != 5; ++i ) panel->add( MakeButton( "Button" + IntToStr(i) ) ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
RegexParseTest( int number ) : TestCase( "RegexParseTest" ), mTestNum( number ) { char name[ 32 ]; snprintf( name, 32, "RegexParseTest%d", number ); name[ 31 ] = '\0'; SetTestName( name ); }
void MyFrame::Test_GridBagLayout_1( wxCommandEvent& event ) { RemoveAll(); SetTestName( "GridBagLayout-1" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; /////////////////////////////////////////////////////////////////// // this code is taken from java.awt.GridBagLayout test-sample // // found in JDK1.1 docs, and adapted for C++ version Serves as a // // test for complience with behaviour of actual java classes // /////////////////////////////////////////////////////////////////// c.fill = GridBagConstraints::BOTH; c.weightx = 1.0; parent->add( CreateComp( "Button1" ), &c ); parent->add( CreateComp( "Button2" ), &c ); parent->add( CreateComp( "Button3" ), &c ); c.gridwidth = GridBagConstraints::REMAINDER; //end row parent->add( CreateComp( "Button4" ), &c ); c.weightx = 0.0; //reset to the default parent->add( CreateComp( "Button5" ), &c ); //another row // Slight-INCOMPATIBILITY:: actually gridwidth of "Button6" should be // defined as "c.gridwidth = GridBagConstraints::REMAINDER;" // THE HACK:: we set gridwidth to 3 instead of REMAINDER // FIXME:: the behaviour of AWT is not simulated completely at this point... c.gridwidth = 3; //next-to-last in row parent->add( CreateComp( "Button6" ), &c ); c.gridwidth = GridBagConstraints::REMAINDER; //end row parent->add( CreateComp( "Button7" ), &c ); c.gridwidth = 1; //reset to the default c.gridheight = 2; c.weighty = 1.0; parent->add( CreateComp( "Button8" ), &c ); c.weighty = 0.0; //reset to the default c.gridwidth = GridBagConstraints::REMAINDER; //end row c.gridheight = 1; //reset to the default parent->add( CreateComp( "Button9" ), &c ); parent->add( CreateComp( "Button10" ), &c ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void TestType::Test<4>() { SetTestName(L"Test 4"); file_.AddFile(10, _T("ReadMe.txt")); file_.AddFile(11, _T("CustomFileImpl.h")); const custom_file::FileInfoPtr &file = file_.GetData(10); Ensure(file->gid_ == 10, _T("GID")); const custom_file::FileInfoPtr &file1 = file_.GetData(11); Ensure(file1->gid_ == 11, _T("GID")); }
SelectorTest::SelectorTest( Selector *s ) : TestCase( "SelectorTest" ), mSelector( s ) { SetTestName( "File Events" ); int res = pipe( mPipe ); if ( res != 0 ) LOG_ERR_FATAL( "failed to create pipe" ); other = jh_new OtherListenerClass( mPipe[ 0 ], 11, this ); mSelector->addListener( mPipe[ 0 ], POLLIN, this, 10 ); mSelector->addListener( mPipe[ 0 ], POLLIN, other, 11 ); }
void MyFrame::Test_BoxLayout_horiz( wxCommandEvent& event ) { RemoveAll(); SetTestName( "BoxLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new BoxLayout( parent, BoxLayout::X_AXIS ) ); for( int i = 0; i != 5; ++i ) parent->add( CreateComp( "Item" + IntToStr(i) ) ); DoPack( parent ); }
void TestType::Test<3>() { SetTestName(L"Test 3"); file_.AddFile(10, _T("ReadMe.txt")); file_.AddFile(11, _T("CustomFileImpl.h")); file_.AddFile(12, _T("CustonFileFormat.vcproj")); file_.ModifyFile(10, _T("stdafx.cpp")); Ensure(file_.GetFilesInfo().find(10) != file_.GetFilesInfo().end()); file_.ModifyFile(11, _T("ReadMe.txt")); Ensure(file_.GetFilesInfo().find(11) != file_.GetFilesInfo().end()); }
EventTest::EventTest( Selector *s, int number ) : TestCase( "EventTest" ), mTestNum( number ), mSelector( s ) { switch( number ) { case 1: SetTestName( "Async Event" ); break; case 2: SetTestName( "Sync Event" ); break; case 3: SetTestName( "Sync Event with return" ); break; } mEvent1Handler = jh_new EventMethod<EventTest,Event1>( this, &EventTest::ProcessFunc1, mSelector ); mEvent2Handler = jh_new EventMethod<EventTest,Event2>( this, &EventTest::ProcessFunc2, mSelector ); mEvent3Handler = jh_new EventMethod<EventTest,Event3>( this, &EventTest::ProcessFunc3, mSelector ); }
void MyFrame::Test_FlowLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "FlowLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new FlowLayout( FlowLayout::CENTER, mCfg.mHgap, mCfg.mVgap ) ); for( int i = 0; i != 5; ++i ) parent->add( CreateComp( "Item" + IntToStr(i) ) ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void MyFrame::Test_BoxLayout_vert( wxCommandEvent& event ) { RemoveAll(); SetTestName( "BoxLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new BoxLayout( parent, BoxLayout::Y_AXIS ) ); for( int i = 0; i != 5; ++i ) parent->add( CreateComp( "Item" + IntToStr(i) ) ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void MyFrame::Test_CardLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "CardLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new CardLayout() ); parent->add( CreateComp( "Card1" ), (Object*)new String("1") ); parent->add( CreateComp( "Card2" ), (Object*)new String("2") ); parent->add( CreateComp( "Card3" ), (Object*)new String("3") ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void TestType::Test<2>() { SetTestName(L"Test 2"); file_.AddFile(10, _T("ReadMe.txt")); file_.AddFile(11, _T("CustomFileImpl.h")); file_.AddFile(12, _T("CustonFileFormat.vcproj")); file_.DeleteFile(10); EnsureLessEqual(file_.GetIndex().size(), 2, L"删除掉一个"); file_.DeleteFile(11); EnsureLessEqual(file_.GetIndex().size(), 1, L"删除掉两个"); file_.DeleteFile(12); EnsureLessEqual(file_.GetIndex().size(), 0, L"删除掉三个"); }
void MyFrame::Test_GridLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "GridLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridLayout( mCfg.mRowCount, mCfg.mColCount, mCfg.mHgap, mCfg.mVgap ) ); for( int i = 0; i != mCfg.mRowCount * mCfg.mColCount - 1; ++i ) parent->add( CreateComp( "Item" + IntToStr(i) ) ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void TestType::Test<1>() { SetTestName(L"Test 1"); file_.AddFile(10, _T("ReadMe.txt")); EnsureEqual(file_.GetIndex().size(), 1, L"ReadMe.txt"); file_.AddFile(11, _T("CustomFileImpl.h")); EnsureEqual(file_.GetIndex().size(), 2, L"CustomFileImpl.h"); file_.AddFile(12, _T("CustonFileFormat.vcproj")); EnsureEqual(file_.GetIndex().size(), 3, L"CustonFileFormat.vcproj"); file_.AddFile(14, _T("CustonFileFormat.cpp")); EnsureEqual(file_.GetIndex().size(), 4, L"CustonFileFormat.cpp"); file_.AddFile(13, _T("CustomFileSerialize.h")); EnsureEqual(file_.GetIndex().size(), 5, L"CustomFileSerialize.h"); }
void MyFrame::Test_BorderLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "BorderLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new BorderLayout( mCfg.mHgap, mCfg.mVgap ) ); Component* north = CreateComp( "North" ); Component* south = CreateComp( "South" ); Component* west = CreateComp( "West" ); Component* east = CreateComp( "East" ); Component* center = CreateComp( "Center" ); parent->add( north, BorderLayout::NORTH ); parent->add( south, BorderLayout::SOUTH ); parent->add( west, BorderLayout::WEST ); parent->add( east, BorderLayout::EAST ); parent->add( center, BorderLayout::CENTER ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void MyFrame::Test_All_1( wxCommandEvent& event ) { RemoveAll(); SetTestName( "Test_All_1" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints::BOTH; c.gridwidth = GridBagConstraints::REMAINDER; Container* sortPanel = MakeStaticBox( "Filtering options: (in GridBagLayout)" ); Container* btnPanel = new Container(); parent->add( sortPanel, &c ); c.weighty = 0.0; parent->add( btnPanel, &c ); btnPanel->setLayout( new FlowLayout() ); btnPanel->setInsets( Insets( 10,10, 10,10 ) ); btnPanel->add( MakeLabel( "Buttons:" ) ); btnPanel->add( MakeButton( "&Apply" ) ); btnPanel->add( MakeButton( "&Cancel" ) ); btnPanel->add( MakeButton( "&Help" ) ); btnPanel->add( MakeLabel( "in a FlowLayout" ) ); SetCurrentContainer( sortPanel ); sortPanel->setInsets( GetInsetsForStaticBox( sortPanel ) ); // creating "Resolution" panel sortPanel->setLayout( new GridBagLayout() ); char* resValues[] = { "FIXED", "INVALID", "WONTFIX", "LATER", "REMIND", "DUPLICATE", "WORKSFORME" }; char* pltfValues[] = { "All", "DEC", "HP", "Macintosh", "PC", "SGI", "Sun", "Other" }; char* opSysValues[] = { "All", "Windows 3.1", "Windows 95", "Windows 98", "Windows NT", "Mac Sys7", "Mac Sys7.5", "Mac Sys7.6.1", "Mac Sys8.0", "Mac Sys7", "Mac Sys8.5", "Mac Sys8.6", "Aix", "BSD", "IRIX", "Linux", "FreeBSD", "NetBSD", "OSF/1", "SOLARIS", "SunOS", "Neutrino", "OS/2", "OpenVMS", "other" }; char* compValues[] = { "Not applied", "wxGrid", "wxHTML", "wxMedia", "wxLayout", "wxDialupManager", "wxFrameLayout" }; char* severValues[] = { "Blocker", "Critical", "Major", "Minor", "Trivial", "Enhancement", "Showstopper" }; char* priValues[] = { "P1", "P2", "P3", "P4", "P5" }; int resCnt = sizeof( resValues ) / sizeof(char*); int pltfCnt = sizeof( pltfValues ) / sizeof(char*); int opSysCnt = sizeof( opSysValues ) / sizeof(char*); int compCnt = sizeof( compValues ) / sizeof(char*); int svrCnt = sizeof( severValues ) / sizeof(char*); int priCnt = sizeof( priValues ) / sizeof(char*); c.weightx = 1.0; c.fill = GridBagConstraints::BOTH; c = GridBagConstraints(); // reset defauls c.fill = GridBagConstraints::BOTH; int rel = GridBagConstraints::RELATIVE; c.weightx = 1.0; c.insets.left = 2; c.insets.right = 2; c.gridx = 1; c.gridy = 1; sortPanel->add( MakeListBox ( resValues, resCnt ), &c ); c.gridx = 2; c.gridwidth = 2; sortPanel->add( MakeListBox ( severValues, svrCnt ), &c ); c.gridx = 4; c.gridwidth = 1; sortPanel->add( MakeListBox ( priValues, priCnt ), &c ); c.gridy = 3; c.gridx = 1; c.weighty = 1.0; c.gridwidth = 2; sortPanel->add( MakeListBox ( compValues, compCnt ), &c ); c.gridx = 3; sortPanel->add( MakeListBox ( pltfValues, pltfCnt ), &c ); c.gridwidth = 1; c.gridx = 0; c.gridy = 1; c.weighty = 1.0; c.gridheight = GridBagConstraints::REMAINDER; sortPanel->add( MakeListBox ( opSysValues, opSysCnt ), &c ); c.gridx = 0; c.gridy = 0; c.gridheight = 1; c.weighty = 0.0; sortPanel->add( MakeCheckBox( "OpSys" ), &c ); c.gridx = 1; sortPanel->add( MakeCheckBox( "Resolution" ), &c ); c.gridx = 2; c.gridwidth = 2; sortPanel->add( MakeCheckBox( "Severity" ), &c ); c.gridx = 4; c.gridwidth = 0; sortPanel->add( MakeCheckBox( "Priority" ), &c ); c.gridx = 1; c.gridy = 2; c.gridwidth = 2; sortPanel->add( MakeCheckBox( "Component" ), &c ); c.gridx = 3; sortPanel->add( MakeCheckBox( "Platform" ), &c ); c.gridwidth = 0; Container* keywordsPanel = MakeStaticBox( "Contain Keywords: (in another grid-bag)" ); keywordsPanel->setInsets( GetInsetsForStaticBox( keywordsPanel ) ); c.gridx = 1; c.gridy = 4; c.insets.top = 5; c.gridwidth = GridBagConstraints::REMAINDER; c.weighty = 0.0; sortPanel->add( keywordsPanel, &c ); keywordsPanel->setLayout( new GridBagLayout() ); SetCurrentContainer( keywordsPanel ); c = GridBagConstraints(); // reset defauls c.anchor = GridBagConstraints::NORTHWEST; c.gridx = 0; c.gridy = 0; keywordsPanel->add( MakeRadioButton( "Up", TRUE ), &c ); c.gridx = 0; c.gridy = 1; keywordsPanel->add( MakeRadioButton( "Down" ), &c ); c.gridx = 0; c.gridy = 2; keywordsPanel->add( MakeRadioButton( "Start" ), &c ); c.fill = GridBagConstraints::BOTH; c.gridx = 1; c.gridy = 0; c.weightx = 1.0; c.weighty = 1.0; c.gridheight = 3; keywordsPanel->add( MakeTextField( "p1, fixed, bcc" ), &c ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }
void MyFrame::Test_All_2( wxCommandEvent& event ) { RemoveAll(); SetTestName( "Test_All_2" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints::BOTH; c.gridwidth = GridBagConstraints::REMAINDER; c.insets = Insets( 5,10,2,10 ); Container* imagePanel = new Container(); parent->add( imagePanel, &c ); imagePanel->setLayout( new FlowLayout() ); for( int i = 0; i != 15; ++i ) { Component* pComp = MakeButton( "< " + IntToStr( i + 1 ) + " >" ); pComp->setMinimumSize( Dimension( 60,60 ) ); imagePanel->add( pComp ); } c.weighty = 0.0; c.fill = GridBagConstraints::VERTICAL; c.insets.top = 2; parent->add( MakeLabel( "---- Purchase A Fine Image Today -----" ), &c ); c.insets.top = 5; c.fill = GridBagConstraints::BOTH; Container* infoPanel = MakeStaticBox( "" ); Container* btnPanel = new Container(); parent->add( infoPanel, &c ); parent->add( btnPanel, &c ); btnPanel->setLayout( new FlowLayout() ); btnPanel->add( MakeButton( "&Purchase" ) ); btnPanel->add( MakeButton( "&Cancel" ) ); infoPanel->setLayout( new GridBagLayout() ); infoPanel->setInsets( GetInsetsForStaticBox( infoPanel ) ); SetCurrentContainer( infoPanel ); int rmd = GridBagConstraints::REMAINDER; c.insets = Insets( 5,5, 0,0 ); c.fill = GridBagConstraints::HORIZONTAL; c.weightx = 0.0; c.gridx = 0; c.gridy = 0; infoPanel->add( MakeLabel( "Name:" ), &c ); c.gridwidth = rmd; c.weightx = 1.0; c.gridwidth = 3; infoPanel->add( MakeTextField( "" ), &c ); c.gridwidth = 0; c.weightx = 0.0; c.gridx = 0; c.gridy = 1; infoPanel->add( MakeLabel( "Address:" ), &c ); c.gridwidth = rmd; c.weightx = 1.0; c.gridwidth = 3; infoPanel->add( MakeTextField( "" ), &c ); c.gridwidth = 0; c.weightx = 0.0; c.gridx = 0; c.gridy = 2; infoPanel->add( MakeLabel( "City:" ), &c ); c.weightx = 1.0; infoPanel->add( MakeTextField( "" ), &c ); c.weightx = 0.0; infoPanel->add( MakeLabel( "State:" ), &c ); infoPanel->add( MakeTextField( "" ), &c ); char* methods[] = { "Visa", "MasterCard", "Check" }; c.weightx = 0.0; c.gridx = 0; c.gridy = 3; infoPanel->add( MakeLabel( "Payment:" ), &c ); c.weightx = 0.0; c.fill = GridBagConstraints::NONE; c.anchor = GridBagConstraints::WEST; infoPanel->add( MakeComboBox( methods, sizeof(methods)/sizeof(char*) ), &c ); // no auto-packing for this panel... // (so many images in flow-layout may cause default width to be too big) parent->doLayout(); }
void MyFrame::Test_GridBagLayout( wxCommandEvent& event ) { RemoveAll(); SetTestName( "GridBagLayout" ); parent = new Container( this ); SetCurrentContainer( parent ); parent->setLayout( new GridBagLayout() ); GridBagConstraints c; /* parent->add( CreateComp( "Item1" ), &c ); parent->add( CreateComp( "Item1-1" ), &c ); parent->add( CreateComp( "Item1-2" ), &c ); c.gridwidth = GridBagConstraints::REMAINDER; parent->add( CreateComp( "Item2" ), &c ); c.gridwidth = 4; c.fill = GridBagConstraints::BOTH; parent->add( CreateComp( "Item3" ), &c ); */ //c.gridwidth = GridBagConstraints::REMAINDER; parent->add( CreateComp( "Item1" ), &c ); parent->add( CreateComp( "Item1-2" ), &c ); c.gridwidth = GridBagConstraints::REMAINDER; parent->add( CreateComp( "Item2" ), &c ); c.gridwidth = 1; parent->add( CreateComp( "Item3" ), &c ); c.gridx = 0; c.gridy = 2; c.gridwidth = 4; c.fill = GridBagConstraints::NONE; parent->add( CreateComp( "Item4" ), &c ); c.fill = GridBagConstraints::NONE; c.gridx = 1; c.gridy = 1; c.gridwidth = 1; parent->add( CreateComp( "Item5" ), &c ); c.gridwidth = 0; c.gridx = 0; c.gridy = 3; c.gridwidth = GridBagConstraints::REMAINDER; c.fill = GridBagConstraints::BOTH; parent->add( CreateComp( "Item6" ), &c ); c.gridx = 3; c.gridy = 1; c.gridwidth = GridBagConstraints::REMAINDER; c.fill = GridBagConstraints::BOTH; parent->add( CreateComp( "Item7" ), &c ); c.gridx = 5; c.gridy = 4; c.gridwidth = GridBagConstraints::REMAINDER; c.fill = GridBagConstraints::BOTH; parent->add( CreateComp( "Item8" ), &c ); if ( mCfg.mAutoPack ) parent->pack(); else parent->doLayout(); }