bitmap and image updates
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4800 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -185,13 +185,14 @@ bool wxApp::RegisterWindowClasses(
|
||||
HAB vHab
|
||||
)
|
||||
{
|
||||
APIRET rc;
|
||||
|
||||
if (!::WinRegisterClass( vHab
|
||||
,wxFrameClassName
|
||||
,(PFNWP)wxWndProc
|
||||
,CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
|
||||
,0
|
||||
))
|
||||
if ((rc = ::WinRegisterClass( vHab
|
||||
,wxFrameClassName
|
||||
,(PFNWP)wxWndProc
|
||||
,CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST | CS_CLIPCHILDREN | CS_FRAME
|
||||
,0
|
||||
)) != 0)
|
||||
{
|
||||
wxLogLastError("RegisterClass(frame)");
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
148
src/os2/icon.cpp
148
src/os2/icon.cpp
@@ -17,12 +17,11 @@
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <stdio.h>
|
||||
#include "wx/setup.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/defs.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/icon.h"
|
||||
#endif
|
||||
|
||||
#include "wx/os2/private.h"
|
||||
@@ -31,120 +30,77 @@
|
||||
#include "wx/icon.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxIconBase)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Icons
|
||||
*/
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
wxIconRefData::wxIconRefData()
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxIconRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxIconRefData::Free()
|
||||
{
|
||||
m_hIcon = (WXHICON) NULL ;
|
||||
if ( m_hIcon )
|
||||
::DestroyIcon((HICON) m_hIcon);
|
||||
}
|
||||
|
||||
wxIconRefData::~wxIconRefData()
|
||||
{
|
||||
if ( m_hIcon )
|
||||
return;
|
||||
// TODO ::DestroyIcon((HICON) m_hIcon);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxIcon
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
||||
wxIcon::wxIcon(
|
||||
const char WXUNUSED(bits)[]
|
||||
, int WXUNUSED(nWidth)
|
||||
, int WXUNUSED(nHeight)
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& icon_file, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
|
||||
wxIcon::wxIcon(
|
||||
const wxString& rIconFile
|
||||
, long lFlags
|
||||
, int nDesiredWidth
|
||||
, int nDesiredHeight
|
||||
)
|
||||
{
|
||||
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
|
||||
LoadFile( rIconFile
|
||||
,lFlags
|
||||
,nDesiredWidth
|
||||
,nDesiredHeight
|
||||
);
|
||||
}
|
||||
|
||||
wxIcon::~wxIcon()
|
||||
{
|
||||
}
|
||||
|
||||
bool wxIcon::LoadFile(const wxString& filename, long type,
|
||||
int desiredWidth, int desiredHeight)
|
||||
bool wxIcon::LoadFile(
|
||||
const wxString& rFilename
|
||||
, long lType
|
||||
, int nDesiredWidth
|
||||
, int nDesiredHeight
|
||||
)
|
||||
{
|
||||
UnRef();
|
||||
wxGDIImageHandler* pHandler = FindHandler(type);
|
||||
|
||||
m_refData = new wxIconRefData;
|
||||
UnRef();
|
||||
m_refData = new wxIconRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxIcon::SetHICON(WXHICON ico)
|
||||
{
|
||||
if ( !M_ICONDATA )
|
||||
m_refData = new wxIconRefData;
|
||||
|
||||
M_ICONDATA->m_hIcon = ico;
|
||||
}
|
||||
|
||||
bool wxICOFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
// TODO
|
||||
/*
|
||||
if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
|
||||
{
|
||||
if (desiredWidth > -1 && desiredHeight > -1)
|
||||
{
|
||||
M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadImage(wxGetInstance(), name, IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR);
|
||||
}
|
||||
if (pHandler)
|
||||
return(pHandler->Load( this
|
||||
,rFilename
|
||||
,lType
|
||||
,nDesiredWidth
|
||||
,nDesiredHeight
|
||||
));
|
||||
else
|
||||
{
|
||||
M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
|
||||
}
|
||||
|
||||
ICONINFO info ;
|
||||
if (::GetIconInfo((HICON) M_ICONHANDLERDATA->m_hIcon, &info))
|
||||
{
|
||||
HBITMAP ms_bitmap = info.hbmMask ;
|
||||
if (ms_bitmap)
|
||||
{
|
||||
BITMAP bm;
|
||||
::GetObject(ms_bitmap, sizeof(BITMAP), (LPSTR) &bm);
|
||||
M_ICONHANDLERDATA->m_width = bm.bmWidth;
|
||||
M_ICONHANDLERDATA->m_height = bm.bmHeight;
|
||||
}
|
||||
if (info.hbmMask)
|
||||
::DeleteObject(info.hbmMask) ;
|
||||
if (info.hbmColor)
|
||||
::DeleteObject(info.hbmColor) ;
|
||||
}
|
||||
}
|
||||
// Override the found values with desired values
|
||||
if (desiredWidth > -1 && desiredHeight > -1)
|
||||
{
|
||||
M_ICONHANDLERDATA->m_width = desiredWidth;
|
||||
M_ICONHANDLERDATA->m_height = desiredHeight;
|
||||
}
|
||||
|
||||
M_ICONHANDLERDATA->m_ok = (M_ICONHANDLERDATA->m_hIcon != 0);
|
||||
return M_ICONHANDLERDATA->m_ok;
|
||||
}
|
||||
else
|
||||
*/
|
||||
return FALSE;
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
// Purpose: wxStaticBitmap
|
||||
// Author: David Webster
|
||||
// Modified by:
|
||||
// Created: ??/??/98
|
||||
// Created: 11/27/99
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) David Webster
|
||||
// Licence: wxWindows licence
|
||||
@@ -34,17 +34,20 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
|
||||
// wxStaticBitmap
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxBitmap& bitmap,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
bool wxStaticBitmap::Create(
|
||||
wxWindow* pParent
|
||||
, wxWindowID nId
|
||||
, const wxGDIImage& rBitmap
|
||||
, const wxPoint& rPos
|
||||
, const wxSize& rSize
|
||||
, long lStyle
|
||||
, const wxString& rName
|
||||
)
|
||||
{
|
||||
Init();
|
||||
|
||||
SetName(name);
|
||||
if (parent) parent->AddChild(this);
|
||||
SetName(rName);
|
||||
if (pParent) parent->AddChild(this);
|
||||
|
||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
@@ -52,52 +55,55 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
m_windowId = nId;
|
||||
|
||||
m_windowStyle = style;
|
||||
m_windowStyle = lStyle;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
int nX= pos.x;
|
||||
int nY = pos.y;
|
||||
int nWidth = size.x;
|
||||
int nHeight = size.y;
|
||||
|
||||
m_windowStyle = style;
|
||||
m_windowStyle = lStyle;
|
||||
|
||||
m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
|
||||
m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
|
||||
|
||||
// TODO: create static bitmap control
|
||||
const wxChar* zClassname = wxT("WX_STATIC");
|
||||
int nWinstyle ? SS_ICON : SS_BITMAP;
|
||||
|
||||
m_hWnd = (WXWHND)::WinCreateWindow( pParent->GetHWND()
|
||||
,zClassname
|
||||
,wxT("")
|
||||
,nWinstyle | WS_VISIBLE
|
||||
,0,0,0,0
|
||||
,pParent->GetHWND()
|
||||
,HWND_TOP
|
||||
,m_windowId
|
||||
,NULL
|
||||
,NULL
|
||||
);
|
||||
|
||||
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
|
||||
|
||||
SetBitmap(bitmap);
|
||||
SetImage(rBitmap);
|
||||
|
||||
// Subclass again for purposes of dialog editing mode
|
||||
SubclassWin(m_hWnd);
|
||||
|
||||
SetFont(GetParent()->GetFont());
|
||||
|
||||
SetSize(x, y, width, height);
|
||||
|
||||
return FALSE;
|
||||
SetSize(nX, nY, nWidth, nHeight);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
bool wxStaticBitmap::ImageIsOk() const
|
||||
{
|
||||
if ( m_isIcon && m_image.icon )
|
||||
return m_image.icon->Ok();
|
||||
else if ( m_image.bitmap )
|
||||
return m_image.bitmap->Ok();
|
||||
else
|
||||
return FALSE;
|
||||
return(m_pImage ** m_pImage->Ok());
|
||||
}
|
||||
|
||||
void wxStaticBitmap::Free()
|
||||
{
|
||||
if ( m_isIcon )
|
||||
delete m_image.icon;
|
||||
else
|
||||
delete m_image.bitmap;
|
||||
|
||||
m_image.icon = NULL;
|
||||
delete m_pImage;
|
||||
m_pImage = NULL;
|
||||
}
|
||||
|
||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||
@@ -107,22 +113,59 @@ wxSize wxStaticBitmap::DoGetBestSize() const
|
||||
return wxWindow::DoGetBestSize();
|
||||
}
|
||||
|
||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||
void wxStaticBitmap::SetImage(
|
||||
const wxGDIImage& rBitmap
|
||||
)
|
||||
{
|
||||
Free();
|
||||
|
||||
m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
|
||||
if ( m_isIcon )
|
||||
m_image.icon = new wxIcon((const wxIcon&)bitmap);
|
||||
m_bIsIcon = rBitmap.IsKindOf(CLASSINFO(wxIcon));
|
||||
if (m_bIsIcon)
|
||||
m_pImage = new wxIcon((const wxIcon&)rBitmap);
|
||||
else
|
||||
m_image.bitmap = new wxBitmap(bitmap);
|
||||
m_pImage = new wxBitmap((const wxBitmap &)rBitmap);
|
||||
|
||||
int x, y;
|
||||
int w, h;
|
||||
GetPosition(&x, &y);
|
||||
GetSize(&w, &h);
|
||||
int nX;
|
||||
int nY;
|
||||
int nW;
|
||||
int nH;
|
||||
|
||||
// TODO: redraw bitmap
|
||||
GetPosition(&nX, &nY);
|
||||
GetSize(&nW, &nHh);
|
||||
|
||||
::WinSendMsg( GetHwnd()
|
||||
,SM_SETHANDLE
|
||||
,MPFROMHWND(m_pImage->GetHandle())
|
||||
,NULL
|
||||
);
|
||||
if (ImageIsOk())
|
||||
{
|
||||
int nWidth = rBitmap.GetWidth();
|
||||
int nHeight = rBitmap.GetHeight();
|
||||
|
||||
if (nWidth && nHeight)
|
||||
{
|
||||
nW = nWidth;
|
||||
nW = nHeight;
|
||||
|
||||
::WinSetWindowPos( GetHwnd()
|
||||
,HWND_TOP
|
||||
,nX
|
||||
,nY
|
||||
,nWidth
|
||||
,nHeight
|
||||
,SWP_SIZE | SWP_MOVE | SWP_SHOW
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
RECTL vRect;
|
||||
|
||||
vRect.xLeft = nW;
|
||||
vRect.yTop = nY;
|
||||
vRect.xRight = nX + nW;
|
||||
vRect.yBottom = nY + nH;
|
||||
|
||||
::WinInvalidateRect(GetHwndOf(GetParent()), &vRect, TRUE);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -596,68 +596,17 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
||||
}
|
||||
|
||||
#if wxUSE_GUI
|
||||
// we can't just wait for the thread to terminate because it might be
|
||||
// calling some GUI functions and so it will never terminate before we
|
||||
// process the Windows messages that result from these functions
|
||||
ULONG ulrc;
|
||||
do
|
||||
// need a way to finish GUI processing before killing the thread
|
||||
// until then we just exit
|
||||
|
||||
if ((gs_nWaitingForGui > 0) && wxGuiOwnedByMainThread())
|
||||
{
|
||||
ulrc = ::MsgWaitForMultipleObjects
|
||||
(
|
||||
1, // number of objects to wait for
|
||||
&hThread, // the objects
|
||||
FALSE, // don't wait for all objects
|
||||
INFINITE, // no timeout
|
||||
QS_ALLEVENTS // return as soon as there are any events
|
||||
);
|
||||
|
||||
switch ( result )
|
||||
{
|
||||
case 0xFFFFFFFF:
|
||||
// error
|
||||
wxLogSysError(_("Can not wait for thread termination"));
|
||||
Kill();
|
||||
return wxTHREAD_KILLED;
|
||||
|
||||
case WAIT_OBJECT_0:
|
||||
// thread we're waiting for terminated
|
||||
break;
|
||||
|
||||
case WAIT_OBJECT_0 + 1:
|
||||
// new message arrived, process it
|
||||
if ( !wxTheApp->DoMessage() )
|
||||
{
|
||||
// WM_QUIT received: kill the thread
|
||||
Kill();
|
||||
|
||||
return wxTHREAD_KILLED;
|
||||
}
|
||||
|
||||
if ( IsMain() )
|
||||
{
|
||||
// give the thread we're waiting for chance to exit
|
||||
// from the GUI call it might have been in
|
||||
if ( (gs_nWaitingForGui > 0) && wxGuiOwnedByMainThread() )
|
||||
{
|
||||
wxMutexGuiLeave();
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("unexpected result of MsgWaitForMultipleObject"));
|
||||
}
|
||||
} while ( result != WAIT_OBJECT_0 );
|
||||
#else // !wxUSE_GUI
|
||||
// simply wait for the thread to terminate
|
||||
//
|
||||
// OTOH, even console apps create windows (in wxExecute, for WinSock
|
||||
// &c), so may be use MsgWaitForMultipleObject() too here?
|
||||
if ( WaitForSingleObject(hThread, INFINITE) != WAIT_OBJECT_0 )
|
||||
{
|
||||
wxFAIL_MSG(wxT("unexpected result of WaitForSingleObject"));
|
||||
wxMutexGuiLeave();
|
||||
}
|
||||
#else // !wxUSE_GUI
|
||||
|
||||
// can't wait for yourself to end under OS/2 so just quit
|
||||
|
||||
#endif // wxUSE_GUI/!wxUSE_GUI
|
||||
|
||||
if ( IsMain() )
|
||||
@@ -670,19 +619,10 @@ wxThreadError wxThread::Delete(ExitCode *pRc)
|
||||
}
|
||||
}
|
||||
|
||||
if ( !::GetExitCodeThread(hThread, (LPDWORD)&rc) )
|
||||
::DosExit(0, 0);
|
||||
// probably won't get this far, but
|
||||
if (IsDetached())
|
||||
{
|
||||
wxLogLastError("GetExitCodeThread");
|
||||
|
||||
rc = (ExitCode)-1;
|
||||
}
|
||||
|
||||
if ( IsDetached() )
|
||||
{
|
||||
// if the thread exits normally, this is done in WinThreadStart, but in
|
||||
// this case it would have been too early because
|
||||
// MsgWaitForMultipleObject() would fail if the therad handle was
|
||||
// closed while we were waiting on it, so we must do it here
|
||||
delete this;
|
||||
}
|
||||
|
||||
@@ -701,14 +641,19 @@ wxThreadError wxThread::Kill()
|
||||
return wxTHREAD_NOT_RUNNING;
|
||||
|
||||
::DosKillThread(m_internal->GetHandle());
|
||||
delete this;
|
||||
m_internal->Free();
|
||||
if (IsDetached())
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
return wxTHREAD_NO_ERROR;
|
||||
}
|
||||
|
||||
void wxThread::Exit(
|
||||
void* pStatus
|
||||
ExitCode pStatus
|
||||
)
|
||||
{
|
||||
m_internal->Free();
|
||||
delete this;
|
||||
::DosExit(EXIT_THREAD, ULONG(pStatus));
|
||||
wxFAIL_MSG(wxT("Couldn't return from DosExit()!"));
|
||||
@@ -730,11 +675,18 @@ unsigned int wxThread::GetPriority() const
|
||||
return m_internal->GetPriority();
|
||||
}
|
||||
|
||||
unsigned long wxThread::GetId() const
|
||||
{
|
||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect); // const_cast
|
||||
|
||||
return (unsigned long)m_internal->GetId();
|
||||
}
|
||||
|
||||
bool wxThread::IsRunning() const
|
||||
{
|
||||
wxCriticalSectionLocker lock((wxCriticalSection &)m_critsect);
|
||||
|
||||
return m_internal->GetState() == STATE_RUNNING;
|
||||
return(m_internal->GetState() == STATE_RUNNING);
|
||||
}
|
||||
|
||||
bool wxThread::IsAlive() const
|
||||
@@ -759,11 +711,6 @@ bool wxThread::TestDestroy()
|
||||
return m_internal->GetState() == STATE_CANCELED;
|
||||
}
|
||||
|
||||
wxThread::~wxThread()
|
||||
{
|
||||
delete m_internal;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Automatic initialization for thread module
|
||||
// ----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user