// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#if wxUSE_IMAGLIST
#ifdef __BORLANDC__
-#pragma hdrstop
+ #pragma hdrstop
#endif
#include "wx/defs.h"
-
#include "wx/imaglist.h"
-
#include "wx/icon.h"
#include "wx/image.h"
#include "wx/dc.h"
-//-----------------------------------------------------------------------------
-// wxImageList
-//-----------------------------------------------------------------------------
-
IMPLEMENT_DYNAMIC_CLASS(wxImageList, wxObject)
+
wxImageList::wxImageList( int width, int height, bool mask, int initialCount )
{
(void)Create(width, height, mask, initialCount);
m_width = bitmap.GetWidth();
m_height = bitmap.GetHeight();
}
-
- return m_images.GetCount()-1;
+
+ return m_images.GetCount() - 1;
}
int wxImageList::Add( const wxBitmap &bitmap )
_T("invalid bitmap size in wxImageList: this might work ")
_T("on this platform but definitely won't under Windows.") );
- m_images.Append( new wxBitmap(bitmap) );
+ m_images.Append( new wxBitmap( bitmap ) );
if (m_width == 0 && m_height == 0)
{
m_width = bitmap.GetWidth();
m_height = bitmap.GetHeight();
}
-
- return m_images.GetCount()-1;
+
+ return m_images.GetCount() - 1;
}
int wxImageList::Add( const wxBitmap& bitmap, const wxBitmap& mask )
{
- wxBitmap bmp(bitmap);
+ wxBitmap bmp( bitmap );
if (mask.Ok())
- bmp.SetMask(new wxMask(mask));
- return Add(bmp);
+ bmp.SetMask( new wxMask( mask ) );
+
+ return Add( bmp );
}
int wxImageList::Add( const wxBitmap& bitmap, const wxColour& maskColour )
{
wxImage img = bitmap.ConvertToImage();
- img.SetMaskColour(maskColour.Red(), maskColour.Green(), maskColour.Blue());
- return Add(wxBitmap(img));
+ img.SetMaskColour( maskColour.Red(), maskColour.Green(), maskColour.Blue() );
+
+ return Add( wxBitmap( img ) );
}
// Get the bitmap
if ( obj == NULL )
return wxNullBitmap ;
else if ( obj->IsKindOf(CLASSINFO(wxIcon)) )
- return wxBitmap( *(wx_static_cast(wxIcon*,obj)) ) ;
- else
- return *(wx_static_cast(wxBitmap*,obj)) ;
+ return wxBitmap( *(wx_static_cast(wxIcon*, obj)) ) ;
+ else
+ return *(wx_static_cast(wxBitmap*, obj)) ;
}
// Get the icon
wxObject* obj = (wxObject*) node->GetData();
if ( obj == NULL )
return wxNullIcon ;
- else if( obj->IsKindOf(CLASSINFO(wxBitmap)) )
+ else if ( obj->IsKindOf(CLASSINFO(wxBitmap)) )
{
wxFAIL_MSG( wxT("cannot convert from bitmap to icon") ) ;
return wxNullIcon ;
}
- else
- return *(wx_static_cast(wxIcon*,obj)) ;
+ else
+ return *(wx_static_cast(wxIcon*, obj)) ;
}
bool wxImageList::Replace( int index, const wxBitmap &bitmap )
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
- wxBitmap* newBitmap = new wxBitmap(bitmap) ;
+ wxBitmap* newBitmap = new wxBitmap( bitmap );
if (index == (int) m_images.GetCount() - 1)
{
delete node->GetData();
+
m_images.Erase( node );
m_images.Append( newBitmap );
}
{
wxList::compatibility_iterator next = node->GetNext();
delete node->GetData();
+
m_images.Erase( node );
m_images.Insert( next, newBitmap );
}
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
- wxIcon* newBitmap = new wxIcon(bitmap) ;
+ wxIcon* newBitmap = new wxIcon( bitmap );
if (index == (int) m_images.GetCount() - 1)
{
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
wxObject *obj = (wxObject*)node->GetData();
- if( obj->IsKindOf(CLASSINFO(wxIcon)))
+ if (obj->IsKindOf(CLASSINFO(wxIcon)))
{
wxIcon *bm = wx_static_cast( wxIcon* , obj ) ;
width = bm->GetWidth();
width = bm->GetWidth();
height = bm->GetHeight();
}
+
return true;
}
-bool wxImageList::Draw( int index, wxDC &dc, int x, int y,
- int flags, bool WXUNUSED(solidBackground) )
+bool wxImageList::Draw(
+ int index, wxDC &dc, int x, int y,
+ int flags, bool WXUNUSED(solidBackground) )
{
wxList::compatibility_iterator node = m_images.Item( index );
wxCHECK_MSG( node, false, wxT("wrong index in image list") );
wxObject *obj = (wxObject*)node->GetData();
- if( obj->IsKindOf(CLASSINFO(wxIcon)))
+ if (obj->IsKindOf(CLASSINFO(wxIcon)))
{
wxIcon *bm = wx_static_cast( wxIcon* , obj ) ;
- dc.DrawIcon( *bm , x, y);
+ dc.DrawIcon( *bm , x, y );
}
else
{
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#if wxUSE_METAFILE
#ifndef WX_PRECOMP
-#include "wx/utils.h"
-#include "wx/app.h"
+ #include "wx/utils.h"
+ #include "wx/app.h"
#endif
#include "wx/metafile.h"
#include "wx/clipbrd.h"
-
#include "wx/mac/private.h"
#include <stdio.h>
#include <string.h>
-extern bool wxClipboardIsOpen;
-
IMPLEMENT_DYNAMIC_CLASS(wxMetafile, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxMetafileDC, wxDC)
class wxMetafileRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxMetafile;
+
public:
- wxMetafileRefData(void);
- ~wxMetafileRefData(void);
+ wxMetafileRefData();
+ ~wxMetafileRefData();
private:
PicHandle m_metafile;
+
#if wxMAC_USE_CORE_GRAPHICS
- QDPictRef m_qdPictRef ;
+ QDPictRef m_qdPictRef;
#endif
};
+extern bool wxClipboardIsOpen;
+
-/*
- * Metafiles
- * Currently, the only purpose for making a metafile is to put
- * it on the clipboard.
- */
+// Metafiles:
+// Currently, the only purpose for making a metafile
+// is to put it on the clipboard.
-wxMetafileRefData::wxMetafileRefData(void)
+wxMetafileRefData::wxMetafileRefData()
{
m_metafile = 0;
+
#if wxMAC_USE_CORE_GRAPHICS
- m_qdPictRef = NULL ;
+ m_qdPictRef = NULL;
#endif
}
-wxMetafileRefData::~wxMetafileRefData(void)
+wxMetafileRefData::~wxMetafileRefData()
{
if (m_metafile)
{
- KillPicture( (PicHandle) m_metafile ) ;
- m_metafile = 0;
+ KillPicture( (PicHandle)m_metafile );
+ m_metafile = NULL;
+
#if wxMAC_USE_CORE_GRAPHICS
- QDPictRelease( m_qdPictRef ) ;
- m_qdPictRef = NULL ;
+ QDPictRelease( m_qdPictRef );
+ m_qdPictRef = NULL;
#endif
}
}
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_metafile = 0;
- wxASSERT_MSG( file.empty() , wxT("no file based metafile support yet") ) ;
-/*
+ wxASSERT_MSG( file.empty(), wxT("no file based metafile support yet") );
+
+#if 0
if (!file.IsNull() && (file.Cmp("") == 0))
- M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile(file);
-*/
+ M_METAFILEDATA->m_metafile = (WXHANDLE) GetMetaFile( file );
+#endif
}
wxMetaFile::~wxMetaFile()
bool success = true;
#if wxUSE_DRAG_AND_DROP
- //TODO finishi this port , we need the data obj first
+ // TODO: to finish this port, we need the data obj first
if (!m_refData)
return false;
- bool alreadyOpen=wxTheClipboard->IsOpened() ;
+ bool alreadyOpen = wxTheClipboard->IsOpened();
if (!alreadyOpen)
{
wxTheClipboard->Open();
wxTheClipboard->Clear();
}
- wxDataObject *data =
- new wxMetafileDataObject( *this) ;
- success = wxTheClipboard->SetData(data);
+
+ wxDataObject *data = new wxMetafileDataObject( *this );
+ success = wxTheClipboard->SetData( data );
if (!alreadyOpen)
wxTheClipboard->Close();
#endif
void wxMetafile::SetHMETAFILE(WXHMETAFILE mf)
{
- UnRef() ;
+ UnRef();
m_refData = new wxMetafileRefData;
M_METAFILEDATA->m_metafile = (PicHandle) mf;
+
#if wxMAC_USE_CORE_GRAPHICS
- size_t sz = GetHandleSize( (Handle) M_METAFILEDATA->m_metafile ) ;
- wxMemoryBuffer* membuf = new wxMemoryBuffer( sz ) ;
- void * data = membuf->GetWriteBuf(sz) ;
- memcpy( data , *M_METAFILEDATA->m_metafile , sz ) ;
- membuf->UngetWriteBuf(sz) ;
- CGDataProviderRef provider = CGDataProviderCreateWithData( membuf , data , sz ,
- wxMacMemoryBufferReleaseProc ) ;
- M_METAFILEDATA->m_qdPictRef = NULL ;
+ size_t sz = GetHandleSize( (Handle) M_METAFILEDATA->m_metafile );
+ wxMemoryBuffer* membuf = new wxMemoryBuffer( sz );
+ void *data = membuf->GetWriteBuf( sz );
+ memcpy( data, *M_METAFILEDATA->m_metafile, sz );
+ membuf->UngetWriteBuf( sz );
+ CGDataProviderRef provider = CGDataProviderCreateWithData(
+ membuf, data, sz, wxMacMemoryBufferReleaseProc );
+ M_METAFILEDATA->m_qdPictRef = NULL;
+
if ( provider != NULL )
{
- M_METAFILEDATA->m_qdPictRef = QDPictCreateWithProvider( provider ) ;
- CGDataProviderRelease( provider ) ;
+ M_METAFILEDATA->m_qdPictRef = QDPictCreateWithProvider( provider );
+ CGDataProviderRelease( provider );
}
#endif
}
{
#if wxMAC_USE_CORE_GRAPHICS
- QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;
- CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;
- CGRect bounds = QDPictGetBounds( cgPictRef ) ;
-
- CGContextSaveGState(cg);
- CGContextTranslateCTM(cg, 0 , bounds.size.width );
- CGContextScaleCTM(cg, 1, -1);
- QDPictDrawToCGContext( cg , bounds , cgPictRef ) ;
- CGContextRestoreGState( cg ) ;
+ QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef;
+ CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext();
+ CGRect bounds = QDPictGetBounds( cgPictRef );
+
+ CGContextSaveGState( cg );
+ CGContextTranslateCTM( cg, 0 , bounds.size.width );
+ CGContextScaleCTM( cg, 1, -1 );
+ QDPictDrawToCGContext( cg , bounds, cgPictRef );
+ CGContextRestoreGState( cg );
#else
- PicHandle pict = (PicHandle) GetHMETAFILE() ;
- wxMacPortSetter helper( dc ) ;
- DrawPicture( pict , &(**pict).picFrame ) ;
+ PicHandle pict = (PicHandle) GetHMETAFILE();
+ wxMacPortSetter helper( dc );
+ DrawPicture( pict , &(**pict).picFrame );
#endif
}
+
return true;
}
wxSize wxMetaFile::GetSize() const
{
wxSize size = wxDefaultSize ;
+
if ( Ok() )
{
PicHandle pict = (PicHandle) GetHMETAFILE() ;
return size;
}
-/*
- * Metafile device context
- *
- */
+// Metafile device context
// New constructor that takes origin and extent. If you use this, don't
// give origin/extent arguments to wxMakeMetaFilePlaceable.
int width , int height ,
const wxString& WXUNUSED(description) )
{
- wxASSERT_MSG( width == 0 || height == 0 , _T("no arbitration of metafilesize supported") ) ;
- wxASSERT_MSG( filename.empty() , _T("no file based metafile support yet")) ;
+ wxASSERT_MSG( width == 0 || height == 0 , wxT("no arbitration of metafilesize supported") );
+ wxASSERT_MSG( filename.empty() , wxT("no file based metafile support yet"));
+
+ m_metaFile = new wxMetaFile( filename );
- m_metaFile = new wxMetaFile(filename) ;
#if wxMAC_USE_CORE_GRAPHICS
#else
- Rect r={0,0,height,width} ;
+ Rect r = { 0, 0, height, width };
+
+ RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r );
+ CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn );
- RectRgn( (RgnHandle) m_macBoundaryClipRgn , &r ) ;
- CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ;
+ m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) );
+ ::GetPort( (GrafPtr*) &m_macPort );
- m_metaFile->SetHMETAFILE( (WXHMETAFILE) OpenPicture( &r ) ) ;
- ::GetPort( (GrafPtr*) &m_macPort ) ;
m_ok = true ;
#endif
- SetMapMode(wxMM_TEXT);
+
+ SetMapMode( wxMM_TEXT );
}
wxMetaFileDC::~wxMetaFileDC()
void wxMetaFileDC::DoGetSize(int *width, int *height) const
{
- wxCHECK_RET( m_metaFile , _T("GetSize() doesn't work without a metafile") );
+ wxCHECK_RET( m_metaFile , wxT("GetSize() doesn't work without a metafile") );
wxSize sz = m_metaFile->GetSize() ;
- if (width) (*width) = sz.x;
- if (height) (*height) = sz.y;
+ if (width)
+ (*width) = sz.x;
+ if (height)
+ (*height) = sz.y;
}
wxMetaFile *wxMetaFileDC::Close()
{
ClosePicture() ;
+
return m_metaFile;
}
#if wxUSE_DATAOBJ
size_t wxMetafileDataObject::GetDataSize() const
{
- return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ;
+ return GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() );
}
bool wxMetafileDataObject::GetDataHere(void *buf) const
{
memcpy( buf , (*(PicHandle)(*((wxMetafile*)&m_metafile)).GetHMETAFILE()) ,
- GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) ) ;
- return true ;
+ GetHandleSize( (Handle) (*((wxMetafile*)&m_metafile)).GetHMETAFILE() ) );
+
+ return true;
}
bool wxMetafileDataObject::SetData(size_t len, const void *buf)
{
- Handle handle = NewHandle( len ) ;
- SetHandleSize( handle , len ) ;
- memcpy( *handle , buf , len ) ;
- m_metafile.SetHMETAFILE( (WXHMETAFILE) handle ) ;
+ Handle handle = NewHandle( len );
+ SetHandleSize( handle, len );
+ memcpy( *handle, buf, len );
+ m_metafile.SetHMETAFILE( (WXHMETAFILE) handle );
+
return true ;
}
#endif
BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
END_EVENT_TABLE()
+
wxTabCtrl::wxTabCtrl()
{
+ m_macIsUserPane = false;
m_imageList = NULL;
}
-bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
- long style, const wxString& name)
+bool wxTabCtrl::Create( wxWindow *parent,
+ wxWindowID id, const wxPoint& pos, const wxSize& size,
+ long style, const wxString& name )
{
- m_macIsUserPane = FALSE ;
-
- if ( !wxControl::Create(parent, id, pos, size,
- style, wxDefaultValidator, name) )
+ m_macIsUserPane = false;
+ m_imageList = NULL;
+
+ if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
return false;
- m_imageList = NULL;
-
- Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
+ Rect bounds = wxMacGetBoundsForControl( this, pos, size );
- UInt16 tabstyle = kControlTabDirectionNorth ;
- ControlTabSize tabsize = kControlTabSizeLarge ;
+ UInt16 tabstyle = kControlTabDirectionNorth;
+ ControlTabSize tabsize = kControlTabSizeLarge;
if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
tabsize = kControlTabSizeSmall ;
else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
{
if (UMAGetSystemVersion() >= 0x1030 )
- tabsize = 3 ;
+ tabsize = 3 ;
else
- tabsize = kControlSizeSmall;
+ tabsize = kControlSizeSmall;
}
-
- m_peer = new wxMacControl(this) ;
- verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
- tabsize , tabstyle, 0, NULL, m_peer->GetControlRefAddr() ) );
-
- MacPostControlCreate(pos,size) ;
- return TRUE ;
+ m_peer = new wxMacControl( this );
+ OSStatus err = CreateTabsControl(
+ MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
+ tabsize, tabstyle, 0, NULL, m_peer->GetControlRefAddr() );
+ verify_noerr( err );
+
+ MacPostControlCreate( pos, size );
+
+ return true;
}
wxTabCtrl::~wxTabCtrl()
{
}
-// Delete all items
bool wxTabCtrl::DeleteAllItems()
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Delete an item
bool wxTabCtrl::DeleteItem(int item)
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Get the selection
int wxTabCtrl::GetSelection() const
{
- // TODO
+ // TODO:
return 0;
}
// Get the tab with the current keyboard focus
+//
int wxTabCtrl::GetCurFocus() const
{
- // TODO
+ // TODO:
return 0;
}
-// Get the associated image list
-wxImageList* wxTabCtrl::GetImageList() const
+wxImageList * wxTabCtrl::GetImageList() const
{
return m_imageList;
}
-// Get the number of items
int wxTabCtrl::GetItemCount() const
{
- // TODO
+ // TODO:
return 0;
}
// Get the rect corresponding to the tab
bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Get the number of rows
int wxTabCtrl::GetRowCount() const
{
- // TODO
+ // TODO:
return 0;
}
-// Get the item text
wxString wxTabCtrl::GetItemText(int item) const
{
- // TODO
+ // TODO:
return wxEmptyString;
}
-// Get the item image
int wxTabCtrl::GetItemImage(int item) const
{
- // TODO
+ // TODO:
return 0;
}
-// Get the item data
void* wxTabCtrl::GetItemData(int item) const
{
- // TODO
+ // TODO:
return NULL;
}
-// Hit test
int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
{
- // TODO
+ // TODO:
return 0;
}
-// Insert an item
bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Set the selection
int wxTabCtrl::SetSelection(int item)
{
- // TODO
+ // TODO:
return 0;
}
-// Set the image list
void wxTabCtrl::SetImageList(wxImageList* imageList)
{
- // TODO
+ // TODO:
}
-// Set the text for an item
bool wxTabCtrl::SetItemText(int item, const wxString& text)
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Set the image for an item
bool wxTabCtrl::SetItemImage(int item, int image)
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
-// Set the data for an item
bool wxTabCtrl::SetItemData(int item, void* data)
{
- // TODO
- return FALSE;
+ // TODO:
+ return false;
}
// Set the size for a fixed-width tab control
void wxTabCtrl::SetItemSize(const wxSize& size)
{
- // TODO
+ // TODO:
}
// Set the padding between tabs
void wxTabCtrl::SetPadding(const wxSize& padding)
{
- // TODO
+ // TODO:
}