From 1e8cb5827d57ecfe18bf5c341b92d60e98c5637c Mon Sep 17 00:00:00 2001 From: LaurentGom Date: Tue, 16 Jun 2009 20:17:56 +0000 Subject: [PATCH] Minor updates to VC2008 project files Better preprocessor detection of FreeBSD OS Improved the Qt sample git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1143 4e206d99-4929-0410-ac5d-dfc041789085 --- build/vc2008/SFML.sln | 26 ++++++++++++++++- build/vc2008/sfml-audio.vcproj | 2 +- include/SFML/Config.hpp | 2 +- samples/build/vc2008/ftp.vcproj | 4 +-- samples/build/vc2008/opengl.vcproj | 4 +-- samples/build/vc2008/pong.vcproj | 4 +-- samples/build/vc2008/postfx.vcproj | 4 +-- samples/build/vc2008/qt.vcproj | 4 +-- samples/build/vc2008/sockets.vcproj | 4 +-- samples/build/vc2008/sound-capture.vcproj | 4 +-- samples/build/vc2008/sound.vcproj | 4 +-- samples/build/vc2008/voip.vcproj | 4 +-- samples/build/vc2008/win32.vcproj | 4 +-- samples/build/vc2008/window.vcproj | 4 +-- samples/build/vc2008/wxwidgets.vcproj | 4 +-- samples/qt/Main.cpp | 34 ++++++++++++++--------- samples/qt/QSFMLCanvas.cpp | 26 ++++++++--------- samples/qt/QSFMLCanvas.hpp | 23 +++++++-------- samples/wxwidgets/Main.cpp | 7 +---- 19 files changed, 98 insertions(+), 70 deletions(-) diff --git a/build/vc2008/SFML.sln b/build/vc2008/SFML.sln index 5831fd3a..58c8d657 100644 --- a/build/vc2008/SFML.sln +++ b/build/vc2008/SFML.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sfml-audio", "sfml-audio.vcproj", "{B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2}" ProjectSection(ProjectDependencies) = postProject {C061A27D-7CA0-4179-9869-672FA04A86A8} = {C061A27D-7CA0-4179-9869-672FA04A86A8} @@ -108,6 +108,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxwidgets", "..\..\samples\ {0F9CE5F0-4D89-4314-9147-8AAB1B8842ED} = {0F9CE5F0-4D89-4314-9147-8AAB1B8842ED} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Samples", "Samples", "{4E210688-F375-4A1B-8422-402081DAA460}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SFML", "SFML", "{5DDF255F-A4D9-4E41-9315-3FB69F8021E4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug DLL|Win32 = Debug DLL|Win32 @@ -338,4 +342,24 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {7236920B-254C-43A3-9DC1-778B477226DF} = {4E210688-F375-4A1B-8422-402081DAA460} + {EAB1A0A4-8CCC-4A74-B3B5-9F60243581D2} = {4E210688-F375-4A1B-8422-402081DAA460} + {4CD9A872-16EF-4C53-81FC-C7E77E782718} = {4E210688-F375-4A1B-8422-402081DAA460} + {DDDE27DC-5568-43EE-BD0E-57C581F73EDE} = {4E210688-F375-4A1B-8422-402081DAA460} + {E8B7727D-2308-4ADC-90AE-D3F46798447D} = {4E210688-F375-4A1B-8422-402081DAA460} + {E6ED898F-218E-4467-8B1D-92E393283E1B} = {4E210688-F375-4A1B-8422-402081DAA460} + {8B3B274A-B3B7-4C6B-8D4A-5334E2116830} = {4E210688-F375-4A1B-8422-402081DAA460} + {11E3764D-850E-4EDA-9823-F66383A11042} = {4E210688-F375-4A1B-8422-402081DAA460} + {34EBDA13-AFA3-4AD9-AB64-2B2D40E09573} = {4E210688-F375-4A1B-8422-402081DAA460} + {4B169017-FFDD-4588-9658-6F1C9ABC6495} = {4E210688-F375-4A1B-8422-402081DAA460} + {303EC049-639D-4F9C-9F33-D4B7F702275B} = {4E210688-F375-4A1B-8422-402081DAA460} + {11E9ABEF-17A5-4FF7-91E5-994F34172F68} = {4E210688-F375-4A1B-8422-402081DAA460} + {B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + {0F9CE5F0-4D89-4314-9147-8AAB1B8842ED} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + {FA4620B1-393A-4719-9BB4-3BC8CAA70C4B} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + {2BD26A09-E1B6-42E2-A0D0-63987B76BB97} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + {823DDC98-42D5-4A38-88CF-9DC06C788AE4} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + {C061A27D-7CA0-4179-9869-672FA04A86A8} = {5DDF255F-A4D9-4E41-9315-3FB69F8021E4} + EndGlobalSection EndGlobal diff --git a/build/vc2008/sfml-audio.vcproj b/build/vc2008/sfml-audio.vcproj index ffad02ee..0260f5be 100644 --- a/build/vc2008/sfml-audio.vcproj +++ b/build/vc2008/sfml-audio.vcproj @@ -406,7 +406,7 @@ > @@ -129,7 +129,7 @@ RuntimeLibrary="2" UsePrecompiledHeader="0" WarningLevel="3" - Detect64BitPortabilityProblems="true" + Detect64BitPortabilityProblems="false" DebugInformationFormat="0" DisableSpecificWarnings="4311;4312" /> diff --git a/samples/build/vc2008/sockets.vcproj b/samples/build/vc2008/sockets.vcproj index 9c3f91e7..40487d22 100644 --- a/samples/build/vc2008/sockets.vcproj +++ b/samples/build/vc2008/sockets.vcproj @@ -49,7 +49,7 @@ RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="4" - Detect64BitPortabilityProblems="true" + Detect64BitPortabilityProblems="false" DebugInformationFormat="4" /> -#include -#include -#include +#include +#include +#include +#include //////////////////////////////////////////////////////////// @@ -20,8 +20,8 @@ public : /// Construct the canvas /// //////////////////////////////////////////////////////////// - MyCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size) : - QSFMLCanvas(Parent, Position, Size) + MyCanvas(QWidget* Parent = NULL) : + QSFMLCanvas(QSize(100, 100), 0, Parent) { } @@ -54,8 +54,13 @@ private : // Stick the sprite to the mouse cursor if (Event.Type == sf::Event::MouseMoved) { - mySprite.SetX(Event.MouseMove.X); - mySprite.SetY(Event.MouseMove.Y); + mySprite.SetPosition(ConvertCoords(Event.MouseMove.X, Event.MouseMove.Y)); + } + + // Adjust the size of the default view when the widget is resized + if (Event.Type == sf::Event::Resized) + { + GetDefaultView().SetHalfSize(Event.Size.Width / 2.f, Event.Size.Height / 2.f); } } @@ -95,13 +100,16 @@ int main(int argc, char **argv) // Create a label for showing some text QLabel* Label = new QLabel("This is a SFML window\nembedded into a Qt frame :", MainFrame); - Label->move(20, 10); Label->setFont(QFont("courier new", 14, 1, false)); - Label->show(); // Create a SFML view inside the main frame - MyCanvas* SFMLView = new MyCanvas(MainFrame, QPoint(20, 60), QSize(360, 320)); - SFMLView->show(); - + MyCanvas* SFMLView = new MyCanvas(MainFrame); + + // Create the main layout + QVBoxLayout* Layout = new QVBoxLayout; + Layout->addWidget(Label, 0); + Layout->addWidget(SFMLView, 1); + MainFrame->setLayout(Layout); + return App.exec(); } diff --git a/samples/qt/QSFMLCanvas.cpp b/samples/qt/QSFMLCanvas.cpp index f4302ee2..2f75566c 100644 --- a/samples/qt/QSFMLCanvas.cpp +++ b/samples/qt/QSFMLCanvas.cpp @@ -3,6 +3,7 @@ // Headers //////////////////////////////////////////////////////////// #include "QSFMLCanvas.hpp" +#include // Platform-specific headers #ifdef Q_WS_X11 @@ -14,10 +15,12 @@ //////////////////////////////////////////////////////////// /// Construct the QSFMLCanvas //////////////////////////////////////////////////////////// -QSFMLCanvas::QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime) : -QWidget (Parent), -myInitialized (false) +QSFMLCanvas::QSFMLCanvas(const QSize& Size, unsigned int FrameTime, QWidget* Parent) : +QWidget(Parent) { + // Resize the widget + resize(Size); + // Setup some states to allow direct rendering into the widget setAttribute(Qt::WA_PaintOnScreen); setAttribute(Qt::WA_OpaquePaintEvent); @@ -26,10 +29,6 @@ myInitialized (false) // Set strong focus to enable keyboard events to be received setFocusPolicy(Qt::StrongFocus); - // Setup the widget geometry - move(Position); - resize(Size); - // Setup the timer myTimer.setInterval(FrameTime); } @@ -74,12 +73,13 @@ QPaintEngine* QSFMLCanvas::paintEngine() const //////////////////////////////////////////////////////////// -/// Called when the widget is shown ; -/// we use it to initialize our SFML window +/// Called each time an event is received by the widget ; +/// we use it to catch the Polish event and initialize +/// our SFML window //////////////////////////////////////////////////////////// -void QSFMLCanvas::showEvent(QShowEvent*) +bool QSFMLCanvas::event(QEvent* Event) { - if (!myInitialized) + if (Event->type() == QEvent::Polish) { // Under X11, we need to flush the commands sent to the server to ensure that // SFML will get an updated view of the windows @@ -96,9 +96,9 @@ void QSFMLCanvas::showEvent(QShowEvent*) // Setup the timer to trigger a refresh at specified framerate connect(&myTimer, SIGNAL(timeout()), this, SLOT(repaint())); myTimer.start(); - - myInitialized = true; } + + return QWidget::event(Event); } diff --git a/samples/qt/QSFMLCanvas.hpp b/samples/qt/QSFMLCanvas.hpp index e02f0263..22a58ea5 100644 --- a/samples/qt/QSFMLCanvas.hpp +++ b/samples/qt/QSFMLCanvas.hpp @@ -6,10 +6,12 @@ // Headers //////////////////////////////////////////////////////////// #include -#include -#include +#include +#include +class QEvent; + //////////////////////////////////////////////////////////// /// QSFMLCanvas allows to run SFML in a Qt control //////////////////////////////////////////////////////////// @@ -20,13 +22,12 @@ public : //////////////////////////////////////////////////////////// /// Construct the QSFMLCanvas /// - /// \param Parent : Parent of the widget - /// \param Position : Position of the widget - /// \param Size : Size of the widget + /// \param Size : Initial size of the widget /// \param FrameTime : Frame duration, in milliseconds (0 by default) + /// \param Parent : Parent of the widget (NULL by default) /// //////////////////////////////////////////////////////////// - QSFMLCanvas(QWidget* Parent, const QPoint& Position, const QSize& Size, unsigned int FrameTime = 0); + QSFMLCanvas(const QSize& Size, unsigned int FrameTime = 0, QWidget* Parent = NULL); //////////////////////////////////////////////////////////// /// Destructor @@ -57,11 +58,12 @@ private : virtual QPaintEngine* paintEngine() const; //////////////////////////////////////////////////////////// - /// Called when the widget is shown ; - /// we use it to initialize our SFML window + /// Called each time an event is received by the widget ; + /// we use it to catch the Polish event and initialize + /// our SFML window /// //////////////////////////////////////////////////////////// - virtual void showEvent(QShowEvent*); + virtual bool event(QEvent* Event); //////////////////////////////////////////////////////////// /// Called when the widget needs to be painted ; @@ -73,8 +75,7 @@ private : //////////////////////////////////////////////////////////// // Member data //////////////////////////////////////////////////////////// - QTimer myTimer; ///< Timer used to update the view - bool myInitialized; ///< Tell whether the SFML window has been initialized or not + QTimer myTimer; ///< Timer used to update the view }; diff --git a/samples/wxwidgets/Main.cpp b/samples/wxwidgets/Main.cpp index dddc7ed8..1757afb1 100644 --- a/samples/wxwidgets/Main.cpp +++ b/samples/wxwidgets/Main.cpp @@ -79,13 +79,8 @@ public : /// //////////////////////////////////////////////////////////// MyFrame() : - wxFrame(NULL, wxID_ANY, wxT("SFML wxWidgets"), wxDefaultPosition, wxSize(680, 280)) + wxFrame(NULL, wxID_ANY, wxT("SFML wxWidgets"), wxDefaultPosition, wxSize(440, 280)) { - // Error log text box - wxTextCtrl* ErrorLog = new wxTextCtrl(this, wxID_ANY, wxT(""), wxPoint(440, 20), wxSize(200, 200), wxTE_MULTILINE | wxTE_READONLY | wxHSCROLL); - std::cerr.rdbuf(ErrorLog); - std::cerr << "-- This is the error log --" << std::endl; - // Let's create a SFML view new MyCanvas(this, wxID_ANY, wxPoint(20, 20), wxSize(400, 200)); }