Initial
This commit is contained in:
176
aladin/splash.cpp
Normal file
176
aladin/splash.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
#include <aladin/splash.hpp>
|
||||
#include <aladin/prodinfo.hpp>
|
||||
#include <common/resbmp.hpp>
|
||||
#include <common/bitmap.hpp>
|
||||
#include <common/assert.hpp>
|
||||
#include <jpgimg/dib24.hpp>
|
||||
|
||||
char SplashScreen::szClassName[]="SplashScreen";
|
||||
|
||||
SplashScreen::SplashScreen(const String &strBitmap,const String &strCaption,const String &strTitle,UINT timeout)
|
||||
: mBitmapName(strBitmap), mStrCaption(strCaption), mStrTitle(strTitle), mTimeout(timeout),
|
||||
mTextFont("Helv",8,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold)
|
||||
{
|
||||
mResBitmap=new ResBitmap(mBitmapName);
|
||||
mResBitmap.disposition(PointerDisposition::Delete);
|
||||
mCreateHandler.setCallback(this,&SplashScreen::createHandler);
|
||||
mPaintHandler.setCallback(this,&SplashScreen::paintHandler);
|
||||
mDestroyHandler.setCallback(this,&SplashScreen::destroyHandler);
|
||||
mPaletteChangedHandler.setCallback(this,&SplashScreen::paletteChangedHandler);
|
||||
mSetFocusHandler.setCallback(this,&SplashScreen::setFocusHandler);
|
||||
mLeftButtonHandler.setCallback(this,&SplashScreen::leftButtonHandler);
|
||||
mTimerHandler.setCallback(this,&SplashScreen::timerHandler);
|
||||
insertHandler(VectorHandler::CreateHandler,&mCreateHandler);
|
||||
insertHandler(VectorHandler::PaintHandler,&mPaintHandler);
|
||||
insertHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
||||
insertHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler);
|
||||
insertHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler);
|
||||
insertHandler(VectorHandler::TimerHandler,&mTimerHandler);
|
||||
insertHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler);
|
||||
registerClass();
|
||||
}
|
||||
|
||||
SplashScreen::SplashScreen(const SplashScreen &someSplashScreen)
|
||||
{ // private implementation
|
||||
}
|
||||
|
||||
SplashScreen::~SplashScreen()
|
||||
{
|
||||
removeHandler(VectorHandler::CreateHandler,&mCreateHandler);
|
||||
removeHandler(VectorHandler::PaintHandler,&mPaintHandler);
|
||||
removeHandler(VectorHandler::DestroyHandler,&mDestroyHandler);
|
||||
removeHandler(VectorHandler::PaletteChangedHandler,&mPaletteChangedHandler);
|
||||
removeHandler(VectorHandler::SetFocusHandler,&mSetFocusHandler);
|
||||
removeHandler(VectorHandler::TimerHandler,&mTimerHandler);
|
||||
removeHandler(VectorHandler::LeftButtonUpHandler,&mLeftButtonHandler);
|
||||
}
|
||||
|
||||
void SplashScreen::registerClass(void)
|
||||
{
|
||||
HINSTANCE hInstance(processInstance());
|
||||
WNDCLASS wndClass;
|
||||
|
||||
if(::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass))return;
|
||||
wndClass.style =CS_HREDRAW|CS_VREDRAW|CS_DBLCLKS|CS_OWNDC;
|
||||
wndClass.lpfnWndProc =(WNDPROC)Window::WndProc;
|
||||
wndClass.cbClsExtra =0;
|
||||
wndClass.cbWndExtra =sizeof(SplashScreen*);
|
||||
wndClass.hInstance =hInstance;
|
||||
wndClass.hIcon =::LoadIcon(NULL,IDI_APPLICATION);
|
||||
wndClass.hCursor =::LoadCursor(NULL,IDC_ARROW);
|
||||
wndClass.hbrBackground =(HBRUSH)::GetStockObject(NULL_BRUSH);
|
||||
wndClass.lpszMenuName =0;
|
||||
wndClass.lpszClassName =szClassName;
|
||||
::RegisterClass(&wndClass);
|
||||
assert(0!=::GetClassInfo(hInstance,szClassName,(WNDCLASS FAR*)&wndClass));
|
||||
}
|
||||
|
||||
SplashScreen &SplashScreen::operator=(const SplashScreen &someSplashScreen)
|
||||
{ // private implementation
|
||||
return *this;
|
||||
}
|
||||
|
||||
BOOL SplashScreen::perform(Rect initRect)
|
||||
{
|
||||
UINT style(0);
|
||||
if(CW_USEDEFAULT==initRect.right())initRect.right(mResBitmap->width());
|
||||
if(CW_USEDEFAULT==initRect.bottom())initRect.bottom(mResBitmap->height());
|
||||
if(timeout())
|
||||
{
|
||||
PureDevice pureDevice;
|
||||
pureDevice.screenDevice();
|
||||
initRect.left((pureDevice.horizontalResolution()-mResBitmap->width())/2);
|
||||
initRect.top((pureDevice.verticalResolution()-mResBitmap->height())/2);
|
||||
style=WS_POPUP|WS_CLIPSIBLINGS|0x04|WS_DLGFRAME;
|
||||
}
|
||||
else style=WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS;
|
||||
createWindow(WS_EX_CONTROLPARENT,szClassName,timeout()?(char*)0:(char*)"Splash",style,initRect,NULL,NULL,processInstance(),(LPSTR)this); // WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_BORDER|WS_DLGFRAME|0x04|WS_CLIPSIBLINGS
|
||||
show(SW_SHOW);
|
||||
update();
|
||||
return messageLoop();
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::leftButtonHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
killTimer(TimerID);
|
||||
postMessage(*this,WM_CLOSE,0,0L);
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::destroyHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
PureDevice pureDevice(*this);
|
||||
((PurePalette&)*mDIBitmap).usePalette(pureDevice,FALSE);
|
||||
postQuitMessage(onDestroy());
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::createHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
mPureDevice=new PureDevice(*this);
|
||||
mPureDevice.disposition(PointerDisposition::Delete);
|
||||
mDIBitmap=new DIB24();
|
||||
mDIBitmap.disposition(PointerDisposition::Delete);
|
||||
mDIBitmap->create(mResBitmap->width(),mResBitmap->height(),*mPureDevice);
|
||||
mDIBitmap->copyBits(*mResBitmap);
|
||||
if(timeout())setTimer(TimerID,timeout());
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::timerHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
killTimer(TimerID);
|
||||
postMessage(*this,WM_CLOSE,0,0L);
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::paletteChangedHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!mDIBitmap.isOkay()||((HWND)*this==(HWND)someCallbackData.wParam()))return (CallbackData::ReturnType)FALSE;
|
||||
PureDevice pureDevice(*this);
|
||||
((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE);
|
||||
update();
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::setFocusHandler(CallbackData &/*someCallbackData*/)
|
||||
{
|
||||
if(!mDIBitmap.isOkay())return (CallbackData::ReturnType)FALSE;
|
||||
PureDevice pureDevice(*this);
|
||||
((PurePalette&)*mDIBitmap).usePalette(pureDevice,TRUE);
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
CallbackData::ReturnType SplashScreen::paintHandler(CallbackData &someCallbackData)
|
||||
{
|
||||
if(!mResBitmap.isOkay())return (CallbackData::ReturnType)FALSE;
|
||||
PaintInformation *pPaintInfo=(PaintInformation*)someCallbackData.lParam();
|
||||
PureDevice &pureDevice=(PureDevice&)*pPaintInfo;
|
||||
mDIBitmap->bitBlt(pureDevice,Rect(0,0,width(),height()),Point());
|
||||
pureDevice.select((GDIObj)mTextFont,TRUE);
|
||||
pureDevice.setTextColor(RGBColor(247,231,33));
|
||||
pureDevice.setBkMode(PureDevice::Transparent);
|
||||
pureDevice.textOut(5,200,mStrCaption);
|
||||
ProductInfo prodInfo;
|
||||
pureDevice.setTextColor(RGBColor(255,255,255));
|
||||
pureDevice.textOut(1,250,prodInfo.strProductName()+String(" ")+prodInfo.strVersion());
|
||||
pureDevice.textOut(1,265,prodInfo.strRegisteredOwner());
|
||||
pureDevice.textOut(1,280,String("OEM:")+prodInfo.strProductID());
|
||||
if(!mStrTitle.isNull())
|
||||
{
|
||||
Font mFont("Helv",12,Font::PitchVariable|Font::FamilySwiss,Font::WeightBold);
|
||||
pureDevice.select((GDIObj)mFont,TRUE);
|
||||
pureDevice.setTextColor(RGBColor(255,255,255));
|
||||
pureDevice.textOut(12,10,mStrTitle);
|
||||
pureDevice.select((GDIObj)mFont,FALSE);
|
||||
}
|
||||
return (CallbackData::ReturnType)FALSE;
|
||||
}
|
||||
|
||||
// virtuals
|
||||
int SplashScreen::onDestroy(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user