From a24aff654fb10971e82abccc1b56217d556d447b Mon Sep 17 00:00:00 2001 From: David Elliott Date: Sat, 22 Mar 2003 02:56:04 +0000 Subject: [PATCH] FIXME: Complete stubs or other cruft necessary to make wxCocoa build git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@19688 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/bitmap.h | 201 +++++++++++++++++ include/wx/cocoa/brush.h | 68 ++++++ include/wx/cocoa/colour.h | 103 +++++++++ include/wx/cocoa/cursor.h | 69 ++++++ include/wx/cocoa/dc.h | 231 ++++++++++++++++++++ include/wx/cocoa/dcclient.h | 69 ++++++ include/wx/cocoa/font.h | 180 ++++++++++++++++ include/wx/cocoa/gdiobj.h | 48 +++++ include/wx/cocoa/icon.h | 57 +++++ include/wx/cocoa/pen.h | 103 +++++++++ include/wx/cocoa/region.h | 156 ++++++++++++++ src/cocoa/bitmap.mm | 419 ++++++++++++++++++++++++++++++++++++ src/cocoa/brush.cpp | 122 +++++++++++ src/cocoa/colour.cpp | 103 +++++++++ src/cocoa/cursor.mm | 221 +++++++++++++++++++ src/cocoa/data.cpp | 134 ++++++++++++ src/cocoa/dc.cpp | 348 ++++++++++++++++++++++++++++++ src/cocoa/dcclient.cpp | 84 ++++++++ src/cocoa/font.cpp | 192 +++++++++++++++++ src/cocoa/fontutil.cpp | 260 ++++++++++++++++++++++ src/cocoa/gdiobj.cpp | 22 ++ src/cocoa/icon.cpp | 62 ++++++ src/cocoa/pen.cpp | 202 +++++++++++++++++ src/cocoa/region.cpp | 107 +++++++++ src/cocoa/settings.cpp | 276 ++++++++++++++++++++++++ src/cocoa/utils.cpp | 170 +++++++++++++++ src/cocoa/utilsexc.cpp | 42 ++++ 27 files changed, 4049 insertions(+) create mode 100644 include/wx/cocoa/bitmap.h create mode 100644 include/wx/cocoa/brush.h create mode 100644 include/wx/cocoa/colour.h create mode 100644 include/wx/cocoa/cursor.h create mode 100644 include/wx/cocoa/dc.h create mode 100644 include/wx/cocoa/dcclient.h create mode 100644 include/wx/cocoa/font.h create mode 100644 include/wx/cocoa/gdiobj.h create mode 100644 include/wx/cocoa/icon.h create mode 100644 include/wx/cocoa/pen.h create mode 100644 include/wx/cocoa/region.h create mode 100644 src/cocoa/bitmap.mm create mode 100644 src/cocoa/brush.cpp create mode 100644 src/cocoa/colour.cpp create mode 100644 src/cocoa/cursor.mm create mode 100644 src/cocoa/data.cpp create mode 100644 src/cocoa/dc.cpp create mode 100644 src/cocoa/dcclient.cpp create mode 100644 src/cocoa/font.cpp create mode 100644 src/cocoa/fontutil.cpp create mode 100644 src/cocoa/gdiobj.cpp create mode 100644 src/cocoa/icon.cpp create mode 100644 src/cocoa/pen.cpp create mode 100644 src/cocoa/region.cpp create mode 100644 src/cocoa/settings.cpp create mode 100644 src/cocoa/utils.cpp create mode 100644 src/cocoa/utilsexc.cpp diff --git a/include/wx/cocoa/bitmap.h b/include/wx/cocoa/bitmap.h new file mode 100644 index 0000000000..619011b7da --- /dev/null +++ b/include/wx/cocoa/bitmap.h @@ -0,0 +1,201 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bitmap.h +// Purpose: wxBitmap class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BITMAP_H_ +#define _WX_BITMAP_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) + #pragma interface "bitmap.h" +#endif + +#include "wx/palette.h" + +// Bitmap +class WXDLLEXPORT wxBitmap; +class WXDLLEXPORT wxBitmapHandler; +class WXDLLEXPORT wxIcon; +class WXDLLEXPORT wxCursor; +class WXDLLEXPORT wxImage; + +// A mask is a mono bitmap used for drawing bitmaps +// transparently. +class WXDLLEXPORT wxMask: public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxMask) + DECLARE_NO_COPY_CLASS(wxMask) + +public: + wxMask(); + + // Construct a mask from a bitmap and a colour indicating + // the transparent area + wxMask(const wxBitmap& bitmap, const wxColour& colour); + + // Construct a mask from a bitmap and a palette index indicating + // the transparent area + wxMask(const wxBitmap& bitmap, int paletteIndex); + + // Construct a mask from a mono bitmap (copies the bitmap). + wxMask(const wxBitmap& bitmap); + + ~wxMask(); + + bool Create(const wxBitmap& bitmap, const wxColour& colour); + bool Create(const wxBitmap& bitmap, int paletteIndex); + bool Create(const wxBitmap& bitmap); + + // Implementation +// inline WXHBITMAP GetMaskBitmap() const { return m_maskBitmap; } +// inline void SetMaskBitmap(WXHBITMAP bmp) { m_maskBitmap = bmp; } +protected: +// WXHBITMAP m_maskBitmap; +}; + +class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData +{ + DECLARE_NO_COPY_CLASS(wxBitmapRefData) + + friend class WXDLLEXPORT wxBitmap; + friend class WXDLLEXPORT wxIcon; + friend class WXDLLEXPORT wxCursor; +public: + wxBitmapRefData(); + ~wxBitmapRefData(); + +public: + int m_width; + int m_height; + int m_depth; + bool m_ok; + int m_numColors; + wxPalette m_bitmapPalette; + int m_quality; + + // TOTO: platofmr specific hBitmap +// WXHBITMAP m_hBitmap; + wxMask * m_bitmapMask; // Optional mask +}; + +#define M_BITMAPDATA ((wxBitmapRefData *)m_refData) + +class WXDLLEXPORT wxBitmapHandler: public wxBitmapHandlerBase +{ + DECLARE_DYNAMIC_CLASS(wxBitmapHandler) +public: + wxBitmapHandler() : m_name(), m_extension(), m_type(0) { } + virtual ~wxBitmapHandler(); + + virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1); + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); + virtual bool SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL); + + 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; } + +protected: + wxString m_name; + wxString m_extension; + long m_type; +}; + +#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData()) + +class WXDLLEXPORT wxBitmap: public wxBitmapBase +{ + DECLARE_DYNAMIC_CLASS(wxBitmap) + + friend class WXDLLEXPORT wxBitmapHandler; + +public: + wxBitmap(); // Platform-specific + + // Copy constructors + wxBitmap(const wxBitmap& bitmap) + : wxBitmapBase() + { Ref(bitmap); } + + // Initialize with raw data. + wxBitmap(const char bits[], int width, int height, int depth = 1); + + // Initialize with XPM data + bool CreateFromXpm(const char **bits); + wxBitmap(const char **bits) { CreateFromXpm(bits); } + wxBitmap(char **bits); + + // Load a file or resource + wxBitmap(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); + + // Constructor for generalised creation from data + wxBitmap(void *data, wxBitmapType type, int width, int height, int depth = 1); + + // If depth is omitted, will create a bitmap compatible with the display + wxBitmap(int width, int height, int depth = -1); + + // Convert from wxImage: + wxBitmap(const wxImage& image, int depth = -1); + + ~wxBitmap(); + + wxImage ConvertToImage() const; + + // get the given part of bitmap + wxBitmap GetSubBitmap( const wxRect& rect ) const; + + virtual bool Create(int width, int height, int depth = -1); + virtual bool Create(void *data, wxBitmapType type, int width, int height, int depth = 1); + virtual bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_BMP_RESOURCE); + virtual bool SaveFile(const wxString& name, wxBitmapType type, const wxPalette *cmap = NULL) const; + + // copies the contents and mask of the given (colour) icon to the bitmap + virtual bool CopyFromIcon(const wxIcon& icon); + + bool Ok() const; + int GetWidth() const; + int GetHeight() const; + int GetDepth() const; + int GetQuality() const; + void SetWidth(int w); + void SetHeight(int h); + void SetDepth(int d); + void SetQuality(int q); + void SetOk(bool isOk); + + wxPalette* GetPalette() const; + void SetPalette(const wxPalette& palette); + + wxMask *GetMask() const; + void SetMask(wxMask *mask) ; + + int GetBitmapType() const; + + inline wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; } + inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; } + inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; } + + static void InitStandardHandlers(); +protected: + + // TODO: Implementation +public: +// void SetHBITMAP(WXHBITMAP bmp); +// WXHBITMAP GetHBITMAP() const; + +// WXHMETAFILE GetPict() const; + + bool FreeResource(bool force = FALSE); +}; +#endif + // _WX_BITMAP_H_ diff --git a/include/wx/cocoa/brush.h b/include/wx/cocoa/brush.h new file mode 100644 index 0000000000..205e7b7a2d --- /dev/null +++ b/include/wx/cocoa/brush.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: brush.h +// Purpose: wxBrush class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_BRUSH_H_ +#define _WX_BRUSH_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "brush.h" +#endif + +#include "wx/gdicmn.h" +#include "wx/gdiobj.h" +#include "wx/bitmap.h" + +class WXDLLEXPORT wxBrush; + +// Brush +class WXDLLEXPORT wxBrush: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxBrush) + +public: + wxBrush(); + wxBrush(const wxColour& col, int style); + wxBrush(const wxBitmap& stipple); + wxBrush(const wxBrush& brush) + : wxGDIObject() + { Ref(brush); } + ~wxBrush(); + + virtual void SetColour(const wxColour& col) ; + virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + virtual void SetStyle(int style) ; + virtual void SetStipple(const wxBitmap& stipple) ; + + wxBrush& operator = (const wxBrush& brush) + { if (*this == brush) return (*this); Ref(brush); return *this; } + bool operator == (const wxBrush& brush) + { return m_refData == brush.m_refData; } + bool operator != (const wxBrush& brush) + { return m_refData != brush.m_refData; } + + wxColour& GetColour() const ; + int GetStyle() const ; + wxBitmap *GetStipple() const ; + + virtual bool Ok() const { return (m_refData != NULL) ; } + +// Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); +}; + +#endif + // _WX_BRUSH_H_ diff --git a/include/wx/cocoa/colour.h b/include/wx/cocoa/colour.h new file mode 100644 index 0000000000..e7a64f7c2b --- /dev/null +++ b/include/wx/cocoa/colour.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: colour.h +// Purpose: wxColour class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_COLOUR_H_ +#define _WX_COLOUR_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "colour.h" +#endif + +#include "wx/object.h" +#include "wx/string.h" + +// Colour +class WXDLLEXPORT wxColour: public wxObject +{ +public: + // ctors + // default + wxColour(); + // from RGB + wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) + : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) + { Set(colRGB); } + + // implicit conversion from the colour name + wxColour( const wxString &colourName ) + : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) + { InitFromName(colourName); } + wxColour( const char *colourName ) + : m_isInit(FALSE), m_red(0), m_blue(0), m_green(0) + { InitFromName(colourName); } + + // copy ctors and assignment operators + wxColour( const wxColour& col ); + wxColour( const wxColour* col ); + wxColour& operator = ( const wxColour& col ); + + // dtor + ~wxColour(); + + // Set() functions + void Set( unsigned char red, unsigned char green, unsigned char blue ); + void Set( unsigned long colRGB ) + { + // we don't need to know sizeof(long) here because we assume that the three + // least significant bytes contain the R, G and B values + Set((unsigned char)colRGB, + (unsigned char)(colRGB >> 8), + (unsigned char)(colRGB >> 16)); + } + + // accessors + bool Ok() const {return m_isInit; } + + // Let's remove this inelegant function +#if WXWIN_COMPATIBILITY + void Get(unsigned char *r, unsigned char *g, unsigned char *b) const; +#endif + + unsigned char Red() const { return m_red; } + unsigned char Green() const { return m_green; } + unsigned char Blue() const { return m_blue; } + + // comparison + bool operator == (const wxColour& colour) const + { + return (m_isInit == colour.m_isInit && + m_red == colour.m_red && + m_green == colour.m_green && + m_blue == colour.m_blue); + } + bool operator != (const wxColour& colour) const { return !(*this == colour); } + + void InitFromName(const wxString& col); + +// const WXCOLORREF& GetPixel() const { return m_pixel; }; + +private: + bool m_isInit; + unsigned char m_red; + unsigned char m_blue; + unsigned char m_green; + +public: +// WXCOLORREF m_pixel ; +// void Set( const WXCOLORREF* color ) ; + +private: + DECLARE_DYNAMIC_CLASS(wxColour) +}; + +#endif + // _WX_COLOUR_H_ diff --git a/include/wx/cocoa/cursor.h b/include/wx/cocoa/cursor.h new file mode 100644 index 0000000000..f37bf2d0fd --- /dev/null +++ b/include/wx/cocoa/cursor.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: cursor.h +// Purpose: wxCursor class +// Author: David Elliott +// Modified by: +// Created: 2002/11/27 +// RCS-ID: +// Copyright: (c) David Elliott +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_COCOA_CURSOR_H_ +#define _WX_COCOA_CURSOR_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "cursor.h" +#endif + +#include "wx/bitmap.h" + +class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData +{ + DECLARE_NO_COPY_CLASS(wxCursorRefData) + + friend class WXDLLEXPORT wxBitmap; + friend class WXDLLEXPORT wxCursor; +public: + wxCursorRefData(); + ~wxCursorRefData(); + +protected: +}; + +#define M_CURSORDATA ((wxCursorRefData *)m_refData) +#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData) + +// Cursor +class WXDLLEXPORT wxCursor: public wxBitmap +{ + DECLARE_DYNAMIC_CLASS(wxCursor) + +public: + wxCursor(); + + // Copy constructors + wxCursor(const wxCursor& cursor) + : wxBitmap() + { Ref(cursor); } + + wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1, + const char maskBits[] = NULL); + + wxCursor(const wxString& name, long flags = 0, + int hotSpotX = 0, int hotSpotY = 0); + + wxCursor(int cursor_type); + ~wxCursor(); + + virtual bool Ok() const { return m_refData ; } + + inline wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; } + inline bool operator == (const wxCursor& cursor) { return m_refData == cursor.m_refData; } + inline bool operator != (const wxCursor& cursor) { return m_refData != cursor.m_refData; } + +}; + +extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor); + +#endif // _WX_COCOA_CURSOR_H_ diff --git a/include/wx/cocoa/dc.h b/include/wx/cocoa/dc.h new file mode 100644 index 0000000000..988d4c0231 --- /dev/null +++ b/include/wx/cocoa/dc.h @@ -0,0 +1,231 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dc.h +// Purpose: wxDC class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DC_H_ +#define _WX_DC_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "dc.h" +#endif + +#include "wx/pen.h" +#include "wx/brush.h" +#include "wx/icon.h" +#include "wx/font.h" +#include "wx/gdicmn.h" + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +#ifndef MM_TEXT +#define MM_TEXT 0 +#define MM_ISOTROPIC 1 +#define MM_ANISOTROPIC 2 +#define MM_LOMETRIC 3 +#define MM_HIMETRIC 4 +#define MM_TWIPS 5 +#define MM_POINTS 6 +#define MM_METRIC 7 +#endif + +//----------------------------------------------------------------------------- +// global variables +//----------------------------------------------------------------------------- + +extern int wxPageNumber; + +//----------------------------------------------------------------------------- +// wxDC +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxDC: public wxDCBase +{ + DECLARE_DYNAMIC_CLASS(wxDC) + DECLARE_NO_COPY_CLASS(wxDC) + + public: + + wxDC(); + ~wxDC(); + + + // implement base class pure virtuals + // ---------------------------------- + + virtual void Clear(); + + virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } + virtual void EndDoc(void) {}; + + virtual void StartPage(void) {}; + virtual void EndPage(void) {}; + + virtual void SetFont(const wxFont& font) {} + virtual void SetPen(const wxPen& pen); + virtual void SetBrush(const wxBrush& brush); + virtual void SetBackground(const wxBrush& brush); + virtual void SetBackgroundMode(int mode) {} + virtual void SetPalette(const wxPalette& palette); + + virtual void DestroyClippingRegion(); + + virtual wxCoord GetCharHeight() const; + virtual wxCoord GetCharWidth() const; + virtual void DoGetTextExtent(const wxString& string, + wxCoord *x, wxCoord *y, + wxCoord *descent = NULL, + wxCoord *externalLeading = NULL, + wxFont *theFont = NULL) const; + + virtual bool CanDrawBitmap() const; + virtual bool CanGetTextExtent() const; + virtual int GetDepth() const; + virtual wxSize GetPPI() const; + + virtual void SetMapMode(int mode); + virtual void SetUserScale(double x, double y); + + virtual void SetLogicalScale(double x, double y); + virtual void SetLogicalOrigin(wxCoord x, wxCoord y); + virtual void SetDeviceOrigin(wxCoord x, wxCoord y); + virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp); + virtual void SetLogicalFunction(int function); + + virtual void SetTextForeground(const wxColour& colour) ; + virtual void SetTextBackground(const wxColour& colour) ; + + void ComputeScaleAndOrigin(void); + public: + + + wxCoord XDEV2LOG(wxCoord x) const + { + long new_x = x - m_deviceOriginX ; + if (new_x > 0) + return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; + else + return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; + } + wxCoord XDEV2LOGREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) / m_scaleX + 0.5); + else + return (wxCoord)((double)(x) / m_scaleX - 0.5); + } + wxCoord YDEV2LOG(wxCoord y) const + { + long new_y = y - m_deviceOriginY ; + if (new_y > 0) + return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; + else + return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; + } + wxCoord YDEV2LOGREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) / m_scaleY + 0.5); + else + return (wxCoord)((double)(y) / m_scaleY - 0.5); + } + wxCoord XLOG2DEV(wxCoord x) const + { + long new_x = x - m_logicalOriginX; + if (new_x > 0) + return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX ; + else + return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX ; + } + wxCoord XLOG2DEVREL(wxCoord x) const + { + if (x > 0) + return (wxCoord)((double)(x) * m_scaleX + 0.5); + else + return (wxCoord)((double)(x) * m_scaleX - 0.5); + } + wxCoord YLOG2DEV(wxCoord y) const + { + long new_y = y - m_logicalOriginY ; + if (new_y > 0) + return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY ; + else + return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY ; + } + wxCoord YLOG2DEVREL(wxCoord y) const + { + if (y > 0) + return (wxCoord)((double)(y) * m_scaleY + 0.5); + else + return (wxCoord)((double)(y) * m_scaleY - 0.5); + } + +protected: + virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, + int style = wxFLOOD_SURFACE); + + virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const; + + virtual void DoDrawPoint(wxCoord x, wxCoord y); + virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2); + + virtual void DoDrawArc(wxCoord x1, wxCoord y1, + wxCoord x2, wxCoord y2, + wxCoord xc, wxCoord yc); + + virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, + double sa, double ea); + + virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y, + wxCoord width, wxCoord height, + double radius); + virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height); + + virtual void DoCrossHair(wxCoord x, wxCoord y); + + virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y); + virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, + bool useMask = FALSE); + + virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y); + virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, + double angle); + + virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, + wxDC *source, wxCoord xsrc, wxCoord ysrc, + int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1); + + // this is gnarly - we can't even call this function DoSetClippingRegion() + // because of virtual function hiding + virtual void DoSetClippingRegionAsRegion(const wxRegion& region); + virtual void DoSetClippingRegion(wxCoord x, wxCoord y, + wxCoord width, wxCoord height); + virtual void DoGetClippingRegion(wxCoord *x, wxCoord *y, + wxCoord *width, wxCoord *height) + { + GetClippingBox(x, y, width, height); + } + + virtual void DoGetSize(int *width, int *height) const; + virtual void DoGetSizeMM(int* width, int* height) const; + + virtual void DoDrawLines(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset); + virtual void DoDrawPolygon(int n, wxPoint points[], + wxCoord xoffset, wxCoord yoffset, + int fillStyle = wxODDEVEN_RULE); + + protected: +}; + +#endif + // _WX_DC_H_ diff --git a/include/wx/cocoa/dcclient.h b/include/wx/cocoa/dcclient.h new file mode 100644 index 0000000000..c7078fe77e --- /dev/null +++ b/include/wx/cocoa/dcclient.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcclient.h +// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_DCCLIENT_H_ +#define _WX_DCCLIENT_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "dcclient.h" +#endif + +#include "wx/dc.h" + +//----------------------------------------------------------------------------- +// classes +//----------------------------------------------------------------------------- + +class WXDLLEXPORT wxPaintDC; +class WXDLLEXPORT wxWindow; + +class WXDLLEXPORT wxWindowDC: public wxDC +{ + DECLARE_DYNAMIC_CLASS(wxWindowDC) + + public: + wxWindowDC(void); + + // Create a DC corresponding to a canvas + wxWindowDC(wxWindow *win); + + ~wxWindowDC(void); +}; + + +class WXDLLEXPORT wxClientDC: public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxClientDC) + + public: + wxClientDC(void); + + // Create a DC corresponding to a canvas + wxClientDC(wxWindow *win); + + ~wxClientDC(void); +}; + +class WXDLLEXPORT wxPaintDC: public wxWindowDC +{ + DECLARE_DYNAMIC_CLASS(wxPaintDC) + + public: + wxPaintDC(void); + + // Create a DC corresponding to a canvas + wxPaintDC(wxWindow *win); + + ~wxPaintDC(void); +}; + +#endif + // _WX_DCCLIENT_H_ diff --git a/include/wx/cocoa/font.h b/include/wx/cocoa/font.h new file mode 100644 index 0000000000..8068b1e5d2 --- /dev/null +++ b/include/wx/cocoa/font.h @@ -0,0 +1,180 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: font.h +// Purpose: wxFont class +// Author: Julian Smart +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) Julian Smart +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_FONT_H_ +#define _WX_FONT_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) + #pragma interface "font.h" +#endif + +class WXDLLEXPORT wxFontRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxFont; +public: + wxFontRefData() + : m_fontId(0) + , m_pointSize(10) + , m_family(wxDEFAULT) + , m_style(wxNORMAL) + , m_weight(wxNORMAL) + , m_underlined(FALSE) + , m_faceName("Geneva") + , m_encoding(wxFONTENCODING_DEFAULT) + { + Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE, + "Geneva", wxFONTENCODING_DEFAULT); + } + + wxFontRefData(const wxFontRefData& data) + : wxGDIRefData() + , m_fontId(data.m_fontId) + , m_pointSize(data.m_pointSize) + , m_family(data.m_family) + , m_style(data.m_style) + , m_weight(data.m_weight) + , m_underlined(data.m_underlined) + , m_faceName(data.m_faceName) + , m_encoding(data.m_encoding) + { + Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight, + data.m_underlined, data.m_faceName, data.m_encoding); + } + + wxFontRefData(int size, + int family, + int style, + int weight, + bool underlined, + const wxString& faceName, + wxFontEncoding encoding) + : m_fontId(0) + , m_pointSize(size) + , m_family(family) + , m_style(style) + , m_weight(weight) + , m_underlined(underlined) + , m_faceName(faceName) + , m_encoding(encoding) + { + Init(size, family, style, weight, underlined, faceName, encoding); + } + + virtual ~wxFontRefData(); +protected: + // common part of all ctors + void Init(int size, + int family, + int style, + int weight, + bool underlined, + const wxString& faceName, + wxFontEncoding encoding); + + // font characterstics + int m_fontId; + int m_pointSize; + int m_family; + int m_style; + int m_weight; + bool m_underlined; + wxString m_faceName; + wxFontEncoding m_encoding; + +public: +}; +// ---------------------------------------------------------------------------- +// wxFont +// ---------------------------------------------------------------------------- + +class WXDLLEXPORT wxFont : public wxFontBase +{ +public: + // ctors and such + wxFont() { Init(); } + wxFont(const wxFont& font) + : wxFontBase() + { + Init(); + Ref(font); + } + + wxFont(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT) + { + Init(); + + (void)Create(size, family, style, weight, underlined, face, encoding); + } + + wxFont(const wxNativeFontInfo& info) + { + Init(); + + (void)Create(info); + } + + wxFont(const wxString& fontDesc); + + bool Create(int size, + int family, + int style, + int weight, + bool underlined = FALSE, + const wxString& face = wxEmptyString, + wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + + bool Create(const wxNativeFontInfo& info); + + virtual ~wxFont(); + + // assignment + wxFont& operator=(const wxFont& font); + + // implement base class pure virtuals + virtual int GetPointSize() const; + virtual int GetFamily() const; + virtual int GetStyle() const; + virtual int GetWeight() const; + virtual bool GetUnderlined() const; + virtual wxString GetFaceName() const; + virtual wxFontEncoding GetEncoding() const; + + virtual void SetPointSize(int pointSize); + virtual void SetFamily(int family); + virtual void SetStyle(int style); + virtual void SetWeight(int weight); + virtual void SetFaceName(const wxString& faceName); + virtual void SetUnderlined(bool underlined); + virtual void SetEncoding(wxFontEncoding encoding); + + // implementation only from now on + // ------------------------------- + + virtual bool RealizeResource(); + +protected: + // common part of all ctors + void Init(); + + void Unshare(); + +private: + DECLARE_DYNAMIC_CLASS(wxFont) +}; + +#endif + // _WX_FONT_H_ diff --git a/include/wx/cocoa/gdiobj.h b/include/wx/cocoa/gdiobj.h new file mode 100644 index 0000000000..c21d5a01ec --- /dev/null +++ b/include/wx/cocoa/gdiobj.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gdiobj.h +// Purpose: wxGDIObject class: base class for other GDI classes +// Author: David Elliott +// Modified by: +// Created: 2002/11/27 +// RCS-ID: +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_GDIOBJ_H_ +#define _WX_GDIOBJ_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "gdiobj.h" +#endif + +#include "wx/object.h" + +class WXDLLEXPORT wxGDIRefData: public wxObjectRefData { +public: + inline wxGDIRefData() + { + } +}; + +#define M_GDIDATA ((wxGDIRefData *)m_refData) + +class WXDLLEXPORT wxGDIObject: public wxObject +{ +DECLARE_DYNAMIC_CLASS(wxGDIObject) + public: + wxGDIObject() : m_visible(FALSE) { } + ~wxGDIObject() { } + + bool IsNull() const { return (m_refData == 0); } + + virtual bool GetVisible() { return m_visible; } + virtual void SetVisible(bool v) { m_visible = v; } + +protected: + bool m_visible; // Can a pointer to this object be safely taken? + // - only if created within FindOrCreate... +}; + +#endif + // _WX_GDIOBJ_H_ diff --git a/include/wx/cocoa/icon.h b/include/wx/cocoa/icon.h new file mode 100644 index 0000000000..b1f045c714 --- /dev/null +++ b/include/wx/cocoa/icon.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: icon.h +// Purpose: wxIcon class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_ICON_H_ +#define _WX_ICON_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "icon.h" +#endif + +#include "wx/bitmap.h" + +// Icon +class WXDLLEXPORT wxIcon: public wxBitmap +{ + DECLARE_DYNAMIC_CLASS(wxIcon) + +public: + wxIcon(); + + // Copy constructors + wxIcon(const wxIcon& icon) + : wxBitmap() + { Ref(icon); } + + wxIcon(const char **data); + wxIcon(char **data); + wxIcon(const char bits[], int width , int height ); + wxIcon(const wxString& name, int flags = wxBITMAP_TYPE_ICON_RESOURCE, + int desiredWidth = -1, int desiredHeight = -1); + ~wxIcon(); + + bool LoadFile(const wxString& name, wxBitmapType flags /* = wxBITMAP_TYPE_ICON_RESOURCE */ , + int desiredWidth /* = -1 */ , int desiredHeight = -1); + bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE ) + { return LoadFile( name , flags , -1 , -1 ) ; } + + inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; } + inline bool operator == (const wxIcon& icon) { return m_refData == icon.m_refData; } + inline bool operator != (const wxIcon& icon) { return m_refData != icon.m_refData; } + + // create from bitmap (which should have a mask unless it's monochrome): + // there shouldn't be any implicit bitmap -> icon conversion (i.e. no + // ctors, assignment operators...), but it's ok to have such function + void CopyFromBitmap(const wxBitmap& bmp); +}; + +#endif + // _WX_ICON_H_ diff --git a/include/wx/cocoa/pen.h b/include/wx/cocoa/pen.h new file mode 100644 index 0000000000..f13fcdfdac --- /dev/null +++ b/include/wx/cocoa/pen.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pen.h +// Purpose: wxPen class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_PEN_H_ +#define _WX_PEN_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "pen.h" +#endif + +#include "wx/gdiobj.h" +#include "wx/colour.h" +#include "wx/bitmap.h" + +class WXDLLEXPORT wxPen; + +class WXDLLEXPORT wxPenRefData: public wxGDIRefData +{ + friend class WXDLLEXPORT wxPen; +public: + wxPenRefData(); + wxPenRefData(const wxPenRefData& data); + ~wxPenRefData(); + + wxPenRefData& operator=(const wxPenRefData& data); + +protected: + int m_width; + int m_style; + int m_join ; + int m_cap ; + wxBitmap m_stipple ; + int m_nbDash ; + wxDash * m_dash ; + wxColour m_colour; +/* TODO: implementation + WXHPEN m_hPen; +*/ +}; + +#define M_PENDATA ((wxPenRefData *)m_refData) + +// Pen +class WXDLLEXPORT wxPen: public wxGDIObject +{ + DECLARE_DYNAMIC_CLASS(wxPen) +public: + wxPen(); + wxPen(const wxColour& col, int width, int style); + wxPen(const wxBitmap& stipple, int width); + wxPen(const wxPen& pen) + : wxGDIObject() + { Ref(pen); } + ~wxPen(); + + inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } + inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; } + inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; } + + virtual bool Ok() const { return (m_refData != NULL) ; } + + // Override in order to recreate the pen + void SetColour(const wxColour& col) ; + void SetColour(unsigned char r, unsigned char g, unsigned char b) ; + + void SetWidth(int width) ; + void SetStyle(int style) ; + void SetStipple(const wxBitmap& stipple) ; + void SetDashes(int nb_dashes, const wxDash *dash) ; + void SetJoin(int join) ; + void SetCap(int cap) ; + + inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; + inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; + inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; + inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; + inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; + inline int GetDashes(wxDash **ptr) const { + *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0); + } + + inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; + +// Implementation + + // Useful helper: create the brush resource + bool RealizeResource(); + + // When setting properties, we must make sure we're not changing + // another object + void Unshare(); +}; + +#endif + // _WX_PEN_H_ diff --git a/include/wx/cocoa/region.h b/include/wx/cocoa/region.h new file mode 100644 index 0000000000..1d26425b96 --- /dev/null +++ b/include/wx/cocoa/region.h @@ -0,0 +1,156 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: region.h +// Purpose: wxRegion class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_REGION_H_ +#define _WX_REGION_H_ + +#if defined(__GNUG__) && !defined(__APPLE__) +#pragma interface "region.h" +#endif + +#include "wx/list.h" +#include "wx/gdiobj.h" +#include "wx/gdicmn.h" + +class WXDLLEXPORT wxRect; +class WXDLLEXPORT wxPoint; + +enum wxRegionContain { + wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2 +}; + +// So far, for internal use only +enum wxRegionOp { +wxRGN_AND, // Creates the intersection of the two combined regions. +wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1. +wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. +wxRGN_OR, // Creates the union of two combined regions. +wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas. +}; + +class WXDLLEXPORT wxRegion : public wxGDIObject { +DECLARE_DYNAMIC_CLASS(wxRegion); + friend class WXDLLEXPORT wxRegionIterator; +public: + wxRegion(long x, long y, long w, long h); + wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight); + wxRegion(const wxRect& rect); + wxRegion(); + ~wxRegion(); + + //# Copying + wxRegion(const wxRegion& r) + : wxGDIObject() + { Ref(r); } + wxRegion& operator = (const wxRegion& r) + { Ref(r); return (*this); } + + //# Modify region + // Clear current region + void Clear(); + + // Union rectangle or region with this. + bool Union(long x, long y, long width, long height) + { return Combine(x, y, width, height, wxRGN_OR); } + bool Union(const wxRect& rect) + { return Combine(rect, wxRGN_OR); } + bool Union(const wxRegion& region) + { return Combine(region, wxRGN_OR); } + + // Intersect rectangle or region with this. + bool Intersect(long x, long y, long width, long height) + { return Combine(x, y, width, height, wxRGN_AND); } + bool Intersect(const wxRect& rect) + { return Combine(rect, wxRGN_AND); } + bool Intersect(const wxRegion& region) + { return Combine(region, wxRGN_AND); } + + // Subtract rectangle or region from this: + // Combines the parts of 'this' that are not part of the second region. + bool Subtract(long x, long y, long width, long height) + { return Combine(x, y, width, height, wxRGN_DIFF); } + bool Subtract(const wxRect& rect) + { return Combine(rect, wxRGN_DIFF); } + bool Subtract(const wxRegion& region) + { return Combine(region, wxRGN_DIFF); } + + // XOR: the union of two combined regions except for any overlapping areas. + bool Xor(long x, long y, long width, long height) + { return Combine(x, y, width, height, wxRGN_XOR); } + bool Xor(const wxRect& rect) + { return Combine(rect, wxRGN_XOR); } + bool Xor(const wxRegion& region) + { return Combine(region, wxRGN_XOR); } + + //# Information on region + // Outer bounds of region + void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const; + wxRect GetBox() const ; + + // Is region empty? + bool Empty() const; + inline bool IsEmpty() const { return Empty(); } + + //# Tests + // Does the region contain the point (x,y)? + wxRegionContain Contains(long x, long y) const; + // Does the region contain the point pt? + wxRegionContain Contains(const wxPoint& pt) const; + // Does the region contain the rectangle (x, y, w, h)? + wxRegionContain Contains(long x, long y, long w, long h) const; + // Does the region contain the rectangle rect? + wxRegionContain Contains(const wxRect& rect) const; + + // Internal + bool Combine(long x, long y, long width, long height, wxRegionOp op); + bool Combine(const wxRegion& region, wxRegionOp op); + bool Combine(const wxRect& rect, wxRegionOp op); +}; + +class WXDLLEXPORT wxRegionIterator : public wxObject +{ + DECLARE_DYNAMIC_CLASS(wxRegionIterator) + +public: + wxRegionIterator(); + wxRegionIterator(const wxRegion& region); + wxRegionIterator(const wxRegionIterator& iterator); + ~wxRegionIterator(); + + wxRegionIterator& operator=(const wxRegionIterator& iterator); + + void Reset() { m_current = 0; } + void Reset(const wxRegion& region); + + operator bool () const { return m_current < m_numRects; } + bool HaveRects() const { return m_current < m_numRects; } + + wxRegionIterator& operator++(); + wxRegionIterator operator++(int); + + long GetX() const; + long GetY() const; + long GetW() const; + long GetWidth() const { return GetW(); } + long GetH() const; + long GetHeight() const { return GetH(); } + wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); } +private: + void SetRects(long numRects, wxRect *rects); + + long m_current; + long m_numRects; + wxRegion m_region; + wxRect* m_rects; +}; + +#endif + // _WX_REGION_H_ diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm new file mode 100644 index 0000000000..ed803d8085 --- /dev/null +++ b/src/cocoa/bitmap.mm @@ -0,0 +1,419 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: bitmap.cpp +// Purpose: wxBitmap +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "bitmap.h" +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/palette.h" +#include "wx/bitmap.h" +#include "wx/icon.h" +#include "wx/log.h" +#include "wx/image.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject) +#endif + +wxBitmapRefData::wxBitmapRefData() +{ + m_ok = FALSE; + m_width = 0; + m_height = 0; + m_depth = 0; + m_quality = 0; + m_numColors = 0; + m_bitmapMask = NULL; +} + +wxBitmapRefData::~wxBitmapRefData() +{ + /* + * TODO: delete the bitmap data here. + */ + + if (m_bitmapMask) + delete m_bitmapMask; + m_bitmapMask = NULL; +} + +wxBitmap::wxBitmap() +{ + m_refData = NULL; + + if ( wxTheBitmapList ) + wxTheBitmapList->AddBitmap(this); +} + +wxBitmap::~wxBitmap() +{ + if (wxTheBitmapList) + wxTheBitmapList->DeleteObject(this); +} + +wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits) +{ + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_width = the_width ; + M_BITMAPDATA->m_height = the_height ; + M_BITMAPDATA->m_depth = no_bits ; + M_BITMAPDATA->m_numColors = 0; + + /* TODO: create the bitmap from data */ + + if ( wxTheBitmapList ) + wxTheBitmapList->AddBitmap(this); +} + +wxBitmap::wxBitmap(int w, int h, int d) +{ + (void)Create(w, h, d); + + if ( wxTheBitmapList ) + wxTheBitmapList->AddBitmap(this); +} + +wxBitmap::wxBitmap(void *data, wxBitmapType type, int width, int height, int depth) +{ + (void) Create(data, type, width, height, depth); + + if ( wxTheBitmapList ) + wxTheBitmapList->AddBitmap(this); +} + +wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) +{ + LoadFile(filename, type); + + if ( wxTheBitmapList ) + wxTheBitmapList->AddBitmap(this); +} + +wxBitmap::wxBitmap(const wxImage& image, int depth) +{ +} + +wxBitmap::wxBitmap(char **bits) +{ +} + +/* TODO: maybe allow creation from XPM +// Create from data +wxBitmap::wxBitmap(const char **data) +{ + (void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0); +} +*/ + +bool wxBitmap::Create(int w, int h, int d) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_width = w; + M_BITMAPDATA->m_height = h; + M_BITMAPDATA->m_depth = d; + + /* TODO: create new bitmap */ + + return M_BITMAPDATA->m_ok; +} + +bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { + wxLogWarning("no bitmap handler for type %d defined.", type); + + return FALSE; + } + + return handler->LoadFile(this, filename, type, -1, -1); +} + +bool wxBitmap::Create(void *data, wxBitmapType type, int width, int height, int depth) +{ + UnRef(); + + m_refData = new wxBitmapRefData; + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { + wxLogWarning("no bitmap handler for type %d defined.", type); + + return FALSE; + } + + return handler->Create(this, data, type, width, height, depth); +} + +bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, const wxPalette *palette) const +{ + wxBitmapHandler *handler = FindHandler(type); + + if ( handler == NULL ) { + wxLogWarning("no bitmap handler for type %d defined.", type); + + return FALSE; + } + + return handler->SaveFile(this, filename, type, palette); +} + +void wxBitmap::SetWidth(int w) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_width = w; +} + +void wxBitmap::SetHeight(int h) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_height = h; +} + +void wxBitmap::SetDepth(int d) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_depth = d; +} + +void wxBitmap::SetQuality(int q) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_quality = q; +} + +void wxBitmap::SetOk(bool isOk) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_ok = isOk; +} + +void wxBitmap::SetPalette(const wxPalette& palette) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_bitmapPalette = palette ; +} + +void wxBitmap::SetMask(wxMask *mask) +{ + if (!M_BITMAPDATA) + m_refData = new wxBitmapRefData; + + M_BITMAPDATA->m_bitmapMask = mask ; +} + +/* + * wxMask + */ + +wxMask::wxMask() +{ +/* TODO + m_maskBitmap = 0; +*/ +} + +// Construct a mask from a bitmap and a colour indicating +// the transparent area +wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour) +{ +/* TODO + m_maskBitmap = 0; +*/ + Create(bitmap, colour); +} + +// Construct a mask from a bitmap and a palette index indicating +// the transparent area +wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex) +{ +/* TODO + m_maskBitmap = 0; +*/ + + Create(bitmap, paletteIndex); +} + +// Construct a mask from a mono bitmap (copies the bitmap). +wxMask::wxMask(const wxBitmap& bitmap) +{ +/* TODO + m_maskBitmap = 0; +*/ + + Create(bitmap); +} + +wxMask::~wxMask() +{ +// TODO: delete mask bitmap +} + +// Create a mask from a mono bitmap (copies the bitmap). +bool wxMask::Create(const wxBitmap& bitmap) +{ +// TODO + return FALSE; +} + +// Create a mask from a bitmap and a palette index indicating +// the transparent area +bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) +{ +// TODO + return FALSE; +} + +// Create a mask from a bitmap and a colour indicating +// the transparent area +bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) +{ +// TODO + return FALSE; +} + +/* + * wxBitmapHandler + */ + +IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject) + +wxBitmapHandler::~wxBitmapHandler() +{ +} + +bool wxBitmapHandler::Create(wxBitmap *bitmap, void *data, long type, int width, int height, int depth) +{ + return FALSE; +} + +bool wxBitmapHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long type, + int desiredWidth, int desiredHeight) +{ + return FALSE; +} + +bool wxBitmapHandler::SaveFile(const wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette) +{ + return FALSE; +} + +/* + * Standard handlers + */ + +/* TODO: bitmap handlers, a bit like this: +class WXDLLEXPORT wxBMPResourceHandler: public wxBitmapHandler +{ + DECLARE_DYNAMIC_CLASS(wxBMPResourceHandler) +public: + inline wxBMPResourceHandler() + { + m_name = "Windows bitmap resource"; + m_extension = ""; + m_type = wxBITMAP_TYPE_BMP_RESOURCE; + }; + + virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags, + int desiredWidth, int desiredHeight); +}; +IMPLEMENT_DYNAMIC_CLASS(wxBMPResourceHandler, wxBitmapHandler) +*/ + +void wxBitmap::InitStandardHandlers() +{ +/* TODO: initialize all standard bitmap or derive class handlers here. + AddHandler(new wxBMPResourceHandler); + AddHandler(new wxBMPFileHandler); + AddHandler(new wxXPMFileHandler); + AddHandler(new wxXPMDataHandler); + AddHandler(new wxICOResourceHandler); + AddHandler(new wxICOFileHandler); +*/ +} + +bool wxBitmap::CopyFromIcon(const wxIcon& icno) +{ + return false; +} + +wxPalette* wxBitmap::GetPalette() const +{ + return NULL; +} + +wxBitmap wxBitmap::GetSubBitmap(wxRect const&) const +{ + return wxNullBitmap; +} + +wxImage wxBitmap::ConvertToImage() const +{ + return wxNullImage; +} + +bool wxBitmap::Ok() const +{ + return FALSE; +} + +wxMask* wxBitmap::GetMask() const +{ + return NULL; +} + +int wxBitmap::GetDepth() const +{ + return 0; +} + +int wxBitmap::GetWidth() const +{ + return 0; +} + +int wxBitmap::GetHeight() const +{ + return 0; +} + + +bool wxBitmap::CreateFromXpm(const char **) +{ + return false; +} + +// vim:sts=4:sw=4:syn=cpp:et diff --git a/src/cocoa/brush.cpp b/src/cocoa/brush.cpp new file mode 100644 index 0000000000..ddf9d8f4ed --- /dev/null +++ b/src/cocoa/brush.cpp @@ -0,0 +1,122 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: brush.cpp +// Purpose: wxBrush +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "brush.h" +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/brush.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) +#endif + +#if 0 // WTF +wxBrushRefData::wxBrushRefData() +{ + m_style = wxSOLID; +// TODO: null data +} + +wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) +{ + m_style = data.m_style; + m_stipple = data.m_stipple; + m_colour = data.m_colour; +/* TODO: null data + m_hBrush = 0; +*/ +} + +wxBrushRefData::~wxBrushRefData() +{ +// TODO: delete data +} +#endif + +// Brushes +wxBrush::wxBrush() +{ + if ( wxTheBrushList ) + wxTheBrushList->AddBrush(this); +} + +wxBrush::~wxBrush() +{ + if ( wxTheBrushList ) + wxTheBrushList->RemoveBrush(this); +} + +wxBrush::wxBrush(const wxColour& col, int Style) +{ + if ( wxTheBrushList ) + wxTheBrushList->AddBrush(this); +} + +wxBrush::wxBrush(const wxBitmap& stipple) +{ + if ( wxTheBrushList ) + wxTheBrushList->AddBrush(this); +} + +void wxBrush::Unshare() +{ +} + +void wxBrush::SetColour(const wxColour& col) +{ + Unshare(); + RealizeResource(); +} + +void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) +{ + Unshare(); + + + RealizeResource(); +} + +void wxBrush::SetStyle(int Style) +{ + Unshare(); + + + RealizeResource(); +} + +void wxBrush::SetStipple(const wxBitmap& Stipple) +{ + Unshare(); + + + RealizeResource(); +} + +bool wxBrush::RealizeResource() +{ +// TODO: create the brush + return FALSE; +} + +int wxBrush::GetStyle() const +{ +return 0; +} + +wxColour& wxBrush::GetColour() const +{ + return *wxWHITE; +} + +// vi:sts=4:sw=5:et diff --git a/src/cocoa/colour.cpp b/src/cocoa/colour.cpp new file mode 100644 index 0000000000..8d0827ef1d --- /dev/null +++ b/src/cocoa/colour.cpp @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: colour.cpp +// Purpose: wxColour class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "colour.h" +#endif + +#include "wx/gdicmn.h" +#include "wx/colour.h" + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject) +#endif + +// Colour + +wxColour::wxColour () +{ + m_isInit = FALSE; + m_red = m_blue = m_green = 0; +/* TODO + m_pixel = 0; +*/ +} + +wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b) +{ + m_red = r; + m_green = g; + m_blue = b; + m_isInit = TRUE; +/* TODO + m_pixel = PALETTERGB (m_red, m_green, m_blue); +*/ +} + +wxColour::wxColour (const wxColour& col) +{ + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; +/* TODO + m_pixel = col.m_pixel; +*/ +} + +wxColour& wxColour::operator =(const wxColour& col) +{ + m_red = col.m_red; + m_green = col.m_green; + m_blue = col.m_blue; + m_isInit = col.m_isInit; +/* TODO + m_pixel = col.m_pixel; +*/ + return *this; +} + +void wxColour::InitFromName(const wxString& col) +{ + wxColour *the_colour = wxTheColourDatabase->FindColour (col); + if (the_colour) + { + m_red = the_colour->Red (); + m_green = the_colour->Green (); + m_blue = the_colour->Blue (); + m_isInit = TRUE; + } + else + { + m_red = 0; + m_green = 0; + m_blue = 0; + m_isInit = FALSE; + } +/* TODO + m_pixel = PALETTERGB (m_red, m_green, m_blue); +*/ +} + +wxColour::~wxColour () +{ +} + +void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) +{ + m_red = r; + m_green = g; + m_blue = b; + m_isInit = TRUE; +/* TODO + m_pixel = PALETTERGB (m_red, m_green, m_blue); +*/ +} diff --git a/src/cocoa/cursor.mm b/src/cocoa/cursor.mm new file mode 100644 index 0000000000..93dee084c7 --- /dev/null +++ b/src/cocoa/cursor.mm @@ -0,0 +1,221 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: cursor.cpp +// Purpose: wxCursor class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "cursor.h" +#endif + +#include "wx/cursor.h" +#include "wx/icon.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap) +#endif + +wxCursorRefData::wxCursorRefData() +{ + m_width = 32; m_height = 32; + +/* TODO + m_hCursor = 0 ; +*/ +} + +wxCursorRefData::~wxCursorRefData() +{ + // TODO: destroy cursor +} + +// Cursors +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 wxString& cursor_file, long flags, int hotSpotX, int hotSpotY) +{ + m_refData = new wxCursorRefData; + + // TODO: create cursor from a file +} + +// Cursors by stock number +wxCursor::wxCursor(int cursor_type) +{ + m_refData = new wxCursorRefData; + +/* TODO + switch (cursor_type) + { + case wxCURSOR_WAIT: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_WAIT); + break; + case wxCURSOR_IBEAM: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_IBEAM); + break; + case wxCURSOR_CROSS: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_CROSS); + break; + case wxCURSOR_SIZENWSE: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENWSE); + break; + case wxCURSOR_SIZENESW: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENESW); + break; + case wxCURSOR_SIZEWE: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZEWE); + break; + case wxCURSOR_SIZENS: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_SIZENS); + break; + case wxCURSOR_CHAR: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + break; + } + case wxCURSOR_HAND: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_HAND"); + break; + } + case wxCURSOR_BULLSEYE: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BULLSEYE"); + break; + } + case wxCURSOR_PENCIL: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PENCIL"); + break; + } + case wxCURSOR_MAGNIFIER: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_MAGNIFIER"); + break; + } + case wxCURSOR_NO_ENTRY: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_NO_ENTRY"); + break; + } + case wxCURSOR_LEFT_BUTTON: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + break; + } + case wxCURSOR_RIGHT_BUTTON: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + break; + } + case wxCURSOR_MIDDLE_BUTTON: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + break; + } + case wxCURSOR_SIZING: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_SIZING"); + break; + } + case wxCURSOR_WATCH: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_WATCH"); + break; + } + case wxCURSOR_SPRAYCAN: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_ROLLER"); + break; + } + case wxCURSOR_PAINT_BRUSH: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PBRUSH"); + break; + } + case wxCURSOR_POINT_LEFT: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PLEFT"); + break; + } + case wxCURSOR_POINT_RIGHT: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_PRIGHT"); + break; + } + case wxCURSOR_QUESTION_ARROW: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_QARROW"); + break; + } + case wxCURSOR_BLANK: + { + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(wxGetInstance(), "wxCURSOR_BLANK"); + break; + } + default: + case wxCURSOR_ARROW: + M_CURSORDATA->m_hCursor = (WXHCURSOR) LoadCursor(NULL, IDC_ARROW); + break; + } +*/ + +} + +wxCursor::~wxCursor() +{ +} + +// Global cursor setting +void wxSetCursor(const wxCursor& cursor) +{ + // TODO (optional on platforms with no global cursor) +} + +static int wxBusyCursorCount = 0; + +// Set the cursor to the busy cursor for all windows +void wxBeginBusyCursor(wxCursor *cursor) +{ + wxBusyCursorCount ++; + if (wxBusyCursorCount == 1) + { + // TODO + } + else + { + // TODO + } +} + +// Restore cursor to normal +void wxEndBusyCursor() +{ + if (wxBusyCursorCount == 0) + return; + + wxBusyCursorCount --; + if (wxBusyCursorCount == 0) + { + // TODO + } +} + +// TRUE if we're between the above two calls +bool wxIsBusy() +{ + return (wxBusyCursorCount > 0); +} + diff --git a/src/cocoa/data.cpp b/src/cocoa/data.cpp new file mode 100644 index 0000000000..77748da0f4 --- /dev/null +++ b/src/cocoa/data.cpp @@ -0,0 +1,134 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: data.cpp +// Purpose: Various data +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/wx.h" + +#if wxUSE_POSTSCRIPT +#include "wx/dcps.h" +#endif + +#define _MAXPATHLEN 500 + +// Windows List +wxWindowList wxTopLevelWindows; + +// List of windows pending deletion +wxList wxPendingDelete; + +int wxPageNumber; + +// GDI Object Lists +wxBrushList *wxTheBrushList = NULL; +wxPenList *wxThePenList = NULL; +wxFontList *wxTheFontList = NULL; +wxBitmapList *wxTheBitmapList = NULL; + +wxColourDatabase *wxTheColourDatabase = NULL; + +// Stock objects +wxFont *wxNORMAL_FONT; +wxFont *wxSMALL_FONT; +wxFont *wxITALIC_FONT; +wxFont *wxSWISS_FONT; +wxPen *wxRED_PEN; + +wxPen *wxCYAN_PEN; +wxPen *wxGREEN_PEN; +wxPen *wxBLACK_PEN; +wxPen *wxWHITE_PEN; +wxPen *wxTRANSPARENT_PEN; +wxPen *wxBLACK_DASHED_PEN; +wxPen *wxGREY_PEN; +wxPen *wxMEDIUM_GREY_PEN; +wxPen *wxLIGHT_GREY_PEN; + +wxBrush *wxBLUE_BRUSH; +wxBrush *wxGREEN_BRUSH; +wxBrush *wxWHITE_BRUSH; +wxBrush *wxBLACK_BRUSH; +wxBrush *wxTRANSPARENT_BRUSH; +wxBrush *wxCYAN_BRUSH; +wxBrush *wxRED_BRUSH; +wxBrush *wxGREY_BRUSH; +wxBrush *wxMEDIUM_GREY_BRUSH; +wxBrush *wxLIGHT_GREY_BRUSH; + +wxColour *wxBLACK; +wxColour *wxWHITE; +wxColour *wxRED; +wxColour *wxBLUE; +wxColour *wxGREEN; +wxColour *wxCYAN; +wxColour *wxLIGHT_GREY; + +wxCursor *wxSTANDARD_CURSOR = NULL; +wxCursor *wxHOURGLASS_CURSOR = NULL; +wxCursor *wxCROSS_CURSOR = NULL; + +// 'Null' objects +wxAcceleratorTable wxNullAcceleratorTable; +wxBitmap wxNullBitmap; +wxIcon wxNullIcon; +wxCursor wxNullCursor; +wxPen wxNullPen; +wxBrush wxNullBrush; +wxPalette wxNullPalette; +wxFont wxNullFont; +wxColour wxNullColour; + +// Default window names +const wxChar *wxControlNameStr = wxT("control"); +const wxChar *wxButtonNameStr = wxT("button"); +const wxChar *wxCanvasNameStr = wxT("canvas"); +const wxChar *wxCheckBoxNameStr = wxT("check"); +const wxChar *wxChoiceNameStr = wxT("choice"); +const wxChar *wxComboBoxNameStr = wxT("comboBox"); +const wxChar *wxDialogNameStr = wxT("dialog"); +const wxChar *wxFrameNameStr = wxT("frame"); +const wxChar *wxGaugeNameStr = wxT("gauge"); +const wxChar *wxStaticBoxNameStr = wxT("groupBox"); +const wxChar *wxListBoxNameStr = wxT("listBox"); +const wxChar *wxStaticTextNameStr = wxT("statictext"); +const wxChar *wxStaticBitmapNameStr = wxT("staticbitmap"); +const wxChar *wxMultiTextNameStr = wxT("multitext"); +const wxChar *wxPanelNameStr = wxT("panel"); +const wxChar *wxRadioBoxNameStr = wxT("radioBox"); +const wxChar *wxRadioButtonNameStr = wxT("radioButton"); +const wxChar *wxBitmapRadioButtonNameStr = wxT("radioButton"); +const wxChar *wxScrollBarNameStr = wxT("scrollBar"); +const wxChar *wxSliderNameStr = wxT("slider"); +const wxChar *wxStaticNameStr = wxT("static"); +const wxChar *wxTextCtrlWindowNameStr = wxT("textWindow"); +const wxChar *wxTextCtrlNameStr = wxT("text"); +const wxChar *wxVirtListBoxNameStr = wxT("virtListBox"); +const wxChar *wxButtonBarNameStr = wxT("buttonbar"); +const wxChar *wxEnhDialogNameStr = wxT("Shell"); +const wxChar *wxToolBarNameStr = wxT("toolbar"); +const wxChar *wxStatusLineNameStr = wxT("status_line"); + +const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text"); +const wxChar *wxMessageBoxCaptionStr = wxT("Message"); +const wxChar *wxFileSelectorPromptStr = wxT("Select a file"); +const wxChar *wxFileSelectorDefaultWildcardStr = wxT("*.*"); +const wxChar *wxTreeCtrlNameStr = wxT("treeCtrl"); +const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl"); +const wxChar *wxDirDialogDefaultFolderStr = wxT("/"); + +// See wx/utils.h +const wxChar *wxFloatToStringStr = wxT("%.2f"); +const wxChar *wxDoubleToStringStr = wxT("%.2f"); + +const wxSize wxDefaultSize(-1, -1); +const wxPoint wxDefaultPosition(-1, -1); diff --git a/src/cocoa/dc.cpp b/src/cocoa/dc.cpp new file mode 100644 index 0000000000..b936c37f99 --- /dev/null +++ b/src/cocoa/dc.cpp @@ -0,0 +1,348 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dc.cpp +// Purpose: wxDC class +// Author: AUTHOR +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dc.h" +#endif + +#include "wx/dc.h" +#include "wx/bitmap.h" +#include "wx/log.h" + +#if !USE_SHARED_LIBRARY +IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) +#endif + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +#define mm2inches 0.0393700787402 +#define inches2mm 25.4 +#define mm2twips 56.6929133859 +#define twips2mm 0.0176388888889 +#define mm2pt 2.83464566929 +#define pt2mm 0.352777777778 + +//----------------------------------------------------------------------------- +// wxDC +//----------------------------------------------------------------------------- + +wxDC::wxDC(void) +{ + m_ok = FALSE; + m_colour = TRUE; + m_clipping = FALSE; + + m_logicalOriginX = 0; + m_logicalOriginY = 0; + m_deviceOriginX = 0; + m_deviceOriginY = 0; + + m_logicalScaleX = 1.0; + m_logicalScaleY = 1.0; + m_userScaleX = 1.0; + m_userScaleY = 1.0; + m_scaleX = 1.0; + m_scaleY = 1.0; + + m_mappingMode = wxMM_TEXT; + + m_signX = 1; // default x-axis left to right + m_signY = 1; // default y-axis top down + + m_maxX = m_maxY = -100000; + m_minY = m_minY = 100000; + + m_logicalFunction = wxCOPY; +// m_textAlignment = wxALIGN_TOP_LEFT; + m_backgroundMode = wxTRANSPARENT; + + m_textForegroundColour = *wxBLACK; + m_textBackgroundColour = *wxWHITE; + m_pen = *wxBLACK_PEN; + m_font = *wxNORMAL_FONT; + m_brush = *wxTRANSPARENT_BRUSH; + m_backgroundBrush = *wxWHITE_BRUSH; + +// m_palette = wxAPP_COLOURMAP; +}; + +wxDC::~wxDC(void) +{ +}; + +void wxDC::DoDrawIcon( const wxIcon &WXUNUSED(icon), int WXUNUSED(x), int WXUNUSED(y) ) +{ +}; + +void wxDC::DoDrawPoint( int x, int y ) +{ +}; + +void wxDC::DoDrawPolygon( int, wxPoint *, int, int, int) +{ +}; + +void wxDC::DoDrawLines( int, wxPoint *, int, int ) +{ +} + +void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2) +{ +} + +int wxDC::GetDepth() const +{ + return 0; +} + +wxSize wxDC::GetPPI() const +{ + return wxSize(0,0); +} + +bool wxDC::CanGetTextExtent() const +{ + return false; +} + +void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const +{ + wxLogDebug("wxDC::DoGetTextExtent(%s)",string.c_str()); + if(x) + *x=0; + if(y) + *y=0; + if(descent) + *descent=0; + if(externalLeading) + *externalLeading=0; +} + +wxCoord wxDC::GetCharHeight() const +{ + return 0; +} + +wxCoord wxDC::GetCharWidth() const +{ + return 0; +} + +bool wxDC::CanDrawBitmap() const +{ + return false; +} + +bool wxDC::DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const +{ + return false; +} + +void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc) +{ +} + +void wxDC::SetPen(const wxPen& pen) +{ +} + +void wxDC::SetBrush(const wxBrush& brush) +{ +} + +void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +{ +} + +void wxDC::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ +} + +void wxDC::DestroyClippingRegion() +{ +} + +void wxDC::DoDrawRoundedRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius) +{ +} + +void wxDC::DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle) +{ +} + +void wxDC::DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h, double sa, double ea) +{ +} + +void wxDC::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ +} + +void wxDC::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height) +{ +} + +void wxDC::DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask) +{ +} + +bool wxDC::DoFloodFill(wxCoord x, wxCoord y, const wxColour& col, int style) +{ + return false; +} + +void wxDC::DoCrossHair(wxCoord x, wxCoord y) +{ +} + +void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) +{ +} + + +bool wxDC::DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int rop, bool useMask , wxCoord xsrcMask, wxCoord ysrcMask) +{ + return false; +} + +void wxDC::DoGetSize( int* width, int* height ) const +{ + *width = m_maxX-m_minX; + *height = m_maxY-m_minY; +}; + +void wxDC::DoGetSizeMM( int* width, int* height ) const +{ + int w = 0; + int h = 0; + GetSize( &w, &h ); +}; + +void wxDC::SetTextForeground( const wxColour &col ) +{ + if (!Ok()) return; + m_textForegroundColour = col; +}; + +void wxDC::SetTextBackground( const wxColour &col ) +{ + if (!Ok()) return; + m_textBackgroundColour = col; +}; + +void wxDC::Clear() +{ +} + +void wxDC::SetBackground(const wxBrush&) +{ +} + +void wxDC::SetPalette(const wxPalette&) +{ +} + +void wxDC::SetLogicalFunction(int) +{ +} + + +void wxDC::SetMapMode( int mode ) +{ + switch (mode) + { + case wxMM_TWIPS: + break; + case wxMM_POINTS: + break; + case wxMM_METRIC: + break; + case wxMM_LOMETRIC: + break; + default: + case wxMM_TEXT: + SetLogicalScale( 1.0, 1.0 ); + break; + }; + if (mode != wxMM_TEXT) + { + }; +}; + +void wxDC::SetUserScale( double x, double y ) +{ + // allow negative ? -> no + m_userScaleX = x; + m_userScaleY = y; + ComputeScaleAndOrigin(); +}; + +void wxDC::SetLogicalScale( double x, double y ) +{ + // allow negative ? + m_logicalScaleX = x; + m_logicalScaleY = y; + ComputeScaleAndOrigin(); +}; + +void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) +{ + m_logicalOriginX = x * m_signX; // is this still correct ? + m_logicalOriginY = y * m_signY; + ComputeScaleAndOrigin(); +}; + +void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) +{ + ComputeScaleAndOrigin(); +}; + +void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) +{ + m_signX = (xLeftRight ? 1 : -1); + m_signY = (yBottomUp ? -1 : 1); + ComputeScaleAndOrigin(); +}; + +void wxDC::ComputeScaleAndOrigin(void) +{ + // CMB: copy scale to see if it changes + double origScaleX = m_scaleX; + double origScaleY = m_scaleY; + + m_scaleX = m_logicalScaleX * m_userScaleX; + m_scaleY = m_logicalScaleY * m_userScaleY; + + // CMB: if scale has changed call SetPen to recalulate the line width + if (m_scaleX != origScaleX || m_scaleY != origScaleY) + { + // this is a bit artificial, but we need to force wxDC to think + // the pen has changed + wxPen* pen = & GetPen(); + wxPen tempPen; + m_pen = tempPen; + SetPen(* pen); + } +}; + +int wxDCBase::DeviceToLogicalX(int x) const +{ + return x; +} + +int wxDCBase::DeviceToLogicalY(int y) const +{ + return y; +} + +// vim:sts=4:sw=4:et diff --git a/src/cocoa/dcclient.cpp b/src/cocoa/dcclient.cpp new file mode 100644 index 0000000000..054a0d4b57 --- /dev/null +++ b/src/cocoa/dcclient.cpp @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dcclient.cpp +// Purpose: wxClientDC class +// Author: AUTHOR +// Modified by: +// Created: 01/02/97 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "dcclient.h" +#endif + +#include "wx/dcclient.h" +#include "wx/dcmemory.h" +#include "wx/region.h" +#include + +//----------------------------------------------------------------------------- +// constants +//----------------------------------------------------------------------------- + +#define RAD2DEG 57.2957795131 + +//----------------------------------------------------------------------------- +// wxPaintDC +//----------------------------------------------------------------------------- + +#if !USE_SHARED_LIBRARY +IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) +IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) +IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC) +#endif + +/* + * wxWindowDC + */ + +wxWindowDC::wxWindowDC(void) +{ +}; + +wxWindowDC::wxWindowDC( wxWindow *window ) +{ +}; + +wxWindowDC::~wxWindowDC(void) +{ +}; + +/* + * wxClientDC + */ + +wxClientDC::wxClientDC(void) +{ +}; + +wxClientDC::wxClientDC( wxWindow *window ) +{ +}; + +wxClientDC::~wxClientDC(void) +{ +}; + +/* + * wxPaintDC + */ + +wxPaintDC::wxPaintDC(void) +{ +}; + +wxPaintDC::wxPaintDC( wxWindow *window ) +{ +}; + +wxPaintDC::~wxPaintDC(void) +{ +}; + diff --git a/src/cocoa/font.cpp b/src/cocoa/font.cpp new file mode 100644 index 0000000000..c907342aa5 --- /dev/null +++ b/src/cocoa/font.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: font.cpp +// Purpose: wxFont class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "font.h" +#endif + +#include "wx/defs.h" +#include "wx/string.h" +#include "wx/font.h" +#include "wx/gdicmn.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) +#endif + +void wxFontRefData::Init(int size, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) +{ + m_family = family; + m_style = style; + m_weight = weight; + m_underlined = underlined; + m_faceName = faceName; + m_encoding = encoding; +} + +wxFontRefData::~wxFontRefData() +{ + // TODO: delete font data +} + +void wxFont::Init() +{ +} + +bool wxFont::Create(const wxNativeFontInfo&) +{ + return FALSE; +} + +void wxFont::SetEncoding(wxFontEncoding) +{ +} + +wxFontEncoding wxFont::GetEncoding() const +{ + return wxFontEncoding(); +} + +int wxFont::GetPointSize() const +{ + return 0; +} + +bool wxFont::GetUnderlined() const +{ + return FALSE; +} + +int wxFont::GetStyle() const +{ + return 0; +} + +int wxFont::GetFamily() const +{ + return 0; +} + +int wxFont::GetWeight() const +{ + return 0; +} + +void wxGetNativeFontEncoding(wxFontEncoding, wxNativeEncodingInfo*); + +bool wxFont::Create(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName, wxFontEncoding encoding) +{ + UnRef(); + m_refData = new wxFontRefData; + + M_FONTDATA->m_family = family; + M_FONTDATA->m_style = style; + M_FONTDATA->m_weight = weight; + M_FONTDATA->m_pointSize = pointSize; + M_FONTDATA->m_underlined = underlined; + M_FONTDATA->m_faceName = faceName; + + RealizeResource(); + + return TRUE; +} + +wxFont::~wxFont() +{ + if (wxTheFontList) + wxTheFontList->DeleteObject(this); +} + +bool wxFont::RealizeResource() +{ + // TODO: create the font (if there is a native font object) + return FALSE; +} + +void wxFont::Unshare() +{ + // Don't change shared data + if (!m_refData) + { + m_refData = new wxFontRefData(); + } + else + { + wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} + +void wxFont::SetPointSize(int pointSize) +{ + Unshare(); + + M_FONTDATA->m_pointSize = pointSize; + + RealizeResource(); +} + +void wxFont::SetFamily(int family) +{ + Unshare(); + + M_FONTDATA->m_family = family; + + RealizeResource(); +} + +void wxFont::SetStyle(int style) +{ + Unshare(); + + M_FONTDATA->m_style = style; + + RealizeResource(); +} + +void wxFont::SetWeight(int weight) +{ + Unshare(); + + M_FONTDATA->m_weight = weight; + + RealizeResource(); +} + +void wxFont::SetFaceName(const wxString& faceName) +{ + Unshare(); + + M_FONTDATA->m_faceName = faceName; + + RealizeResource(); +} + +void wxFont::SetUnderlined(bool underlined) +{ + Unshare(); + + M_FONTDATA->m_underlined = underlined; + + RealizeResource(); +} + +/* New font system */ +wxString wxFont::GetFaceName() const +{ + wxString str(""); + if (M_FONTDATA) + str = M_FONTDATA->m_faceName ; + return str; +} + +// vim:sts=4:sw=4:et diff --git a/src/cocoa/fontutil.cpp b/src/cocoa/fontutil.cpp new file mode 100644 index 0000000000..06814b4bca --- /dev/null +++ b/src/cocoa/fontutil.cpp @@ -0,0 +1,260 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: unix/fontutil.cpp +// Purpose: Font helper functions for X11 (GDK/X) +// Author: Vadim Zeitlin +// Modified by: +// Created: 05.11.99 +// RCS-ID: $Id$ +// Copyright: (c) Vadim Zeitlin +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + +// ============================================================================ +// declarations +// ============================================================================ + +// ---------------------------------------------------------------------------- +// headers +// ---------------------------------------------------------------------------- + +#ifdef __GNUG__ + #pragma implementation "fontutil.h" +#endif + +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP +#endif // PCH + +#include "wx/fontutil.h" +#include "wx/fontmap.h" +#include "wx/tokenzr.h" +#include "wx/hash.h" +#include "wx/module.h" + +#ifdef __WXGTK20__ + +#include "wx/gtk/private.h" + +// ---------------------------------------------------------------------------- +// wxNativeFontInfo +// ---------------------------------------------------------------------------- + +void wxNativeFontInfo::Init() +{ + description = NULL; +} + +int wxNativeFontInfo::GetPointSize() const +{ + return pango_font_description_get_size( description ) / PANGO_SCALE; +} + +wxFontStyle wxNativeFontInfo::GetStyle() const +{ + wxFontStyle m_style = wxFONTSTYLE_NORMAL; + + switch (pango_font_description_get_style( description )) + { + case PANGO_STYLE_NORMAL: + m_style = wxFONTSTYLE_NORMAL; + break; + case PANGO_STYLE_ITALIC: + m_style = wxFONTSTYLE_ITALIC; + break; + case PANGO_STYLE_OBLIQUE: + m_style = wxFONTSTYLE_SLANT; + break; + } + + return m_style; +} + +wxFontWeight wxNativeFontInfo::GetWeight() const +{ + wxFontWeight m_weight = wxFONTWEIGHT_NORMAL; + + switch (pango_font_description_get_weight( description )) + { + case PANGO_WEIGHT_ULTRALIGHT: + m_weight = wxFONTWEIGHT_LIGHT; + break; + case PANGO_WEIGHT_LIGHT: + m_weight = wxFONTWEIGHT_LIGHT; + break; + case PANGO_WEIGHT_NORMAL: + m_weight = wxFONTWEIGHT_NORMAL; + break; + case PANGO_WEIGHT_BOLD: + m_weight = wxFONTWEIGHT_BOLD; + break; + case PANGO_WEIGHT_ULTRABOLD: + m_weight = wxFONTWEIGHT_BOLD; + break; + case PANGO_WEIGHT_HEAVY: + m_weight = wxFONTWEIGHT_BOLD; + break; + } + + return m_weight; +} + +bool wxNativeFontInfo::GetUnderlined() const +{ + return FALSE; +} + +wxString wxNativeFontInfo::GetFaceName() const +{ + wxString tmp = wxGTK_CONV_BACK( pango_font_description_get_family( description ) ); + + return tmp; +} + +wxFontFamily wxNativeFontInfo::GetFamily() const +{ + return wxFONTFAMILY_SWISS; +} + +wxFontEncoding wxNativeFontInfo::GetEncoding() const +{ + return wxFONTENCODING_SYSTEM; +} + +// ---------------------------------------------------------------------------- +// wxNativeEncodingInfo +// ---------------------------------------------------------------------------- + +bool wxNativeEncodingInfo::FromString(const wxString& s) +{ + return FALSE; +} + +wxString wxNativeEncodingInfo::ToString() const +{ + return wxEmptyString; +} + +bool wxTestFontEncoding(const wxNativeEncodingInfo& info) +{ + return TRUE; +} + +bool wxGetNativeFontEncoding(wxFontEncoding encoding, + wxNativeEncodingInfo *info) +{ + return FALSE; +} + +#else + // __WXGTK20__ + +#ifdef __X__ + #ifdef __VMS__ + #pragma message disable nosimpint + #endif + + #include + + #ifdef __VMS__ + #pragma message enable nosimpint + #endif + + #include "wx/utils.h" // for wxGetDisplay() +#elif defined(__WXGTK__) + // we have to declare struct tm to avoid problems with first forward + // declaring it in C code (glib.h included from gdk.h does it) and then + // defining it when time.h is included from the headers below - this is + // known not to work at least with Sun CC 6.01 + #include + + #include +#endif + + +// ---------------------------------------------------------------------------- +// private data +// ---------------------------------------------------------------------------- + +static wxHashTable *g_fontHash = (wxHashTable*) NULL; + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +// ============================================================================ +// implementation +// ============================================================================ + +// ---------------------------------------------------------------------------- +// wxNativeEncodingInfo +// ---------------------------------------------------------------------------- + +// convert to/from the string representation: format is +// encodingid;registry;encoding[;facename] +bool wxNativeEncodingInfo::FromString(const wxString& s) +{ +return false; +} + +wxString wxNativeEncodingInfo::ToString() const +{ +return wxEmptyString; +} + +// ---------------------------------------------------------------------------- +// common functions +// ---------------------------------------------------------------------------- + +bool wxGetNativeFontEncoding(wxFontEncoding encoding, + wxNativeEncodingInfo *info) +{ + return FALSE; +} + +bool wxTestFontEncoding(const wxNativeEncodingInfo& info) +{ +return false; +} + +// ---------------------------------------------------------------------------- +// private functions +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// wxFontModule +// ---------------------------------------------------------------------------- + +class wxFontModule : public wxModule +{ +public: + bool OnInit(); + void OnExit(); + +private: + DECLARE_DYNAMIC_CLASS(wxFontModule) +}; + +IMPLEMENT_DYNAMIC_CLASS(wxFontModule, wxModule) + +bool wxFontModule::OnInit() +{ + g_fontHash = new wxHashTable( wxKEY_STRING ); + + return TRUE; +} + +void wxFontModule::OnExit() +{ + delete g_fontHash; + + g_fontHash = (wxHashTable *)NULL; +} + +#endif + // not GTK 2.0 diff --git a/src/cocoa/gdiobj.cpp b/src/cocoa/gdiobj.cpp new file mode 100644 index 0000000000..63697c8354 --- /dev/null +++ b/src/cocoa/gdiobj.cpp @@ -0,0 +1,22 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: gdiobj.cpp +// Purpose: wxGDIObject class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "gdiobj.h" +#endif + +#include "wx/gdiobj.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject) +#endif + +// TODO: Nothing to do, unless you want to. diff --git a/src/cocoa/icon.cpp b/src/cocoa/icon.cpp new file mode 100644 index 0000000000..26a7c1b1eb --- /dev/null +++ b/src/cocoa/icon.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: icon.cpp +// Purpose: wxIcon class +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "icon.h" +#endif + +#include "wx/icon.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap) +#endif + +/* + * Icons + */ + + +wxIcon::wxIcon() +{ +} + +wxIcon::wxIcon(const char WXUNUSED(bits)[], int WXUNUSED(width), int WXUNUSED(height)) +{ +} + +wxIcon::wxIcon(const wxString& icon_file, int flags, + int desiredWidth, int desiredHeight) + +{ + LoadFile(icon_file, (wxBitmapType)flags, desiredWidth, desiredHeight); +} + +wxIcon::~wxIcon() +{ +} + +bool wxIcon::LoadFile(const wxString& filename, wxBitmapType type, + int desiredWidth, int desiredHeight) +{ + UnRef(); + + wxBitmapHandler *handler = FindHandler(type); + + if ( handler ) + return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); + else + return FALSE; +} + +void wxIcon::CopyFromBitmap(const wxBitmap& icno) +{ +} + diff --git a/src/cocoa/pen.cpp b/src/cocoa/pen.cpp new file mode 100644 index 0000000000..1e3ced2a3a --- /dev/null +++ b/src/cocoa/pen.cpp @@ -0,0 +1,202 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pen.cpp +// Purpose: wxPen +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "pen.h" +#endif + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/pen.h" + +#if !USE_SHARED_LIBRARIES +IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) +#endif + +wxPenRefData::wxPenRefData() +{ + m_style = wxSOLID; + m_width = 1; + m_join = wxJOIN_ROUND ; + m_cap = wxCAP_ROUND ; + m_nbDash = 0 ; + m_dash = 0 ; +/* TODO: null data + m_hPen = 0; +*/ +} + +wxPenRefData::wxPenRefData(const wxPenRefData& data) +{ + m_style = data.m_style; + m_width = data.m_width; + m_join = data.m_join; + m_cap = data.m_cap; + m_nbDash = data.m_nbDash; + m_dash = data.m_dash; + m_colour = data.m_colour; +/* TODO: null data + m_hPen = 0; +*/ +} + +wxPenRefData::~wxPenRefData() +{ + // TODO: delete data +} + +// Pens + +wxPen::wxPen() +{ + if ( wxThePenList ) + wxThePenList->AddPen(this); +} + +wxPen::~wxPen() +{ + if (wxThePenList) + wxThePenList->RemovePen(this); +} + +// Should implement Create +wxPen::wxPen(const wxColour& col, int Width, int Style) +{ + m_refData = new wxPenRefData; + + M_PENDATA->m_colour = col; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = Style; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = 0 ; + + RealizeResource(); + + if ( wxThePenList ) + wxThePenList->AddPen(this); +} + +wxPen::wxPen(const wxBitmap& stipple, int Width) +{ + m_refData = new wxPenRefData; + + M_PENDATA->m_stipple = stipple; + M_PENDATA->m_width = Width; + M_PENDATA->m_style = wxSTIPPLE; + M_PENDATA->m_join = wxJOIN_ROUND ; + M_PENDATA->m_cap = wxCAP_ROUND ; + M_PENDATA->m_nbDash = 0 ; + M_PENDATA->m_dash = 0 ; + + RealizeResource(); + + if ( wxThePenList ) + wxThePenList->AddPen(this); +} + +void wxPen::Unshare() +{ + // Don't change shared data + if (!m_refData) + { + m_refData = new wxPenRefData(); + } + else + { + wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); + UnRef(); + m_refData = ref; + } +} + +void wxPen::SetColour(const wxColour& col) +{ + Unshare(); + + M_PENDATA->m_colour = col; + + RealizeResource(); +} + +void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) +{ + Unshare(); + + M_PENDATA->m_colour.Set(r, g, b); + + RealizeResource(); +} + +void wxPen::SetWidth(int Width) +{ + Unshare(); + + M_PENDATA->m_width = Width; + + RealizeResource(); +} + +void wxPen::SetStyle(int Style) +{ + Unshare(); + + M_PENDATA->m_style = Style; + + RealizeResource(); +} + +void wxPen::SetStipple(const wxBitmap& Stipple) +{ + Unshare(); + + M_PENDATA->m_stipple = Stipple; + M_PENDATA->m_style = wxSTIPPLE; + + RealizeResource(); +} + +void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) +{ + Unshare(); + + M_PENDATA->m_nbDash = nb_dashes; + M_PENDATA->m_dash = (wxDash *)Dash; + + RealizeResource(); +} + +void wxPen::SetJoin(int Join) +{ + Unshare(); + + M_PENDATA->m_join = Join; + + RealizeResource(); +} + +void wxPen::SetCap(int Cap) +{ + Unshare(); + + M_PENDATA->m_cap = Cap; + + RealizeResource(); +} + +bool wxPen::RealizeResource() +{ + // TODO: create actual pen + return FALSE; +} + + diff --git a/src/cocoa/region.cpp b/src/cocoa/region.cpp new file mode 100644 index 0000000000..260565f5fe --- /dev/null +++ b/src/cocoa/region.cpp @@ -0,0 +1,107 @@ +///////////////////////////////////////////////////////////////////////////// +// File: region.cpp +// Purpose: Region class +// Author: Markus Holzem, Julian Smart, Robert Roebling +// Created: Fri Oct 24 10:46:34 MET 1997 +// RCS-ID: $Id$ +// Copyright: (c) 1997 Markus Holzem, Julian Smart, Robert Roebling +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "region.h" +#endif + +#include "wx/region.h" +#include "wx/gdicmn.h" +#include "wx/log.h" + +// ---------------------------------------------------------------------------- +// macros +// ---------------------------------------------------------------------------- + +IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject); +IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject); + +// ---------------------------------------------------------------------------- +// wxRegion construction +// ---------------------------------------------------------------------------- + +wxRegion::~wxRegion() +{ + // m_refData unrefed in ~wxObject +} + +// ---------------------------------------------------------------------------- +// wxRegion comparison +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// wxRegion operations +// ---------------------------------------------------------------------------- + +void wxRegion::Clear() +{ + UnRef(); +} + +bool wxRegion::Combine(long x, long y, long width, long height, wxRegionOp op) +{ + return false; +} +bool wxRegion::Combine(const wxRegion& region, wxRegionOp op) +{ + return false; +} +bool wxRegion::Combine(const wxRect& rect, wxRegionOp op) +{ + return false; +} + + +// Does the region contain the point (x,y)? +wxRegionContain wxRegion::Contains(long x, long y) const +{ +return wxOutRegion; +} + +// Does the region contain the point pt? +wxRegionContain wxRegion::Contains(const wxPoint& pt) const +{ +return wxOutRegion; +} + +// Does the region contain the rectangle (x, y, w, h)? +wxRegionContain wxRegion::Contains(long x, long y, long w, long h) const +{ +return wxOutRegion; +} + +// Does the region contain the rectangle rect? +wxRegionContain wxRegion::Contains(const wxRect& rect) const +{ +return wxOutRegion; +} + +void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const +{ +} + +wxRect wxRegion::GetBox() const +{ + return wxRect(); +} + +wxRegion::wxRegion() +{ +} + +wxRegionIterator::wxRegionIterator() +{ +} + +wxRegionIterator::~wxRegionIterator() +{ +} + +// vi:sts=4:sw=4:et diff --git a/src/cocoa/settings.cpp b/src/cocoa/settings.cpp new file mode 100644 index 0000000000..79e530be39 --- /dev/null +++ b/src/cocoa/settings.cpp @@ -0,0 +1,276 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: settings.cpp +// Purpose: wxSettings +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation "settings.h" +#endif + +#include "wx/settings.h" +#include "wx/gdicmn.h" +#include "wx/utils.h" + +// ---------------------------------------------------------------------------- +// wxSystemSettingsNative +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// colours +// ---------------------------------------------------------------------------- + +wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) +{ + return wxColour(); +#if 0 + int major,minor; + wxGetOsVersion( &major, &minor ); + + switch( index ) + { + case wxSYS_COLOUR_SCROLLBAR : + case wxSYS_COLOUR_BACKGROUND: + case wxSYS_COLOUR_ACTIVECAPTION: + case wxSYS_COLOUR_INACTIVECAPTION: + case wxSYS_COLOUR_MENU: + case wxSYS_COLOUR_WINDOW: + case wxSYS_COLOUR_WINDOWFRAME: + case wxSYS_COLOUR_ACTIVEBORDER: + case wxSYS_COLOUR_INACTIVEBORDER: + case wxSYS_COLOUR_BTNFACE: + case wxSYS_COLOUR_MENUBAR: + return wxColor( 0xDD , 0xDD , 0xDD ) ; + break ; + + case wxSYS_COLOUR_LISTBOX : + { + if (major >= 10) + return *wxWHITE ; + else + return wxColor( 0xEE , 0xEE , 0xEE ) ; + break ; + } + case wxSYS_COLOUR_BTNSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + + case wxSYS_COLOUR_BTNTEXT: + case wxSYS_COLOUR_MENUTEXT: + case wxSYS_COLOUR_WINDOWTEXT: + case wxSYS_COLOUR_CAPTIONTEXT: + case wxSYS_COLOUR_INFOTEXT: + case wxSYS_COLOUR_INACTIVECAPTIONTEXT: + return *wxBLACK; + break ; + case wxSYS_COLOUR_HIGHLIGHT: + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + return wxColor( hilite.red >> 8 , hilite.green >> 8 , hilite.blue >> 8 ) ; + } + break ; + case wxSYS_COLOUR_BTNHIGHLIGHT: + case wxSYS_COLOUR_GRAYTEXT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + + case wxSYS_COLOUR_3DDKSHADOW: + return wxColor( 0x44 , 0x44 , 0x44 ) ; + break ; + case wxSYS_COLOUR_3DLIGHT: + return wxColor( 0xCC , 0xCC , 0xCC ) ; + break ; + case wxSYS_COLOUR_HIGHLIGHTTEXT : + { + RGBColor hilite ; + LMGetHiliteRGB(&hilite) ; + if ( ( hilite.red + hilite.green + hilite.blue ) == 0 ) + return *wxWHITE ; + else + return *wxBLACK ; + } + break ; + case wxSYS_COLOUR_INFOBK : + case wxSYS_COLOUR_APPWORKSPACE: + return *wxWHITE ; + break ; + + case wxSYS_COLOUR_HOTLIGHT: + case wxSYS_COLOUR_GRADIENTACTIVECAPTION: + case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: + case wxSYS_COLOUR_MENUHILIGHT: + // TODO + return *wxBLACK; + + case wxSYS_COLOUR_MAX: + wxFAIL_MSG( _T("unknown system colour index") ); + break ; + } + return *wxWHITE; +#endif +} + +// ---------------------------------------------------------------------------- +// fonts +// ---------------------------------------------------------------------------- + +wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) +{ +// return a nonworking font object, crash from wxInitializeStockObjects + return wxFont(); + switch (index) + { + case wxSYS_ANSI_VAR_FONT : + case wxSYS_SYSTEM_FONT : + case wxSYS_DEVICE_DEFAULT_FONT : + case wxSYS_DEFAULT_GUI_FONT : + { + return *wxSMALL_FONT ; + } ; + break ; + case wxSYS_OEM_FIXED_FONT : + case wxSYS_ANSI_FIXED_FONT : + case wxSYS_SYSTEM_FIXED_FONT : + default : + { + return *wxNORMAL_FONT ; + } ; + break ; + + } + return *wxNORMAL_FONT; +} + +// ---------------------------------------------------------------------------- +// system metrics/features +// ---------------------------------------------------------------------------- + +// Get a system metric, e.g. scrollbar size +int wxSystemSettingsNative::GetMetric(wxSystemMetric index) +{ + switch ( index) + { + case wxSYS_MOUSE_BUTTONS: + return 2; // we emulate a two button mouse (ctrl + click = right button ) + case wxSYS_BORDER_X: + // TODO + return 0; + case wxSYS_BORDER_Y: + // TODO + return 0; + case wxSYS_CURSOR_X: + // TODO + return 0; + case wxSYS_CURSOR_Y: + // TODO + return 0; + case wxSYS_DCLICK_X: + // TODO + return 0; + case wxSYS_DCLICK_Y: + // TODO + return 0; + case wxSYS_DRAG_X: + // TODO + return 0; + case wxSYS_DRAG_Y: + // TODO + return 0; + case wxSYS_EDGE_X: + // TODO + return 0; + case wxSYS_EDGE_Y: + // TODO + return 0; + case wxSYS_HSCROLL_ARROW_X: + return 16; + case wxSYS_HSCROLL_ARROW_Y: + return 16; + case wxSYS_HTHUMB_X: + return 16; + case wxSYS_ICON_X: + // TODO + return 0; + case wxSYS_ICON_Y: + // TODO + return 0; + case wxSYS_ICONSPACING_X: + // TODO + return 0; + case wxSYS_ICONSPACING_Y: + // TODO + return 0; + case wxSYS_WINDOWMIN_X: + // TODO + return 0; + case wxSYS_WINDOWMIN_Y: + // TODO + return 0; + case wxSYS_SCREEN_X: + // TODO + return 0; + case wxSYS_SCREEN_Y: + // TODO + return 0; + case wxSYS_FRAMESIZE_X: + // TODO + return 0; + case wxSYS_FRAMESIZE_Y: + // TODO + return 0; + case wxSYS_SMALLICON_X: + // TODO + return 0; + case wxSYS_SMALLICON_Y: + // TODO + return 0; + case wxSYS_HSCROLL_Y: + return 16; + case wxSYS_VSCROLL_X: + return 16; + case wxSYS_VSCROLL_ARROW_X: + return 16; + case wxSYS_VSCROLL_ARROW_Y: + return 16; + case wxSYS_VTHUMB_Y: + return 16; + case wxSYS_CAPTION_Y: + // TODO + return 0; + case wxSYS_MENU_Y: + // TODO + return 0; + case wxSYS_NETWORK_PRESENT: + // TODO + return 0; + case wxSYS_PENWINDOWS_PRESENT: + return 0; + case wxSYS_SHOW_SOUNDS: + // TODO + return 0; + case wxSYS_SWAP_BUTTONS: + return 0; + default: + return 0; + } + return 0; +} + +bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) +{ + switch (index) + { + case wxSYS_CAN_ICONIZE_FRAME: + case wxSYS_CAN_DRAW_FRAME_DECORATIONS: + return TRUE; + + default: + return FALSE; + } +} diff --git a/src/cocoa/utils.cpp b/src/cocoa/utils.cpp new file mode 100644 index 0000000000..14c47ad65c --- /dev/null +++ b/src/cocoa/utils.cpp @@ -0,0 +1,170 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: utils.cpp +// Purpose: Various utilities +// Author: AUTHOR +// Modified by: +// Created: 2003/??/?? +// RCS-ID: $Id: +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/setup.h" +#include "wx/utils.h" +#include "wx/app.h" + +#include + +#include +#include +#include +#include + +// Get size of display +void wxDisplaySize(int *width, int *height) +{ + // TODO +} + +void wxDisplaySizeMM(int*,int*) +{ + // TODO +} + +void wxClientDisplayRect(int *x,int *y,int *width,int *height) +{ + // TODO + if(x) + *x = 0; + if(y) + *y = 0; + if(width) + *width=1024; + if(height) + *height=768; +} + +int wxGetOsVersion(int *majorVsn, int *minorVsn) +{ + // TODO + return 0; +} + +// Return TRUE if we have a colour display +bool wxColourDisplay() +{ + // TODO + return TRUE; +} + +void wxGetMousePosition( int* x, int* y ) +{ + // TODO +}; + +// Returns depth of screen +int wxDisplayDepth() +{ + // TODO + return 0; +} + +// Emit a beeeeeep +void wxBell() +{ + // TODO +} + +#if 0 +// DFE: These aren't even implemented by wxGTK, and no wxWindows code calls +// them. If someone needs them, then they'll get a link error + +// Consume all events until no more left +void wxFlushEvents() +{ +} + +// Check whether this window wants to process messages, e.g. Stop button +// in long calculations. +bool wxCheckForInterrupt(wxWindow *wnd) +{ + // TODO + return FALSE; +} + +#endif + +// Reading and writing resources (eg WIN.INI, .Xdefaults) +#if wxUSE_RESOURCES +bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file) +{ + // TODO + return FALSE; +} + +bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file) +{ + char buf[50]; + sprintf(buf, "%.4f", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file) +{ + char buf[50]; + sprintf(buf, "%ld", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file) +{ + char buf[50]; + sprintf(buf, "%d", value); + return wxWriteResource(section, entry, buf, file); +} + +bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file) +{ + // TODO + return FALSE; +} + +bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (float)strtod(s, NULL); + delete[] s; + return TRUE; + } + else return FALSE; +} + +bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; +} + +bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file) +{ + char *s = NULL; + bool succ = wxGetResource(section, entry, (char **)&s, file); + if (succ) + { + *value = (int)strtol(s, NULL, 10); + delete[] s; + return TRUE; + } + else return FALSE; +} +#endif // wxUSE_RESOURCES diff --git a/src/cocoa/utilsexc.cpp b/src/cocoa/utilsexc.cpp new file mode 100644 index 0000000000..d6553a7531 --- /dev/null +++ b/src/cocoa/utilsexc.cpp @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: utilsexec.cpp +// Purpose: Execution-related utilities +// Author: AUTHOR +// Modified by: +// Created: ??/??/98 +// RCS-ID: $Id$ +// Copyright: (c) AUTHOR +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifdef __GNUG__ +#pragma implementation +#endif + +#include "wx/utils.h" +#ifdef __DARWIN__ +#include "wx/unix/execute.h" +#endif + +#include +#include +#include + +#ifndef __DARWIN__ +#define wxEXECUTE_WIN_MESSAGE 10000 + +long wxExecute(const wxString& command, int flags, wxProcess *handler) +{ + // TODO + wxFAIL_MSG( _T("wxExecute() not yet implemented") ); + return 0; +} +#endif + +#ifdef __DARWIN__ +int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) +{ + wxFAIL_MSG( _T("wxAddProcessCallback() not yet implemented") ); + return 0; +} +#endif -- 2.45.2