00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "splash_screen.h"
00031
00032 #include <wx/dcclient.h>
00033
00034 #define TEXT_AREA_HEIGHT 16
00035
00036 namespace rviz
00037 {
00038
00039 SplashScreen::SplashScreen(wxWindow* parent, const wxBitmap& background)
00040 : wxFrame(0, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, wxFRAME_NO_TASKBAR|wxFRAME_FLOAT_ON_PARENT)
00041 , background_(background)
00042 {
00043 Connect(wxEVT_PAINT, wxPaintEventHandler(SplashScreen::onPaint), 0, this);
00044
00045 wxSize size = wxSize(background_.GetWidth(), background_.GetHeight());
00046 size.SetHeight(size.GetHeight() + TEXT_AREA_HEIGHT);
00047 SetSize(size);
00048
00049 wxSize display_size = wxGetDisplaySize();
00050 SetPosition(wxPoint(display_size.GetWidth()/2 - size.GetWidth()/2, display_size.GetHeight()/2 - size.GetHeight()/2));
00051 }
00052
00053 SplashScreen::~SplashScreen()
00054 {
00055
00056 }
00057
00058 void SplashScreen::setState(const std::string& state)
00059 {
00060 state_ = state;
00061 Refresh();
00062
00063 wxSafeYield(this, true);
00064 }
00065
00066 void SplashScreen::onPaint(wxPaintEvent& evt)
00067 {
00068 wxPaintDC dc(this);
00069
00070 wxSize text_size = dc.GetTextExtent(wxString::FromAscii(state_.c_str()));
00071
00072 dc.DrawBitmap(background_, 0, 0);
00073 dc.SetBrush(*wxWHITE_BRUSH);
00074 dc.DrawRectangle(0, background_.GetHeight(), background_.GetWidth(), TEXT_AREA_HEIGHT);
00075 dc.DrawText(wxString::FromAscii(state_.c_str()), 4, background_.GetHeight() + (TEXT_AREA_HEIGHT/2) - (text_size.GetHeight()/2));
00076 }
00077
00078 }