Added wxQuantize, wxSplashScreen, wxEffects & added palette to wxImage
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7892 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
cbb4b02f09
commit
3f4fc7967b
@ -92,6 +92,7 @@ propform.cpp G
|
||||
proplist.cpp G
|
||||
sashwin.cpp G
|
||||
scrolwin.cpp G
|
||||
splash.cpp G
|
||||
splitter.cpp G
|
||||
statline.cpp G U,R,P
|
||||
statusbr.cpp G
|
||||
@ -124,6 +125,7 @@ docmdi.cpp C
|
||||
docview.cpp C
|
||||
dynarray.cpp C B
|
||||
dynlib.cpp C B
|
||||
effects.cpp C
|
||||
encconv.cpp C B
|
||||
event.cpp C B
|
||||
extended.c C B
|
||||
@ -174,6 +176,7 @@ paper.cpp C
|
||||
prntbase.cpp C
|
||||
process.cpp C 32,B
|
||||
protocol.cpp C S,B
|
||||
quantize.cpp C
|
||||
resource.cpp C
|
||||
sckaddr.cpp C S,B
|
||||
sckfile.cpp C S,B
|
||||
|
49
include/wx/effects.h
Normal file
49
include/wx/effects.h
Normal file
@ -0,0 +1,49 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: effects.h
|
||||
// Purpose: wxEffects class
|
||||
// Draws 3D effects.
|
||||
// Author: Julian Smart et al
|
||||
// Modified by:
|
||||
// Created: 25/4/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "effects.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_EFFECTS_H_
|
||||
#define _WX_EFFECTS_H_
|
||||
|
||||
/*
|
||||
* wxEffects: various 3D effects
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxEffects: public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxEffects)
|
||||
|
||||
public:
|
||||
// Assume system colours
|
||||
wxEffects() ;
|
||||
// Going from lightest to darkest
|
||||
wxEffects(const wxColour& highlightColour, const wxColour& lightShadow,
|
||||
const wxColour& faceColour, const wxColour& mediumShadow, const wxColour& darkShadow) ;
|
||||
|
||||
// Draw a sunken edge
|
||||
void DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize = 1);
|
||||
|
||||
// Tile a bitmap
|
||||
bool TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap);
|
||||
protected:
|
||||
wxColour m_highlightColour; // Usually white
|
||||
wxColour m_lightShadow; // Usually light grey
|
||||
wxColour m_faceColour; // Usually grey
|
||||
wxColour m_mediumShadow; // Usually dark grey
|
||||
wxColour m_darkShadow; // Usually black
|
||||
};
|
||||
|
||||
#endif
|
||||
|
85
include/wx/generic/splash.h
Normal file
85
include/wx/generic/splash.h
Normal file
@ -0,0 +1,85 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: splash.h
|
||||
// Purpose: Splash screen class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 28/6/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "splash.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_SPLASH_H_
|
||||
#define _WX_SPLASH_H_
|
||||
|
||||
#include "wx/frame.h"
|
||||
#include "wx/timer.h"
|
||||
|
||||
/*
|
||||
* A window for displaying a splash screen
|
||||
*/
|
||||
|
||||
#define wxSPLASH_CENTRE_ON_PARENT 0x01
|
||||
#define wxSPLASH_CENTRE_ON_SCREEN 0x02
|
||||
#define wxSPLASH_NO_CENTRE 0x00
|
||||
#define wxSPLASH_TIMEOUT 0x04
|
||||
#define wxSPLASH_NO_TIMEOUT 0x00
|
||||
|
||||
class WXDLLEXPORT wxSplashScreenWindow;
|
||||
|
||||
/*
|
||||
* wxSplashScreen
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxSplashScreen: public wxFrame
|
||||
{
|
||||
public:
|
||||
wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxSIMPLE_BORDER|wxFRAME_FLOAT_ON_PARENT);
|
||||
~wxSplashScreen();
|
||||
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
void OnNotify(wxTimerEvent& event);
|
||||
|
||||
long GetSplashStyle() const { return m_splashStyle; }
|
||||
wxSplashScreenWindow* GetSplashWindow() const { return m_window; }
|
||||
int GetTimeout() const { return m_milliseconds; }
|
||||
|
||||
protected:
|
||||
wxSplashScreenWindow* m_window;
|
||||
long m_splashStyle;
|
||||
int m_milliseconds;
|
||||
wxTimer m_timer;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
/*
|
||||
* wxSplashScreenWindow
|
||||
*/
|
||||
|
||||
class WXDLLEXPORT wxSplashScreenWindow: public wxWindow
|
||||
{
|
||||
public:
|
||||
wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxNO_BORDER);
|
||||
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnEraseBackground(wxEraseEvent& event);
|
||||
void OnMouseEvent(wxMouseEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
|
||||
void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
|
||||
wxBitmap& GetBitmap() { return m_bitmap; }
|
||||
|
||||
protected:
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
// _WX_SPLASH_H_
|
@ -177,6 +177,10 @@ public:
|
||||
void SetMask( bool mask = TRUE );
|
||||
bool HasMask() const;
|
||||
|
||||
bool HasPalette() const { return m_palette.Ok(); }
|
||||
const wxPalette& GetPalette() const { return m_palette; }
|
||||
void SetPalette(const wxPalette& palette) { m_palette = palette; }
|
||||
|
||||
unsigned long CountColours( unsigned long stopafter = (unsigned long) -1 );
|
||||
unsigned long ComputeHistogram( wxHashTable &h );
|
||||
|
||||
@ -206,6 +210,7 @@ public:
|
||||
|
||||
protected:
|
||||
static wxList sm_handlers;
|
||||
wxPalette m_palette;
|
||||
|
||||
private:
|
||||
friend class WXDLLEXPORT wxImageHandler;
|
||||
|
71
include/wx/quantize.h
Normal file
71
include/wx/quantize.h
Normal file
@ -0,0 +1,71 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: quantize.h
|
||||
// Purpose: wxQuantizer class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 22/6/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence:
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
* From jquant2.c
|
||||
*
|
||||
* Copyright (C) 1991-1996, Thomas G. Lane.
|
||||
* This file is part of the Independent JPEG Group's software.
|
||||
* For conditions of distribution and use, see the accompanying README file.
|
||||
*/
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "quantize.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_QUANTIZE_H_
|
||||
#define _WX_QUANTIZE_H_
|
||||
|
||||
class WXDLLEXPORT wxImage;
|
||||
|
||||
/*
|
||||
* wxQuantize
|
||||
* Based on the JPEG quantization code. Reduces the number of colours in a wxImage.
|
||||
*/
|
||||
|
||||
#define wxQUANTIZE_INCLUDE_WINDOWS_COLOURS 0x01
|
||||
#define wxQUANTIZE_RETURN_8BIT_DATA 0x02
|
||||
#define wxQUANTIZE_FILL_DESTINATION_IMAGE 0x04
|
||||
|
||||
class WXDLLEXPORT wxQuantize: public wxObject
|
||||
{
|
||||
public:
|
||||
DECLARE_DYNAMIC_CLASS(wxQuantize)
|
||||
|
||||
//// Constructor
|
||||
|
||||
wxQuantize() {};
|
||||
|
||||
//// Operations
|
||||
|
||||
// Reduce the colours in the source image and put the result into the
|
||||
// destination image. Both images may be the same, to overwrite the source image.
|
||||
// Specify an optional palette pointer to receive the resulting palette.
|
||||
// This palette may be passed to ConvertImageToBitmap, for example.
|
||||
// If you pass a palette pointer, you must free the palette yourself.
|
||||
|
||||
static bool Quantize(const wxImage& src, wxImage& dest, wxPalette** pPalette = NULL, int desiredNoColours = 236,
|
||||
unsigned char** eightBitData = 0, int flags = wxQUANTIZE_INCLUDE_WINDOWS_COLOURS|wxQUANTIZE_FILL_DESTINATION_IMAGE|wxQUANTIZE_RETURN_8BIT_DATA);
|
||||
|
||||
//// Helpers
|
||||
|
||||
// Converts input bitmap(s) into 8bit representation with custom palette
|
||||
|
||||
// in_rows and out_rows are arrays [0..h-1] of pointer to rows
|
||||
// (in_rows contains w * 3 bytes per row, out_rows w bytes per row)
|
||||
// fills out_rows with indexes into palette (which is also stored into palette variable)
|
||||
static void DoQuantize(unsigned w, unsigned h, unsigned char **in_rows, unsigned char **out_rows, unsigned char *palette, int desiredNoColours);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_QUANTIZE_H_
|
||||
|
7
include/wx/splash.h
Normal file
7
include/wx/splash.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef _WX_SPLASH_H_BASE_
|
||||
#define _WX_SPLASH_H_BASE_
|
||||
|
||||
#include "wx/generic/splash.h"
|
||||
|
||||
#endif
|
||||
// _WX_SPLASH_H_BASE_
|
121
src/common/effects.cpp
Normal file
121
src/common/effects.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: effects.cpp
|
||||
// Purpose: wxEffects implementation
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 25/4/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "effects.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/pen.h"
|
||||
#include "wx/dcmemory.h"
|
||||
|
||||
#include "wx/effects.h"
|
||||
|
||||
/*
|
||||
* wxEffects: various 3D effects
|
||||
*/
|
||||
|
||||
IMPLEMENT_CLASS(wxEffects, wxObject)
|
||||
|
||||
// Assume system colours
|
||||
wxEffects::wxEffects()
|
||||
{
|
||||
m_highlightColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DHILIGHT) ;
|
||||
m_lightShadow = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT) ;
|
||||
m_faceColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
|
||||
m_mediumShadow = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DSHADOW) ;
|
||||
m_darkShadow = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DDKSHADOW) ;
|
||||
}
|
||||
|
||||
// Going from lightest to darkest
|
||||
wxEffects::wxEffects(const wxColour& highlightColour, const wxColour& lightShadow,
|
||||
const wxColour& faceColour, const wxColour& mediumShadow, const wxColour& darkShadow)
|
||||
{
|
||||
m_highlightColour = highlightColour;
|
||||
m_lightShadow = lightShadow;
|
||||
m_faceColour = faceColour;
|
||||
m_mediumShadow = mediumShadow;
|
||||
m_darkShadow = darkShadow;
|
||||
}
|
||||
|
||||
// Draw a sunken edge
|
||||
void wxEffects::DrawSunkenEdge(wxDC& dc, const wxRect& rect, int borderSize)
|
||||
{
|
||||
wxPen highlightPen(m_highlightColour, 1, wxSOLID);
|
||||
wxPen lightShadowPen(m_lightShadow, 1, wxSOLID);
|
||||
wxPen facePen(m_faceColour, 1, wxSOLID);
|
||||
wxPen mediumShadowPen(m_mediumShadow, 1, wxSOLID);
|
||||
wxPen darkShadowPen(m_darkShadow, 1, wxSOLID);
|
||||
|
||||
//// LEFT AND TOP
|
||||
// Draw a medium shadow pen on left and top, followed by dark shadow line to
|
||||
// right and below of these lines
|
||||
|
||||
dc.SetPen(mediumShadowPen);
|
||||
dc.DrawLine(rect.x, rect.y, rect.x+rect.width-1, rect.y); // Top
|
||||
dc.DrawLine(rect.x, rect.y, rect.x, rect.y+rect.height-1); // Left
|
||||
|
||||
dc.SetPen(darkShadowPen);
|
||||
dc.DrawLine(rect.x+1, rect.y+1, rect.x+rect.width-2, rect.y+1); // Top
|
||||
dc.DrawLine(rect.x+1, rect.y+1, rect.x+1, rect.y+rect.height-1); // Left
|
||||
|
||||
//// RIGHT AND BOTTOM
|
||||
|
||||
dc.SetPen(highlightPen);
|
||||
dc.DrawLine(rect.x+rect.width-1, rect.y, rect.x+rect.width-1, rect.y+rect.height-1); // Right
|
||||
dc.DrawLine(rect.x, rect.y+rect.height-1, rect.x+rect.width, rect.y+rect.height-1); // Bottom
|
||||
|
||||
dc.SetPen(lightShadowPen);
|
||||
dc.DrawLine(rect.x+rect.width-2, rect.y+1, rect.x+rect.width-2, rect.y+rect.height-2); // Right
|
||||
dc.DrawLine(rect.x+1, rect.y+rect.height-2, rect.x+rect.width-1, rect.y+rect.height-2); // Bottom
|
||||
|
||||
dc.SetPen(wxNullPen);
|
||||
}
|
||||
|
||||
bool wxEffects::TileBitmap(const wxRect& rect, wxDC& dc, wxBitmap& bitmap)
|
||||
{
|
||||
static bool hiColour = (wxDisplayDepth() >= 16) ;
|
||||
|
||||
int w = bitmap.GetWidth();
|
||||
int h = bitmap.GetHeight();
|
||||
|
||||
wxMemoryDC dcMem;
|
||||
|
||||
if (bitmap.GetPalette() && !hiColour)
|
||||
{
|
||||
dc.SetPalette(* bitmap.GetPalette());
|
||||
dcMem.SetPalette(* bitmap.GetPalette());
|
||||
}
|
||||
dcMem.SelectObject(bitmap);
|
||||
|
||||
int i, j;
|
||||
for (i = rect.x; i < rect.x + rect.width; i += w)
|
||||
{
|
||||
for (j = rect.y; j < rect.y + rect.height; j+= h)
|
||||
dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
|
||||
}
|
||||
dcMem.SelectObject(wxNullBitmap);
|
||||
|
||||
if (bitmap.GetPalette() && !hiColour)
|
||||
{
|
||||
dc.SetPalette(wxNullPalette);
|
||||
dcMem.SetPalette(wxNullPalette);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
@ -126,6 +126,22 @@ bool wxGIFDecoder::ConvertToImage(wxImage *image) const
|
||||
else
|
||||
image->SetMask(FALSE);
|
||||
|
||||
// Set the palette
|
||||
if (pal)
|
||||
{
|
||||
unsigned char* r = new unsigned char[256];
|
||||
unsigned char* g = new unsigned char[256];
|
||||
unsigned char* b = new unsigned char[256];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
r[i] = pal[3*i + 0];
|
||||
g[i] = pal[3*i + 1];
|
||||
b[i] = pal[3*i + 2];
|
||||
}
|
||||
image->SetPalette(wxPalette(256, r, g, b));
|
||||
delete[] r; delete[] g; delete[] b;
|
||||
}
|
||||
|
||||
/* copy image data */
|
||||
for (i = 0; i < (GetWidth() * GetHeight()); i++, src++)
|
||||
{
|
||||
|
@ -286,13 +286,26 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose
|
||||
*/
|
||||
if (bpp < 16 && ncolors != 0)
|
||||
{
|
||||
unsigned char* r = new unsigned char[ncolors];
|
||||
unsigned char* g = new unsigned char[ncolors];
|
||||
unsigned char* b = new unsigned char[ncolors];
|
||||
for (int j = 0; j < ncolors; j++)
|
||||
{
|
||||
stream.Read( bbuf, 4 );
|
||||
cmap[j].b = bbuf[0];
|
||||
cmap[j].g = bbuf[1];
|
||||
cmap[j].r = bbuf[2];
|
||||
|
||||
r[j] = cmap[j].r;
|
||||
g[j] = cmap[j].g;
|
||||
b[j] = cmap[j].b;
|
||||
}
|
||||
// Set the palette for the wxImage
|
||||
image->SetPalette(wxPalette(ncolors, r, g, b));
|
||||
|
||||
delete[] r;
|
||||
delete[] g;
|
||||
delete[] b;
|
||||
}
|
||||
else if (bpp == 16 || bpp == 32)
|
||||
{
|
||||
|
@ -1020,6 +1020,13 @@ wxBitmap wxImage::ConvertToBitmap() const
|
||||
hbitmap = ::CreateCompatibleBitmap( hdc, width, bmpHeight );
|
||||
::SelectObject( memdc, hbitmap);
|
||||
|
||||
HPALETTE hOldPalette = 0;
|
||||
if (GetPalette().Ok())
|
||||
{
|
||||
hOldPalette = ::SelectPalette(memdc, (HPALETTE) GetPalette().GetHPALETTE(), FALSE);
|
||||
::RealizePalette(memdc);
|
||||
}
|
||||
|
||||
// copy image data into DIB data and then into DDB (in a loop)
|
||||
unsigned char *data = GetData();
|
||||
int i, j, n;
|
||||
@ -1069,6 +1076,9 @@ wxBitmap wxImage::ConvertToBitmap() const
|
||||
}
|
||||
bitmap.SetHBITMAP( (WXHBITMAP) hbitmap );
|
||||
|
||||
if (hOldPalette)
|
||||
SelectPalette(memdc, hOldPalette, FALSE);
|
||||
|
||||
// similarly, created an mono-bitmap for the possible mask
|
||||
if( HasMask() )
|
||||
{
|
||||
|
@ -276,6 +276,18 @@ int ReadPCX(wxImage *image, wxInputStream& stream)
|
||||
*(p++) = pal[3 * index + 1];
|
||||
*(p++) = pal[3 * index + 2];
|
||||
}
|
||||
|
||||
unsigned char* r = new unsigned char[256];
|
||||
unsigned char* g = new unsigned char[256];
|
||||
unsigned char* b = new unsigned char[256];
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
r[i] = pal[3*i + 0];
|
||||
g[i] = pal[3*i + 1];
|
||||
b[i] = pal[3*i + 2];
|
||||
}
|
||||
image->SetPalette(wxPalette(256, r, g, b));
|
||||
delete[] r; delete[] g; delete[] b;
|
||||
}
|
||||
|
||||
return wxPCX_OK;
|
||||
|
1564
src/common/quantize.cpp
Normal file
1564
src/common/quantize.cpp
Normal file
File diff suppressed because it is too large
Load Diff
158
src/generic/splash.cpp
Normal file
158
src/generic/splash.cpp
Normal file
@ -0,0 +1,158 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: splash.cpp
|
||||
// Purpose: wxSplashScreen class
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 28/6/2000
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "splash.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx/wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#endif
|
||||
|
||||
#include "wx/splash.h"
|
||||
|
||||
/*
|
||||
* wxSplashScreen
|
||||
*/
|
||||
|
||||
#define wxSPLASH_TIMER_ID 9999
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSplashScreen, wxFrame)
|
||||
EVT_TIMER(wxSPLASH_TIMER_ID, wxSplashScreen::OnNotify)
|
||||
EVT_CLOSE(wxSplashScreen::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSplashScreen::wxSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxFrame(parent, id, wxEmptyString, pos, size, style)
|
||||
{
|
||||
m_window = NULL;
|
||||
m_splashStyle = splashStyle;
|
||||
m_milliseconds = milliseconds;
|
||||
|
||||
m_window = new wxSplashScreenWindow(bitmap, this, -1, pos, size, wxNO_BORDER);
|
||||
|
||||
SetClientSize(bitmap.GetWidth(), bitmap.GetHeight());
|
||||
|
||||
if (m_splashStyle & wxSPLASH_CENTRE_ON_PARENT)
|
||||
CentreOnParent();
|
||||
else if (m_splashStyle & wxSPLASH_CENTRE_ON_SCREEN)
|
||||
CentreOnScreen();
|
||||
|
||||
if (m_splashStyle & wxSPLASH_TIMEOUT)
|
||||
{
|
||||
m_timer.SetOwner(this, wxSPLASH_TIMER_ID);
|
||||
m_timer.Start(milliseconds, TRUE);
|
||||
}
|
||||
|
||||
Show(TRUE);
|
||||
m_window->SetFocus();
|
||||
wxYield(); // Without this, you see a blank screen for an instant
|
||||
}
|
||||
|
||||
wxSplashScreen::~wxSplashScreen()
|
||||
{
|
||||
m_timer.Stop();
|
||||
}
|
||||
|
||||
void wxSplashScreen::OnNotify(wxTimerEvent& event)
|
||||
{
|
||||
m_timer.Stop();
|
||||
this->Destroy();
|
||||
}
|
||||
|
||||
void wxSplashScreen::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
m_timer.Stop();
|
||||
this->Destroy();
|
||||
}
|
||||
|
||||
/*
|
||||
* wxSplashScreenWindow
|
||||
*/
|
||||
|
||||
BEGIN_EVENT_TABLE(wxSplashScreenWindow, wxWindow)
|
||||
//EVT_PAINT(wxSplashScreenWindow::OnPaint)
|
||||
EVT_ERASE_BACKGROUND(wxSplashScreenWindow::OnEraseBackground)
|
||||
EVT_CHAR(wxSplashScreenWindow::OnChar)
|
||||
EVT_MOUSE_EVENTS(wxSplashScreenWindow::OnMouseEvent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxSplashScreenWindow::wxSplashScreenWindow(const wxBitmap& bitmap, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
|
||||
wxWindow(parent, id, pos, size, style)
|
||||
{
|
||||
m_bitmap = bitmap;
|
||||
}
|
||||
|
||||
void wxSplashScreenWindow::OnPaint(wxPaintEvent& event)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
if (m_bitmap.Ok())
|
||||
dc.DrawBitmap(m_bitmap, 0, 0);
|
||||
}
|
||||
|
||||
static void wxDrawSplashBitmap(wxDC& dc, const wxBitmap& bitmap, int x, int y)
|
||||
{
|
||||
wxMemoryDC dcMem;
|
||||
|
||||
bool hiColour = (wxDisplayDepth() >= 16) ;
|
||||
|
||||
if (bitmap.GetPalette() && !hiColour)
|
||||
{
|
||||
dc.SetPalette(* bitmap.GetPalette());
|
||||
dcMem.SetPalette(* bitmap.GetPalette());
|
||||
}
|
||||
dcMem.SelectObject(bitmap);
|
||||
dc.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0);
|
||||
dcMem.SelectObject(wxNullBitmap);
|
||||
if (bitmap.GetPalette() && !hiColour)
|
||||
{
|
||||
dc.SetPalette(wxNullPalette);
|
||||
dcMem.SetPalette(wxNullPalette);
|
||||
}
|
||||
}
|
||||
|
||||
void wxSplashScreenWindow::OnEraseBackground(wxEraseEvent& event)
|
||||
{
|
||||
if (event.GetDC())
|
||||
{
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
wxDrawSplashBitmap(* event.GetDC(), m_bitmap, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
wxDrawSplashBitmap(dc, m_bitmap, 0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxSplashScreenWindow::OnMouseEvent(wxMouseEvent& event)
|
||||
{
|
||||
if (event.LeftDown() || event.RightDown())
|
||||
GetParent()->Close(TRUE);
|
||||
}
|
||||
|
||||
void wxSplashScreenWindow::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
GetParent()->Close(TRUE);
|
||||
}
|
||||
|
12
src/wxvc.dsp
12
src/wxvc.dsp
@ -167,6 +167,10 @@ SOURCE=.\common\dynlib.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\effects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\encconv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -368,6 +372,10 @@ SOURCE=.\common\protocol.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\quantize.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\resource.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -588,6 +596,10 @@ SOURCE=.\generic\scrolwin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\splash.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\splitter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -174,6 +174,10 @@ SOURCE=.\common\dynlib.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\effects.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\encconv.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -375,6 +379,10 @@ SOURCE=.\common\protocol.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\quantize.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\resourc2.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
@ -586,6 +594,10 @@ SOURCE=.\generic\scrolwin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\splash.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\generic\splitter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
Loading…
Reference in New Issue
Block a user