mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
46
tutorial/Image04/main.cpp
Normal file
46
tutorial/Image04/main.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct MyApp : public TopWindow {
|
||||
Image img;
|
||||
FileSel fs;
|
||||
|
||||
void Open();
|
||||
|
||||
virtual void Paint(Draw& w);
|
||||
virtual void LeftDown(Point, dword) { Open(); }
|
||||
|
||||
typedef MyApp CLASSNAME;
|
||||
MyApp();
|
||||
};
|
||||
|
||||
MyApp::MyApp()
|
||||
{
|
||||
fs.Type("Image file", "*.bmp;*.png;*.tif;*.tiff;*.jpg;*.jpeg;*.gif");
|
||||
Sizeable();
|
||||
}
|
||||
|
||||
void MyApp::Paint(Draw& w)
|
||||
{
|
||||
w.DrawRect(GetSize(), White);
|
||||
if(img)
|
||||
w.DrawImage(0, 0, img);
|
||||
else
|
||||
w.DrawText(0, 0, "No image loaded!", Arial(30).Italic());
|
||||
}
|
||||
|
||||
void MyApp::Open()
|
||||
{
|
||||
if(fs.ExecuteOpen("Choose the image file to open")) {
|
||||
img = StreamRaster::LoadFileAny(~fs);
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
MyApp app;
|
||||
app.Open();
|
||||
app.Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue