PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
WindowTest.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 49 of file WindowTest.cpp.

50{
51
52 //This sets the video driver
53 setenv("SDL_VIDEODRIVER", "dga",1);
54 setenv("SDL_VIDEODRIVER", "x11",1);
55
56
57
58 //Make a few new colors.
59 cout << "Creating new colors\n";
60 PColor red = PColor("red");
61 PColor grey = PColor("grey");
62 grey.SetAlpha(150);
63
66
67 PlatformWindow * myWindow = new PlatformWindow();
68 myWindow->Initialize();
69 myWindow->SetBackgroundColor(grey);
70
72
73
74 //Add window to environment.
75 myEnv->AddWindow(myWindow);
76
77
78 //Now make an Image Widget.
79 PlatformImageBox * myImage1 = new PlatformImageBox;
80 if(!myImage1->LoadImage("media/images/pebl.bmp"))
81 cout << "Loading image1 failed\n" ;
82
83
84 //Make another image, just for kicks.
85 PlatformImageBox * myImage2 = new PlatformImageBox;
86 if(!myImage2->LoadImage("media/images/pebl.png"))
87 cout << "Loading image2 failed\n" ;
88
89 //Make a font.
90 cout << "Creating a font\n";
91 PlatformFont * myFont1 = new PlatformFont("media/fonts/VeraSe.ttf", PFS_Normal, 22, red, grey, true );
92 PlatformFont * myFont2 = new PlatformFont("media/fonts/VeraSe.ttf", PFS_Normal, 22, red, grey, false );
93
94
95 cout << "Creating PlatformWord object\n";
96 //Now, make a 'word object.
97 PlatformWord * myWord1 = new PlatformWord("Hello World: anti-aliased", myFont1);
98 myWord1->SetPosition(30,30);
99
100 PlatformWord * myWord2 = new PlatformWord("Hello World:aliased", myFont2);
101 myWord2->SetPosition(30,50);
102
103
104
105
106 myWindow->AddSubWidget(myImage1);
107 myWindow->AddSubWidget(myImage2);
108 myWindow->AddSubWidget(myWord1);
109 myWindow->AddSubWidget(myWord2);
110
111
112 myEnv->Draw();
113 myKeyboard->WaitForAnyKeyDown();
114 myKeyboard->WaitForAllKeysUp();
115
116
117 myImage1->SetPosition(10,10);
118 myImage2->SetPosition(10,200);
119 myEnv->Draw();
120 myKeyboard->WaitForAnyKeyDown();
121 myKeyboard->WaitForAllKeysUp();
122
123
124
125 myImage1->SetPosition(100,20);
126 myImage2->SetPosition(100,300);
127 myEnv->Draw();
128 myKeyboard->WaitForAllKeysUp();
129 myKeyboard->WaitForAnyKeyDown();
130
131
132
133 myImage1->SetPosition(200,200);
134 myImage2->SetPosition(200,400);
135 myEnv->Draw();
136 myKeyboard->WaitForAllKeysUp();
137
138 myKeyboard->WaitForAnyKeyDown();
139
140
141 for(int i= 0; i<500;i+=10){
142 myImage1->SetPosition(i,400);
143 myEnv->Draw();
144 }
145
146
147 myKeyboard->WaitForAllKeysUp();
148 myKeyboard->WaitForAnyKeyDown();
149 cout << "Done\n";
150
151
152 delete myImage1, myImage2;
153 delete myWindow;
154 delete myEnv;
155
156 return 0;
157}
PlatformEnvironment * myEnv
Definition PEBL.cpp:189
@ PFS_Normal
Definition PFont.h:45
void SetAlpha(int color)
Definition PColor.cpp:218
virtual bool AddWindow(PWindow *window)
virtual void SetPosition(pInt x, pInt y)
Definition PImageBox.cpp:44
void Initialize()
This method initiates everything needed to display the main window.
Validator platform image box - no image loading, used only for compilation.
virtual bool LoadImage(const std::string &imagefilename)
virtual bool AddSubWidget(PlatformWidget *widget)
bool Initialize(PEBLVideoMode mode, PEBLVideoDepth vdepth, bool windowed, bool resizeable, unsigned int width, unsigned int height)
This method initiates everything needed to display the main window.
virtual void SetBackgroundColor(const PColor &color)
PlatformKeyboard myKeyboard

References PlatformWidget::AddSubWidget(), PEnvironment::AddWindow(), PlatformEnvironment::Draw(), PlatformEnvironment::Initialize(), PlatformWindow::Initialize(), PlatformImageBox::LoadImage(), myEnv, PFS_Normal, PColor::SetAlpha(), PlatformWindow::SetBackgroundColor(), and PImageBox::SetPosition().