frame.cpp M
gauge95.cpp M 32
gaugemsw.cpp M 16
+gdiimage.cpp M
gdiobj.cpp M
helpwin.cpp M
icon.cpp M
gauge.h 9
gauge95.h 9
gaugemsw.h 9
+gdiimage.h 9
gdiobj.h 9
helpwin.h 9
icon.h 9
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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_
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "cursor.h"
+ #pragma implementation "cursor.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#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/cursor.h"
-#include "wx/icon.h"
+ #include "wx/list.h"
+ #include "wx/utils.h"
+ #include "wx/app.h"
+ #include "wx/cursor.h"
+ #include "wx/icon.h"
#endif
#include "wx/msw/private.h"
#include "wx/msw/dib.h"
-#include "assert.h"
-
#if wxUSE_RESOURCE_LOADING_IN_MSW
-#include "wx/msw/curico.h"
-#include "wx/msw/curicop.h"
+ #include "wx/msw/curico.h"
+ #include "wx/msw/curicop.h"
#endif
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
#if !USE_SHARED_LIBRARIES
-IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
+ IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxCursorBase)
#endif
-wxCursorRefData::wxCursorRefData(void)
+// ----------------------------------------------------------------------------
+// wxCursorRefData
+// ----------------------------------------------------------------------------
+
+wxCursorRefData::wxCursorRefData()
{
- m_width = 32; m_height = 32;
- m_hCursor = 0 ;
+ m_width = 32;
+ m_height = 32;
+
m_destroyCursor = FALSE;
}
-wxCursorRefData::~wxCursorRefData(void)
+void wxCursorRefData::Free()
{
- if ( m_hCursor && m_destroyCursor)
-#ifdef __WXWINE__
- ::DestroyCursor((HCURSOR) m_hCursor);
-#else
- ::DestroyCursor((HICON) m_hCursor);
-#endif
+ if ( m_hCursor && m_destroyCursor )
+ ::DestroyCursor((HCURSOR)m_hCursor);
}
+// ----------------------------------------------------------------------------
// Cursors
-wxCursor::wxCursor(void)
+// ----------------------------------------------------------------------------
+
+wxCursor::wxCursor()
{
}
-wxCursor::wxCursor(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height),
- int WXUNUSED(hotSpotX), int WXUNUSED(hotSpotY), const char WXUNUSED(maskBits)[])
+wxCursor::wxCursor(const char WXUNUSED(bits)[],
+ 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;
- M_CURSORDATA->m_destroyCursor = FALSE;
- M_CURSORDATA->m_hCursor = 0;
- M_CURSORDATA->m_ok = FALSE;
- if (flags == wxBITMAP_TYPE_CUR_RESOURCE)
- {
+ refData->m_destroyCursor = FALSE;
+
+ if (flags == wxBITMAP_TYPE_CUR_RESOURCE)
+ {
#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
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), cursor_file);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), cursor_file);
#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__
- 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
#if wxUSE_RESOURCE_LOADING_IN_MSW
- M_CURSORDATA->m_hCursor = (WXHCURSOR) ReadCursorFile(WXSTRINGCAST cursor_file, wxGetInstance(), &M_CURSORDATA->m_width, &M_CURSORDATA->m_height);
- M_CURSORDATA->m_destroyCursor = TRUE;
+ refData->m_hCursor = (WXHCURSOR) ReadCursorFile(WXSTRINGCAST cursor_file, wxGetInstance(), &refData->m_width, &refData->m_height);
+ refData->m_destroyCursor = TRUE;
#endif
#endif
- }
- else if (flags == wxBITMAP_TYPE_ICO)
- {
+ }
+ else if (flags == wxBITMAP_TYPE_ICO)
+ {
#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);
- M_CURSORDATA->m_destroyCursor = TRUE;
+ refData->m_hCursor = (WXHCURSOR) IconToCursor(WXSTRINGCAST cursor_file, wxGetInstance(), hotSpotX, hotSpotY, &refData->m_width, &refData->m_height);
+ refData->m_destroyCursor = TRUE;
#endif
- }
- else if (flags == wxBITMAP_TYPE_BMP)
- {
+ }
+ else if (flags == wxBITMAP_TYPE_BMP)
+ {
#if wxUSE_RESOURCE_LOADING_IN_MSW
- HBITMAP hBitmap = 0;
- HPALETTE hPalette = 0;
- bool success = wxReadDIB(WXSTRINGCAST cursor_file, &hBitmap, &hPalette) != 0;
- if (!success)
- return;
- if (hPalette)
- DeleteObject(hPalette);
- POINT pnt;
- pnt.x = hotSpotX;
- pnt.y = hotSpotY;
- M_CURSORDATA->m_hCursor = (WXHCURSOR) MakeCursorFromBitmap(wxGetInstance(), hBitmap, &pnt);
- M_CURSORDATA->m_destroyCursor = TRUE;
- DeleteObject(hBitmap);
- if (M_CURSORDATA->m_hCursor)
- M_CURSORDATA->m_ok = TRUE;
+ HBITMAP hBitmap = 0;
+ HPALETTE hPalette = 0;
+ bool success = wxReadDIB(WXSTRINGCAST cursor_file, &hBitmap, &hPalette) != 0;
+ if (!success)
+ return;
+ if (hPalette)
+ DeleteObject(hPalette);
+ POINT pnt;
+ pnt.x = hotSpotX;
+ pnt.y = hotSpotY;
+ refData->m_hCursor = (WXHCURSOR) MakeCursorFromBitmap(wxGetInstance(), hBitmap, &pnt);
+ refData->m_destroyCursor = TRUE;
+ DeleteObject(hBitmap);
#endif
- }
+ }
+
+#if WXWIN_COMPATIBILITY_2
+ refData->SetOk();
+#endif // WXWIN_COMPATIBILITY_2
}
// Cursors by stock number
wxCursor::wxCursor(int cursor_type)
{
- m_refData = new wxCursorRefData;
+ wxCursorRefData *refData = new wxCursorRefData;
+ m_refData = refData;
switch (cursor_type)
{
case wxCURSOR_WAIT:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_WAIT);
break;
case wxCURSOR_IBEAM:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_IBEAM);
break;
case wxCURSOR_CROSS:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_CROSS);
break;
case wxCURSOR_SIZENWSE:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENWSE);
break;
case wxCURSOR_SIZENESW:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENESW);
break;
case wxCURSOR_SIZEWE:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZEWE);
break;
case wxCURSOR_SIZENS:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_SIZENS);
break;
case wxCURSOR_CHAR:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_HAND:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_HAND"));
break;
}
case wxCURSOR_BULLSEYE:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BULLSEYE"));
break;
}
case wxCURSOR_PENCIL:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PENCIL"));
break;
}
case wxCURSOR_MAGNIFIER:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_MAGNIFIER"));
break;
}
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;
}
case wxCURSOR_LEFT_BUTTON:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_RIGHT_BUTTON:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_MIDDLE_BUTTON:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
case wxCURSOR_SIZING:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_SIZING"));
break;
}
case wxCURSOR_WATCH:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_WATCH"));
break;
}
case wxCURSOR_SPRAYCAN:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_ROLLER"));
break;
}
case wxCURSOR_PAINT_BRUSH:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PBRUSH"));
break;
}
case wxCURSOR_POINT_LEFT:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PLEFT"));
break;
}
case wxCURSOR_POINT_RIGHT:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_PRIGHT"));
break;
}
case wxCURSOR_QUESTION_ARROW:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_QARROW"));
break;
}
case wxCURSOR_BLANK:
{
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
+ refData->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), wxT("wxCURSOR_BLANK"));
break;
}
default:
case wxCURSOR_ARROW:
- M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
+ refData->m_hCursor = (WXHCURSOR) LoadCursor((HINSTANCE) NULL, IDC_ARROW);
break;
}
}
-wxCursor::~wxCursor(void)
-{
-// 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)
+wxCursor::~wxCursor()
{
- if ( !M_CURSORDATA )
- m_refData = new wxCursorRefData;
-
- M_CURSORDATA->m_hCursor = cursor;
}
+// ----------------------------------------------------------------------------
// Global cursor setting
+// ----------------------------------------------------------------------------
+
void wxSetCursor(const wxCursor& cursor)
{
extern wxCursor *g_globalCursor;
bitmap->SetWidth(bm.bmWidth);
bitmap->SetHeight(bm.bmHeight);
bitmap->SetDepth(bm.bmPlanes * bm.bmBitsPixel);
+#if WXWIN_COMPATIBILITY_2
bitmap->SetOk(TRUE);
+#endif // WXWIN_COMPATIBILITY_2
return TRUE;
}
else return FALSE;
if ( UsesNativeStatusBar() )
{
statusBar = new wxStatusBar95(this, id, style);
+
+ statusBar->SetFieldsCount(number);
}
else
#endif
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// 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;
+}
/////////////////////////////////////////////////////////////////////////////
-// Name: icon.cpp
+// Name: msw/icon.cpp
// Purpose: wxIcon class
// Author: Julian Smart
-// Modified by:
+// Modified by: 20.11.99 (VZ): don't derive from wxBitmap any more
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
+// ============================================================================
+// declarations
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
#ifdef __GNUG__
-#pragma implementation "icon.h"
+ #pragma implementation "icon.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#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/msw/private.h"
-#include "assert.h"
#if wxUSE_RESOURCE_LOADING_IN_MSW
-#include "wx/msw/curico.h"
-#include "wx/msw/curicop.h"
+ #include "wx/msw/curico.h"
+ #include "wx/msw/curicop.h"
#endif
+// ----------------------------------------------------------------------------
+// wxWin macros
+// ----------------------------------------------------------------------------
+
#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)
+void wxIconRefData::Free()
{
- m_hIcon = (WXHICON) NULL ;
+ if ( m_hIcon )
+ ::DestroyIcon((HICON) m_hIcon);
}
-wxIconRefData::~wxIconRefData(void)
-{
- if ( m_hIcon )
- ::DestroyIcon((HICON) m_hIcon);
-}
+// ----------------------------------------------------------------------------
+// wxIcon
+// ----------------------------------------------------------------------------
-wxIcon::wxIcon(void)
+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,
- int desiredWidth, int desiredHeight)
+wxIcon::wxIcon(const wxString& iconfile,
+ 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,
+ int desiredWidth, int desiredHeight)
{
- if (M_ICONDATA && M_ICONDATA->m_hIcon)
- {
- DestroyIcon((HICON) M_ICONDATA->m_hIcon);
- M_ICONDATA->m_hIcon = (WXHICON) NULL;
- }
- return TRUE;
-}
+ UnRef();
-bool wxIcon::LoadFile(const wxString& filename, long type,
- int desiredWidth, int desiredHeight)
-{
- 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;
+ wxGDIImageHandler *handler = FindHandler(type);
- 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
+ if ( !handler )
{
- M_ICONHANDLERDATA->m_hIcon = (WXHICON) ::LoadIcon(wxGetInstance(), name);
+ // say something?
+ return FALSE;
}
-#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;
+ return handler->Load(this, filename, type, desiredWidth, desiredHeight);
}
-# 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!
#
$(MSWDIR)\fontutil.obj \
$(MSWDIR)\frame.obj \
$(MSWDIR)\gauge95.obj \
+ $(MSWDIR)\gdiimage.obj \
$(MSWDIR)\gdiobj.obj \
$(MSWDIR)\gsocket.obj \
$(MSWDIR)\helpwin.obj \
$(MSWDIR)\gauge95.obj: $(MSWDIR)\gauge95.$(SRCSUFF)
+$(MSWDIR)\gdiimage.obj: $(MSWDIR)\gdiimage.$(SRCSUFF)
+
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
-# 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!
#
$(MSWDIR)\fontutil.obj \
$(MSWDIR)\frame.obj \
$(MSWDIR)\gaugemsw.obj \
+ $(MSWDIR)\gdiimage.obj \
$(MSWDIR)\gdiobj.obj \
$(MSWDIR)\gsocket.obj \
$(MSWDIR)\helpwin.obj \
$(MSWDIR)\gaugemsw.obj: $(MSWDIR)\gaugemsw.$(SRCSUFF)
+$(MSWDIR)\gdiimage.obj: $(MSWDIR)\gdiimage.$(SRCSUFF)
+
$(MSWDIR)\gdiobj.obj: $(MSWDIR)\gdiobj.$(SRCSUFF)
$(MSWDIR)\gsocket.obj: $(MSWDIR)\gsocket.c
-# 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!
#
$(MSWDIR)\fontutil.obj \
$(MSWDIR)\frame.obj \
$(MSWDIR)\gaugemsw.obj \
+ $(MSWDIR)\gdiimage.obj \
$(MSWDIR)\gdiobj.obj \
$(MSWDIR)\gsocket.obj \
$(MSWDIR)\helpwin.obj \
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
<<
+$(MSWDIR)/gdiimage.obj: $*.$(SRCSUFF)
+ cl @<<
+$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
+<<
+
$(MSWDIR)/gdiobj.obj: $*.$(SRCSUFF)
cl @<<
$(CPPFLAGS) /Fo$@ /c /Tp $*.$(SRCSUFF)
-# 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!
#
$(MSWDIR)/fontutil.$(OBJSUFF) \
$(MSWDIR)/frame.$(OBJSUFF) \
$(MSWDIR)/gauge95.$(OBJSUFF) \
+ $(MSWDIR)/gdiimage.$(OBJSUFF) \
$(MSWDIR)/gdiobj.$(OBJSUFF) \
$(MSWDIR)/gsocket.$(OBJSUFF) \
$(MSWDIR)/helpwin.$(OBJSUFF) \
-# 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!
# Symantec C++ makefile for the msw objects
$(MSWDIR)\frame.obj \
$(MSWDIR)\gauge95.obj \
$(MSWDIR)\gaugemsw.obj \
+ $(MSWDIR)\gdiimage.obj \
$(MSWDIR)\gdiobj.obj \
$(MSWDIR)\gsocket.obj \
$(MSWDIR)\helpwin.obj \
-# 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!
# File: makefile.vc
..\msw\$D\fontutil.obj \
..\msw\$D\frame.obj \
..\msw\$D\gauge95.obj \
+ ..\msw\$D\gdiimage.obj \
..\msw\$D\gdiobj.obj \
..\msw\$D\gsocket.obj \
..\msw\$D\helpwin.obj \
#!/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!
#
frame.obj &
gauge95.obj &
gaugemsw.obj &
+ gdiimage.obj &
gdiobj.obj &
gsocket.obj &
helpwin.obj &
gaugemsw.obj: $(MSWDIR)\gaugemsw.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+gdiimage.obj: $(MSWDIR)\gdiimage.cpp
+ *$(CCC) $(CPPFLAGS) $(IFLAGS) $<
+
gdiobj.obj: $(MSWDIR)\gdiobj.cpp
*$(CCC) $(CPPFLAGS) $(IFLAGS) $<
// ----------------------------------------------------------------------------
#ifdef __GNUG__
- #pragma implementation "dataobj.h"
+ #pragma implementation "dataobj.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if defined(__BORLANDC__)
- #pragma hdrstop
+ #pragma hdrstop
#endif
+
+#if defined(__WIN32__) && !defined(__GNUWIN32_OLD__)
+
#ifndef WX_PRECOMP
-#include "wx/intl.h"
+ #include "wx/intl.h"
+ #include "wx/log.h"
#endif
-#include "wx/defs.h"
-#if defined(__WIN32__) && !defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS)
-
-#include "wx/log.h"
#include "wx/dataobj.h"
-#include <windows.h>
+#include "wx/msw/private.h" // includes <windows.h>
+
#ifdef wxUSE_NORLANDER_HEADERS
#include <ole2.h>
#endif
#include <shlobj.h>
-#include "wx/msw/ole/oleutils.h"
+#include "wx/msw/ole/oleutils.h"
+
+#include "wx/msw/dib.h"
// ----------------------------------------------------------------------------
// functions
#define GetTymedName(tymed) ""
#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
// ----------------------------------------------------------------------------
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
// ============================================================================
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)
{
- wxBitmap bitmap(wxConvertDIBToBitmap((const BITMAPINFO *)buf));
+ wxBitmap bitmap(wxConvertDIBToBitmap((const LPBITMAPINFO)buf));
if ( !bitmap.Ok() ) {
wxFAIL_MSG(wxT("pasting/dropping invalid bitmap"));
}
}
-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") );
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
// BITMAPINFO starts with BITMAPINFOHEADER followed by colour info
bitmap->SetDepth(GetDepth());
if ( GetDepth() > 1 && Palette )
bitmap->SetPalette(*Palette);
+#if WXWIN_COMPATIBILITY_2
bitmap->SetOk(TRUE);
-
+#endif // WXWIN_COMPATIBILITY_2
// Make a mask if appropriate
if ( bgindex > -1 )
// ---------------------------------------------------------------------------
bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
- const wxBitmap& bitmap,
+ const wxGDIImage& bitmap,
const wxPoint& pos,
const wxSize& size,
long style,
wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create static bitmap") );
- SetBitmap(bitmap);
+ SetImage(bitmap);
// Subclass again for purposes of dialog editing mode
SubclassWin(m_hWnd);
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_image && m_image->Ok();
}
void wxStaticBitmap::Free()
{
- if ( m_isIcon )
- delete m_image.icon;
- else
- delete m_image.bitmap;
+ delete m_image;
- m_image.icon = NULL;
+ m_image = NULL;
}
wxSize wxStaticBitmap::DoGetBestSize() const
return wxWindow::DoGetBestSize();
}
-void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
+void wxStaticBitmap::SetImage(const wxGDIImage& bitmap)
{
Free();
m_isIcon = bitmap.IsKindOf(CLASSINFO(wxIcon));
if ( m_isIcon )
- m_image.icon = new wxIcon((const wxIcon&)bitmap);
+ m_image = new wxIcon((const wxIcon&)bitmap);
else
- m_image.bitmap = new wxBitmap(bitmap);
+ m_image = new wxBitmap((const wxBitmap &)bitmap);
int x, y;
int w, h;
GetSize(&w, &h);
#ifdef __WIN32__
- HANDLE handle = m_isIcon ? (HANDLE)m_image.icon->GetHICON()
- : (HANDLE)m_image.bitmap->GetHBITMAP();
- ::SendMessage((HWND)m_hWnd, STM_SETIMAGE,
+ HANDLE handle = (HANDLE)m_image->GetHandle();
+ ::SendMessage(GetHwnd(), STM_SETIMAGE,
m_isIcon ? IMAGE_ICON : IMAGE_BITMAP, (LPARAM)handle);
#endif // Win32
w = width;
h = height;
- ::MoveWindow((HWND)GetHWND(), x, y, width, height, FALSE);
+ ::MoveWindow(GetHwnd(), x, y, width, height, FALSE);
}
}
- RECT rect ;
- rect.left = x ;
- rect.top = y ;
- rect.right = x + w ;
- rect.bottom = y + h ;
- InvalidateRect((HWND)GetParent()->GetHWND(), &rect, TRUE);
+ RECT rect;
+ rect.left = x;
+ rect.top = y;
+ rect.right = x + w;
+ rect.bottom = y + h;
+ InvalidateRect(GetHwndOf(GetParent()), &rect, TRUE);
}
// under Win32 we use the standard static control style for this
# include <fstream>
#endif
-#if wxUSE_RICHEDIT && (!defined(__GNUWIN32__) || defined(wxUSE_NORLANDER_HEADERS))
+#if wxUSE_RICHEDIT
#include <richedit.h>
#endif
if ( !CreateBase(parent, id, pos, size, style, validator, name) )
return FALSE;
- // Validator was set in CreateBase
- //SetValidator(validator);
if ( parent )
parent->AddChild(this);
{
wxASSERT_MSG( !(m_windowStyle & wxTE_PROCESS_ENTER),
wxT("wxTE_PROCESS_ENTER style is ignored for multiline "
- "text controls (they always process it)") );
+ "text controls (they always process it)") );
msStyle |= ES_MULTILINE | ES_WANTRETURN;
if ((m_windowStyle & wxTE_NO_VSCROLL) == 0)
#if wxUSE_RICHEDIT
if ( m_windowStyle & wxTE_RICH )
{
- msStyle |= ES_AUTOVSCROLL;
- m_isRich = TRUE;
- windowClass = wxT("RICHEDIT");
+ 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;
+ m_isRich = TRUE;
+ windowClass = wxT("RICHEDIT");
+ }
}
else
m_isRich = FALSE;
#if wxUSE_THREADS
-#include <stdio.h>
-
-#include <windows.h>
+#include "wx/msw/private.h"
#include "wx/module.h"
#include "wx/thread.h"
// ----------------------------------------------------------------------------
// wxMutex implementation
// ----------------------------------------------------------------------------
+
class wxMutexInternal
{
public:
// 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()
{
- 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()
{
- delete m_critsect;
+ ::DeleteCriticalSection((CRITICAL_SECTION *)m_buffer);
}
void wxCriticalSection::Enter()
{
- ::EnterCriticalSection(*m_critsect);
+ ::EnterCriticalSection((CRITICAL_SECTION *)m_buffer);
}
void wxCriticalSection::Leave()
{
- ::LeaveCriticalSection(*m_critsect);
+ ::LeaveCriticalSection((CRITICAL_SECTION *)m_buffer);
}
// ----------------------------------------------------------------------------
short y = HIWORD(lParam);
processed = HandleMouseMove(x, y, wParam);
- break;
- }
+ }
+ break;
+
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_LBUTTONDBLCLK:
#include "wx/xpmhand.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)
bool wxXPMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
XpmAttributes xpmAttr;
HDC dc;
- M_BITMAPHANDLERDATA->m_ok = FALSE;
dc = CreateCompatibleDC(NULL);
if (dc)
{
DeleteDC(dc);
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);
XImageFree(ximage);
-
- M_BITMAPHANDLERDATA->m_ok = TRUE;
- return TRUE;
- }
- else
- {
- M_BITMAPHANDLERDATA->m_ok = FALSE;
- return FALSE;
}
+
+#if WXWIN_COMPATIBILITY_2
+ bitmap->SetOk(errorStatus == XpmSuccess);
+#endif // WXWIN_COMPATIBILITY_2
+
+ return bitmap->Ok();
}
#endif
{
#if wxUSE_XPM_IN_MSW
HDC dc = NULL;
-
+
XImage ximage;
-
+
dc = CreateCompatibleDC(NULL);
if (dc)
{
- if (SelectObject(dc, (HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap))
+ if ( SelectObject(dc, GetHbitmapOf(*bitmap)) )
{
/* for following SetPixel */
/* fill the XImage struct 'by hand' */
- ximage.width = M_BITMAPHANDLERDATA->m_width;
- ximage.height = M_BITMAPHANDLERDATA->m_height;
- ximage.depth = M_BITMAPHANDLERDATA->m_depth;
- ximage.bitmap = (HBITMAP)M_BITMAPHANDLERDATA->m_hBitmap;
+ wxBitmapRefData *refData = bitmap->GetBitmapData();
+ ximage.width = refData->m_width;
+ ximage.height = refData->m_height;
+ ximage.depth = refData->m_depth;
+ ximage.bitmap = (HBITMAP)refData->m_hBitmap;
int errorStatus = XpmWriteFileFromImage(&dc, wxMBSTRINGCAST name.fn_str(),
- &ximage, (XImage *) NULL, (XpmAttributes *) NULL);
-
+ &ximage, (XImage *) NULL,
+ (XpmAttributes *) NULL);
+
if (dc)
DeleteDC(dc);
-
+
if (errorStatus == XpmSuccess)
return TRUE; /* no error */
else
XpmAttributes xpmAttr;
HDC dc;
- M_BITMAPHANDLERDATA->m_ok = FALSE;
- M_BITMAPHANDLERDATA->m_numColors = 0;
-
dc = CreateCompatibleDC(NULL); /* memory DC */
if (dc)
{
xpmAttr.valuemask = XpmReturnInfos; /* get infos back */
ErrorStatus = XpmCreateImageFromData(&dc, (char **)data,
- &ximage, (XImage **) NULL, &xpmAttr);
+ &ximage, (XImage **) NULL, &xpmAttr);
if (ErrorStatus == XpmSuccess)
{
- /* ximage is malloced and contains bitmap and attributes */
- M_BITMAPHANDLERDATA->m_hBitmap = (WXHBITMAP) ximage->bitmap;
-
- BITMAP bm;
- GetObject((HBITMAP) M_BITMAPHANDLERDATA->m_hBitmap, sizeof(bm), (LPSTR) & bm);
+ XpmToBitmap(bitmap, ximage, xpmAttr);
- 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);
XImageFree(ximage); // releases the malloc, but does not detroy
// the bitmap
- M_BITMAPHANDLERDATA->m_ok = TRUE;
- DeleteDC(dc);
-
- return TRUE;
- }
+ }
else
{
- M_BITMAPHANDLERDATA->m_ok = FALSE;
-// XpmDebugError(ErrorStatus, NULL);
- DeleteDC(dc);
- return FALSE;
+ // XpmDebugError(ErrorStatus, NULL);
}
+
+ DeleteDC(dc);
+
+#if WXWIN_COMPATIBILITY_2
+ bitmap->SetOk(errorStatus == XpmSuccess);
+#endif // WXWIN_COMPATIBILITY_2
+
+ return bitmap->Ok();
}
#endif