diff --git a/build/vc2008/SFML.sln b/build/vc2008/SFML.sln index b7689fc1..fd6efd10 100644 --- a/build/vc2008/SFML.sln +++ b/build/vc2008/SFML.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sfml-audio", "sfml-audio.vcproj", "{B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2}" @@ -343,23 +342,23 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} - {0F9CE5F0-4D89-4314-9147-8AAB1B8842ED} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} {FA4620B1-393A-4719-9BB4-3BC8CAA70C4B} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} {2BD26A09-E1B6-42E2-A0D0-63987B76BB97} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} {823DDC98-42D5-4A38-88CF-9DC06C788AE4} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} {C061A27D-7CA0-4179-9869-672FA04A86A8} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} - {7236920B-254C-43A3-9DC1-778B477226DF} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {0F9CE5F0-4D89-4314-9147-8AAB1B8842ED} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} + {B1BDA469-E6A7-4AF7-BDF9-EDDD7AD979A2} = {8A8AFD7B-453B-40BE-9C46-A5748C1ABA45} {4CD9A872-16EF-4C53-81FC-C7E77E782718} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} {DDDE27DC-5568-43EE-BD0E-57C581F73EDE} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} {E8B7727D-2308-4ADC-90AE-D3F46798447D} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} {EAB1A0A4-8CCC-4A74-B3B5-9F60243581D2} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} {E6ED898F-218E-4467-8B1D-92E393283E1B} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} - {8B3B274A-B3B7-4C6B-8D4A-5334E2116830} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} - {11E9ABEF-17A5-4FF7-91E5-994F34172F68} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} - {303EC049-639D-4F9C-9F33-D4B7F702275B} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} - {4B169017-FFDD-4588-9658-6F1C9ABC6495} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} - {34EBDA13-AFA3-4AD9-AB64-2B2D40E09573} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} {11E3764D-850E-4EDA-9823-F66383A11042} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {34EBDA13-AFA3-4AD9-AB64-2B2D40E09573} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {4B169017-FFDD-4588-9658-6F1C9ABC6495} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {303EC049-639D-4F9C-9F33-D4B7F702275B} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {11E9ABEF-17A5-4FF7-91E5-994F34172F68} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {8B3B274A-B3B7-4C6B-8D4A-5334E2116830} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} + {7236920B-254C-43A3-9DC1-778B477226DF} = {BF8295B9-DE13-4CF5-A71F-A345BCA50D68} EndGlobalSection EndGlobal diff --git a/build/vc2008/sfml-audio.vcproj b/build/vc2008/sfml-audio.vcproj index 970eb9a5..df373948 100644 --- a/build/vc2008/sfml-audio.vcproj +++ b/build/vc2008/sfml-audio.vcproj @@ -360,7 +360,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) { } @@ -56,6 +56,12 @@ private : { 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().SetRect(sf::FloatRect(0, 0, Event.Size.Width, Event.Size.Height)); + } } // Rotate the sprite @@ -94,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/Makefile b/samples/qt/Makefile index b02aba9b..43d09cdd 100644 --- a/samples/qt/Makefile +++ b/samples/qt/Makefile @@ -7,7 +7,7 @@ qt: $(OBJ) $(CC) $(LDFLAGS) -o $(EXECPATH)/$@ $(OBJ) -lsfml-graphics -lsfml-window -lsfml-system -lQtCore -lQtGui -lX11 %.o: %.cpp - $(CC) -o $@ -c $< $(CFLAGS) -I/usr/include/qt4 + $(CC) -o $@ -c $< $(CFLAGS) -I/usr/include/qt4 -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui .PHONY: clean mrproper 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 ee883209..b9565405 100644 --- a/samples/wxwidgets/Main.cpp +++ b/samples/wxwidgets/Main.cpp @@ -78,13 +78,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)); } diff --git a/src/SFML/Network/Http.cpp b/src/SFML/Network/Http.cpp index af34a345..64793406 100644 --- a/src/SFML/Network/Http.cpp +++ b/src/SFML/Network/Http.cpp @@ -386,6 +386,14 @@ Http::Response Http::SendRequest(const Http::Request& Req, float Timeout) Out << ToSend.myBody.size(); ToSend.SetField("Content-Length", Out.str()); } + if ((ToSend.myMethod == Request::Post) && !ToSend.HasField("Content-Type")) + { + ToSend.SetField("Content-Type", "application/x-www-form-urlencoded"); + } + if ((ToSend.myMajorVersion * 10 + ToSend.myMinorVersion >= 11) && !ToSend.HasField("Connection")) + { + ToSend.SetField("Connection", "close"); + } // Prepare the response Response Received; diff --git a/src/SFML/Window/Cocoa/GLKit.mm b/src/SFML/Window/Cocoa/GLKit.mm index a570f44b..08215f72 100644 --- a/src/SFML/Window/Cocoa/GLKit.mm +++ b/src/SFML/Window/Cocoa/GLKit.mm @@ -287,9 +287,12 @@ static GLContext *sharedCtx = nil; { assert(myDelegate != NULL); - NSText *field = [[self window] fieldEditor:YES forObject:nil]; - [field interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; - [field setString:@""]; + if (sf::priv::WindowImplCocoa::IsTextEvent((void *)theEvent)) + { + NSText *field = [[self window] fieldEditor:YES forObject:nil]; + [field interpretKeyEvents:[NSArray arrayWithObject:theEvent]]; + [field setString:@""]; + } myDelegate->HandleKeyDown(theEvent); } diff --git a/src/SFML/Window/Cocoa/WindowImplCocoa.hpp b/src/SFML/Window/Cocoa/WindowImplCocoa.hpp index bc93d54c..23ca1397 100644 --- a/src/SFML/Window/Cocoa/WindowImplCocoa.hpp +++ b/src/SFML/Window/Cocoa/WindowImplCocoa.hpp @@ -108,6 +108,10 @@ public : void HandleMouseMove(void *eventRef); void HandleMouseWheel(void *eventRef); + //////////////////////////////////////////////////////////// + /// Return whether 'ev' must be considered as a TextEntered event + //////////////////////////////////////////////////////////// + static bool IsTextEvent(void *event); private : //////////////////////////////////////////////////////////// diff --git a/src/SFML/Window/Cocoa/WindowImplCocoa.mm b/src/SFML/Window/Cocoa/WindowImplCocoa.mm index 3b66bbcc..4f905535 100644 --- a/src/SFML/Window/Cocoa/WindowImplCocoa.mm +++ b/src/SFML/Window/Cocoa/WindowImplCocoa.mm @@ -511,6 +511,25 @@ void WindowImplCocoa::HandleMouseWheel(void *eventRef) } } +//////////////////////////////////////////////////////////// +/// Return whether 'ev' must be considered as a TextEntered event +//////////////////////////////////////////////////////////// +bool WindowImplCocoa::IsTextEvent(void *eventRef) +{ + NSEvent *event = (NSEvent *)eventRef; + bool res = false; + + if (event && [event type] == NSKeyDown && [[event characters] length]) { + unichar code = [[event characters] characterAtIndex:0]; + + // Codes from 0xF700 to 0xF8FF are non text keys (see NSEvent.h) + // 0x35 is the Escape key + if ([event keyCode] != 0x35 && (code < 0xF700 || code > 0xF8FF)) + res = true; + } + + return res; +} //////////////////////////////////////////////////////////// /// /see sfWindowImpl::Display @@ -797,25 +816,6 @@ static Key::Code KeyForUnicode(unsigned short uniCode) } -//////////////////////////////////////////////////////////// -/// Return whether 'ev' must be considered as a TextEntered event -//////////////////////////////////////////////////////////// -static bool IsTextEvent(NSEvent *event) -{ - bool res = false; - - if (event && [event type] == NSKeyDown && [[event characters] length]) { - unichar code = [[event characters] characterAtIndex:0]; - - // Codes from 0xF700 to 0xF8FF are non text keys (see NSEvent.h) - if (code < 0xF700 || code > 0xF8FF) - res = true; - } - - return res; -} - - } // namespace priv } // namespace sf