Code-style consistency improvement:

Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files.
make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type.
This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
erwincoumans
2018-09-23 14:17:31 -07:00
parent b73b05e9fb
commit ab8f16961e
1773 changed files with 1081087 additions and 474249 deletions

View File

@@ -4,72 +4,68 @@ using namespace Gwen;
class Button : public GUnit
{
public:
GWEN_CONTROL_INLINE( Button, GUnit )
public:
GWEN_CONTROL_INLINE(Button, GUnit)
{
// Normal button
Controls::Button* pButtonA = new Controls::Button( this );
pButtonA->SetText( L"Event Tester" );
pButtonA->onPress.Add( this, &Button::onButtonA );
// Normal button
Controls::Button* pButtonA = new Controls::Button(this);
pButtonA->SetText(L"Event Tester");
pButtonA->onPress.Add(this, &Button::onButtonA);
{
Controls::Button* pButtonA = new Controls::Button( this );
pButtonA->SetBounds( 200, 30, 300, 200 );
pButtonA->SetText( L"Event Tester" );
pButtonA->onPress.Add( this, &Button::onButtonA );
}
{
Controls::Button* pButtonA = new Controls::Button(this);
pButtonA->SetBounds(200, 30, 300, 200);
pButtonA->SetText(L"Event Tester");
pButtonA->onPress.Add(this, &Button::onButtonA);
}
// Unicode test
Controls::Button* pButtonB = new Controls::Button( this );
pButtonB->SetText( L"\u0417\u0430\u043C\u0435\u0436\u043D\u0430\u044F \u043C\u043E\u0432\u0430" );
Gwen::Align::PlaceBelow( pButtonB, pButtonA, 10 );
// Unicode test
Controls::Button* pButtonB = new Controls::Button(this);
pButtonB->SetText(L"\u0417\u0430\u043C\u0435\u0436\u043D\u0430\u044F \u043C\u043E\u0432\u0430");
Gwen::Align::PlaceBelow(pButtonB, pButtonA, 10);
// Image with text
Controls::Button* pButtonC = new Controls::Button( this );
pButtonC->SetText( L"Image Button" );
pButtonC->SetImage( L"test16.png" );
Gwen::Align::PlaceBelow( pButtonC, pButtonB, 10 );
// Image with text
Controls::Button* pButtonC = new Controls::Button(this);
pButtonC->SetText(L"Image Button");
pButtonC->SetImage(L"test16.png");
Gwen::Align::PlaceBelow(pButtonC, pButtonB, 10);
// Just image
Controls::Button* pButtonD = new Controls::Button( this );
pButtonD->SetText( L"" );
pButtonD->SetImage( L"test16.png" );
pButtonD->SetSize( 20, 20 );
Gwen::Align::PlaceBelow( pButtonD, pButtonC, 10 );
// Just image
Controls::Button* pButtonD = new Controls::Button(this);
pButtonD->SetText(L"");
pButtonD->SetImage(L"test16.png");
pButtonD->SetSize(20, 20);
Gwen::Align::PlaceBelow(pButtonD, pButtonC, 10);
// Toggle button
Controls::Button* pButtonE = new Controls::Button( this );
pButtonE->SetText( L"Toggle Me" );
pButtonE->SetIsToggle( true );
pButtonE->onToggle.Add( this, &Button::OnToggle );
pButtonE->onToggleOn.Add( this, &Button::OnToggleOn );
pButtonE->onToggleOff.Add( this, &Button::OnToggleOff );
Gwen::Align::PlaceBelow( pButtonE, pButtonD, 10 );
// Toggle button
Controls::Button* pButtonE = new Controls::Button(this);
pButtonE->SetText(L"Toggle Me");
pButtonE->SetIsToggle(true);
pButtonE->onToggle.Add(this, &Button::OnToggle);
pButtonE->onToggleOn.Add(this, &Button::OnToggleOn);
pButtonE->onToggleOff.Add(this, &Button::OnToggleOff);
Gwen::Align::PlaceBelow(pButtonE, pButtonD, 10);
}
void onButtonA( Controls::Base* pControl )
void onButtonA(Controls::Base* pControl)
{
UnitPrint( L"Button Pressed (using 'OnPress' event)" );
UnitPrint(L"Button Pressed (using 'OnPress' event)");
}
void OnToggle( Controls::Base* pControl )
void OnToggle(Controls::Base* pControl)
{
UnitPrint( L"Button Toggled (using 'OnToggle' event)" );
UnitPrint(L"Button Toggled (using 'OnToggle' event)");
}
void OnToggleOn( Controls::Base* pControl )
void OnToggleOn(Controls::Base* pControl)
{
UnitPrint( L"Button Toggled ON (using 'OnToggleOn' event)" );
UnitPrint(L"Button Toggled ON (using 'OnToggleOn' event)");
}
void OnToggleOff( Controls::Base* pControl )
void OnToggleOff(Controls::Base* pControl)
{
UnitPrint( L"Button Toggled Off (using 'OnToggleOff' event)" );
UnitPrint(L"Button Toggled Off (using 'OnToggleOff' event)");
}
};
DEFINE_UNIT_TEST( Button, L"Button" );
DEFINE_UNIT_TEST(Button, L"Button");

View File

@@ -5,44 +5,38 @@ using namespace Gwen;
class Checkbox : public GUnit
{
public:
GWEN_CONTROL_INLINE( Checkbox, GUnit )
public:
GWEN_CONTROL_INLINE(Checkbox, GUnit)
{
Gwen::Controls::CheckBox* check = new Gwen::Controls::CheckBox( this );
check->SetPos( 10, 10 );
check->onChecked.Add( this, &Checkbox::OnChecked );
check->onUnChecked.Add( this, &Checkbox::OnUnchecked );
check->onCheckChanged.Add( this, &Checkbox::OnCheckChanged );
Gwen::Controls::CheckBoxWithLabel* labeled = new Gwen::Controls::CheckBoxWithLabel( this );
labeled->SetPos( 10, 10 );
labeled->Label()->SetText( "Labeled CheckBox" );
labeled->Checkbox()->onChecked.Add( this, &Checkbox::OnChecked );
labeled->Checkbox()->onUnChecked.Add( this, &Checkbox::OnUnchecked );
labeled->Checkbox()->onCheckChanged.Add( this, &Checkbox::OnCheckChanged );
Gwen::Align::PlaceBelow( labeled, check, 10 );
Gwen::Controls::CheckBox* check = new Gwen::Controls::CheckBox(this);
check->SetPos(10, 10);
check->onChecked.Add(this, &Checkbox::OnChecked);
check->onUnChecked.Add(this, &Checkbox::OnUnchecked);
check->onCheckChanged.Add(this, &Checkbox::OnCheckChanged);
Gwen::Controls::CheckBoxWithLabel* labeled = new Gwen::Controls::CheckBoxWithLabel(this);
labeled->SetPos(10, 10);
labeled->Label()->SetText("Labeled CheckBox");
labeled->Checkbox()->onChecked.Add(this, &Checkbox::OnChecked);
labeled->Checkbox()->onUnChecked.Add(this, &Checkbox::OnUnchecked);
labeled->Checkbox()->onCheckChanged.Add(this, &Checkbox::OnCheckChanged);
Gwen::Align::PlaceBelow(labeled, check, 10);
}
void OnChecked( Controls::Base* pControl )
void OnChecked(Controls::Base* pControl)
{
UnitPrint( L"Checkbox Checked (using 'OnChecked' event)" );
UnitPrint(L"Checkbox Checked (using 'OnChecked' event)");
}
void OnUnchecked( Controls::Base* pControl )
void OnUnchecked(Controls::Base* pControl)
{
UnitPrint( L"Checkbox Unchecked (using 'OnUnchecked' event)" );
UnitPrint(L"Checkbox Unchecked (using 'OnUnchecked' event)");
}
void OnCheckChanged( Controls::Base* pControl )
void OnCheckChanged(Controls::Base* pControl)
{
UnitPrint( L"Checkbox CheckChanged (using 'OnCheckChanged' event)" );
UnitPrint(L"Checkbox CheckChanged (using 'OnCheckChanged' event)");
}
};
DEFINE_UNIT_TEST( Checkbox, L"Checkbox" );
DEFINE_UNIT_TEST(Checkbox, L"Checkbox");

View File

@@ -5,54 +5,48 @@ using namespace Gwen;
class ComboBox : public GUnit
{
public:
GWEN_CONTROL_INLINE( ComboBox, GUnit )
public:
GWEN_CONTROL_INLINE(ComboBox, GUnit)
{
{
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox(this);
combo->SetKeyboardInputEnabled(true);
combo->SetPos( 50, 50 );
combo->SetWidth( 200 );
combo->SetPos(50, 50);
combo->SetWidth(200);
combo->AddItem(L"Option One", "one");
combo->AddItem(L"Number Two", "two");
combo->AddItem(L"Door Three", "three");
combo->AddItem(L"Four Legs", "four");
combo->AddItem(L"Five Birds", "five");
combo->AddItem( L"Option One", "one" );
combo->AddItem( L"Number Two", "two" );
combo->AddItem( L"Door Three", "three" );
combo->AddItem( L"Four Legs", "four" );
combo->AddItem( L"Five Birds", "five" );
combo->onSelection.Add( this, &ComboBox::OnComboSelect );
combo->onSelection.Add(this, &ComboBox::OnComboSelect);
}
{
// Empty..
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
combo->SetPos( 50, 80 );
combo->SetWidth( 200 );
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox(this);
combo->SetPos(50, 80);
combo->SetWidth(200);
}
{
// Empty..
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox( this );
combo->SetPos( 50, 110 );
combo->SetWidth( 200 );
Gwen::Controls::ComboBox* combo = new Gwen::Controls::ComboBox(this);
combo->SetPos(50, 110);
combo->SetWidth(200);
for (int i=0; i<500; i++ )
combo->AddItem( L"Lots Of Options" );
for (int i = 0; i < 500; i++)
combo->AddItem(L"Lots Of Options");
}
}
void OnComboSelect( Gwen::Controls::Base* pControl )
void OnComboSelect(Gwen::Controls::Base* pControl)
{
Gwen::Controls::ComboBox* combo = (Gwen::Controls::ComboBox*)pControl;
UnitPrint( Utility::Format( L"Combo Changed: %s", combo->GetSelectedItem()->GetText().c_str() ) );
UnitPrint(Utility::Format(L"Combo Changed: %s", combo->GetSelectedItem()->GetText().c_str()));
}
};
DEFINE_UNIT_TEST( ComboBox, L"ComboBox" );
DEFINE_UNIT_TEST(ComboBox, L"ComboBox");

View File

@@ -7,78 +7,74 @@ using namespace Gwen;
class CrossSplitter : public GUnit
{
public:
GWEN_CONTROL_INLINE( CrossSplitter, GUnit )
public:
GWEN_CONTROL_INLINE(CrossSplitter, GUnit)
{
m_bSplittersVisible = false;
m_iCurZoom = 0;
m_Splitter = new Gwen::Controls::CrossSplitter( this );
m_Splitter = new Gwen::Controls::CrossSplitter(this);
m_Splitter->SetPos(0, 0);
m_Splitter->Dock( Pos::Fill );
m_Splitter->Dock(Pos::Fill);
{
Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter );
testButton->SetText( "TOPLEFT");
m_Splitter->SetPanel( 0, testButton );
Gwen::Controls::Button* testButton = new Gwen::Controls::Button(m_Splitter);
testButton->SetText("TOPLEFT");
m_Splitter->SetPanel(0, testButton);
}
{
Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter );
testButton->SetText( "TOPRIGHT");
m_Splitter->SetPanel( 1, testButton );
Gwen::Controls::Button* testButton = new Gwen::Controls::Button(m_Splitter);
testButton->SetText("TOPRIGHT");
m_Splitter->SetPanel(1, testButton);
}
{
Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter );
testButton->SetText( "BOTTOMRIGHT");
m_Splitter->SetPanel( 2, testButton );
Gwen::Controls::Button* testButton = new Gwen::Controls::Button(m_Splitter);
testButton->SetText("BOTTOMRIGHT");
m_Splitter->SetPanel(2, testButton);
}
{
Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_Splitter );
testButton->SetText( "BOTTOMLEFT");
m_Splitter->SetPanel( 3, testButton );
Gwen::Controls::Button* testButton = new Gwen::Controls::Button(m_Splitter);
testButton->SetText("BOTTOMLEFT");
m_Splitter->SetPanel(3, testButton);
}
//Status bar to hold unit testing buttons
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar( this );
pStatus->Dock( Pos::Bottom );
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar(this);
pStatus->Dock(Pos::Bottom);
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "Zoom" );
pButton->onPress.Add( this, &CrossSplitter::ZoomTest );
pStatus->AddControl( pButton, false );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("Zoom");
pButton->onPress.Add(this, &CrossSplitter::ZoomTest);
pStatus->AddControl(pButton, false);
}
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "UnZoom" );
pButton->onPress.Add( this, &CrossSplitter::UnZoomTest );
pStatus->AddControl( pButton, false );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("UnZoom");
pButton->onPress.Add(this, &CrossSplitter::UnZoomTest);
pStatus->AddControl(pButton, false);
}
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "CenterPanels" );
pButton->onPress.Add( this, &CrossSplitter::CenterPanels );
pStatus->AddControl( pButton, true );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("CenterPanels");
pButton->onPress.Add(this, &CrossSplitter::CenterPanels);
pStatus->AddControl(pButton, true);
}
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "Splitters" );
pButton->onPress.Add( this, &CrossSplitter::ToggleSplitters );
pStatus->AddControl( pButton, true );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("Splitters");
pButton->onPress.Add(this, &CrossSplitter::ToggleSplitters);
pStatus->AddControl(pButton, true);
}
}
void ZoomTest( Gwen::Controls::Base* pFromPanel )
void ZoomTest(Gwen::Controls::Base* pFromPanel)
{
m_Splitter->Zoom(m_iCurZoom);
m_iCurZoom++;
@@ -86,30 +82,26 @@ class CrossSplitter : public GUnit
m_iCurZoom = 0;
}
void UnZoomTest( Gwen::Controls::Base* pFromPanel )
void UnZoomTest(Gwen::Controls::Base* pFromPanel)
{
m_Splitter->UnZoom();
}
void CenterPanels( Gwen::Controls::Base* pFromPanel )
void CenterPanels(Gwen::Controls::Base* pFromPanel)
{
m_Splitter->CenterPanels();
m_Splitter->UnZoom();
}
void ToggleSplitters( Gwen::Controls::Base* pFromPanel )
void ToggleSplitters(Gwen::Controls::Base* pFromPanel)
{
m_Splitter->SetSplittersVisible( !m_bSplittersVisible );
m_Splitter->SetSplittersVisible(!m_bSplittersVisible);
m_bSplittersVisible = !m_bSplittersVisible;
}
bool m_bSplittersVisible;
int m_iCurZoom;
int m_iCurZoom;
Controls::CrossSplitter* m_Splitter;
};
DEFINE_UNIT_TEST( CrossSplitter, L"CrossSplitter" );
DEFINE_UNIT_TEST(CrossSplitter, L"CrossSplitter");

View File

@@ -5,17 +5,13 @@ using namespace Gwen;
class GroupBox2 : public GUnit
{
public:
GWEN_CONTROL_INLINE( GroupBox2, GUnit )
public:
GWEN_CONTROL_INLINE(GroupBox2, GUnit)
{
Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox( this );
pGroup->Dock( Pos::Fill );
pGroup->SetText( "Group Box" );
Gwen::Controls::GroupBox* pGroup = new Gwen::Controls::GroupBox(this);
pGroup->Dock(Pos::Fill);
pGroup->SetText("Group Box");
}
};
DEFINE_UNIT_TEST( GroupBox2, L"GroupBox" );
DEFINE_UNIT_TEST(GroupBox2, L"GroupBox");

View File

@@ -5,28 +5,23 @@ using namespace Gwen;
class ImagePanel : public GUnit
{
public:
GWEN_CONTROL_INLINE( ImagePanel, GUnit )
public:
GWEN_CONTROL_INLINE(ImagePanel, GUnit)
{
// Normal
{
Controls::ImagePanel* img = new Controls::ImagePanel( this );
img->SetImage( L"gwen.png" );
img->SetBounds( 10, 10, 100, 100 );
Controls::ImagePanel* img = new Controls::ImagePanel(this);
img->SetImage(L"gwen.png");
img->SetBounds(10, 10, 100, 100);
}
// Missing
{
Controls::ImagePanel* img = new Controls::ImagePanel( this );
img->SetImage( L"missingimage.png" );
img->SetBounds( 120, 10, 100, 100 );
Controls::ImagePanel* img = new Controls::ImagePanel(this);
img->SetImage(L"missingimage.png");
img->SetBounds(120, 10, 100, 100);
}
}
};
DEFINE_UNIT_TEST( ImagePanel, L"ImagePanel" );
DEFINE_UNIT_TEST(ImagePanel, L"ImagePanel");

View File

@@ -5,66 +5,65 @@ using namespace Gwen;
class Label : public GUnit
{
public:
GWEN_CONTROL_INLINE( Label, GUnit )
public:
GWEN_CONTROL_INLINE(Label, GUnit)
{
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( "Garry's Normal Label" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText("Garry's Normal Label");
label->SizeToContents();
label->SetPos( 10, 10 );
label->SetPos(10, 10);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Chinese: \u4E45\u6709\u5F52\u5929\u613F \u7EC8\u8FC7\u9B3C\u95E8\u5173");
label->SizeToContents();
label->SetPos( 10, 30 );
label->SetPos(10, 30);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Japanese: \u751F\u3080\u304E\u3000\u751F\u3054\u3081\u3000\u751F\u305F\u307E\u3054");
label->SizeToContents();
label->SetPos( 10, 50 );
label->SetPos(10, 50);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Korean: \uADF9\uC9C0\uD0D0\uD5D8\u3000\uD611\uD68C\uACB0\uC131\u3000\uCCB4\uACC4\uC801\u3000\uC5F0\uAD6C");
label->SizeToContents();
label->SetPos( 10, 70 );
label->SetPos(10, 70);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Hindi: \u092F\u0947 \u0905\u0928\u0941\u091A\u094D\u091B\u0947\u0926 \u0939\u093F\u0928\u094D\u0926\u0940 \u092E\u0947\u0902 \u0939\u0948\u0964");
label->SizeToContents();
label->SetPos( 10, 90 );
label->SetPos(10, 90);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A" );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Arabic: \u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631 \u0627\u0644\u0645\u0624\u062A\u0645\u0631 \u0627\u0644\u062F\u0648\u0644\u064A");
label->SizeToContents();
label->SetPos( 10, 110 );
label->SetPos(10, 110);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Wow, Coloured Text" );
label->SetTextColor( Gwen::Color( 0, 0, 255, 255 ) );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Wow, Coloured Text");
label->SetTextColor(Gwen::Color(0, 0, 255, 255));
label->SizeToContents();
label->SetPos( 10, 130 );
label->SetPos(10, 130);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Coloured Text With Alpha" );
label->SetTextColor( Gwen::Color( 0, 0, 255, 100 ) );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Coloured Text With Alpha");
label->SetTextColor(Gwen::Color(0, 0, 255, 100));
label->SizeToContents();
label->SetPos( 10, 150 );
label->SetPos(10, 150);
}
{
@@ -75,25 +74,22 @@ class Label : public GUnit
m_Font.facename = L"Comic Sans MS";
m_Font.size = 25;
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Custom Font (Comic Sans 25)" );
label->SetFont( &m_Font );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Custom Font (Comic Sans 25)");
label->SetFont(&m_Font);
label->SizeToContents();
label->SetPos( 10, 170 );
label->SetPos(10, 170);
}
{
Gwen::Controls::Label* label = new Gwen::Controls::Label( this );
label->SetText( L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." );
Gwen::Controls::Label* label = new Gwen::Controls::Label(this);
label->SetText(L"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n\nLorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
label->SizeToContents();
label->SetBounds( 300, 10, 150, 500 );
label->SetBounds(300, 10, 150, 500);
}
}
Gwen::Font m_Font;
Gwen::Font m_Font;
};
DEFINE_UNIT_TEST( Label, L"Label" );
DEFINE_UNIT_TEST(Label, L"Label");

View File

@@ -5,67 +5,63 @@ using namespace Gwen;
class ListBox : public GUnit
{
public:
GWEN_CONTROL_INLINE( ListBox, GUnit )
public:
GWEN_CONTROL_INLINE(ListBox, GUnit)
{
{
Gwen::Controls::ListBox* ctrl = new Gwen::Controls::ListBox( this );
ctrl->SetBounds( 10, 10, 100, 200 );
Gwen::Controls::ListBox* ctrl = new Gwen::Controls::ListBox(this);
ctrl->SetBounds(10, 10, 100, 200);
ctrl->AddItem( L"First" );
ctrl->AddItem( L"Blue" );
ctrl->AddItem( L"Yellow" );
ctrl->AddItem( L"Orange" );
ctrl->AddItem( L"Brown" );
ctrl->AddItem( L"Green" );
ctrl->AddItem( L"Dog" );
ctrl->AddItem( L"Cat" );
ctrl->AddItem( L"Shoes" );
ctrl->AddItem( L"Chair" );
ctrl->AddItem( L"Last" );
ctrl->AddItem(L"First");
ctrl->AddItem(L"Blue");
ctrl->AddItem(L"Yellow");
ctrl->AddItem(L"Orange");
ctrl->AddItem(L"Brown");
ctrl->AddItem(L"Green");
ctrl->AddItem(L"Dog");
ctrl->AddItem(L"Cat");
ctrl->AddItem(L"Shoes");
ctrl->AddItem(L"Chair");
ctrl->AddItem(L"Last");
ctrl->onRowSelected.Add( this, &ThisClass::RowSelected );
ctrl->onRowSelected.Add(this, &ThisClass::RowSelected);
}
{
Gwen::Controls::ListBox* ctrl = new Gwen::Controls::ListBox( this );
ctrl->SetBounds( 120, 10, 200, 200 );
ctrl->SetColumnCount( 3 );
ctrl->SetAllowMultiSelect( true );
ctrl->onRowSelected.Add( this, &ThisClass::RowSelected );
Gwen::Controls::ListBox* ctrl = new Gwen::Controls::ListBox(this);
ctrl->SetBounds(120, 10, 200, 200);
ctrl->SetColumnCount(3);
ctrl->SetAllowMultiSelect(true);
ctrl->onRowSelected.Add(this, &ThisClass::RowSelected);
{
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem( L"Baked Beans" );
pRow->SetCellText( 1, L"Heinz" );
pRow->SetCellText( 2, L"£3.50" );
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem(L"Baked Beans");
pRow->SetCellText(1, L"Heinz");
pRow->SetCellText(2, L"£3.50");
}
{
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem( L"Bananas" );
pRow->SetCellText( 1, L"Trees" );
pRow->SetCellText( 2, L"£1.27" );
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem(L"Bananas");
pRow->SetCellText(1, L"Trees");
pRow->SetCellText(2, L"£1.27");
}
{
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem( L"Chicken" );
pRow->SetCellText( 1, L"\u5355\u5143\u6D4B\u8BD5" );
pRow->SetCellText( 2, L"£8.95" );
Gwen::Controls::Layout::TableRow* pRow = ctrl->AddItem(L"Chicken");
pRow->SetCellText(1, L"\u5355\u5143\u6D4B\u8BD5");
pRow->SetCellText(2, L"£8.95");
}
}
}
void RowSelected( Gwen::Controls::Base* pControl )
void RowSelected(Gwen::Controls::Base* pControl)
{
Gwen::Controls::ListBox* ctrl = (Gwen::Controls::ListBox*)pControl;
UnitPrint( Utility::Format( L"Listbox Item Selected: %s", ctrl->GetSelectedRow()->GetText( 0 ).c_str() ) );
UnitPrint(Utility::Format(L"Listbox Item Selected: %s", ctrl->GetSelectedRow()->GetText(0).c_str()));
}
Gwen::Font m_Font;
Gwen::Font m_Font;
};
DEFINE_UNIT_TEST( ListBox, L"ListBox" );
DEFINE_UNIT_TEST(ListBox, L"ListBox");

View File

@@ -5,101 +5,96 @@ using namespace Gwen;
class MenuStrip : public GUnit
{
public:
GWEN_CONTROL_INLINE( MenuStrip, GUnit )
public:
GWEN_CONTROL_INLINE(MenuStrip, GUnit)
{
Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip( this );
Gwen::Controls::MenuStrip* menu = new Gwen::Controls::MenuStrip(this);
{
Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"File" );
pRoot->GetMenu()->AddItem( L"New", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
pRoot->GetMenu()->AddItem( L"Load", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
pRoot->GetMenu()->AddItem( L"Save", GWEN_MCALL( ThisClass::MenuItemSelect ) );
pRoot->GetMenu()->AddItem( L"Save As..", GWEN_MCALL( ThisClass::MenuItemSelect ) );
pRoot->GetMenu()->AddItem( L"Quit", GWEN_MCALL( ThisClass::MenuItemSelect ) );
Gwen::Controls::MenuItem* pRoot = menu->AddItem(L"File");
pRoot->GetMenu()->AddItem(L"New", L"test16.png", GWEN_MCALL(ThisClass::MenuItemSelect));
pRoot->GetMenu()->AddItem(L"Load", L"test16.png", GWEN_MCALL(ThisClass::MenuItemSelect));
pRoot->GetMenu()->AddItem(L"Save", GWEN_MCALL(ThisClass::MenuItemSelect));
pRoot->GetMenu()->AddItem(L"Save As..", GWEN_MCALL(ThisClass::MenuItemSelect));
pRoot->GetMenu()->AddItem(L"Quit", GWEN_MCALL(ThisClass::MenuItemSelect));
}
{
Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E" );
pRoot->GetMenu()->AddItem( L"\u5355\u5143\u6D4B\u8BD5", GWEN_MCALL( ThisClass::MenuItemSelect ) );
pRoot->GetMenu()->AddItem( L"\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", L"test16.png", GWEN_MCALL( ThisClass::MenuItemSelect ) );
Gwen::Controls::MenuItem* pRoot = menu->AddItem(L"\u043F\u0438\u0440\u0430\u0442\u0441\u0442\u0432\u043E");
pRoot->GetMenu()->AddItem(L"\u5355\u5143\u6D4B\u8BD5", GWEN_MCALL(ThisClass::MenuItemSelect));
pRoot->GetMenu()->AddItem(L"\u0111\u01A1n v\u1ECB th\u1EED nghi\u1EC7m", L"test16.png", GWEN_MCALL(ThisClass::MenuItemSelect));
}
{
Gwen::Controls::MenuItem* pRoot = menu->AddItem( L"Submenu" );
Gwen::Controls::MenuItem* pRoot = menu->AddItem(L"Submenu");
pRoot->GetMenu()->AddItem( "One" )->SetCheckable( true );
pRoot->GetMenu()->AddItem("One")->SetCheckable(true);
{
Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem( "Two" );
pRootB->GetMenu()->AddItem( "Two.One" );
pRootB->GetMenu()->AddItem( "Two.Two" );
pRootB->GetMenu()->AddItem( "Two.Three" );
pRootB->GetMenu()->AddItem( "Two.Four" );
pRootB->GetMenu()->AddItem( "Two.Five" );
pRootB->GetMenu()->AddItem( "Two.Six" );
pRootB->GetMenu()->AddItem( "Two.Seven" );
pRootB->GetMenu()->AddItem( "Two.Eight" );
pRootB->GetMenu()->AddItem( "Two.Nine", "test16.png" );
Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem("Two");
pRootB->GetMenu()->AddItem("Two.One");
pRootB->GetMenu()->AddItem("Two.Two");
pRootB->GetMenu()->AddItem("Two.Three");
pRootB->GetMenu()->AddItem("Two.Four");
pRootB->GetMenu()->AddItem("Two.Five");
pRootB->GetMenu()->AddItem("Two.Six");
pRootB->GetMenu()->AddItem("Two.Seven");
pRootB->GetMenu()->AddItem("Two.Eight");
pRootB->GetMenu()->AddItem("Two.Nine", "test16.png");
}
pRoot->GetMenu()->AddItem( "Three" );
pRoot->GetMenu()->AddItem( "Four" );
pRoot->GetMenu()->AddItem( "Five" );
pRoot->GetMenu()->AddItem("Three");
pRoot->GetMenu()->AddItem("Four");
pRoot->GetMenu()->AddItem("Five");
{
Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem( "Six" );
pRootB->GetMenu()->AddItem( "Six.One" );
pRootB->GetMenu()->AddItem( "Six.Two" );
pRootB->GetMenu()->AddItem( "Six.Three" );
pRootB->GetMenu()->AddItem( "Six.Four" );
pRootB->GetMenu()->AddItem( "Six.Five", "test16.png" );
Gwen::Controls::MenuItem* pRootB = pRoot->GetMenu()->AddItem("Six");
pRootB->GetMenu()->AddItem("Six.One");
pRootB->GetMenu()->AddItem("Six.Two");
pRootB->GetMenu()->AddItem("Six.Three");
pRootB->GetMenu()->AddItem("Six.Four");
pRootB->GetMenu()->AddItem("Six.Five", "test16.png");
{
Gwen::Controls::MenuItem* pRootC = pRootB->GetMenu()->AddItem( "Six.Six" );
pRootC->GetMenu()->AddItem( "Sheep" );
pRootC->GetMenu()->AddItem( "Goose" );
Gwen::Controls::MenuItem* pRootC = pRootB->GetMenu()->AddItem("Six.Six");
pRootC->GetMenu()->AddItem("Sheep");
pRootC->GetMenu()->AddItem("Goose");
{
Gwen::Controls::MenuItem* pRootD = pRootC->GetMenu()->AddItem( "Camel" );
pRootD->GetMenu()->AddItem( "Eyes" );
pRootD->GetMenu()->AddItem( "Nose" );
Gwen::Controls::MenuItem* pRootD = pRootC->GetMenu()->AddItem("Camel");
pRootD->GetMenu()->AddItem("Eyes");
pRootD->GetMenu()->AddItem("Nose");
{
Gwen::Controls::MenuItem* pRootE = pRootD->GetMenu()->AddItem( "Hair" );
pRootE->GetMenu()->AddItem( "Blonde" );
pRootE->GetMenu()->AddItem( "Black" );
Gwen::Controls::MenuItem* pRootE = pRootD->GetMenu()->AddItem("Hair");
pRootE->GetMenu()->AddItem("Blonde");
pRootE->GetMenu()->AddItem("Black");
{
Gwen::Controls::MenuItem* pRootF = pRootE->GetMenu()->AddItem( "Red" );
pRootF->GetMenu()->AddItem( "Light" );
pRootF->GetMenu()->AddItem( "Medium" );
pRootF->GetMenu()->AddItem( "Dark" );
Gwen::Controls::MenuItem* pRootF = pRootE->GetMenu()->AddItem("Red");
pRootF->GetMenu()->AddItem("Light");
pRootF->GetMenu()->AddItem("Medium");
pRootF->GetMenu()->AddItem("Dark");
}
pRootE->GetMenu()->AddItem( "Brown" );
pRootE->GetMenu()->AddItem("Brown");
}
pRootD->GetMenu()->AddItem( "Ears" );
pRootD->GetMenu()->AddItem("Ears");
}
pRootC->GetMenu()->AddItem( "Duck" );
pRootC->GetMenu()->AddItem("Duck");
}
pRootB->GetMenu()->AddItem( "Six.Seven" );
pRootB->GetMenu()->AddItem( "Six.Eight" );
pRootB->GetMenu()->AddItem( "Six.Nine" );
pRootB->GetMenu()->AddItem("Six.Seven");
pRootB->GetMenu()->AddItem("Six.Eight");
pRootB->GetMenu()->AddItem("Six.Nine");
}
pRoot->GetMenu()->AddItem( "Seven" );
pRoot->GetMenu()->AddItem("Seven");
}
}
void MenuItemSelect( Base* pControl )
void MenuItemSelect(Base* pControl)
{
Gwen::Controls::MenuItem* pMenuItem = (Gwen::Controls::MenuItem*)pControl;
UnitPrint( Utility::Format( L"Menu Selected: %s", pMenuItem->GetText().c_str() ) );
UnitPrint(Utility::Format(L"Menu Selected: %s", pMenuItem->GetText().c_str()));
}
};
DEFINE_UNIT_TEST( MenuStrip, L"MenuStrip" );
DEFINE_UNIT_TEST(MenuStrip, L"MenuStrip");

View File

@@ -5,27 +5,22 @@ using namespace Gwen;
class Numeric : public GUnit
{
public:
GWEN_CONTROL_INLINE( Numeric, GUnit )
public:
GWEN_CONTROL_INLINE(Numeric, GUnit)
{
Controls::NumericUpDown* pCtrl = new Controls::NumericUpDown( this );
pCtrl->SetBounds( 10, 10, 50, 20 );
pCtrl->SetValue( 50 );
pCtrl->SetMax( 1000 );
pCtrl->SetMin( -1000 );
Controls::NumericUpDown* pCtrl = new Controls::NumericUpDown(this);
pCtrl->SetBounds(10, 10, 50, 20);
pCtrl->SetValue(50);
pCtrl->SetMax(1000);
pCtrl->SetMin(-1000);
// pCtrl->onPress.Add( this, &ThisClass::onButtonA );
}
void onButtonA( Controls::Base* pControl )
void onButtonA(Controls::Base* pControl)
{
// UnitPrint( L"Button Pressed (using 'OnPress' event)" );
// UnitPrint( L"Button Pressed (using 'OnPress' event)" );
}
};
DEFINE_UNIT_TEST( Numeric, L"Numeric" );
DEFINE_UNIT_TEST(Numeric, L"Numeric");

View File

@@ -23,9 +23,9 @@ extern unsigned char OpenSansData[];
#else
//let's cross the fingers it is Linux/X11
#include "OpenGLWindow/X11OpenGLWindow.h"
#endif //_WIN32
#endif//__APPLE__
#endif //B3_USE_GLFW
#endif //_WIN32
#endif //__APPLE__
#endif //B3_USE_GLFW
#include "OpenGLWindow/opengl_fontstashcallbacks.h"
#ifndef NO_OPENGL3
#include "OpenGLWindow/GwenOpenGL3CoreRenderer.h"
@@ -33,24 +33,24 @@ extern unsigned char OpenSansData[];
#endif
#include <assert.h>
Gwen::Controls::Canvas* pCanvas = NULL;
Gwen::Controls::Canvas* pCanvas = NULL;
Gwen::Skin::Simple skin;
void MyMouseMoveCallback( float x, float y)
void MyMouseMoveCallback(float x, float y)
{
//b3DefaultMouseCallback(button,state,x,y);
static int m_lastmousepos[2] = {0,0};
static int m_lastmousepos[2] = {0, 0};
static bool isInitialized = false;
if (pCanvas)
{
if (!isInitialized)
{
isInitialized = true;
m_lastmousepos[0] = x+1;
m_lastmousepos[1] = y+1;
m_lastmousepos[0] = x + 1;
m_lastmousepos[1] = y + 1;
}
bool handled = pCanvas->InputMouseMoved(x,y,m_lastmousepos[0],m_lastmousepos[1]);
bool handled = pCanvas->InputMouseMoved(x, y, m_lastmousepos[0], m_lastmousepos[1]);
}
}
@@ -60,11 +60,11 @@ void MyMouseButtonCallback(int button, int state, float x, float y)
if (pCanvas)
{
bool handled = pCanvas->InputMouseMoved(x,y,x, y);
bool handled = pCanvas->InputMouseMoved(x, y, x, y);
if (button>=0)
if (button >= 0)
{
handled = pCanvas->InputMouseButton(button,state);
handled = pCanvas->InputMouseButton(button, state);
if (handled)
{
if (!state)
@@ -74,13 +74,13 @@ void MyMouseButtonCallback(int button, int state, float x, float y)
}
}
int sWidth = 800;//1050;
int sHeight = 600;//768;
GLPrimitiveRenderer* primRenderer=0;
int sWidth = 800; //1050;
int sHeight = 600; //768;
GLPrimitiveRenderer* primRenderer = 0;
//GwenOpenGL3CoreRenderer* gwenRenderer=0;
Gwen::Renderer::Base* gwenRenderer =0;
Gwen::Renderer::Base* gwenRenderer = 0;
static void MyResizeCallback( float width, float height)
static void MyResizeCallback(float width, float height)
{
sWidth = width;
sHeight = height;
@@ -88,33 +88,31 @@ static void MyResizeCallback( float width, float height)
#ifndef NO_OPENGL3
if (primRenderer)
{
primRenderer->setScreenSize(width,height);
primRenderer->setScreenSize(width, height);
}
#endif
if (gwenRenderer)
{
gwenRenderer->Resize(width,height);
gwenRenderer->Resize(width, height);
}
if (pCanvas)
{
pCanvas->SetSize( sWidth, sHeight);
pCanvas->SetSize(sWidth, sHeight);
}
}
int droidRegular;//, droidItalic, droidBold, droidJapanese, dejavu;
int droidRegular; //, droidItalic, droidBold, droidJapanese, dejavu;
#ifndef NO_OPENGL3
sth_stash* initFont(GLPrimitiveRenderer* primRenderer)
{
GLint err;
struct sth_stash* stash = 0;
OpenGL2RenderCallbacks* renderCallbacks = new OpenGL2RenderCallbacks(primRenderer);
struct sth_stash* stash = 0;
OpenGL2RenderCallbacks* renderCallbacks = new OpenGL2RenderCallbacks(primRenderer);
stash = sth_create(512,512,renderCallbacks);//256,256);//,1024);//512,512);
err = glGetError();
assert(err==GL_NO_ERROR);
stash = sth_create(512, 512, renderCallbacks); //256,256);//,1024);//512,512);
err = glGetError();
assert(err == GL_NO_ERROR);
if (!stash)
{
@@ -122,97 +120,92 @@ sth_stash* initFont(GLPrimitiveRenderer* primRenderer)
return 0;
}
#ifdef LOAD_FONTS_FROM_FILE
int datasize;
int datasize;
unsigned char* data;
float sx,sy,dx,dy,lh;
float sx, sy, dx, dy, lh;
GLuint texture;
const char* fontPaths[] = {
"./",
"../../bin/",
"../bin/",
"bin/"};
const char* fontPaths[]={
"./",
"../../bin/",
"../bin/",
"bin/"
};
int numPaths=sizeof(fontPaths)/sizeof(char*);
int numPaths = sizeof(fontPaths) / sizeof(char*);
// Load the first truetype font from memory (just because we can).
FILE* fp = 0;
const char* fontPath ="./";
const char* fontPath = "./";
char fullFontFileName[1024];
for (int i=0;i<numPaths;i++)
for (int i = 0; i < numPaths; i++)
{
fontPath = fontPaths[i];
//sprintf(fullFontFileName,"%s%s",fontPath,"OpenSans.ttf");//"DroidSerif-Regular.ttf");
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Regular.ttf");//OpenSans.ttf");//"DroidSerif-Regular.ttf");
sprintf(fullFontFileName, "%s%s", fontPath, "DroidSerif-Regular.ttf"); //OpenSans.ttf");//"DroidSerif-Regular.ttf");
fp = fopen(fullFontFileName, "rb");
if (fp)
break;
}
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
assert(fp);
if (fp)
{
fseek(fp, 0, SEEK_END);
datasize = (int)ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (unsigned char*)malloc(datasize);
if (data == NULL)
{
assert(0);
return 0;
}
else
fread(data, 1, datasize, fp);
fclose(fp);
fp = 0;
}
assert(fp);
if (fp)
{
fseek(fp, 0, SEEK_END);
datasize = (int)ftell(fp);
fseek(fp, 0, SEEK_SET);
data = (unsigned char*)malloc(datasize);
if (data == NULL)
{
assert(0);
return 0;
}
else
fread(data, 1, datasize, fp);
fclose(fp);
fp = 0;
}
if (!(droidRegular = sth_add_font_from_memory(stash, data)))
{
assert(0);
return 0;
}
err = glGetError();
assert(err==GL_NO_ERROR);
{
assert(0);
return 0;
}
err = glGetError();
assert(err == GL_NO_ERROR);
// Load the remaining truetype fonts directly.
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Italic.ttf");
sprintf(fullFontFileName, "%s%s", fontPath, "DroidSerif-Italic.ttf");
if (!(droidItalic = sth_add_font(stash,fullFontFileName)))
if (!(droidItalic = sth_add_font(stash, fullFontFileName)))
{
assert(0);
return 0;
}
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSerif-Bold.ttf");
assert(0);
return 0;
}
sprintf(fullFontFileName, "%s%s", fontPath, "DroidSerif-Bold.ttf");
if (!(droidBold = sth_add_font(stash,fullFontFileName)))
if (!(droidBold = sth_add_font(stash, fullFontFileName)))
{
assert(0);
return 0;
}
err = glGetError();
assert(err==GL_NO_ERROR);
assert(0);
return 0;
}
err = glGetError();
assert(err == GL_NO_ERROR);
sprintf(fullFontFileName,"%s%s",fontPath,"DroidSansJapanese.ttf");
if (!(droidJapanese = sth_add_font(stash,fullFontFileName)))
sprintf(fullFontFileName, "%s%s", fontPath, "DroidSansJapanese.ttf");
if (!(droidJapanese = sth_add_font(stash, fullFontFileName)))
{
assert(0);
return 0;
}
assert(0);
return 0;
}
#else
unsigned char* data = OpenSansData;
if (!(droidRegular = sth_add_font_from_memory(stash, data)))
{
printf("error!\n");
@@ -221,88 +214,85 @@ sth_stash* initFont(GLPrimitiveRenderer* primRenderer)
#endif
err = glGetError();
assert(err==GL_NO_ERROR);
assert(err == GL_NO_ERROR);
return stash;
}
#endif
void keyCallback(int key, int value)
{
printf("key = %d, value = %d\n", key,value);
printf("key = %d, value = %d\n", key, value);
//pCanvas->InputKey(key,value==1);
int gwenKey = -1;
switch (key)
{
case B3G_LEFT_ARROW:
case B3G_LEFT_ARROW:
{
gwenKey = Gwen::Key::Left;
break;
}
case B3G_RIGHT_ARROW:
case B3G_RIGHT_ARROW:
{
gwenKey = Gwen::Key::Right;
break;
}
case B3G_UP_ARROW:
case B3G_UP_ARROW:
{
gwenKey = Gwen::Key::Up;
break;
}
case B3G_DOWN_ARROW:
case B3G_DOWN_ARROW:
{
gwenKey = Gwen::Key::Down;
break;
}
case B3G_BACKSPACE:
case B3G_BACKSPACE:
{
gwenKey = Gwen::Key::Backspace;
break;
}
case B3G_DELETE:
case B3G_DELETE:
{
gwenKey = Gwen::Key::Delete;
break;
}
case B3G_HOME:
case B3G_HOME:
{
gwenKey = Gwen::Key::Home;
break;
}
case B3G_END:
case B3G_END:
{
gwenKey = Gwen::Key::End;
break;
}
case B3G_SHIFT:
case B3G_SHIFT:
{
gwenKey = Gwen::Key::Shift;
break;
}
case B3G_CONTROL:
case B3G_CONTROL:
{
gwenKey = Gwen::Key::Control;
break;
}
default:
default:
{
}
};
if (gwenKey>=0)
if (gwenKey >= 0)
{
pCanvas->InputKey(gwenKey,value==1);
} else
pCanvas->InputKey(gwenKey, value == 1);
}
else
{
if (key<256 && value)
if (key < 256 && value)
{
Gwen::UnicodeChar c = ( Gwen::UnicodeChar ) key;
Gwen::UnicodeChar c = (Gwen::UnicodeChar)key;
pCanvas->InputCharacter(c);
}
}
@@ -312,14 +302,13 @@ extern int avoidUpdate;
int main()
{
b3gDefaultOpenGLWindow* window = new b3gDefaultOpenGLWindow();
window->setKeyboardCallback(keyCallback);
b3gWindowConstructionInfo wci;
#ifndef NO_OPENGL3
wci.m_openglVersion = 3;
#else
wci.m_openglVersion = 2;
wci.m_openglVersion = 2;
#endif
wci.m_width = sWidth;
wci.m_height = sHeight;
@@ -327,105 +316,94 @@ int main()
window->createWindow(wci);
window->setResizeCallback(MyResizeCallback);
int majorGlVersion, minorGlVersion;
int majorGlVersion, minorGlVersion;
if (!(sscanf((const char*)glGetString(GL_VERSION), "%d.%d", &majorGlVersion, &minorGlVersion)==2))
{
printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
exit(0);
}
if (!(sscanf((const char*)glGetString(GL_VERSION), "%d.%d", &majorGlVersion, &minorGlVersion) == 2))
{
printf("Exit: Error cannot extract OpenGL version from GL_VERSION string\n");
exit(0);
}
char title[1024];
if (wci.m_openglVersion>2)
if (wci.m_openglVersion > 2)
{
sprintf(title,"Gwen with OpenGL %d.%d\n",majorGlVersion,minorGlVersion);
} else
sprintf(title, "Gwen with OpenGL %d.%d\n", majorGlVersion, minorGlVersion);
}
else
{
sprintf(title,"Gwen with OpenGL %d\n",wci.m_openglVersion);
sprintf(title, "Gwen with OpenGL %d\n", wci.m_openglVersion);
}
window->setWindowTitle(title);
float retinaScale = window->getRetinaScale();
#ifndef NO_OPENGL3
if (majorGlVersion>=3 && wci.m_openglVersion>=3)
{
#ifndef B3_USE_GLFW
if (majorGlVersion >= 3 && wci.m_openglVersion >= 3)
{
#ifndef B3_USE_GLFW
#ifndef __APPLE__
#ifndef _WIN32
//we need glewExperimental on Linux
#endif // _WIN32
//we need glewExperimental on Linux
#endif // _WIN32
gladLoaderLoadGL();
#endif
#endif //B3_USE_GLFW
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
#endif //B3_USE_GLFW \
//we ned to call glGetError twice, because of some Ubuntu/Intel/OpenGL issue
GLuint err = glGetError();
err = glGetError();
assert(err==GL_NO_ERROR);
GLuint err = glGetError();
err = glGetError();
assert(err == GL_NO_ERROR);
primRenderer = new GLPrimitiveRenderer(sWidth, sHeight);
primRenderer = new GLPrimitiveRenderer(sWidth,sHeight);
sth_stash* font = initFont(primRenderer);
sth_stash* font = initFont(primRenderer );
gwenRenderer = new GwenOpenGL3CoreRenderer(primRenderer,font,sWidth,sHeight,retinaScale);
} else
gwenRenderer = new GwenOpenGL3CoreRenderer(primRenderer, font, sWidth, sHeight, retinaScale);
}
else
#endif
{
//OpenGL 2.x
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont(retinaScale);
skin.SetRender( gwenRenderer );
glClearColor(1,0,0,1);
}
{
//OpenGL 2.x
gwenRenderer = new Gwen::Renderer::OpenGL_DebugFont(retinaScale);
skin.SetRender(gwenRenderer);
glClearColor(1, 0, 0, 1);
}
//
// Create a GWEN OpenGL Renderer
//
// Gwen::Renderer::OpenGL_DebugFont * pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
// Gwen::Renderer::OpenGL_DebugFont * pRenderer = new Gwen::Renderer::OpenGL_DebugFont();
//
// Create a GWEN skin
//
#ifdef USE_TEXTURED_SKIN
Gwen::Skin::TexturedBase skin;
skin.SetRender( pRenderer );
skin.SetRender(pRenderer);
skin.Init("DefaultSkin.png");
#else
skin.SetRender( gwenRenderer );
skin.SetRender(gwenRenderer);
#endif
//
// Create a Canvas (it's root, on which all other GWEN panels are created)
//
pCanvas = new Gwen::Controls::Canvas( &skin );
pCanvas->SetSize( sWidth, sHeight);
pCanvas->SetDrawBackground( true );
pCanvas->SetBackgroundColor( Gwen::Color( 150, 170, 170, 255 ) );
pCanvas = new Gwen::Controls::Canvas(&skin);
pCanvas->SetSize(sWidth, sHeight);
pCanvas->SetDrawBackground(true);
pCanvas->SetBackgroundColor(Gwen::Color(150, 170, 170, 255));
window->setMouseButtonCallback(MyMouseButtonCallback);
window->setMouseMoveCallback(MyMouseMoveCallback);
//
// Create our unittest control (which is a Window with controls in it)
//
UnitTest* pUnit = new UnitTest( pCanvas );
pUnit->SetPos( 10, 10 );
UnitTest* pUnit = new UnitTest(pCanvas);
pUnit->SetPos(10, 10);
//
// Create a Windows Control helper
@@ -437,110 +415,101 @@ int main()
//
// Begin the main game loop
//
// MSG msg;
while( !window->requestedExit() )
// MSG msg;
while (!window->requestedExit())
{
if (majorGlVersion<3 || wci.m_openglVersion<3)
{
saveOpenGLState(sWidth,sHeight);
}
if (majorGlVersion < 3 || wci.m_openglVersion < 3)
{
saveOpenGLState(sWidth, sHeight);
}
// Skip out if the window is closed
//if ( !IsWindowVisible( g_pHWND ) )
//break;
//break;
// If we have a message from windows..
// if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
// if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) )
{
// .. give it to the input handler to process
// GwenInput.ProcessMessage( msg );
// GwenInput.ProcessMessage( msg );
// if it's QUIT then quit..
// if ( msg.message == WM_QUIT )
// if ( msg.message == WM_QUIT )
// break;
// Handle the regular window stuff..
// TranslateMessage(&msg);
// DispatchMessage(&msg);
// TranslateMessage(&msg);
// DispatchMessage(&msg);
}
window->startRendering();
// Main OpenGL Render Loop
{
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_BLEND);
GLint err = glGetError();
assert(err==GL_NO_ERROR);
glEnable(GL_BLEND);
GLint err = glGetError();
assert(err == GL_NO_ERROR);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
glDisable(GL_DEPTH_TEST);
err = glGetError();
assert(err==GL_NO_ERROR);
glDisable(GL_DEPTH_TEST);
err = glGetError();
assert(err == GL_NO_ERROR);
//glColor4ub(255,0,0,255);
//glColor4ub(255,0,0,255);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
err = glGetError();
assert(err==GL_NO_ERROR);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
err = glGetError();
assert(err == GL_NO_ERROR);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// saveOpenGLState(width,height);//m_glutScreenWidth,m_glutScreenHeight);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
err = glGetError();
assert(err==GL_NO_ERROR);
glDisable(GL_CULL_FACE);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
err = glGetError();
assert(err == GL_NO_ERROR);
glDisable(GL_DEPTH_TEST);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err==GL_NO_ERROR);
glEnable(GL_BLEND);
err = glGetError();
assert(err==GL_NO_ERROR);
err = glGetError();
assert(err == GL_NO_ERROR);
glEnable(GL_BLEND);
err = glGetError();
assert(err == GL_NO_ERROR);
pCanvas->RenderCanvas();
if (avoidUpdate<=0)
if (avoidUpdate <= 0)
avoidUpdate++;
// SwapBuffers( GetDC( g_pHWND ) );
// SwapBuffers( GetDC( g_pHWND ) );
}
window->endRendering();
if (majorGlVersion<3 || wci.m_openglVersion<3)
{
restoreOpenGLState();
}
if (majorGlVersion < 3 || wci.m_openglVersion < 3)
{
restoreOpenGLState();
}
}
window->closeWindow();
delete window;
}

View File

@@ -7,48 +7,46 @@ using namespace Gwen;
class PanelListPanel : public GUnit
{
public:
GWEN_CONTROL_INLINE( PanelListPanel, GUnit )
public:
GWEN_CONTROL_INLINE(PanelListPanel, GUnit)
{
m_PLP = new Gwen::Controls::PanelListPanel( this );
m_PLP->Dock( Pos::Fill );
m_PLP->SetPadding( Gwen::Padding( 10, 10 ));
m_PLP = new Gwen::Controls::PanelListPanel(this);
m_PLP->Dock(Pos::Fill);
m_PLP->SetPadding(Gwen::Padding(10, 10));
m_PLP->SetVertical();
m_PLP->SetSizeToChildren( false );
m_PLP->SetSizeToChildren(false);
for ( int i = 0; i < 16; i++)
for (int i = 0; i < 16; i++)
{
Gwen::String testName = "TEST" + Utility::ToString( i );
Gwen::Controls::Button* testButton = new Gwen::Controls::Button( m_PLP );
testButton->SetText( testName );
Gwen::String testName = "TEST" + Utility::ToString(i);
Gwen::Controls::Button* testButton = new Gwen::Controls::Button(m_PLP);
testButton->SetText(testName);
}
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar( this );
pStatus->Dock( Pos::Bottom );
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar(this);
pStatus->Dock(Pos::Bottom);
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "Horizontal" );
pButton->onPress.Add( this, &PanelListPanel::GoHorizontal );
pStatus->AddControl( pButton, false );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("Horizontal");
pButton->onPress.Add(this, &PanelListPanel::GoHorizontal);
pStatus->AddControl(pButton, false);
}
{
Gwen::Controls::Button* pButton = new Gwen::Controls::Button( pStatus );
pButton->SetText( "Vertical" );
pButton->onPress.Add( this, &PanelListPanel::GoVertical );
pStatus->AddControl( pButton, true );
Gwen::Controls::Button* pButton = new Gwen::Controls::Button(pStatus);
pButton->SetText("Vertical");
pButton->onPress.Add(this, &PanelListPanel::GoVertical);
pStatus->AddControl(pButton, true);
}
}
void GoVertical( Gwen::Controls::Base* pFromPanel )
void GoVertical(Gwen::Controls::Base* pFromPanel)
{
m_PLP->SetVertical();
}
void GoHorizontal( Gwen::Controls::Base* pFromPanel )
void GoHorizontal(Gwen::Controls::Base* pFromPanel)
{
m_PLP->SetHorizontal();
}
@@ -56,6 +54,4 @@ class PanelListPanel : public GUnit
Gwen::Controls::PanelListPanel* m_PLP;
};
DEFINE_UNIT_TEST( PanelListPanel, L"PanelListPanel" );
DEFINE_UNIT_TEST(PanelListPanel, L"PanelListPanel");

View File

@@ -6,88 +6,82 @@ using namespace Gwen;
class ProgressBar : public GUnit
{
public:
GWEN_CONTROL_INLINE( ProgressBar, GUnit )
public:
GWEN_CONTROL_INLINE(ProgressBar, GUnit)
{
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 20, 200, 20 ) );
pb->SetValue( 0.27f );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 20, 200, 20));
pb->SetValue(0.27f);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 50, 200, 20 ) );
pb->SetValue( 0.66f );
pb->SetAlignment( Pos::Right | Pos::CenterV );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 50, 200, 20));
pb->SetValue(0.66f);
pb->SetAlignment(Pos::Right | Pos::CenterV);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 80, 200, 20 ) );
pb->SetValue( 0.88f );
pb->SetAlignment( Pos::Left | Pos::CenterV );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 80, 200, 20));
pb->SetValue(0.88f);
pb->SetAlignment(Pos::Left | Pos::CenterV);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 110, 200, 20 ) );
pb->SetAutoLabel( false );
pb->SetValue( 0.20f );
pb->SetAlignment( Pos::Right | Pos::CenterV );
pb->SetText( L"40,245 MB" );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 110, 200, 20));
pb->SetAutoLabel(false);
pb->SetValue(0.20f);
pb->SetAlignment(Pos::Right | Pos::CenterV);
pb->SetText(L"40,245 MB");
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 140, 200, 20 ) );
pb->SetAutoLabel( false );
pb->SetValue( 1.00f );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 140, 200, 20));
pb->SetAutoLabel(false);
pb->SetValue(1.00f);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 170, 200, 20 ) );
pb->SetAutoLabel( false );
pb->SetValue( 0.00f );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 170, 200, 20));
pb->SetAutoLabel(false);
pb->SetValue(0.00f);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 110, 200, 200, 20 ) );
pb->SetAutoLabel( false );
pb->SetValue( 0.50f );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(110, 200, 200, 20));
pb->SetAutoLabel(false);
pb->SetValue(0.50f);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 20, 20, 25, 200 ) );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(20, 20, 25, 200));
pb->SetVertical();
pb->SetValue( 0.25f );
pb->SetAlignment( Pos::Top | Pos::CenterH );
pb->SetValue(0.25f);
pb->SetAlignment(Pos::Top | Pos::CenterH);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 50, 20, 25, 200 ) );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(50, 20, 25, 200));
pb->SetVertical();
pb->SetValue( 0.40f );
pb->SetValue(0.40f);
}
{
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar( this );
pb->SetBounds( Gwen::Rect( 80, 20, 25, 200 ) );
Gwen::Controls::ProgressBar* pb = new Gwen::Controls::ProgressBar(this);
pb->SetBounds(Gwen::Rect(80, 20, 25, 200));
pb->SetVertical();
pb->SetAlignment( Pos::Bottom | Pos::CenterH );
pb->SetValue( 0.65f );
pb->SetAlignment(Pos::Bottom | Pos::CenterH);
pb->SetValue(0.65f);
}
}
};
DEFINE_UNIT_TEST( ProgressBar, L"ProgressBar" );
DEFINE_UNIT_TEST(ProgressBar, L"ProgressBar");

View File

@@ -6,58 +6,52 @@ using namespace Gwen;
class Properties2 : public GUnit
{
public:
GWEN_CONTROL_INLINE( Properties2, GUnit )
public:
GWEN_CONTROL_INLINE(Properties2, GUnit)
{
{
Gwen::Controls::Properties* props = new Gwen::Controls::Properties( this );
Gwen::Controls::Properties* props = new Gwen::Controls::Properties(this);
props->SetBounds( 10, 10, 150, 300 );
props->SetBounds(10, 10, 150, 300);
{
{
Gwen::Controls::PropertyRow* pRow = props->Add( L"First Name" );
pRow->onChange.Add( this, &Properties2::OnFirstNameChanged );
Gwen::Controls::PropertyRow* pRow = props->Add(L"First Name");
pRow->onChange.Add(this, &Properties2::OnFirstNameChanged);
}
props->Add( L"Middle Name" );
props->Add( L"Last Name" );
props->Add(L"Middle Name");
props->Add(L"Last Name");
}
}
{
Gwen::Controls::PropertyTree* ptree = new Gwen::Controls::PropertyTree( this );
ptree->SetBounds( 200, 10, 200, 200 );
Gwen::Controls::PropertyTree* ptree = new Gwen::Controls::PropertyTree(this);
ptree->SetBounds(200, 10, 200, 200);
{
Gwen::Controls::Properties* props = ptree->Add( L"Item One" );
props->Add( L"Middle Name" );
props->Add( L"Last Name" );
props->Add( L"Four" );
Gwen::Controls::Properties* props = ptree->Add(L"Item One");
props->Add(L"Middle Name");
props->Add(L"Last Name");
props->Add(L"Four");
}
{
Gwen::Controls::Properties* props = ptree->Add( L"Item Two" );
props->Add( L"More Items" );
props->Add( L"To Fill" );
props->Add( L"Out Here" );
Gwen::Controls::Properties* props = ptree->Add(L"Item Two");
props->Add(L"More Items");
props->Add(L"To Fill");
props->Add(L"Out Here");
}
ptree->ExpandAll();
}
}
void OnFirstNameChanged( Controls::Base* pControl )
void OnFirstNameChanged(Controls::Base* pControl)
{
Gwen::Controls::PropertyRow* pRow = (Gwen::Controls::PropertyRow*) pControl;
UnitPrint( Utility::Format( L"First Name Changed: %s", pRow->GetProperty()->GetPropertyValue().c_str() ) );
Gwen::Controls::PropertyRow* pRow = (Gwen::Controls::PropertyRow*)pControl;
UnitPrint(Utility::Format(L"First Name Changed: %s", pRow->GetProperty()->GetPropertyValue().c_str()));
}
};
DEFINE_UNIT_TEST( Properties2, L"Properties" );
DEFINE_UNIT_TEST(Properties2, L"Properties");

View File

@@ -5,34 +5,28 @@ using namespace Gwen;
class RadioButton2 : public GUnit
{
public:
GWEN_CONTROL_INLINE( RadioButton2, GUnit )
public:
GWEN_CONTROL_INLINE(RadioButton2, GUnit)
{
Gwen::Controls::RadioButtonController* rc = new Gwen::Controls::RadioButtonController(this);
Gwen::Controls::RadioButtonController* rc = new Gwen::Controls::RadioButtonController( this );
rc->AddOption( "Option 1" );
rc->AddOption( "Option 2" );
rc->AddOption( "Option 3" );
rc->AddOption( L"\u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631" );
rc->SetBounds( 30, 30, 200, 200 );
rc->onSelectionChange.Add( this, &RadioButton2::OnChange );
rc->AddOption("Option 1");
rc->AddOption("Option 2");
rc->AddOption("Option 3");
rc->AddOption(L"\u0627\u0644\u0622\u0646 \u0644\u062D\u0636\u0648\u0631");
rc->SetBounds(30, 30, 200, 200);
rc->onSelectionChange.Add(this, &RadioButton2::OnChange);
}
void OnChange( Controls::Base* pControl )
void OnChange(Controls::Base* pControl)
{
Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*) pControl;
Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*)pControl;
Gwen::Controls::LabeledRadioButton* pSelected = rc->GetSelected();
UnitPrint( Utility::Format( L"RadioButton changed (using 'OnChange' event)\n Chosen Item: '%s'", pSelected->GetLabel()->GetText().c_str() ) );
UnitPrint(Utility::Format(L"RadioButton changed (using 'OnChange' event)\n Chosen Item: '%s'", pSelected->GetLabel()->GetText().c_str()));
}
};
DEFINE_UNIT_TEST( RadioButton2, L"RadioButton" );
DEFINE_UNIT_TEST(RadioButton2, L"RadioButton");

View File

@@ -5,134 +5,129 @@ using namespace Gwen;
class ScrollControl : public GUnit
{
public:
GWEN_CONTROL_INLINE( ScrollControl, GUnit )
public:
GWEN_CONTROL_INLINE(ScrollControl, GUnit)
{
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 10, 10, 100, 100 );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(10, 10, 100, 100);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Twice As Big" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Twice As Big");
pTestButton->SetBounds(0, 0, 200, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 110, 10, 100, 100 );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(110, 10, 100, 100);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Same Size" );
pTestButton->SetBounds( 0, 0, 100, 100 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Same Size");
pTestButton->SetBounds(0, 0, 100, 100);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 210, 10, 100, 100 );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(210, 10, 100, 100);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Wide" );
pTestButton->SetBounds( 0, 0, 200, 50 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Wide");
pTestButton->SetBounds(0, 0, 200, 50);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 310, 10, 100, 100 );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(310, 10, 100, 100);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Tall" );
pTestButton->SetBounds( 0, 0, 50, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Tall");
pTestButton->SetBounds(0, 0, 50, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 410, 10, 100, 100 );
pCtrl->SetScroll( false, true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(410, 10, 100, 100);
pCtrl->SetScroll(false, true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Vertical" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Vertical");
pTestButton->SetBounds(0, 0, 200, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 510, 10, 100, 100 );
pCtrl->SetScroll( true, false );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(510, 10, 100, 100);
pCtrl->SetScroll(true, false);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Horinzontal" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Horinzontal");
pTestButton->SetBounds(0, 0, 200, 200);
}
// Bottom Row
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 10, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(10, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Twice As Big" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Twice As Big");
pTestButton->SetBounds(0, 0, 200, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 110, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(110, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Same Size" );
pTestButton->SetBounds( 0, 0, 100, 100 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Same Size");
pTestButton->SetBounds(0, 0, 100, 100);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 210, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(210, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Wide" );
pTestButton->SetBounds( 0, 0, 200, 50 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Wide");
pTestButton->SetBounds(0, 0, 200, 50);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 310, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(310, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Tall" );
pTestButton->SetBounds( 0, 0, 50, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Tall");
pTestButton->SetBounds(0, 0, 50, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 410, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
pCtrl->SetScroll( false, true );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(410, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
pCtrl->SetScroll(false, true);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Vertical" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Vertical");
pTestButton->SetBounds(0, 0, 200, 200);
}
{
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl( this );
pCtrl->SetBounds( 510, 110, 100, 100 );
pCtrl->SetAutoHideBars( true );
pCtrl->SetScroll( true, false );
Gwen::Controls::ScrollControl* pCtrl = new Gwen::Controls::ScrollControl(this);
pCtrl->SetBounds(510, 110, 100, 100);
pCtrl->SetAutoHideBars(true);
pCtrl->SetScroll(true, false);
Controls::Button* pTestButton = new Controls::Button( pCtrl );
pTestButton->SetText( L"Horinzontal" );
pTestButton->SetBounds( 0, 0, 200, 200 );
Controls::Button* pTestButton = new Controls::Button(pCtrl);
pTestButton->SetText(L"Horinzontal");
pTestButton->SetBounds(0, 0, 200, 200);
}
}
};
DEFINE_UNIT_TEST( ScrollControl, L"Scroll" );
DEFINE_UNIT_TEST(ScrollControl, L"Scroll");

View File

@@ -7,60 +7,56 @@ using namespace Gwen;
class Slider : public GUnit
{
public:
GWEN_CONTROL_INLINE( Slider, GUnit )
public:
GWEN_CONTROL_INLINE(Slider, GUnit)
{
{
Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( this );
pSlider->SetPos( 10, 10 );
pSlider->SetSize( 150, 20 );
pSlider->SetRange( 0, 100 );
pSlider->SetValue( 25 );
pSlider->onValueChanged.Add( this, &Slider::SliderMoved );
Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider(this);
pSlider->SetPos(10, 10);
pSlider->SetSize(150, 20);
pSlider->SetRange(0, 100);
pSlider->SetValue(25);
pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
}
{
Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider( this );
pSlider->SetPos( 10, 40 );
pSlider->SetSize( 150, 20 );
pSlider->SetRange( 0, 100 );
pSlider->SetValue( 25 );
pSlider->SetNotchCount( 10 );
pSlider->SetClampToNotches( true );
pSlider->onValueChanged.Add( this, &Slider::SliderMoved );
Gwen::Controls::HorizontalSlider* pSlider = new Gwen::Controls::HorizontalSlider(this);
pSlider->SetPos(10, 40);
pSlider->SetSize(150, 20);
pSlider->SetRange(0, 100);
pSlider->SetValue(25);
pSlider->SetNotchCount(10);
pSlider->SetClampToNotches(true);
pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
}
{
Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider( this );
pSlider->SetPos( 160, 10 );
pSlider->SetSize( 20, 200 );
pSlider->SetRange( 0, 100 );
pSlider->SetValue( 25 );
pSlider->onValueChanged.Add( this, &Slider::SliderMoved );
Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider(this);
pSlider->SetPos(160, 10);
pSlider->SetSize(20, 200);
pSlider->SetRange(0, 100);
pSlider->SetValue(25);
pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
}
{
Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider( this );
pSlider->SetPos( 190, 10 );
pSlider->SetSize( 20, 200 );
pSlider->SetRange( 0, 100 );
pSlider->SetValue( 25 );
pSlider->SetNotchCount( 10 );
pSlider->SetClampToNotches( true );
pSlider->onValueChanged.Add( this, &Slider::SliderMoved );
Gwen::Controls::VerticalSlider* pSlider = new Gwen::Controls::VerticalSlider(this);
pSlider->SetPos(190, 10);
pSlider->SetSize(20, 200);
pSlider->SetRange(0, 100);
pSlider->SetValue(25);
pSlider->SetNotchCount(10);
pSlider->SetClampToNotches(true);
pSlider->onValueChanged.Add(this, &Slider::SliderMoved);
}
}
void SliderMoved( Base* pControl )
void SliderMoved(Base* pControl)
{
Gwen::Controls::Slider* pSlider = (Gwen::Controls::Slider*)pControl;
UnitPrint( Utility::Format( L"Slider Value: %.2f", pSlider->GetValue() ) );
UnitPrint(Utility::Format(L"Slider Value: %.2f", pSlider->GetValue()));
}
};
DEFINE_UNIT_TEST( Slider, L"Slider" );
DEFINE_UNIT_TEST(Slider, L"Slider");

View File

@@ -6,23 +6,20 @@ using namespace Gwen;
class StatusBar : public GUnit
{
public:
GWEN_CONTROL_INLINE( StatusBar, GUnit )
public:
GWEN_CONTROL_INLINE(StatusBar, GUnit)
{
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar( this );
pStatus->Dock( Pos::Bottom );
Gwen::Controls::StatusBar* pStatus = new Gwen::Controls::StatusBar(this);
pStatus->Dock(Pos::Bottom);
Gwen::Controls::Label* pLeft = new Gwen::Controls::Label( pStatus );
Gwen::Controls::Label* pLeft = new Gwen::Controls::Label(pStatus);
pLeft->SetText(L"Label Added to left");
pStatus->AddControl( pLeft, false );
pStatus->AddControl(pLeft, false);
Gwen::Controls::Label* pRight = new Gwen::Controls::Label( pStatus );
Gwen::Controls::Label* pRight = new Gwen::Controls::Label(pStatus);
pRight->SetText(L"Label Added to Right");
pStatus->AddControl( pRight, true );
pStatus->AddControl(pRight, true);
}
};
DEFINE_UNIT_TEST( StatusBar, L"StatusBar" );
DEFINE_UNIT_TEST(StatusBar, L"StatusBar");

View File

@@ -6,66 +6,62 @@ using namespace Gwen;
class TabControl2 : public GUnit
{
public:
public:
Controls::TabControl* m_pDockControlLeft;
GWEN_CONTROL_INLINE( TabControl2, GUnit )
GWEN_CONTROL_INLINE(TabControl2, GUnit)
{
{
m_pDockControlLeft = new Controls::TabControl( this );
m_pDockControlLeft->SetBounds( 10, 10, 200, 200 );
m_pDockControlLeft = new Controls::TabControl(this);
m_pDockControlLeft->SetBounds(10, 10, 200, 200);
{
Controls::TabButton* pButton = m_pDockControlLeft->AddPage( L"Controls" );
Controls::TabButton* pButton = m_pDockControlLeft->AddPage(L"Controls");
Base* pPage = pButton->GetPage();
{
Controls::RadioButtonController* pRadio = new Controls::RadioButtonController( pPage );
pRadio->SetBounds( 10, 10, 100, 100 );
Controls::RadioButtonController* pRadio = new Controls::RadioButtonController(pPage);
pRadio->SetBounds(10, 10, 100, 100);
pRadio->AddOption( "Top" )->Select();
pRadio->AddOption( "Bottom" );
pRadio->AddOption( "Left" );
pRadio->AddOption( "Right" );
pRadio->onSelectionChange.Add( this, &ThisClass::OnDockChange );
pRadio->AddOption("Top")->Select();
pRadio->AddOption("Bottom");
pRadio->AddOption("Left");
pRadio->AddOption("Right");
pRadio->onSelectionChange.Add(this, &ThisClass::OnDockChange);
}
}
m_pDockControlLeft->AddPage( L"Red" );
m_pDockControlLeft->AddPage( L"Green" );
m_pDockControlLeft->AddPage( L"Blue" );
m_pDockControlLeft->AddPage(L"Red");
m_pDockControlLeft->AddPage(L"Green");
m_pDockControlLeft->AddPage(L"Blue");
}
{
Controls::TabControl* pDragMe = new Controls::TabControl( this );
pDragMe->SetBounds( 220, 10, 200, 200 );
Controls::TabControl* pDragMe = new Controls::TabControl(this);
pDragMe->SetBounds(220, 10, 200, 200);
pDragMe->AddPage( L"You" );
pDragMe->AddPage( L"Can" );
pDragMe->AddPage( L"Reorder" )->SetImage( L"test16.png" );
pDragMe->AddPage( L"These" );
pDragMe->AddPage( L"Tabs" );
pDragMe->AddPage(L"You");
pDragMe->AddPage(L"Can");
pDragMe->AddPage(L"Reorder")->SetImage(L"test16.png");
pDragMe->AddPage(L"These");
pDragMe->AddPage(L"Tabs");
pDragMe->SetAllowReorder( true );
pDragMe->SetAllowReorder(true);
}
}
void OnDockChange( Gwen::Controls::Base* pControl )
void OnDockChange(Gwen::Controls::Base* pControl)
{
Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*) pControl;
Gwen::Controls::RadioButtonController* rc = (Gwen::Controls::RadioButtonController*)pControl;
if ( rc->GetSelectedLabel() == L"Top" ) m_pDockControlLeft->SetTabStripPosition( Pos::Top );
if ( rc->GetSelectedLabel() == L"Bottom" ) m_pDockControlLeft->SetTabStripPosition( Pos::Bottom );
if ( rc->GetSelectedLabel() == L"Left" ) m_pDockControlLeft->SetTabStripPosition( Pos::Left );
if ( rc->GetSelectedLabel() == L"Right" ) m_pDockControlLeft->SetTabStripPosition( Pos::Right );
if (rc->GetSelectedLabel() == L"Top") m_pDockControlLeft->SetTabStripPosition(Pos::Top);
if (rc->GetSelectedLabel() == L"Bottom") m_pDockControlLeft->SetTabStripPosition(Pos::Bottom);
if (rc->GetSelectedLabel() == L"Left") m_pDockControlLeft->SetTabStripPosition(Pos::Left);
if (rc->GetSelectedLabel() == L"Right") m_pDockControlLeft->SetTabStripPosition(Pos::Right);
}
Gwen::Font m_Font;
Gwen::Font m_Font;
};
DEFINE_UNIT_TEST( TabControl2, L"TabControl" );
DEFINE_UNIT_TEST(TabControl2, L"TabControl");

View File

@@ -5,75 +5,69 @@ using namespace Gwen;
class TextBox : public GUnit
{
public:
GWEN_CONTROL_INLINE( TextBox, GUnit )
public:
GWEN_CONTROL_INLINE(TextBox, GUnit)
{
{
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox( this );
label->SetText( "" );
label->SetPos( 10, 10 );
label->onTextChanged.Add( this, &ThisClass::OnEdit );
label->onReturnPressed.Add( this, &ThisClass::OnSubmit );
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
label->SetText("");
label->SetPos(10, 10);
label->onTextChanged.Add(this, &ThisClass::OnEdit);
label->onReturnPressed.Add(this, &ThisClass::OnSubmit);
}
{
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox( this );
label->SetText( "Normal Everyday Label" );
label->SetPos( 10, 10 + 25 );
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
label->SetText("Normal Everyday Label");
label->SetPos(10, 10 + 25);
}
{
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox( this );
label->SetText( "Select All Text On Focus" );
label->SetPos( 10, 10 + 25 * 2 );
label->SetSelectAllOnFocus( true );
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
label->SetText("Select All Text On Focus");
label->SetPos(10, 10 + 25 * 2);
label->SetSelectAllOnFocus(true);
}
{
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox( this );
label->SetText( L"Different Coloured Text, for some reason" );
label->SetTextColor( Gwen::Color( 255, 0, 255, 255 ) );
label->SetPos( 10, 10 + 25 * 3 );
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
label->SetText(L"Different Coloured Text, for some reason");
label->SetTextColor(Gwen::Color(255, 0, 255, 255));
label->SetPos(10, 10 + 25 * 3);
}
{
Gwen::Controls::TextBoxNumeric* label = new Gwen::Controls::TextBoxNumeric( this );
label->SetText( L"2004" );
label->SetTextColor( Gwen::Color( 255, 0, 255, 255 ) );
label->SetPos( 10, 10 + 25 * 4 );
Gwen::Controls::TextBoxNumeric* label = new Gwen::Controls::TextBoxNumeric(this);
label->SetText(L"2004");
label->SetTextColor(Gwen::Color(255, 0, 255, 255));
label->SetPos(10, 10 + 25 * 4);
}
{
m_Font.facename = L"Impact";
m_Font.size = 50;
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox( this );
label->SetText( L"Different Font" );
label->SetPos( 10, 10 + 25 * 5 );
label->SetFont( &m_Font );
label->SetSize( 200, 55 );
Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
label->SetText(L"Different Font");
label->SetPos(10, 10 + 25 * 5);
label->SetFont(&m_Font);
label->SetSize(200, 55);
}
}
void OnEdit( Gwen::Controls::Base* pControl )
void OnEdit(Gwen::Controls::Base* pControl)
{
Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*) (pControl);
UnitPrint( Utility::Format( L"Textbox Edit: [%s]\n", textbox->GetText().c_str() ) );
Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*)(pControl);
UnitPrint(Utility::Format(L"Textbox Edit: [%s]\n", textbox->GetText().c_str()));
}
void OnSubmit( Gwen::Controls::Base* pControl )
void OnSubmit(Gwen::Controls::Base* pControl)
{
Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*) (pControl);
UnitPrint( Utility::Format( L"Textbox Submit: [%s]\n", textbox->GetText().c_str() ) );
Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*)(pControl);
UnitPrint(Utility::Format(L"Textbox Submit: [%s]\n", textbox->GetText().c_str()));
}
Gwen::Font m_Font;
Gwen::Font m_Font;
};
DEFINE_UNIT_TEST( TextBox, L"TextBox" );
DEFINE_UNIT_TEST(TextBox, L"TextBox");

View File

@@ -5,57 +5,52 @@ using namespace Gwen;
using namespace Gwen::Controls;
class TreeControl2 : public GUnit
{
public:
GWEN_CONTROL_INLINE( TreeControl2, GUnit )
public:
GWEN_CONTROL_INLINE(TreeControl2, GUnit)
{
{
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl( this );
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(this);
ctrl->SetKeyboardInputEnabled(true);
ctrl->AddNode( L"Node One" );
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
ctrl->AddNode(L"Node One");
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
pNode->SetSelected(true);
pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
ctrl->AddNode( L"Node Three" );
pNode->AddNode(L"Brown")->AddNode(L"Node Two Inside")->AddNode(L"Eyes")->AddNode(L"Brown");
ctrl->AddNode(L"Node Three");
ctrl->Focus();
ctrl->SetKeyboardInputEnabled(true);
ctrl->SetBounds( 30, 30, 200, 200 );
ctrl->SetBounds(30, 30, 200, 200);
ctrl->ExpandAll();
}
{
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl( this );
Gwen::Controls::TreeControl* ctrl = new Gwen::Controls::TreeControl(this);
ctrl->AllowMultiSelect( true );
ctrl->AllowMultiSelect(true);
ctrl->AddNode( L"Node One" );
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
Gwen::Controls::TreeNode* pNodeTwo = pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" );
pNodeTwo->AddNode( L"Brown" );
pNodeTwo->AddNode( L"Green" );
pNodeTwo->AddNode( L"Slime" );
pNodeTwo->AddNode( L"Grass" );
pNodeTwo->AddNode( L"Pipe" );
ctrl->AddNode(L"Node One");
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
Gwen::Controls::TreeNode* pNodeTwo = pNode->AddNode(L"Brown")->AddNode(L"Node Two Inside")->AddNode(L"Eyes");
pNodeTwo->AddNode(L"Brown");
pNodeTwo->AddNode(L"Green");
pNodeTwo->AddNode(L"Slime");
pNodeTwo->AddNode(L"Grass");
pNodeTwo->AddNode(L"Pipe");
ctrl->AddNode( L"Node Three" );
ctrl->AddNode(L"Node Three");
ctrl->SetBounds( 240, 30, 200, 200 );
ctrl->SetBounds(240, 30, 200, 200);
ctrl->ExpandAll();
}
}
};
DEFINE_UNIT_TEST( TreeControl2, L"TreeControl" );
DEFINE_UNIT_TEST(TreeControl2, L"TreeControl");

View File

@@ -10,170 +10,153 @@
using namespace Gwen;
#define ADD_UNIT_TEST( name )\
GUnit* RegisterUnitTest_##name( Gwen::Controls::TabControl* tab );\
RegisterUnitTest_##name( m_TabControl )->SetUnitTest( this );
#define ADD_UNIT_TEST(name) \
GUnit* RegisterUnitTest_##name(Gwen::Controls::TabControl* tab); \
RegisterUnitTest_##name(m_TabControl)->SetUnitTest(this);
GWEN_CONTROL_CONSTRUCTOR( UnitTest )
GWEN_CONTROL_CONSTRUCTOR(UnitTest)
{
SetTitle( L"GWEN Unit Test" );
SetTitle(L"GWEN Unit Test");
SetSize( 600, 450 );
SetSize(600, 450);
m_TabControl = new Controls::TabControl(this);
m_TabControl->Dock(Pos::Fill);
m_TabControl->SetMargin(Margin(2, 2, 2, 2));
m_TabControl = new Controls::TabControl( this );
m_TabControl->Dock( Pos::Fill );
m_TabControl->SetMargin( Margin( 2, 2, 2, 2 ) );
m_TextOutput = new Controls::ListBox(this);
m_TextOutput->Dock(Pos::Bottom);
m_TextOutput->SetHeight(100);
m_TextOutput = new Controls::ListBox( this );
m_TextOutput->Dock( Pos::Bottom );
m_TextOutput->SetHeight( 100 );
ADD_UNIT_TEST( ImagePanel );
ADD_UNIT_TEST(ImagePanel);
//ADD_UNIT_TEST( MenuStrip );
Gwen::UnicodeString str1(L"testje");
Gwen::Controls::TabButton* tab = m_TabControl->AddPage(str1);
Gwen::Controls::TreeControl* ctrl=0;
Gwen::Controls::TreeControl* ctrl = 0;
{
ctrl = new Gwen::Controls::TreeControl(tab->GetPage());
ctrl = new Gwen::Controls::TreeControl(tab->GetPage());
ctrl->SetKeyboardInputEnabled(true);
ctrl->AddNode( L"Node One" );
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode( L"Node Two" );
pNode->AddNode( L"Node Two Inside" );
pNode->AddNode( L"Eyes" );
pNode->SetSelected(true);
pNode->AddNode( L"Brown" )->AddNode( L"Node Two Inside" )->AddNode( L"Eyes" )->AddNode( L"Brown" );
}
ctrl->AddNode( L"Node Three" );
ctrl->Focus();
ctrl->SetKeyboardInputEnabled(true);
ctrl->SetBounds( 30, 30, 200, 30+16*10 );
//ctrl->ExpandAll();
ctrl->ForceUpdateScrollBars();
ctrl->OnKeyDown(true);
ctrl->SetKeyboardInputEnabled(true);
ctrl->AddNode(L"Node One");
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
}
//GUnit* u = new TreeControl2(m_TabControl);..Gwen::Controls::TreeControl2( m_TabControl );
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
}
{
Gwen::Controls::TreeNode* pNode = ctrl->AddNode(L"Node Two");
pNode->AddNode(L"Node Two Inside");
pNode->AddNode(L"Eyes");
pNode->SetSelected(true);
pNode->AddNode(L"Brown")->AddNode(L"Node Two Inside")->AddNode(L"Eyes")->AddNode(L"Brown");
}
ctrl->AddNode(L"Node Three");
ctrl->Focus();
ctrl->SetKeyboardInputEnabled(true);
ctrl->SetBounds(30, 30, 200, 30 + 16 * 10);
//ctrl->ExpandAll();
ctrl->ForceUpdateScrollBars();
ctrl->OnKeyDown(true);
}
//GUnit* u = new TreeControl2(m_TabControl);..Gwen::Controls::TreeControl2( m_TabControl );
//GUnit* RegisterUnitTest_TreeControl2( Gwen::Controls::TabControl* tab );\
//RegisterUnitTest_TreeControl2( m_TabControl )->SetUnitTest( this );
//#define DEFINE_UNIT_TEST( name, displayname )
//#define DEFINE_UNIT_TEST( name, displayname )
//GUnit* RegisterUnitTest_TreeControl2( Gwen::Controls::TabControl* tab )
//{
// GUnit* u = new TreeControl2( tab );
// tab->AddPage( displayname, u );
// return u;
// GUnit* u = new TreeControl2( tab );
// tab->AddPage( displayname, u );
// return u;
//}
//ADD_UNIT_TEST( TreeControl2 );
ADD_UNIT_TEST( Properties2 );
ADD_UNIT_TEST( TabControl2 );
ADD_UNIT_TEST( ScrollControl );
ADD_UNIT_TEST( MenuStrip );
ADD_UNIT_TEST( Numeric );
ADD_UNIT_TEST( ComboBox );
ADD_UNIT_TEST( TextBox );
ADD_UNIT_TEST( ListBox );
ADD_UNIT_TEST( Slider );
ADD_UNIT_TEST( ProgressBar );
ADD_UNIT_TEST( RadioButton2 );
ADD_UNIT_TEST( Label );
ADD_UNIT_TEST( Checkbox );
ADD_UNIT_TEST( Button );
ADD_UNIT_TEST( CrossSplitter );
ADD_UNIT_TEST(Properties2);
ADD_UNIT_TEST( PanelListPanel );
ADD_UNIT_TEST( GroupBox2 );
ADD_UNIT_TEST(TabControl2);
ADD_UNIT_TEST(ScrollControl);
ADD_UNIT_TEST(MenuStrip);
ADD_UNIT_TEST(Numeric);
ADD_UNIT_TEST(ComboBox);
ADD_UNIT_TEST(TextBox);
ADD_UNIT_TEST(ListBox);
ADD_UNIT_TEST(Slider);
ADD_UNIT_TEST(ProgressBar);
ADD_UNIT_TEST(RadioButton2);
ADD_UNIT_TEST( StatusBar );
ADD_UNIT_TEST(Label);
ADD_UNIT_TEST(Checkbox);
ADD_UNIT_TEST(Button);
ADD_UNIT_TEST(CrossSplitter);
ADD_UNIT_TEST(PanelListPanel);
ADD_UNIT_TEST(GroupBox2);
ADD_UNIT_TEST(StatusBar);
ctrl->Focus();
PrintText( L"Unit Test Started.\n" );
PrintText(L"Unit Test Started.\n");
m_fLastSecond = Gwen::Platform::GetTimeInSeconds();
m_iFrames = 0;
}
void UnitTest::PrintText( const Gwen::UnicodeString& str )
void UnitTest::PrintText(const Gwen::UnicodeString& str)
{
m_TextOutput->AddItem( str );
m_TextOutput->AddItem(str);
m_TextOutput->Scroller()->ScrollToBottom();
}
void UnitTest::Render( Gwen::Skin::Base* skin )
void UnitTest::Render(Gwen::Skin::Base* skin)
{
m_iFrames++;
if ( m_fLastSecond < Gwen::Platform::GetTimeInSeconds() )
if (m_fLastSecond < Gwen::Platform::GetTimeInSeconds())
{
SetTitle( Gwen::Utility::Format( L"GWEN Unit Test - %i fps", m_iFrames ) );
SetTitle(Gwen::Utility::Format(L"GWEN Unit Test - %i fps", m_iFrames));
m_fLastSecond = Gwen::Platform::GetTimeInSeconds() + 1.0f;
m_iFrames = 0;
}
BaseClass::Render( skin );
BaseClass::Render(skin);
}
void GUnit::UnitPrint( const Gwen::UnicodeString& str )
void GUnit::UnitPrint(const Gwen::UnicodeString& str)
{
m_pUnitTest->PrintText( str );
m_pUnitTest->PrintText(str);
}
void GUnit::UnitPrint( const Gwen::String& str )
void GUnit::UnitPrint(const Gwen::String& str)
{
UnitPrint( Utility::StringToUnicode( str ) );
UnitPrint(Utility::StringToUnicode(str));
}

View File

@@ -4,7 +4,6 @@
See license in Gwen.h
*/
#pragma once
#ifndef GWEN_UNITTEST_UNITTEST_H
#define GWEN_UNITTEST_UNITTEST_H
@@ -18,47 +17,43 @@
class UnitTest;
class GUnit : public Gwen::Controls::Base
{
public:
public:
GWEN_CONTROL_INLINE(GUnit, Gwen::Controls::Base)
{
m_pUnitTest = NULL;
}
GWEN_CONTROL_INLINE( GUnit, Gwen::Controls::Base )
{
m_pUnitTest = NULL;
}
void SetUnitTest(UnitTest* u) { m_pUnitTest = u; }
void SetUnitTest( UnitTest* u ){ m_pUnitTest = u; }
void UnitPrint(const Gwen::UnicodeString& str);
void UnitPrint(const Gwen::String& str);
void UnitPrint( const Gwen::UnicodeString& str );
void UnitPrint( const Gwen::String& str );
UnitTest* m_pUnitTest;
UnitTest* m_pUnitTest;
};
class UnitTest : public Gwen::Controls::WindowControl
{
public:
public:
GWEN_CONTROL(UnitTest, Gwen::Controls::WindowControl);
GWEN_CONTROL( UnitTest, Gwen::Controls::WindowControl );
void PrintText(const Gwen::UnicodeString& str);
void PrintText( const Gwen::UnicodeString& str );
void Render( Gwen::Skin::Base* skin );
private:
Gwen::Controls::TabControl* m_TabControl;
Gwen::Controls::ListBox* m_TextOutput;
unsigned int m_iFrames;
float m_fLastSecond;
void Render(Gwen::Skin::Base* skin);
private:
Gwen::Controls::TabControl* m_TabControl;
Gwen::Controls::ListBox* m_TextOutput;
unsigned int m_iFrames;
float m_fLastSecond;
};
#define DEFINE_UNIT_TEST( name, displayname ) GUnit* RegisterUnitTest_##name( Gwen::Controls::TabControl* tab ){ GUnit* u = new name( tab ); tab->AddPage( displayname, u ); return u; }
#define DEFINE_UNIT_TEST(name, displayname) \
GUnit* RegisterUnitTest_##name(Gwen::Controls::TabControl* tab) \
{ \
GUnit* u = new name(tab); \
tab->AddPage(displayname, u); \
return u; \
}
#endif