Go to the documentation of this file.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, "", 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
00064 void SplashScreen::onPaint(wxPaintEvent& evt)
00065 {
00066 wxPaintDC dc(this);
00067
00068 wxSize text_size = dc.GetTextExtent(state_);
00069
00070 dc.DrawBitmap(background_, 0, 0);
00071 dc.SetBrush(*wxWHITE_BRUSH);
00072 dc.DrawRectangle(0, background_.GetHeight(), background_.GetWidth(), TEXT_AREA_HEIGHT);
00073 dc.DrawText(state_, 4, background_.GetHeight() + (TEXT_AREA_HEIGHT/2) - (text_size.GetHeight()/2));
00074 }
00075
00076 }