1. wxIcon/wxCursor change, wxGDIImage class added
2. wxCriticalSection doesn't alloc memory any more 3. many minor fixes in bitmap/icon code git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4674 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6d167489bd
commit
0d0512bd8f
@ -230,6 +230,7 @@ fontutil.cpp M
|
|||||||
frame.cpp M
|
frame.cpp M
|
||||||
gauge95.cpp M 32
|
gauge95.cpp M 32
|
||||||
gaugemsw.cpp M 16
|
gaugemsw.cpp M 16
|
||||||
|
gdiimage.cpp M
|
||||||
gdiobj.cpp M
|
gdiobj.cpp M
|
||||||
helpwin.cpp M
|
helpwin.cpp M
|
||||||
icon.cpp M
|
icon.cpp M
|
||||||
@ -772,6 +773,7 @@ frame.h 9
|
|||||||
gauge.h 9
|
gauge.h 9
|
||||||
gauge95.h 9
|
gauge95.h 9
|
||||||
gaugemsw.h 9
|
gaugemsw.h 9
|
||||||
|
gdiimage.h 9
|
||||||
gdiobj.h 9
|
gdiobj.h 9
|
||||||
helpwin.h 9
|
helpwin.h 9
|
||||||
icon.h 9
|
icon.h 9
|
||||||
|
190
include/wx/msw/gdiimage.h
Normal file
190
include/wx/msw/gdiimage.h
Normal file
@ -0,0 +1,190 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: include/wx/msw/gdiimage.h
|
||||||
|
// Purpose: wxGDIImage class: base class for wxBitmap, wxIcon, wxCursor
|
||||||
|
// under MSW
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 20.11.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// NB: this is a private header, it is not intended to be directly included by
|
||||||
|
// user code (but may be included from other, public, wxWin headers
|
||||||
|
|
||||||
|
#ifndef _WX_MSW_GDIIMAGE_H_
|
||||||
|
#define _WX_MSW_GDIIMAGE_H_
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "gdiimage.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/gdiobj.h" // base class
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGDIImageRefData;
|
||||||
|
class WXDLLEXPORT wxGDIImageHandler;
|
||||||
|
class WXDLLEXPORT wxGDIImage;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIImageRefData: common data fields for all derived classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGDIImageRefData : public wxGDIRefData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxGDIImageRefData()
|
||||||
|
{
|
||||||
|
m_width = m_height = m_depth = 0;
|
||||||
|
|
||||||
|
m_handle = 0;
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
m_ok = FALSE;
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
}
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
bool IsOk() const { return m_handle != 0; }
|
||||||
|
|
||||||
|
void SetSize(int w, int h) { m_width = w; m_height = h; }
|
||||||
|
|
||||||
|
// free the ressources we allocated
|
||||||
|
virtual void Free() = 0;
|
||||||
|
|
||||||
|
// for compatibility, the member fields are public
|
||||||
|
|
||||||
|
// the size of the image
|
||||||
|
int m_width, m_height;
|
||||||
|
|
||||||
|
// the depth of the image
|
||||||
|
int m_depth;
|
||||||
|
|
||||||
|
// the handle to it
|
||||||
|
union
|
||||||
|
{
|
||||||
|
WXHANDLE m_handle; // for untyped access
|
||||||
|
WXHBITMAP m_hBitmap;
|
||||||
|
WXHICON m_hIcon;
|
||||||
|
WXHCURSOR m_hCursor;
|
||||||
|
};
|
||||||
|
|
||||||
|
// this filed is redundant and using it is error prone but keep it for
|
||||||
|
// backwards compatibility
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
void SetOk() { m_ok = m_handle != 0; }
|
||||||
|
|
||||||
|
bool m_ok;
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIImageHandler: a class which knows how to load/save wxGDIImages.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGDIImageHandler : public wxObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// ctor
|
||||||
|
wxGDIImageHandler() { m_type = wxBITMAP_TYPE_INVALID; }
|
||||||
|
wxGDIImageHandler(const wxString& name,
|
||||||
|
const wxString& ext,
|
||||||
|
long type)
|
||||||
|
: m_name(name), m_extension(ext)
|
||||||
|
{
|
||||||
|
m_type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
void SetName(const wxString& name) { m_name = name; }
|
||||||
|
void SetExtension(const wxString& ext) { m_extension = ext; }
|
||||||
|
void SetType(long type) { m_type = type; }
|
||||||
|
|
||||||
|
wxString GetName() const { return m_name; }
|
||||||
|
wxString GetExtension() const { return m_extension; }
|
||||||
|
long GetType() const { return m_type; }
|
||||||
|
|
||||||
|
// real handler operations: to implement in derived classes
|
||||||
|
virtual bool Create(wxGDIImage *image,
|
||||||
|
void *data,
|
||||||
|
long flags,
|
||||||
|
int width, int height, int depth = 1) = 0;
|
||||||
|
virtual bool Load(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight) = 0;
|
||||||
|
virtual bool Save(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
int type) = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString m_name;
|
||||||
|
wxString m_extension;
|
||||||
|
long m_type;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIImage: this class supports GDI image handlers which may be registered
|
||||||
|
// dynamically and will be used for loading/saving the images in the specified
|
||||||
|
// format. It also falls back to wxImage if no appropriate image is found.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxGDIImage : public wxGDIObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// handlers list interface
|
||||||
|
static wxList& GetHandlers() { return ms_handlers; }
|
||||||
|
|
||||||
|
static void AddHandler(wxGDIImageHandler *handler);
|
||||||
|
static void InsertHandler(wxGDIImageHandler *handler);
|
||||||
|
static bool RemoveHandler(const wxString& name);
|
||||||
|
|
||||||
|
static wxGDIImageHandler *FindHandler(const wxString& name);
|
||||||
|
static wxGDIImageHandler *FindHandler(const wxString& extension, long type);
|
||||||
|
static wxGDIImageHandler *FindHandler(long type);
|
||||||
|
|
||||||
|
static void InitStandardHandlers();
|
||||||
|
static void CleanUpHandlers();
|
||||||
|
|
||||||
|
// access to the ref data casted to the right type
|
||||||
|
wxGDIImageRefData *GetGDIImageData() const
|
||||||
|
{ return (wxGDIImageRefData *)m_refData; }
|
||||||
|
|
||||||
|
// create data if we don't have it yet
|
||||||
|
void EnsureHasData() { if ( IsNull() ) m_refData = CreateData(); }
|
||||||
|
|
||||||
|
// accessors
|
||||||
|
WXHANDLE GetHandle() const
|
||||||
|
{ return IsNull() ? 0 : GetGDIImageData()->m_handle; }
|
||||||
|
void SetHandle(WXHANDLE handle)
|
||||||
|
{ EnsureHasData(); GetGDIImageData()->m_handle = handle; }
|
||||||
|
|
||||||
|
bool Ok() const { return GetHandle() != 0; }
|
||||||
|
|
||||||
|
int GetWidth() const { return IsNull() ? 0 : GetGDIImageData()->m_width; }
|
||||||
|
int GetHeight() const { return IsNull() ? 0 : GetGDIImageData()->m_height; }
|
||||||
|
int GetDepth() const { return IsNull() ? 0 : GetGDIImageData()->m_depth; }
|
||||||
|
|
||||||
|
void SetWidth(int w) { EnsureHasData(); GetGDIImageData()->m_width = w; }
|
||||||
|
void SetHeight(int h) { EnsureHasData(); GetGDIImageData()->m_height = h; }
|
||||||
|
void SetDepth(int d) { EnsureHasData(); GetGDIImageData()->m_depth = d; }
|
||||||
|
|
||||||
|
void SetSize(int w, int h)
|
||||||
|
{
|
||||||
|
EnsureHasData();
|
||||||
|
GetGDIImageData()->SetSize(w, h);
|
||||||
|
}
|
||||||
|
void SetSize(const wxSize& size) { SetSize(size.x, size.y); }
|
||||||
|
|
||||||
|
// forward some of base class virtuals to wxGDIImageRefData
|
||||||
|
bool FreeResource(bool force = FALSE);
|
||||||
|
virtual WXHANDLE GetResourceHandle();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// create the data for the derived class here
|
||||||
|
virtual wxGDIImageRefData *CreateData() const = 0;
|
||||||
|
|
||||||
|
static wxList ms_handlers;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_MSW_GDIIMAGE_H_
|
@ -9,6 +9,14 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "cursor.h"
|
#pragma implementation "cursor.h"
|
||||||
#endif
|
#endif
|
||||||
@ -21,8 +29,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
@ -33,79 +39,86 @@
|
|||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#include "wx/msw/dib.h"
|
#include "wx/msw/dib.h"
|
||||||
|
|
||||||
#include "assert.h"
|
|
||||||
|
|
||||||
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
||||||
#include "wx/msw/curico.h"
|
#include "wx/msw/curico.h"
|
||||||
#include "wx/msw/curicop.h"
|
#include "wx/msw/curicop.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARIES
|
#if !USE_SHARED_LIBRARIES
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
|
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxCursorBase)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxCursorRefData::wxCursorRefData(void)
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxCursorRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxCursorRefData::wxCursorRefData()
|
||||||
{
|
{
|
||||||
m_width = 32; m_height = 32;
|
m_width = 32;
|
||||||
m_hCursor = 0 ;
|
m_height = 32;
|
||||||
|
|
||||||
m_destroyCursor = FALSE;
|
m_destroyCursor = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursorRefData::~wxCursorRefData(void)
|
void wxCursorRefData::Free()
|
||||||
{
|
{
|
||||||
if ( m_hCursor && m_destroyCursor )
|
if ( m_hCursor && m_destroyCursor )
|
||||||
#ifdef __WXWINE__
|
|
||||||
::DestroyCursor((HCURSOR)m_hCursor);
|
::DestroyCursor((HCURSOR)m_hCursor);
|
||||||
#else
|
|
||||||
::DestroyCursor((HICON) m_hCursor);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
// Cursors
|
// Cursors
|
||||||
wxCursor::wxCursor(void)
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxCursor::wxCursor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
|
wxCursor::wxCursor(const char WXUNUSED(bits)[],
|
||||||
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
|
int WXUNUSED(width),
|
||||||
|
int WXUNUSED(height),
|
||||||
|
int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY),
|
||||||
|
const char WXUNUSED(maskBits)[])
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int hotSpotY)
|
wxCursor::wxCursor(const wxString& cursor_file,
|
||||||
|
long flags,
|
||||||
|
int hotSpotX, int hotSpotY)
|
||||||
{
|
{
|
||||||
m_refData = new wxCursorRefData;
|
wxCursorRefData *refData = new wxCursorRefData;
|
||||||
|
m_refData = refData;
|
||||||
|
|
||||||
|
refData->m_destroyCursor = FALSE;
|
||||||
|
|
||||||
M_CURSORDATA->m_destroyCursor = FALSE;
|
|
||||||
M_CURSORDATA->m_hCursor = 0;
|
|
||||||
M_CURSORDATA->m_ok = FALSE;
|
|
||||||
if (flags == wxBITMAP_TYPE_CUR_RESOURCE)
|
if (flags == wxBITMAP_TYPE_CUR_RESOURCE)
|
||||||
{
|
{
|
||||||
#ifdef __WIN95__
|
#ifdef __WIN95__
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
|
refData->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, 0);
|
||||||
#else
|
#else
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), cursor_file);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), cursor_file);
|
||||||
#endif
|
#endif
|
||||||
if (M_CURSORDATA->m_hCursor)
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
else
|
|
||||||
M_CURSORDATA->m_ok = FALSE;
|
|
||||||
}
|
}
|
||||||
else if (flags == wxBITMAP_TYPE_CUR)
|
else if (flags == wxBITMAP_TYPE_CUR)
|
||||||
{
|
{
|
||||||
#ifdef __WIN95__
|
#ifdef __WIN95__
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
|
refData->m_hCursor = (WXHCURSOR) LoadImage(wxGetInstance(), cursor_file, IMAGE_CURSOR, 0, 0, LR_LOADFROMFILE);
|
||||||
#else
|
#else
|
||||||
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) ReadCursorFile(WXSTRINGCAST cursor_file, wxGetInstance(), &M_CURSORDATA->m_width, &M_CURSORDATA->m_height);
|
refData->m_hCursor = (WXHCURSOR) ReadCursorFile(WXSTRINGCAST cursor_file, wxGetInstance(), &refData->m_width, &refData->m_height);
|
||||||
M_CURSORDATA->m_destroyCursor = TRUE;
|
refData->m_destroyCursor = TRUE;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (flags == wxBITMAP_TYPE_ICO)
|
else if (flags == wxBITMAP_TYPE_ICO)
|
||||||
{
|
{
|
||||||
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) IconToCursor(WXSTRINGCAST cursor_file, wxGetInstance(), hotSpotX, hotSpotY, &M_CURSORDATA->m_width, &M_CURSORDATA->m_height);
|
refData->m_hCursor = (WXHCURSOR) IconToCursor(WXSTRINGCAST cursor_file, wxGetInstance(), hotSpotX, hotSpotY, &refData->m_width, &refData->m_height);
|
||||||
M_CURSORDATA->m_destroyCursor = TRUE;
|
refData->m_destroyCursor = TRUE;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (flags == wxBITMAP_TYPE_BMP)
|
else if (flags == wxBITMAP_TYPE_BMP)
|
||||||
@ -121,159 +134,146 @@ wxCursor::wxCursor(const wxString& cursor_file, long flags, int hotSpotX, int ho
|
|||||||
POINT pnt;
|
POINT pnt;
|
||||||
pnt.x = hotSpotX;
|
pnt.x = hotSpotX;
|
||||||
pnt.y = hotSpotY;
|
pnt.y = hotSpotY;
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) MakeCursorFromBitmap(wxGetInstance(), hBitmap, &pnt);
|
refData->m_hCursor = (WXHCURSOR) MakeCursorFromBitmap(wxGetInstance(), hBitmap, &pnt);
|
||||||
M_CURSORDATA->m_destroyCursor = TRUE;
|
refData->m_destroyCursor = TRUE;
|
||||||
DeleteObject(hBitmap);
|
DeleteObject(hBitmap);
|
||||||
if (M_CURSORDATA->m_hCursor)
|
|
||||||
M_CURSORDATA->m_ok = TRUE;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
refData->SetOk();
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cursors by stock number
|
// Cursors by stock number
|
||||||
wxCursor::wxCursor(int cursor_type)
|
wxCursor::wxCursor(int cursor_type)
|
||||||
{
|
{
|
||||||
m_refData = new wxCursorRefData;
|
wxCursorRefData *refData = new wxCursorRefData;
|
||||||
|
m_refData = refData;
|
||||||
|
|
||||||
switch (cursor_type)
|
switch (cursor_type)
|
||||||
{
|
{
|
||||||
case wxCURSOR_WAIT:
|
case wxCURSOR_WAIT:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_IBEAM:
|
case wxCURSOR_IBEAM:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_CROSS:
|
case wxCURSOR_CROSS:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_SIZENWSE:
|
case wxCURSOR_SIZENWSE:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_SIZENESW:
|
case wxCURSOR_SIZENESW:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_SIZEWE:
|
case wxCURSOR_SIZEWE:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_SIZENS:
|
case wxCURSOR_SIZENS:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
|
||||||
break;
|
break;
|
||||||
case wxCURSOR_CHAR:
|
case wxCURSOR_CHAR:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_HAND:
|
case wxCURSOR_HAND:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_BULLSEYE:
|
case wxCURSOR_BULLSEYE:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_PENCIL:
|
case wxCURSOR_PENCIL:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_MAGNIFIER:
|
case wxCURSOR_MAGNIFIER:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_NO_ENTRY:
|
case wxCURSOR_NO_ENTRY:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_NO_ENTRY"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_LEFT_BUTTON:
|
case wxCURSOR_LEFT_BUTTON:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_RIGHT_BUTTON:
|
case wxCURSOR_RIGHT_BUTTON:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_MIDDLE_BUTTON:
|
case wxCURSOR_MIDDLE_BUTTON:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_SIZING:
|
case wxCURSOR_SIZING:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_WATCH:
|
case wxCURSOR_WATCH:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_SPRAYCAN:
|
case wxCURSOR_SPRAYCAN:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_PAINT_BRUSH:
|
case wxCURSOR_PAINT_BRUSH:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_POINT_LEFT:
|
case wxCURSOR_POINT_LEFT:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_POINT_RIGHT:
|
case wxCURSOR_POINT_RIGHT:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_QUESTION_ARROW:
|
case wxCURSOR_QUESTION_ARROW:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case wxCURSOR_BLANK:
|
case wxCURSOR_BLANK:
|
||||||
{
|
{
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
|
refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
case wxCURSOR_ARROW:
|
case wxCURSOR_ARROW:
|
||||||
M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCursor::~wxCursor(void)
|
wxCursor::~wxCursor()
|
||||||
{
|
{
|
||||||
// FreeResource(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxCursor::FreeResource(bool WXUNUSED(force))
|
|
||||||
{
|
|
||||||
if (M_CURSORDATA && M_CURSORDATA->m_hCursor && M_CURSORDATA->m_destroyCursor)
|
|
||||||
{
|
|
||||||
DestroyCursor((HCURSOR) M_CURSORDATA->m_hCursor);
|
|
||||||
M_CURSORDATA->m_hCursor = 0;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxCursor::SetHCURSOR(WXHCURSOR cursor)
|
|
||||||
{
|
|
||||||
if ( !M_CURSORDATA )
|
|
||||||
m_refData = new wxCursorRefData;
|
|
||||||
|
|
||||||
M_CURSORDATA->m_hCursor = cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
// Global cursor setting
|
// Global cursor setting
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxSetCursor(const wxCursor& cursor)
|
void wxSetCursor(const wxCursor& cursor)
|
||||||
{
|
{
|
||||||
extern wxCursor *g_globalCursor;
|
extern wxCursor *g_globalCursor;
|
||||||
|
@ -731,7 +731,9 @@ bool wxLoadIntoBitmap(wxChar *filename, wxBitmap *bitmap, wxPalette **pal)
|
|||||||
bitmap->SetWidth(bm.bmWidth);
|
bitmap->SetWidth(bm.bmWidth);
|
||||||
bitmap->SetHeight(bm.bmHeight);
|
bitmap->SetHeight(bm.bmHeight);
|
||||||
bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
|
bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
bitmap->SetOk(TRUE);
|
bitmap->SetOk(TRUE);
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
|
@ -357,6 +357,8 @@ wxStatusBar *wxFrame::OnCreateStatusBar(int number,
|
|||||||
if ( UsesNativeStatusBar() )
|
if ( UsesNativeStatusBar() )
|
||||||
{
|
{
|
||||||
statusBar = new wxStatusBar95(this, id, style);
|
statusBar = new wxStatusBar95(this, id, style);
|
||||||
|
|
||||||
|
statusBar->SetFieldsCount(number);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
503
src/msw/gdiimage.cpp
Normal file
503
src/msw/gdiimage.cpp
Normal file
@ -0,0 +1,503 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: msw/gdiimage.cpp
|
||||||
|
// Purpose: wxGDIImage implementation
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 20.11.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "gdiimage.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/string.h"
|
||||||
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/app.h"
|
||||||
|
|
||||||
|
#include "wx/msw/dib.h"
|
||||||
|
#include "wx/msw/gdiimage.h"
|
||||||
|
|
||||||
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// all image handlers are declared/defined in this file because the outside
|
||||||
|
// world doesn't have to know about them (but only about wxBITMAP_TYPE_XXX ids)
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxBMPFileHandler : public wxBitmapHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxBMPFileHandler() : wxBitmapHandler(_T("Windows bitmap file"), _T("bmp"),
|
||||||
|
wxBITMAP_TYPE_BMP)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool LoadFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name, long flags,
|
||||||
|
int desiredWidth, int desiredHeight);
|
||||||
|
virtual bool SaveFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name, int type,
|
||||||
|
const wxPalette *palette = NULL);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxBMPFileHandler)
|
||||||
|
};
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxBMPResourceHandler() : wxBitmapHandler(_T("Windows bitmap resource"),
|
||||||
|
wxEmptyString,
|
||||||
|
wxBITMAP_TYPE_BMP_RESOURCE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool LoadFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name, long flags,
|
||||||
|
int desiredWidth, int desiredHeight);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler)
|
||||||
|
};
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxIconHandler : public wxGDIImageHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxIconHandler(const wxString& name, const wxString& ext, long type)
|
||||||
|
: wxGDIImageHandler(name, ext, type)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// creating and saving icons is not supported
|
||||||
|
virtual bool Create(wxGDIImage *WXUNUSED(image),
|
||||||
|
void *WXUNUSED(data),
|
||||||
|
long WXUNUSED(flags),
|
||||||
|
int WXUNUSED(width),
|
||||||
|
int WXUNUSED(height),
|
||||||
|
int WXUNUSED(depth) = 1)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Save(wxGDIImage *WXUNUSED(image),
|
||||||
|
const wxString& WXUNUSED(name),
|
||||||
|
int WXUNUSED(type))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool Load(wxGDIImage *image,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight)
|
||||||
|
{
|
||||||
|
wxIcon *icon = wxDynamicCast(image, wxIcon);
|
||||||
|
wxCHECK_MSG( icon, FALSE, _T("wxIconHandler only works with icons") );
|
||||||
|
|
||||||
|
return LoadIcon(icon, name, flags, desiredWidth, desiredHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool LoadIcon(wxIcon *icon,
|
||||||
|
const wxString& name, long flags,
|
||||||
|
int desiredWidth = -1, int desiredHeight = -1) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxICOFileHandler : public wxIconHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxICOFileHandler() : wxIconHandler(_T("ICO icon file"),
|
||||||
|
_T("ico"),
|
||||||
|
wxBITMAP_TYPE_ICO)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool LoadIcon(wxIcon *icon,
|
||||||
|
const wxString& name, long flags,
|
||||||
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxICOFileHandler)
|
||||||
|
};
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxICOResourceHandler: public wxIconHandler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxICOResourceHandler() : wxIconHandler(_T("ICO resource"),
|
||||||
|
_T("ico"),
|
||||||
|
wxBITMAP_TYPE_ICO_RESOURCE)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool LoadIcon(wxIcon *icon,
|
||||||
|
const wxString& name, long flags,
|
||||||
|
int desiredWidth = -1, int desiredHeight = -1);
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxICOResourceHandler)
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if !USE_SHARED_LIBRARIES
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBMPFileHandler, wxBitmapHandler)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxGDIImageHandler)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxGDIImageHandler)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static wxSize GetHiconSize(HICON hicon);
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
wxList wxGDIImage::ms_handlers;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIImage functions forwarded to wxGDIImageRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxGDIImage::FreeResource(bool WXUNUSED(force))
|
||||||
|
{
|
||||||
|
if ( !IsNull() )
|
||||||
|
{
|
||||||
|
GetGDIImageData()->Free();
|
||||||
|
GetGDIImageData()->m_handle = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
WXHANDLE wxGDIImage::GetResourceHandle()
|
||||||
|
{
|
||||||
|
return GetHandle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxGDIImage handler stuff
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxGDIImage::AddHandler(wxGDIImageHandler *handler)
|
||||||
|
{
|
||||||
|
ms_handlers.Append(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGDIImage::InsertHandler(wxGDIImageHandler *handler)
|
||||||
|
{
|
||||||
|
ms_handlers.Insert(handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxGDIImage::RemoveHandler(const wxString& name)
|
||||||
|
{
|
||||||
|
wxGDIImageHandler *handler = FindHandler(name);
|
||||||
|
if ( handler )
|
||||||
|
{
|
||||||
|
ms_handlers.DeleteObject(handler);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& name)
|
||||||
|
{
|
||||||
|
wxNode *node = ms_handlers.First();
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxGDIImageHandler *handler = (wxGDIImageHandler *)node->Data();
|
||||||
|
if ( handler->GetName() == name )
|
||||||
|
return handler;
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGDIImageHandler *wxGDIImage::FindHandler(const wxString& extension,
|
||||||
|
long type)
|
||||||
|
{
|
||||||
|
wxNode *node = ms_handlers.First();
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxGDIImageHandler *handler = (wxGDIImageHandler *)node->Data();
|
||||||
|
if ( (handler->GetExtension() = extension) &&
|
||||||
|
(type == -1 || handler->GetType() == type) )
|
||||||
|
{
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxGDIImageHandler *wxGDIImage::FindHandler(long type)
|
||||||
|
{
|
||||||
|
wxNode *node = ms_handlers.First();
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxGDIImageHandler *handler = (wxGDIImageHandler *)node->Data();
|
||||||
|
if ( handler->GetType() == type )
|
||||||
|
return handler;
|
||||||
|
|
||||||
|
node = node->Next();
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGDIImage::CleanUpHandlers()
|
||||||
|
{
|
||||||
|
wxNode *node = ms_handlers.First();
|
||||||
|
while ( node )
|
||||||
|
{
|
||||||
|
wxGDIImageHandler *handler = (wxGDIImageHandler *)node->Data();
|
||||||
|
wxNode *next = node->Next();
|
||||||
|
delete handler;
|
||||||
|
delete node;
|
||||||
|
node = next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxGDIImage::InitStandardHandlers()
|
||||||
|
{
|
||||||
|
AddHandler(new wxBMPResourceHandler);
|
||||||
|
AddHandler(new wxBMPFileHandler);
|
||||||
|
|
||||||
|
// Not added by default: include xpmhand.h in your app
|
||||||
|
// and call these in your wxApp::OnInit.
|
||||||
|
// AddHandler(new wxXPMFileHandler);
|
||||||
|
// AddHandler(new wxXPMDataHandler);
|
||||||
|
|
||||||
|
AddHandler(new wxICOResourceHandler);
|
||||||
|
AddHandler(new wxICOFileHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBitmap handlers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxBMPResourceHandler::LoadFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name, long WXUNUSED(flags),
|
||||||
|
int WXUNUSED(desiredWidth),
|
||||||
|
int WXUNUSED(desiredHeight))
|
||||||
|
{
|
||||||
|
// TODO: load colourmap.
|
||||||
|
bitmap->SetHBITMAP((WXHBITMAP)::LoadBitmap(wxGetInstance(), name));
|
||||||
|
|
||||||
|
wxBitmapRefData *data = bitmap->GetBitmapData();
|
||||||
|
if ( bitmap->Ok() )
|
||||||
|
{
|
||||||
|
BITMAP bm;
|
||||||
|
if ( !::GetObject(GetHbitmapOf(*bitmap), sizeof(BITMAP), (LPSTR) &bm) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetObject(HBITMAP)");
|
||||||
|
}
|
||||||
|
|
||||||
|
data->m_width = bm.bmWidth;
|
||||||
|
data->m_height = bm.bmHeight;
|
||||||
|
data->m_depth = bm.bmBitsPixel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// it's probably not found
|
||||||
|
wxLogError(wxT("Can't load bitmap '%s' from resources! Check .rc file."),
|
||||||
|
name.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return bitmap->Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBMPFileHandler::LoadFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name, long WXUNUSED(flags),
|
||||||
|
int WXUNUSED(desiredWidth),
|
||||||
|
int WXUNUSED(desiredHeight))
|
||||||
|
{
|
||||||
|
#if wxUSE_IMAGE_LOADING_IN_MSW
|
||||||
|
wxPalette *palette = NULL;
|
||||||
|
bool success = wxLoadIntoBitmap(WXSTRINGCAST name, bitmap, &palette) != 0;
|
||||||
|
if ( success && palette )
|
||||||
|
{
|
||||||
|
bitmap->SetPalette(*palette);
|
||||||
|
}
|
||||||
|
|
||||||
|
// it was copied by the bitmap if it was loaded successfully
|
||||||
|
delete palette;
|
||||||
|
|
||||||
|
return success;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBMPFileHandler::SaveFile(wxBitmap *bitmap,
|
||||||
|
const wxString& name,
|
||||||
|
int WXUNUSED(type),
|
||||||
|
const wxPalette *pal)
|
||||||
|
{
|
||||||
|
#if wxUSE_IMAGE_LOADING_IN_MSW
|
||||||
|
wxPalette *actualPalette = (wxPalette *)pal;
|
||||||
|
if ( !actualPalette )
|
||||||
|
actualPalette = bitmap->GetPalette();
|
||||||
|
return wxSaveBitmap(WXSTRINGCAST name, bitmap, actualPalette) != 0;
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxIcon handlers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxICOFileHandler::LoadIcon(wxIcon *icon,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight)
|
||||||
|
{
|
||||||
|
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
||||||
|
icon->UnRef();
|
||||||
|
|
||||||
|
// actual size
|
||||||
|
wxSize size;
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
HICON hicon = ::ExtractIcon(wxGetInstance(), name, 0 /* first */);
|
||||||
|
if ( !hicon )
|
||||||
|
{
|
||||||
|
wxLogSysError(_T("Failed to load icon from the file '%s'"),
|
||||||
|
name.c_str());
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = GetHiconSize(hicon);
|
||||||
|
#else // Win16
|
||||||
|
HICON hicon = ReadIconFile((wxChar *)name.c_str(),
|
||||||
|
wxGetInstance(),
|
||||||
|
&size.x, &size.y);
|
||||||
|
#endif // Win32/Win16
|
||||||
|
|
||||||
|
if ( (desiredWidth != -1 && desiredWidth != size.x) ||
|
||||||
|
(desiredHeight != -1 && desiredHeight != size.y) )
|
||||||
|
{
|
||||||
|
wxLogDebug(_T("Returning FALSE from wxICOFileHandler::Load because "
|
||||||
|
"of the size mismatch: actual (%d, %d), "
|
||||||
|
"requested (%d, %d)"),
|
||||||
|
size.x, size.y,
|
||||||
|
desiredWidth, desiredHeight);
|
||||||
|
|
||||||
|
::DestroyIcon(hicon);
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
icon->SetHICON((WXHICON)hicon);
|
||||||
|
icon->SetSize(size.x, size.y);
|
||||||
|
|
||||||
|
return icon->Ok();
|
||||||
|
#else
|
||||||
|
return FALSE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxICOResourceHandler::LoadIcon(wxIcon *icon,
|
||||||
|
const wxString& name,
|
||||||
|
long flags,
|
||||||
|
int desiredWidth, int desiredHeight)
|
||||||
|
{
|
||||||
|
HICON hicon;
|
||||||
|
|
||||||
|
#if defined(__WIN32__) && !defined(__SC__)
|
||||||
|
if ( desiredWidth != -1 && desiredHeight != -1 )
|
||||||
|
{
|
||||||
|
hicon = (HICON)::LoadImage(wxGetInstance(), name, IMAGE_ICON,
|
||||||
|
desiredWidth, desiredHeight,
|
||||||
|
LR_DEFAULTCOLOR);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // Win32
|
||||||
|
{
|
||||||
|
hicon = ::LoadIcon(wxGetInstance(), name);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize size = GetHiconSize(hicon);
|
||||||
|
icon->SetSize(size.x, size.y);
|
||||||
|
|
||||||
|
// Override the found values with desired values
|
||||||
|
if ( desiredWidth > -1 && desiredHeight > -1 )
|
||||||
|
{
|
||||||
|
icon->SetSize(desiredWidth, desiredHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
icon->SetHICON((WXHICON)hicon);
|
||||||
|
|
||||||
|
return icon->Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// private functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static wxSize GetHiconSize(HICON hicon)
|
||||||
|
{
|
||||||
|
wxSize size(32, 32); // default
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
// Win32s doesn't have GetIconInfo function...
|
||||||
|
if ( hicon && wxGetOsVersion() != wxWIN32S )
|
||||||
|
{
|
||||||
|
ICONINFO info;
|
||||||
|
if ( !::GetIconInfo(hicon, &info) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetIconInfo");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HBITMAP hbmp = info.hbmMask;
|
||||||
|
if ( hbmp )
|
||||||
|
{
|
||||||
|
BITMAP bm;
|
||||||
|
if ( ::GetObject(hbmp, sizeof(BITMAP), (LPSTR) &bm) )
|
||||||
|
{
|
||||||
|
size = wxSize(bm.bmWidth, bm.bmHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
::DeleteObject(info.hbmMask);
|
||||||
|
}
|
||||||
|
if ( info.hbmColor )
|
||||||
|
::DeleteObject(info.hbmColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
166
src/msw/icon.cpp
166
src/msw/icon.cpp
@ -1,14 +1,22 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: icon.cpp
|
// Name: msw/icon.cpp
|
||||||
// Purpose: wxIcon class
|
// Purpose: wxIcon class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart
|
||||||
// Modified by:
|
// Modified by: 20.11.99 (VZ): don't derive from wxBitmap any more
|
||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart and Markus Holzem
|
// Copyright: (c) Julian Smart and Markus Holzem
|
||||||
// Licence: wxWindows license
|
// Licence: wxWindows license
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "icon.h"
|
#pragma implementation "icon.h"
|
||||||
#endif
|
#endif
|
||||||
@ -21,8 +29,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
#include "wx/defs.h"
|
||||||
#include "wx/setup.h"
|
|
||||||
#include "wx/list.h"
|
#include "wx/list.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
@ -30,160 +37,75 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
#include "assert.h"
|
|
||||||
|
|
||||||
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
||||||
#include "wx/msw/curico.h"
|
#include "wx/msw/curico.h"
|
||||||
#include "wx/msw/curicop.h"
|
#include "wx/msw/curicop.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARIES
|
#if !USE_SHARED_LIBRARIES
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxIconBase)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxICOFileHandler, wxBitmapHandler)
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxICOResourceHandler, wxBitmapHandler)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// ============================================================================
|
||||||
* Icons
|
// implementation
|
||||||
*/
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxIconRefData
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxIconRefData::wxIconRefData(void)
|
void wxIconRefData::Free()
|
||||||
{
|
|
||||||
m_hIcon = (WXHICON) NULL ;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxIconRefData::~wxIconRefData(void)
|
|
||||||
{
|
{
|
||||||
if ( m_hIcon )
|
if ( m_hIcon )
|
||||||
::DestroyIcon((HICON) m_hIcon);
|
::DestroyIcon((HICON) m_hIcon);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon(void)
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxIcon
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxIcon::wxIcon()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height))
|
wxIcon::wxIcon(const char WXUNUSED(bits)[],
|
||||||
|
int WXUNUSED(width),
|
||||||
|
int WXUNUSED(height))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::wxIcon(const wxString& icon_file, long flags,
|
wxIcon::wxIcon(const wxString& iconfile,
|
||||||
int desiredWidth, int desiredHeight)
|
long flags,
|
||||||
|
int desiredWidth,
|
||||||
|
int desiredHeight)
|
||||||
|
|
||||||
{
|
{
|
||||||
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
|
LoadFile(iconfile, flags, desiredWidth, desiredHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxIcon::~wxIcon(void)
|
wxIcon::~wxIcon()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxIcon::FreeResource(bool force)
|
bool wxIcon::LoadFile(const wxString& filename,
|
||||||
{
|
long type,
|
||||||
if (M_ICONDATA && M_ICONDATA->m_hIcon)
|
|
||||||
{
|
|
||||||
DestroyIcon((HICON) M_ICONDATA->m_hIcon);
|
|
||||||
M_ICONDATA->m_hIcon = (WXHICON) NULL;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxIcon::LoadFile(const wxString& filename, long type,
|
|
||||||
int desiredWidth, int desiredHeight)
|
int desiredWidth, int desiredHeight)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
m_refData = new wxIconRefData;
|
wxGDIImageHandler *handler = FindHandler(type);
|
||||||
|
|
||||||
wxBitmapHandler *handler = FindHandler(type);
|
if ( !handler )
|
||||||
|
{
|
||||||
if ( handler )
|
// say something?
|
||||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
|
||||||
else
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxIcon::SetHICON(WXHICON ico)
|
return handler->Load(this, filename, type, desiredWidth, desiredHeight);
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
#if wxUSE_RESOURCE_LOADING_IN_MSW
|
|
||||||
if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
|
|
||||||
{
|
|
||||||
wxIcon *icon = (wxIcon *)bitmap;
|
|
||||||
wxIconRefData *data = (wxIconRefData *)icon->GetRefData();
|
|
||||||
data->m_hIcon = (WXHICON)ReadIconFile((wxChar *)name.c_str(), wxGetInstance(),
|
|
||||||
&data->m_width, &data->m_height);
|
|
||||||
|
|
||||||
data->m_ok = data->m_hIcon != 0;
|
|
||||||
return data->m_ok;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxICOResourceHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
|
||||||
int desiredWidth, int desiredHeight)
|
|
||||||
{
|
|
||||||
if ( bitmap->IsKindOf(CLASSINFO(wxIcon)) )
|
|
||||||
{
|
|
||||||
#if defined(__WIN32__) && !defined(__SC__)
|
|
||||||
if (desiredWidth > -1 && desiredHeight > -1)
|
|
||||||
{
|
|
||||||
M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadImage(wxGetInstance(), name, IMAGE_ICON, desiredWidth, desiredHeight, LR_DEFAULTCOLOR);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
// Win32s doesn't have GetIconInfo function...
|
|
||||||
if (M_ICONHANDLERDATA->m_hIcon && wxGetOsVersion()!=wxWIN32S)
|
|
||||||
{
|
|
||||||
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) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
M_ICONHANDLERDATA->m_width = 32;
|
|
||||||
M_ICONHANDLERDATA->m_height = 32;
|
|
||||||
#endif
|
|
||||||
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:56, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE B32.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -245,6 +245,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
|
|||||||
$(MSWDIR)\fontutil.obj \
|
$(MSWDIR)\fontutil.obj \
|
||||||
$(MSWDIR)\frame.obj \
|
$(MSWDIR)\frame.obj \
|
||||||
$(MSWDIR)\gauge95.obj \
|
$(MSWDIR)\gauge95.obj \
|
||||||
|
$(MSWDIR)\gdiimage.obj \
|
||||||
$(MSWDIR)\gdiobj.obj \
|
$(MSWDIR)\gdiobj.obj \
|
||||||
$(MSWDIR)\gsocket.obj \
|
$(MSWDIR)\gsocket.obj \
|
||||||
$(MSWDIR)\helpwin.obj \
|
$(MSWDIR)\helpwin.obj \
|
||||||
@ -446,6 +447,8 @@ $(MSWDIR)\frame.obj: $(MSWDIR)\frame.$(SRCSUFF)
|
|||||||
|
|
||||||
$(MSWDIR)\gauge95.obj: $(MSWDIR)\gauge95.$(SRCSUFF)
|
$(MSWDIR)\gauge95.obj: $(MSWDIR)\gauge95.$(SRCSUFF)
|
||||||
|
|
||||||
|
$(MSWDIR)\gdiimage.obj: $(MSWDIR)\gdiimage.$(SRCSUFF)
|
||||||
|
|
||||||
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
|
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
|
||||||
|
|
||||||
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
|
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:24, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE BCC.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -215,6 +215,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
|
|||||||
$(MSWDIR)\fontutil.obj \
|
$(MSWDIR)\fontutil.obj \
|
||||||
$(MSWDIR)\frame.obj \
|
$(MSWDIR)\frame.obj \
|
||||||
$(MSWDIR)\gaugemsw.obj \
|
$(MSWDIR)\gaugemsw.obj \
|
||||||
|
$(MSWDIR)\gdiimage.obj \
|
||||||
$(MSWDIR)\gdiobj.obj \
|
$(MSWDIR)\gdiobj.obj \
|
||||||
$(MSWDIR)\gsocket.obj \
|
$(MSWDIR)\gsocket.obj \
|
||||||
$(MSWDIR)\helpwin.obj \
|
$(MSWDIR)\helpwin.obj \
|
||||||
@ -360,6 +361,8 @@ $(MSWDIR)\frame.obj: $(MSWDIR)\frame.$(SRCSUFF)
|
|||||||
|
|
||||||
$(MSWDIR)\gaugemsw.obj: $(MSWDIR)\gaugemsw.$(SRCSUFF)
|
$(MSWDIR)\gaugemsw.obj: $(MSWDIR)\gaugemsw.$(SRCSUFF)
|
||||||
|
|
||||||
|
$(MSWDIR)\gdiimage.obj: $(MSWDIR)\gdiimage.$(SRCSUFF)
|
||||||
|
|
||||||
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
|
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
|
||||||
|
|
||||||
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
|
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 14:24, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE DOS.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -204,6 +204,7 @@ MSWOBJS1 = $(MSWDIR)\accel.obj \
|
|||||||
$(MSWDIR)\fontutil.obj \
|
$(MSWDIR)\fontutil.obj \
|
||||||
$(MSWDIR)\frame.obj \
|
$(MSWDIR)\frame.obj \
|
||||||
$(MSWDIR)\gaugemsw.obj \
|
$(MSWDIR)\gaugemsw.obj \
|
||||||
|
$(MSWDIR)\gdiimage.obj \
|
||||||
$(MSWDIR)\gdiobj.obj \
|
$(MSWDIR)\gdiobj.obj \
|
||||||
$(MSWDIR)\gsocket.obj \
|
$(MSWDIR)\gsocket.obj \
|
||||||
$(MSWDIR)\helpwin.obj \
|
$(MSWDIR)\helpwin.obj \
|
||||||
@ -498,6 +499,11 @@ $(MSWDIR)/gaugemsw.obj: $*.$(SRCSUFF)
|
|||||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||||
<<
|
<<
|
||||||
|
|
||||||
|
$(MSWDIR)/gdiimage.obj: $*.$(SRCSUFF)
|
||||||
|
cl @<<
|
||||||
|
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||||
|
<<
|
||||||
|
|
||||||
$(MSWDIR)/gdiobj.obj: $*.$(SRCSUFF)
|
$(MSWDIR)/gdiobj.obj: $*.$(SRCSUFF)
|
||||||
cl @<<
|
cl @<<
|
||||||
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 14:24, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE G95.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -224,6 +224,7 @@ MSWOBJS = \
|
|||||||
$(MSWDIR)/fontutil.$(OBJSUFF) \
|
$(MSWDIR)/fontutil.$(OBJSUFF) \
|
||||||
$(MSWDIR)/frame.$(OBJSUFF) \
|
$(MSWDIR)/frame.$(OBJSUFF) \
|
||||||
$(MSWDIR)/gauge95.$(OBJSUFF) \
|
$(MSWDIR)/gauge95.$(OBJSUFF) \
|
||||||
|
$(MSWDIR)/gdiimage.$(OBJSUFF) \
|
||||||
$(MSWDIR)/gdiobj.$(OBJSUFF) \
|
$(MSWDIR)/gdiobj.$(OBJSUFF) \
|
||||||
$(MSWDIR)/gsocket.$(OBJSUFF) \
|
$(MSWDIR)/gsocket.$(OBJSUFF) \
|
||||||
$(MSWDIR)/helpwin.$(OBJSUFF) \
|
$(MSWDIR)/helpwin.$(OBJSUFF) \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:24, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE SC.T!
|
||||||
|
|
||||||
# Symantec C++ makefile for the msw objects
|
# Symantec C++ makefile for the msw objects
|
||||||
@ -184,6 +184,7 @@ MSWOBJS = $(MSWDIR)\accel.obj \
|
|||||||
$(MSWDIR)\frame.obj \
|
$(MSWDIR)\frame.obj \
|
||||||
$(MSWDIR)\gauge95.obj \
|
$(MSWDIR)\gauge95.obj \
|
||||||
$(MSWDIR)\gaugemsw.obj \
|
$(MSWDIR)\gaugemsw.obj \
|
||||||
|
$(MSWDIR)\gdiimage.obj \
|
||||||
$(MSWDIR)\gdiobj.obj \
|
$(MSWDIR)\gdiobj.obj \
|
||||||
$(MSWDIR)\gsocket.obj \
|
$(MSWDIR)\gsocket.obj \
|
||||||
$(MSWDIR)\helpwin.obj \
|
$(MSWDIR)\helpwin.obj \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# This file was automatically generated by tmake at 10:51, 1999/11/24
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE VC.T!
|
||||||
|
|
||||||
# File: makefile.vc
|
# File: makefile.vc
|
||||||
@ -262,6 +262,7 @@ MSWOBJS = ..\msw\$D\accel.obj \
|
|||||||
..\msw\$D\fontutil.obj \
|
..\msw\$D\fontutil.obj \
|
||||||
..\msw\$D\frame.obj \
|
..\msw\$D\frame.obj \
|
||||||
..\msw\$D\gauge95.obj \
|
..\msw\$D\gauge95.obj \
|
||||||
|
..\msw\$D\gdiimage.obj \
|
||||||
..\msw\$D\gdiobj.obj \
|
..\msw\$D\gdiobj.obj \
|
||||||
..\msw\$D\gsocket.obj \
|
..\msw\$D\gsocket.obj \
|
||||||
..\msw\$D\helpwin.obj \
|
..\msw\$D\helpwin.obj \
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/binb/wmake.exe
|
#!/binb/wmake.exe
|
||||||
|
|
||||||
# This file was automatically generated by tmake at 14:24, 1999/11/15
|
# This file was automatically generated by tmake at 13:22, 1999/11/24
|
||||||
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE WAT.T!
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -217,6 +217,7 @@ MSWOBJS = accel.obj &
|
|||||||
frame.obj &
|
frame.obj &
|
||||||
gauge95.obj &
|
gauge95.obj &
|
||||||
gaugemsw.obj &
|
gaugemsw.obj &
|
||||||
|
gdiimage.obj &
|
||||||
gdiobj.obj &
|
gdiobj.obj &
|
||||||
gsocket.obj &
|
gsocket.obj &
|
||||||
helpwin.obj &
|
helpwin.obj &
|
||||||
@ -422,6 +423,9 @@ gauge95.obj: $(MSWDIR)\gauge95.cpp
|
|||||||
gaugemsw.obj: $(MSWDIR)\gaugemsw.cpp
|
gaugemsw.obj: $(MSWDIR)\gaugemsw.cpp
|
||||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||||
|
|
||||||
|
gdiimage.obj: $(MSWDIR)\gdiimage.cpp
|
||||||
|
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||||
|
|
||||||
gdiobj.obj: $(MSWDIR)\gdiobj.cpp
|
gdiobj.obj: $(MSWDIR)\gdiobj.cpp
|
||||||
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
|
||||||
|
|
||||||
|
@ -27,17 +27,18 @@
|
|||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WIN32__) && !defined(__GNUWIN32_OLD__)
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/intl.h"
|
#include "wx/intl.h"
|
||||||
#endif
|
|
||||||
#include "wx/defs.h"
|
|
||||||
|
|
||||||
#if defined(__WIN32__) && !defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS)
|
|
||||||
|
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/dataobj.h"
|
#include "wx/dataobj.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include "wx/msw/private.h" // includes <windows.h>
|
||||||
|
|
||||||
#ifdef wxUSE_NORLANDER_HEADERS
|
#ifdef wxUSE_NORLANDER_HEADERS
|
||||||
#include <ole2.h>
|
#include <ole2.h>
|
||||||
#endif
|
#endif
|
||||||
@ -52,6 +53,8 @@
|
|||||||
|
|
||||||
#include "wx/msw/ole/oleutils.h"
|
#include "wx/msw/ole/oleutils.h"
|
||||||
|
|
||||||
|
#include "wx/msw/dib.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// functions
|
// functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -62,10 +65,6 @@
|
|||||||
#define GetTymedName(tymed) ""
|
#define GetTymedName(tymed) ""
|
||||||
#endif // Debug/!Debug
|
#endif // Debug/!Debug
|
||||||
|
|
||||||
// to be moved into wx/msw/bitmap.h
|
|
||||||
extern size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap);
|
|
||||||
extern wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *bmi);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxIEnumFORMATETC interface implementation
|
// wxIEnumFORMATETC interface implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -124,22 +123,6 @@ private:
|
|||||||
bool m_mustDelete;
|
bool m_mustDelete;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// small helper class for getting screen DC (we're working with bitmaps and
|
|
||||||
// DIBs here)
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class ScreenHDC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScreenHDC() { m_hdc = GetDC(NULL); }
|
|
||||||
~ScreenHDC() { ReleaseDC(NULL, m_hdc); }
|
|
||||||
operator HDC() const { return m_hdc; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
HDC m_hdc;
|
|
||||||
};
|
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// implementation
|
// implementation
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@ -736,12 +719,12 @@ size_t wxBitmapDataObject::GetDataSize() const
|
|||||||
|
|
||||||
bool wxBitmapDataObject::GetDataHere(void *buf) const
|
bool wxBitmapDataObject::GetDataHere(void *buf) const
|
||||||
{
|
{
|
||||||
return wxConvertBitmapToDIB((BITMAPINFO *)buf, GetBitmap()) != 0;
|
return wxConvertBitmapToDIB((LPBITMAPINFO)buf, GetBitmap()) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapDataObject::SetData(size_t len, const void *buf)
|
bool wxBitmapDataObject::SetData(size_t len, const void *buf)
|
||||||
{
|
{
|
||||||
wxBitmap bitmap(wxConvertDIBToBitmap((const BITMAPINFO *)buf));
|
wxBitmap bitmap(wxConvertDIBToBitmap((const LPBITMAPINFO)buf));
|
||||||
|
|
||||||
if ( !bitmap.Ok() ) {
|
if ( !bitmap.Ok() ) {
|
||||||
wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
|
wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
|
||||||
@ -1065,7 +1048,7 @@ static size_t wxGetNumOfBitmapColors(size_t bitsPerPixel)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap)
|
size_t wxConvertBitmapToDIB(LPBITMAPINFO pbi, const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( bitmap.Ok(), wxT("invalid bmp can't be converted to DIB") );
|
wxASSERT_MSG( bitmap.Ok(), wxT("invalid bmp can't be converted to DIB") );
|
||||||
|
|
||||||
@ -1139,7 +1122,7 @@ size_t wxConvertBitmapToDIB(BITMAPINFO *pbi, const wxBitmap& bitmap)
|
|||||||
return dwLen + bi.biSizeImage;
|
return dwLen + bi.biSizeImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxConvertDIBToBitmap(const BITMAPINFO *pbmi)
|
wxBitmap wxConvertDIBToBitmap(const LPBITMAPINFO pbmi)
|
||||||
{
|
{
|
||||||
// here we get BITMAPINFO struct followed by the actual bitmap bits and
|
// here we get BITMAPINFO struct followed by the actual bitmap bits and
|
||||||
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
|
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
|
||||||
|
@ -313,8 +313,9 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap)
|
|||||||
bitmap->SetDepth(GetDepth());
|
bitmap->SetDepth(GetDepth());
|
||||||
if ( GetDepth() > 1 && Palette )
|
if ( GetDepth() > 1 && Palette )
|
||||||
bitmap->SetPalette(*Palette);
|
bitmap->SetPalette(*Palette);
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
bitmap->SetOk(TRUE);
|
bitmap->SetOk(TRUE);
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
// Make a mask if appropriate
|
// Make a mask if appropriate
|
||||||
if ( bgindex > -1 )
|
if ( bgindex > -1 )
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxBitmap& bitmap,
|
const wxGDIImage& bitmap,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size,
|
const wxSize& size,
|
||||||
long style,
|
long style,
|
||||||
@ -108,7 +108,7 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
|
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
|
||||||
|
|
||||||
SetBitmap(bitmap);
|
SetImage(bitmap);
|
||||||
|
|
||||||
// Subclass again for purposes of dialog editing mode
|
// Subclass again for purposes of dialog editing mode
|
||||||
SubclassWin(m_hWnd);
|
SubclassWin(m_hWnd);
|
||||||
@ -122,22 +122,14 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
bool wxStaticBitmap::ImageIsOk() const
|
bool wxStaticBitmap::ImageIsOk() const
|
||||||
{
|
{
|
||||||
if ( m_isIcon && m_image.icon )
|
return m_image && m_image->Ok();
|
||||||
return m_image.icon->Ok();
|
|
||||||
else if ( m_image.bitmap )
|
|
||||||
return m_image.bitmap->Ok();
|
|
||||||
else
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::Free()
|
void wxStaticBitmap::Free()
|
||||||
{
|
{
|
||||||
if ( m_isIcon )
|
delete m_image;
|
||||||
delete m_image.icon;
|
|
||||||
else
|
|
||||||
delete m_image.bitmap;
|
|
||||||
|
|
||||||
m_image.icon = NULL;
|
m_image = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||||
@ -147,15 +139,15 @@ wxSize wxStaticBitmap::DoGetBestSize() const
|
|||||||
return wxWindow::DoGetBestSize();
|
return wxWindow::DoGetBestSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
void wxStaticBitmap::SetImage(const wxGDIImage& bitmap)
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
|
|
||||||
m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
|
m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
|
||||||
if ( m_isIcon )
|
if ( m_isIcon )
|
||||||
m_image.icon = new wxIcon((const wxIcon&)bitmap);
|
m_image = new wxIcon((const wxIcon&)bitmap);
|
||||||
else
|
else
|
||||||
m_image.bitmap = new wxBitmap(bitmap);
|
m_image = new wxBitmap((const wxBitmap &)bitmap);
|
||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
int w, h;
|
int w, h;
|
||||||
@ -163,9 +155,8 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
|||||||
GetSize(&w, &h);
|
GetSize(&w, &h);
|
||||||
|
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
HANDLE handle = m_isIcon ? (HANDLE)m_image.icon->GetHICON()
|
HANDLE handle = (HANDLE)m_image->GetHandle();
|
||||||
: (HANDLE)m_image.bitmap->GetHBITMAP();
|
::SendMessage(GetHwnd(), STM_SETIMAGE,
|
||||||
::SendMessage((HWND)m_hWnd, STM_SETIMAGE,
|
|
||||||
m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
|
m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
|
||||||
#endif // Win32
|
#endif // Win32
|
||||||
|
|
||||||
@ -178,7 +169,7 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
|||||||
w = width;
|
w = width;
|
||||||
h = height;
|
h = height;
|
||||||
|
|
||||||
::MoveWindow((HWND)GetHWND(), x, y, width, height, FALSE);
|
::MoveWindow(GetHwnd(), x, y, width, height, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,7 +178,7 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
|||||||
rect.top = y;
|
rect.top = y;
|
||||||
rect.right = x + w;
|
rect.right = x + w;
|
||||||
rect.bottom = y + h;
|
rect.bottom = y + h;
|
||||||
InvalidateRect((HWND)GetParent()->GetHWND(), &rect, TRUE);
|
InvalidateRect(GetHwndOf(GetParent()), &rect, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// under Win32 we use the standard static control style for this
|
// under Win32 we use the standard static control style for this
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
# include <fstream>
|
# include <fstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS))
|
#if wxUSE_RICHEDIT
|
||||||
#include <richedit.h>
|
#include <richedit.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -115,8 +115,6 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
if ( !CreateBase(parent, id, pos, size, style, validator, name) )
|
if ( !CreateBase(parent, id, pos, size, style, validator, name) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Validator was set in CreateBase
|
|
||||||
//SetValidator(validator);
|
|
||||||
if ( parent )
|
if ( parent )
|
||||||
parent->AddChild(this);
|
parent->AddChild(this);
|
||||||
|
|
||||||
@ -171,11 +169,34 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
#if wxUSE_RICHEDIT
|
#if wxUSE_RICHEDIT
|
||||||
if ( m_windowStyle & wxTE_RICH )
|
if ( m_windowStyle & wxTE_RICH )
|
||||||
|
{
|
||||||
|
static bool s_errorGiven = FALSE; // MT-FIXME
|
||||||
|
|
||||||
|
// only give the error msg once if the DLL can't be loaded
|
||||||
|
if ( !s_errorGiven )
|
||||||
|
{
|
||||||
|
// first try to load the RichEdit DLL (will do nothing if already
|
||||||
|
// done)
|
||||||
|
if ( !wxTheApp->InitRichEdit() )
|
||||||
|
{
|
||||||
|
wxLogError(_("Impossible to create a rich edit control, "
|
||||||
|
"using simple text control instead."));
|
||||||
|
|
||||||
|
s_errorGiven = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( s_errorGiven )
|
||||||
|
{
|
||||||
|
m_isRich = FALSE;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
msStyle |= ES_AUTOVSCROLL;
|
msStyle |= ES_AUTOVSCROLL;
|
||||||
m_isRich = TRUE;
|
m_isRich = TRUE;
|
||||||
windowClass = wxT("RICHEDIT");
|
windowClass = wxT("RICHEDIT");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
m_isRich = FALSE;
|
m_isRich = FALSE;
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,9 +31,7 @@
|
|||||||
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
|
|
||||||
#include <stdio.h>
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#include "wx/module.h"
|
#include "wx/module.h"
|
||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
@ -84,6 +82,7 @@ static bool s_waitingForThread = FALSE;
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxMutex implementation
|
// wxMutex implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxMutexInternal
|
class wxMutexInternal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -237,42 +236,27 @@ void wxCondition::Broadcast()
|
|||||||
// wxCriticalSection implementation
|
// wxCriticalSection implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxCriticalSectionInternal
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// init the critical section object
|
|
||||||
wxCriticalSectionInternal()
|
|
||||||
{ ::InitializeCriticalSection(&m_data); }
|
|
||||||
|
|
||||||
// implicit cast to the associated data
|
|
||||||
operator CRITICAL_SECTION *() { return &m_data; }
|
|
||||||
|
|
||||||
// free the associated ressources
|
|
||||||
~wxCriticalSectionInternal()
|
|
||||||
{ ::DeleteCriticalSection(&m_data); }
|
|
||||||
|
|
||||||
private:
|
|
||||||
CRITICAL_SECTION m_data;
|
|
||||||
};
|
|
||||||
|
|
||||||
wxCriticalSection::wxCriticalSection()
|
wxCriticalSection::wxCriticalSection()
|
||||||
{
|
{
|
||||||
m_critsect = new wxCriticalSectionInternal;
|
wxASSERT_MSG( sizeof(CRITICAL_SECTION) == sizeof(m_buffer),
|
||||||
|
_T("must increase buffer size in wx/thread.h") );
|
||||||
|
|
||||||
|
::InitializeCriticalSection((CRITICAL_SECTION *)m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxCriticalSection::~wxCriticalSection()
|
wxCriticalSection::~wxCriticalSection()
|
||||||
{
|
{
|
||||||
delete m_critsect;
|
::DeleteCriticalSection((CRITICAL_SECTION *)m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCriticalSection::Enter()
|
void wxCriticalSection::Enter()
|
||||||
{
|
{
|
||||||
::EnterCriticalSection(*m_critsect);
|
::EnterCriticalSection((CRITICAL_SECTION *)m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxCriticalSection::Leave()
|
void wxCriticalSection::Leave()
|
||||||
{
|
{
|
||||||
::LeaveCriticalSection(*m_critsect);
|
::LeaveCriticalSection((CRITICAL_SECTION *)m_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -1841,8 +1841,9 @@ long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
|
|||||||
short y = HIWORD(lParam);
|
short y = HIWORD(lParam);
|
||||||
|
|
||||||
processed = HandleMouseMove(x, y, wParam);
|
processed = HandleMouseMove(x, y, wParam);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN:
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP:
|
||||||
case WM_LBUTTONDBLCLK:
|
case WM_LBUTTONDBLCLK:
|
||||||
|
@ -45,6 +45,25 @@
|
|||||||
#include "wx/xpmhand.h"
|
#include "wx/xpmhand.h"
|
||||||
#include "wx/msw/dib.h"
|
#include "wx/msw/dib.h"
|
||||||
|
|
||||||
|
static void XpmToBitmap(wxBitmap *bitmap,
|
||||||
|
const XImage *ximage,
|
||||||
|
const XpmAttributes& xpmAttr)
|
||||||
|
{
|
||||||
|
wxBitmapRefData *refData = bitmap->GetBitmapData();
|
||||||
|
refData->m_hBitmap = (WXHBITMAP)ximage->bitmap;
|
||||||
|
|
||||||
|
BITMAP bm;
|
||||||
|
if ( !::GetObject(GetHbitmapOf(*bitmap), sizeof(bm), (LPSTR) & bm) )
|
||||||
|
{
|
||||||
|
wxLogLastError("GetObject(bitmap)");
|
||||||
|
}
|
||||||
|
|
||||||
|
refData->m_width = bm.bmWidth;
|
||||||
|
refData->m_height = bm.bmHeight;
|
||||||
|
refData->m_depth = bm.bmPlanes * bm.bmBitsPixel;
|
||||||
|
refData->m_numColors = xpmAttr.npixels;
|
||||||
|
}
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
|
||||||
|
|
||||||
bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
|
||||||
@ -55,7 +74,6 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
|
|||||||
XpmAttributes xpmAttr;
|
XpmAttributes xpmAttr;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
|
||||||
dc = CreateCompatibleDC(NULL);
|
dc = CreateCompatibleDC(NULL);
|
||||||
if (dc)
|
if (dc)
|
||||||
{
|
{
|
||||||
@ -64,26 +82,17 @@ bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long fla
|
|||||||
DeleteDC(dc);
|
DeleteDC(dc);
|
||||||
if (errorStatus == XpmSuccess)
|
if (errorStatus == XpmSuccess)
|
||||||
{
|
{
|
||||||
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
|
XpmToBitmap(bitmap, ximage, xpmAttr);
|
||||||
|
|
||||||
BITMAP bm;
|
|
||||||
GetObject((HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm);
|
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
|
|
||||||
M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel);
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
|
||||||
XpmFreeAttributes(&xpmAttr);
|
XpmFreeAttributes(&xpmAttr);
|
||||||
XImageFree(ximage);
|
XImageFree(ximage);
|
||||||
|
}
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
#if WXWIN_COMPATIBILITY_2
|
||||||
return TRUE;
|
bitmap->SetOk(errorStatus == XpmSuccess);
|
||||||
}
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
else
|
|
||||||
{
|
return bitmap->Ok();
|
||||||
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -100,16 +109,18 @@ bool wxXPMFileHandler::SaveFile(wxBitmap *bitmap, const wxString& name, int type
|
|||||||
dc = CreateCompatibleDC(NULL);
|
dc = CreateCompatibleDC(NULL);
|
||||||
if (dc)
|
if (dc)
|
||||||
{
|
{
|
||||||
if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
|
if ( SelectObject(dc, GetHbitmapOf(*bitmap)) )
|
||||||
{
|
{
|
||||||
/* for following SetPixel */
|
/* for following SetPixel */
|
||||||
/* fill the XImage struct 'by hand' */
|
/* fill the XImage struct 'by hand' */
|
||||||
ximage.width = M_BITMAPHANDLERDATA->m_width;
|
wxBitmapRefData *refData = bitmap->GetBitmapData();
|
||||||
ximage.height = M_BITMAPHANDLERDATA->m_height;
|
ximage.width = refData->m_width;
|
||||||
ximage.depth = M_BITMAPHANDLERDATA->m_depth;
|
ximage.height = refData->m_height;
|
||||||
ximage.bitmap = (HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap;
|
ximage.depth = refData->m_depth;
|
||||||
|
ximage.bitmap = (HBITMAP)refData->m_hBitmap;
|
||||||
int errorStatus = XpmWriteFileFromImage(&dc, wxMBSTRINGCAST name.fn_str(),
|
int errorStatus = XpmWriteFileFromImage(&dc, wxMBSTRINGCAST name.fn_str(),
|
||||||
&ximage, (XImage *) NULL, (XpmAttributes *) NULL);
|
&ximage, (XImage *) NULL,
|
||||||
|
(XpmAttributes *) NULL);
|
||||||
|
|
||||||
if (dc)
|
if (dc)
|
||||||
DeleteDC(dc);
|
DeleteDC(dc);
|
||||||
@ -135,9 +146,6 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt
|
|||||||
XpmAttributes xpmAttr;
|
XpmAttributes xpmAttr;
|
||||||
HDC dc;
|
HDC dc;
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = 0;
|
|
||||||
|
|
||||||
dc = CreateCompatibleDC(NULL); /* memory DC */
|
dc = CreateCompatibleDC(NULL); /* memory DC */
|
||||||
|
|
||||||
if (dc)
|
if (dc)
|
||||||
@ -148,32 +156,25 @@ bool wxXPMDataHandler::Create(wxBitmap *bitmap, void *data, long flags, int widt
|
|||||||
|
|
||||||
if (ErrorStatus == XpmSuccess)
|
if (ErrorStatus == XpmSuccess)
|
||||||
{
|
{
|
||||||
/* ximage is malloced and contains bitmap and attributes */
|
XpmToBitmap(bitmap, ximage, xpmAttr);
|
||||||
M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
|
|
||||||
|
|
||||||
BITMAP bm;
|
|
||||||
GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm);
|
|
||||||
|
|
||||||
M_BITMAPHANDLERDATA->m_width = (bm.bmWidth);
|
|
||||||
M_BITMAPHANDLERDATA->m_height = (bm.bmHeight);
|
|
||||||
M_BITMAPHANDLERDATA->m_depth = (bm.bmPlanes * bm.bmBitsPixel);
|
|
||||||
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
|
|
||||||
XpmFreeAttributes(&xpmAttr);
|
XpmFreeAttributes(&xpmAttr);
|
||||||
|
|
||||||
XImageFree(ximage); // releases the malloc, but does not detroy
|
XImageFree(ximage); // releases the malloc, but does not detroy
|
||||||
// the bitmap
|
// the bitmap
|
||||||
M_BITMAPHANDLERDATA->m_ok = TRUE;
|
|
||||||
DeleteDC(dc);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
M_BITMAPHANDLERDATA->m_ok = FALSE;
|
|
||||||
// XpmDebugError(ErrorStatus, NULL);
|
// XpmDebugError(ErrorStatus, NULL);
|
||||||
DeleteDC(dc);
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeleteDC(dc);
|
||||||
|
|
||||||
|
#if WXWIN_COMPATIBILITY_2
|
||||||
|
bitmap->SetOk(errorStatus == XpmSuccess);
|
||||||
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
|
return bitmap->Ok();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user