cleanup - reformat

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36795 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell 2006-01-09 09:46:05 +00:00
parent 633ecf268b
commit 274b7a40ef
3 changed files with 167 additions and 169 deletions

View File

@ -7,29 +7,23 @@
// 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);
@ -73,7 +67,7 @@ int wxImageList::Add( const wxIcon &bitmap )
m_height = bitmap.GetHeight();
}
return m_images.GetCount()-1;
return m_images.GetCount() - 1;
}
int wxImageList::Add( const wxBitmap &bitmap )
@ -83,7 +77,7 @@ 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)
{
@ -91,22 +85,24 @@ int wxImageList::Add( const wxBitmap &bitmap )
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
@ -120,9 +116,9 @@ wxBitmap wxImageList::GetBitmap(int index) const
if ( obj == NULL )
return wxNullBitmap ;
else if ( obj->IsKindOf(CLASSINFO(wxIcon)) )
return wxBitmap( *(wx_static_cast(wxIcon*,obj)) ) ;
return wxBitmap( *(wx_static_cast(wxIcon*, obj)) ) ;
else
return *(wx_static_cast(wxBitmap*,obj)) ;
return *(wx_static_cast(wxBitmap*, obj)) ;
}
// Get the icon
@ -135,13 +131,13 @@ wxIcon wxImageList::GetIcon(int index) const
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)) ;
return *(wx_static_cast(wxIcon*, obj)) ;
}
bool wxImageList::Replace( int index, const wxBitmap &bitmap )
@ -150,11 +146,12 @@ 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 );
}
@ -162,6 +159,7 @@ bool wxImageList::Replace( int index, const wxBitmap &bitmap )
{
wxList::compatibility_iterator next = node->GetNext();
delete node->GetData();
m_images.Erase( node );
m_images.Insert( next, newBitmap );
}
@ -175,7 +173,7 @@ bool wxImageList::Replace( int index, const wxIcon &bitmap )
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)
{
@ -224,7 +222,7 @@ bool wxImageList::GetSize( int index, int &width, int &height ) const
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();
@ -236,21 +234,23 @@ bool wxImageList::GetSize( int index, int &width, int &height ) const
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
{

View File

@ -9,7 +9,6 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
@ -19,61 +18,62 @@
#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.
*/
wxMetafileRefData::wxMetafileRefData(void)
// Metafiles:
// Currently, the only purpose for making a metafile
// is to put it on the clipboard.
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
}
}
@ -83,11 +83,12 @@ wxMetaFile::wxMetaFile(const wxString& file)
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()
@ -109,19 +110,19 @@ bool wxMetaFile::SetClipboard(int width, int height)
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
@ -131,24 +132,26 @@ bool wxMetaFile::SetClipboard(int width, int height)
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
}
@ -163,27 +166,29 @@ bool wxMetaFile::Play(wxDC *dc)
{
#if wxMAC_USE_CORE_GRAPHICS
QDPictRef cgPictRef = M_METAFILEDATA->m_qdPictRef ;
CGContextRef cg = ((wxMacCGContext*)(dc->GetGraphicContext()))->GetNativeContext() ;
CGRect bounds = QDPictGetBounds( cgPictRef ) ;
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 ) ;
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() ;
@ -195,10 +200,7 @@ wxSize wxMetaFile::GetSize() const
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.
@ -207,22 +209,25 @@ wxMetaFileDC::wxMetaFileDC(const wxString& filename ,
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()
@ -231,38 +236,43 @@ 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

View File

@ -25,26 +25,27 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGING)
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) )
return false;
m_macIsUserPane = false;
m_imageList = NULL;
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
return false;
UInt16 tabstyle = kControlTabDirectionNorth ;
ControlTabSize tabsize = kControlTabSizeLarge ;
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
UInt16 tabstyle = kControlTabDirectionNorth;
ControlTabSize tabsize = kControlTabSizeLarge;
if ( GetWindowVariant() == wxWINDOW_VARIANT_SMALL )
tabsize = kControlTabSizeSmall ;
else if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI )
@ -55,13 +56,15 @@ bool wxTabCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons
tabsize = kControlSizeSmall;
}
m_peer = new wxMacControl(this) ;
verify_noerr ( CreateTabsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds ,
tabsize , tabstyle, 0, NULL, m_peer->GetControlRefAddr() ) );
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 );
MacPostControlCreate(pos,size) ;
return TRUE ;
return true;
}
wxTabCtrl::~wxTabCtrl()
@ -72,139 +75,124 @@ void wxTabCtrl::Command(wxCommandEvent& event)
{
}
// 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:
}