// Convenience functions
virtual bool Write(const wxString& key, double value);
virtual bool Write(const wxString& key, bool value);
+ virtual bool Write(const wxString& key, const wxChar *text ) ;
// permanently writes all changes
virtual bool Flush(bool bCurrentOnly = FALSE) = 0;
// #include "wx/motif/dataobj2.h" -- not yet
#elif defined(__WXGTK__)
#include "wx/gtk/dataobj2.h"
+#elif defined(__WXMAC__)
+ #include "wx/mac/dataobj2.h"
#elif defined(__WXPM__)
#include "wx/os2/dataobj2.h"
#endif
#define wxByte wxUint8
#define wxWord wxUint16
+// base floating point types
+// wxFloat32 : 32 bit IEEE float ( 1 sign , 8 exponent bits , 23 fraction bits
+// wxFloat64 : 64 bit IEEE float ( 1 sign , 11 exponent bits , 52 fraction bits
+// wxDouble : native fastest representation that has at least wxFloat64
+// precision, so use the IEEE types for storage , and this for calculations
+
+typedef float wxFloat32 ;
+#if defined( __WXMAC__ ) && defined (__MWERKS__)
+ typedef short double wxFloat64;
+#else
+ typedef double wxFloat64;
+#endif
+
+#if defined( __WXMAC__ ) && !defined( __POWERPC__ )
+ typedef long double wxDouble;
+#else
+ typedef double wxDouble ;
+#endif
+
// ----------------------------------------------------------------------------
// byte ordering related definition and macros
// ----------------------------------------------------------------------------
// byte swapping
+#if defined (__MWERKS__) && ( (__MWERKS__ < 0x0900) || macintosh )
+// assembler versions for these
+#ifdef __POWERPC__
+ inline wxUint16 wxUINT16_SWAP_ALWAYS( wxUint16 i )
+ {return (__lhbrx( &i , 0 ) ) ;}
+ inline wxInt16 wxINT16_SWAP_ALWAYS( wxInt16 i )
+ {return (__lhbrx( &i , 0 ) ) ;}
+ inline wxUint32 wxUINT32_SWAP_ALWAYS( wxUint32 i )
+ {return (__lwbrx( &i , 0 ) ) ;}
+ inline wxInt32 wxINT32_SWAP_ALWAYS( wxInt32 i )
+ {return (__lwbrx( &i , 0 ) ) ;}
+#else
+ #pragma parameter __D0 wxUINT16_SWAP_ALWAYS(__D0)
+ pascal wxUint16 wxUINT16_SWAP_ALWAYS(wxUint16 value)
+ = { 0xE158 };
+
+ #pragma parameter __D0 wxINT16_SWAP_ALWAYS(__D0)
+ pascal wxInt16 wxUINT16_SWAP_ALWAYS(wxInt16 value)
+ = { 0xE158 };
+
+ #pragma parameter __D0 wxUINT32_SWAP_ALWAYS (__D0)
+ pascal wxUint32 wxUINT32_SWAP_ALWAYS(wxUint32 value)
+ = { 0xE158, 0x4840, 0xE158 };
+
+ #pragma parameter __D0 wxINT32_SWAP_ALWAYS (__D0)
+ pascal wxInt32 wxUINT32_SWAP_ALWAYS(wxInt32 value)
+ = { 0xE158, 0x4840, 0xE158 };
+
+#endif
+#else // !MWERKS
#define wxUINT16_SWAP_ALWAYS(val) \
((wxUint16) ( \
(((wxUint16) (val) & (wxUint16) 0x00ffU) << 8) | \
(((wxUint32) (val) & (wxUint32) 0x0000ff00U) << 8) | \
(((wxUint32) (val) & (wxUint32) 0x00ff0000U) >> 8) | \
(((wxUint32) (val) & (wxUint32) 0xff000000U) >> 24)))
-
+#endif
// machine specific byte swapping
#ifdef WORDS_BIGENDIAN
{ return wxConfigBase::Write(key, value); }
bool Write(const wxString& key, bool value)
{ return wxConfigBase::Write(key, value); }
+ bool Write(const wxString& key, const wxChar* value)
+ { return wxConfigBase::Write(key, value); }
virtual bool Flush(bool bCurrentOnly = FALSE);
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnSize( wxSizeEvent &event );
-
+ void OnScroll(wxScrollWinEvent& event) ;
+
void DrawImage( int index, wxDC *dc, int x, int y );
void GetImageSize( int index, int &width, int &height );
int GetIndexOfLine( const wxListLineData *line );
public:
wxFontRefData()
{
- Init(12, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
- "", wxFONTENCODING_DEFAULT);
+ Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
+ "Geneva", wxFONTENCODING_DEFAULT);
}
wxFontRefData(const wxFontRefData& data)
// Checks if there is a toolbar, and returns the first free client position
virtual wxPoint GetClientAreaOrigin() const;
- virtual void GetClientSize(int *x, int *y) const ;
+ virtual void DoGetClientSize(int *x, int *y) const ;
virtual void DoSetClientSize(int clientwidth, int clientheight) ;
// tooltip management
// Gets the size available for subwindows after menu size, toolbar size
// and status bar size have been subtracted. If you want to manage your own
// toolbar(s), don't call SetToolBar.
- void GetClientSize(int *width, int *height) const;
+ void DoGetClientSize(int *width, int *height) const;
// Get the active MDI child window (Windows only)
wxMDIChildFrame *GetActiveChild() const ;
*
*/
+#define WORDS_BIGENDIAN 1
+
#define wxUSE_CONFIG 1
// Use wxConfig, with CreateConfig in wxApp
// since you may well need to output
// an error log in a production
// version (or non-debugging beta)
-#define wxUSE_GLOBAL_MEMORY_OPERATORS 1
+#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
// In debug mode, cause new and delete to be redefined globally.
// If this causes problems (e.g. link errors), set this to 0.
// --------------
void OnEraseBackground(wxEraseEvent& event);
void OnIdle(wxIdleEvent& event);
+ void MacOnScroll(wxScrollEvent&event ) ;
public:
// For implementation purposes - sometimes decorations make the client area
virtual void MacGetPortClientParams(Point* localOrigin, Rect* clipRect, WindowRef *window , wxWindow** rootwin) ;
MacWindowData* MacGetWindowData() { return m_macWindowData ; }
static WindowRef MacGetWindowInUpdate() { return s_macWindowInUpdate ; }
+ bool MacIsWindowScrollbar( const wxScrollBar* sb ) { return (m_hScrollBar == sb || m_vScrollBar == sb) ; }
static wxWindow* s_lastMouseWindow ;
private:
virtual bool MacGetWindowFromPointSub( const wxPoint &point , wxWindow** outWin ) ;
#endif
#ifdef __MWERKS__
- void * operator new[] (size_t size, wxChar * fileName , int lineNum = 0);
+ void * operator new[] (size_t size, wxChar * fileName , int lineNum = 0);
+ void * operator new[] (size_t size) { return operator new[] ( size , NULL , 0 ) ; }
void operator delete[] (void * buf);
#endif
///////////////////////////////////////////////////////////////////////////////
-// Name: os2/dataobj2.h
+// Name: mac/dataobj2.h
// Purpose: declaration of standard wxDataObjectSimple-derived classes
-// Author: David Webster (adapted from Robert Roebling's gtk port
+// Author: Stefan Csomor (adapted from Robert Roebling's gtk port
// Modified by:
// Created: 10/21/99
// RCS-ID: $Id$
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
-#ifndef _WX_GTK_DATAOBJ2_H_
-#define _WX_GTK_DATAOBJ2_H_
+#ifndef _WX_MAC_DATAOBJ2_H_
+#define _WX_MAC_DATAOBJ2_H_
#ifdef __GNUG__
#pragma interface "dataobj.h"
{ return(wxDataObjectSimple::SetData(rFormat, nLen, pBuf)); }
};
-#endif // _WX_GTK_DATAOBJ2_H_
+#endif // _WX_MAC_DATAOBJ2_H_
wxString(const unsigned char* psz, size_t nLength = wxSTRING_MAXLEN)
{ InitWith((const char*)psz, 0, nLength); }
// from multibyte string
- wxString(const char *psz, wxMBConv& WXUNUSED(conv), size_t nLength = wxSTRING_MAXLEN)
+ wxString(const char *psz, wxMBConv& WXUNUSED(conv) , size_t nLength = wxSTRING_MAXLEN)
{ InitWith(psz, 0, nLength); }
#if wxUSE_WCHAR_T
#include "forty.h"
#include "card.h"
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#include "pictures.xpm"
#include "symbols.xbm"
#endif
{
#ifdef __WXMSW__
m_devMode = NULL;
+#elif defined( __WXMAC__ )
+ m_macPrintInfo = NULL ;
#endif
-
(*this) = printData;
}
{
#ifdef __WXMSW__
m_printDlgData = NULL;
+#elif defined( __WXMAC__ )
+ m_macPrintInfo = NULL ;
#endif
m_printFromPage = 0;
m_printToPage = 0;
wxPrintDialogData::wxPrintDialogData(const wxPrintDialogData& dialogData)
{
+#ifdef __WXMSW__
+ m_printDlgData = NULL;
+#elif defined( __WXMAC__ )
+ m_macPrintInfo = NULL ;
+#endif
(*this) = dialogData;
}
wxPageSetupDialogData::wxPageSetupDialogData(const wxPageSetupDialogData& dialogData)
{
+#if defined(__WIN95__)
+ m_pageSetupData = NULL;
+#elif defined( __WXMAC__ )
+ m_macPageSetupInfo = NULL ;
+#endif
(*this) = dialogData;
}
#endif // Win95
#ifdef __WXMAC__
-void wxPageSetupData::ConvertToNative()
+void wxPageSetupDialogData::ConvertToNative()
{
if ( !m_macPageSetupInfo )
{
}
}
-void wxPageSetupData::ConvertFromNative()
+void wxPageSetupDialogData::ConvertFromNative()
{
if ( m_macPageSetupInfo )
{
return Write(key, l);
}
+bool wxConfigBase::Write( const wxString &key, const wxChar *text )
+{
+ wxString str( text ) ;
+ return Write( key, str ) ;
+}
wxString wxConfigBase::ExpandEnvVars(const wxString& str) const
{
wxString tmp; // Required for BC++
tmp_fname = new char[fname_len];
wxWX2MB(tmp_fname, filename, fname_len);
+#ifdef __WXMAC__
+ m_fp = fopen(wxUnix2MacFilename( tmp_fname ), mode);
+#else
m_fp = fopen(tmp_fname, mode);
+#endif
delete tmp_fname;
+#else
+#ifdef __WXMAC__
+ m_fp = fopen(wxUnix2MacFilename( filename ), mode);
#else
m_fp = fopen(filename, mode);
#endif
+#endif
if ( !m_fp )
#define MAX_PATH 512
#endif
-#ifdef __WXMAC__
- char gwxMacFileName[ MAX_PATH ] ;
- char gwxMacFileName2[ MAX_PATH ] ;
- char gwxMacFileName3[ MAX_PATH ] ;
-#endif
-
// some broken compilers don't have 3rd argument in open() and creat()
#ifdef __SALFORDC__
#define ACCESS(access)
#if wxUSE_UNICODE && wxMBFILES
wxCharBuffer fname = wxConvFile.cWC2MB(name);
+#ifdef __WXMAC__
+ return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
+#else
return !access(fname, 0) &&
!stat(wxMBSTRINGCAST fname, &st) &&
(st.st_mode & S_IFREG);
+#endif
+#else
+#ifdef __WXMAC__
+ return !access(wxUnix2MacFilename( name ) , 0) && !stat(wxUnix2MacFilename( name ), &st) && (st.st_mode & S_IFREG);
#else
return !access(name, 0) &&
!stat((wxChar*) name, &st) &&
(st.st_mode & S_IFREG);
#endif
+#endif
}
bool wxFile::Access(const wxChar *name, OpenMode mode)
{
// if bOverwrite we create a new file or truncate the existing one,
// otherwise we only create the new file and fail if it already exists
+#ifdef __WXMAC__
+ int fd = open(wxUnix2MacFilename( szFileName ), O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL), access);
+#else
int fd = open(wxFNCONV(szFileName),
O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)
ACCESS(accessMode));
-
+#endif
if ( fd == -1 ) {
wxLogSysError(_("can't create file '%s'"), szFileName);
return FALSE;
break;
}
+#ifdef __WXMAC__
+ int fd = open(wxUnix2MacFilename( szFileName ), flags, access);
+#else
int fd = open(wxFNCONV(szFileName), flags ACCESS(accessMode));
-
+#endif
if ( fd == -1 ) {
wxLogSysError(_("can't open file '%s'"), szFileName);
return FALSE;
{
m_file.Close();
+#ifndef __WXMAC__
if ( wxFile::Exists(m_strName) && remove(m_strName.fn_str()) != 0 ) {
wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
return FALSE;
wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
return FALSE;
}
+#else
+ if ( wxFile::Exists(m_strName) && remove(wxUnix2MacFilename( m_strName )) != 0 ) {
+ wxLogSysError(_("can't remove file '%s'"), m_strName.c_str());
+ return FALSE;
+ }
+
+ if ( rename(wxUnix2MacFilename( m_strTemp ), wxUnix2MacFilename( m_strName )) != 0 ) {
+ wxLogSysError(_("can't commit changes to file '%s'"), m_strName.c_str());
+ return FALSE;
+ }
+#endif
return TRUE;
}
void wxTempFile::Discard()
{
m_file.Close();
+#ifndef __WXMAC__
if ( remove(m_strTemp.fn_str()) != 0 )
wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
+#else
+ if ( remove( wxUnix2MacFilename(m_strTemp.fn_str())) != 0 )
+ wxLogSysError(_("can't remove temporary file '%s'"), m_strTemp.c_str());
+#endif
}
#endif
#elif defined(__WXSTUBS__)
wxASSERT_MSG( FALSE, wxT("TODO") ) ;
#elif defined(__WXMAC__)
- wxASSERT_MSG( FALSE, wxT("TODO") ) ;
+ {
+ short vRefNum ;
+ long dirID ;
+
+ if ( FindFolder( (short) kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder, &vRefNum, &dirID) == noErr)
+ {
+ FSSpec file ;
+ if ( FSMakeFSSpec( vRefNum , dirID , "\p" , &file ) == noErr )
+ {
+ strDir = wxMacFSSpec2UnixFilename( &file ) + "/" ;
+ }
+ }
+ }
#else // Windows
wxChar szWinDir[MAX_PATH];
::GetWindowsDirectory(szWinDir, MAX_PATH);
{
wxString strDir;
+#ifndef __WXMAC__
wxGetHomeDir(&strDir);
#ifdef __UNIX__
#else
if (strDir.Last() != wxT('\\')) strDir << wxT('\\');
#endif
+#else
+ // no local dir concept on mac
+ return GetGlobalDir() ;
+#endif
return strDir;
}
if ( wxStrchr(szFile, wxT('.')) == NULL )
#ifdef __UNIX__
str << wxT(".conf");
+ #elif defined( __WXMAC__ )
+ str << " Preferences";
#else // Windows
str << wxT(".ini");
#endif // UNIX/Win
str << wxT(".ini");
#endif
+
+ #ifdef __WXMAC__
+ str << " Preferences";
+ #endif
return str;
}
}
}
+#ifndef __WXMAC__
return file.Commit();
+#else
+ bool ret = file.Commit();
+ if ( ret )
+ {
+ FSSpec spec ;
+
+ wxUnixFilename2FSSpec( m_strLocalFile , &spec ) ;
+ FInfo finfo ;
+ if ( FSpGetFInfo( &spec , &finfo ) == noErr )
+ {
+ finfo.fdType = 'TEXT' ;
+ finfo.fdCreator = 'ttxt' ;
+ FSpSetFInfo( &spec , &finfo ) ;
+ }
+ }
+ return ret ;
+#endif
}
// ----------------------------------------------------------------------------
return result;
}
+#elif defined(__WXMAC__)
+
+struct MacDirectoryIterator
+{
+ CInfoPBRec m_CPB ;
+ wxInt16 m_index ;
+ long m_dirId ;
+ Str255 m_name ;
+} ;
+
+static int g_iter_flags ;
+
+static MacDirectoryIterator g_iter ;
+
+wxString wxFindFirstFile(const wxChar *spec, int flags)
+{
+ wxString result;
+
+ g_iter_flags = flags; /* MATTHEW: [5] Remember flags */
+
+ // Find path only so we can concatenate found file onto path
+ wxString path(wxPathOnly(spec));
+ if ( !path.IsEmpty() )
+ result << path << wxT('\\');
+
+ FSSpec fsspec ;
+
+ wxUnixFilename2FSSpec( result , &fsspec ) ;
+ g_iter.m_CPB.hFileInfo.ioVRefNum = fsspec.vRefNum ;
+ g_iter.m_CPB.hFileInfo.ioNamePtr = g_iter.m_name ;
+ g_iter.m_index = 0 ;
+
+ Boolean isDir ;
+ FSpGetDirectoryID( &fsspec , &g_iter.m_dirId , &isDir ) ;
+ if ( !isDir )
+ return wxEmptyString ;
+
+ return wxFindNextFile( ) ;
+}
+
+wxString wxFindNextFile()
+{
+ wxString result;
+
+ short err = noErr ;
+
+ while ( err == noErr )
+ {
+ g_iter.m_index++ ;
+ g_iter.m_CPB.dirInfo.ioFDirIndex = g_iter.m_index;
+ g_iter.m_CPB.dirInfo.ioDrDirID = g_iter.m_dirId; /* we need to do this every time */
+ err = PBGetCatInfoSync((CInfoPBPtr)&g_iter.m_CPB);
+ if ( err != noErr )
+ break ;
+
+ if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) != 0 && (g_iter_flags & wxDIR) ) // we have a directory
+ break ;
+
+ if ( ( g_iter.m_CPB.dirInfo.ioFlAttrib & ioDirMask) == 0 && !(g_iter_flags & wxFILE ) )
+ continue ;
+
+ // hit !
+ break ;
+ }
+ if ( err != noErr )
+ {
+ return wxEmptyString ;
+ }
+ FSSpec spec ;
+
+ FSMakeFSSpecCompat(g_iter.m_CPB.hFileInfo.ioVRefNum,
+ g_iter.m_dirId,
+ g_iter.m_name,
+ &spec) ;
+
+ return wxMacFSSpec2UnixFilename( &spec ) ;
+}
+
#elif defined(__WXMSW__)
#ifdef __WIN32__
FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
strcpy( buf , res ) ;
- if (0)
+ if (0) {
#else
if (getcwd(cbuf, sz) == NULL) {
#endif
delete [] cbuf;
-#else
+#else // wxUnicode
#ifdef _MSC_VER
if (_getcwd(buf, sz) == NULL) {
+#elif defined( __WXMAC__)
+ enum
+ {
+ SFSaveDisk = 0x214, CurDirStore = 0x398
+ };
+ FSSpec cwdSpec ;
+
+ FSMakeFSSpec( - *(short *) SFSaveDisk , *(long *) CurDirStore , NULL , &cwdSpec ) ;
+ wxString res = wxMacFSSpec2UnixFilename( &cwdSpec ) ;
+ strcpy( buf , res ) ;
+ if (0) {
#else
if (getcwd(buf, sz) == NULL) {
#endif
#endif
+#ifdef __WXMAC__
+
+#include <PictUtils.h>
+
+extern CTabHandle wxMacCreateColorTable( int numColors ) ;
+extern void wxMacDestroyColorTable( CTabHandle colors ) ;
+extern void wxMacSetColorTableEntry( CTabHandle newColors , int index , int red , int green , int blue ) ;
+extern GWorldPtr wxMacCreateGWorld( int height , int width , int depth ) ;
+extern void wxMacDestroyGWorld( GWorldPtr gw ) ;
+
+wxBitmap wxImage::ConvertToBitmap() const
+{
+ // width and height of the device-dependent bitmap
+ int width = GetWidth();
+ int height = GetHeight();
+
+ // Create picture
+
+ wxBitmap bitmap( width , height , wxDisplayDepth() ) ;
+
+ // Create mask
+
+ if (HasMask())
+ {
+ /*
+ unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
+
+ mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
+
+ wxMask *mask = new wxMask();
+ mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
+
+ bitmap.SetMask( mask );
+ */
+ }
+
+ // Render
+
+ int r_mask = GetMaskRed();
+ int g_mask = GetMaskGreen();
+ int b_mask = GetMaskBlue();
+
+ CGrafPtr origPort ;
+ GDHandle origDevice ;
+
+ GetGWorld( &origPort , &origDevice ) ;
+ SetGWorld( bitmap.GetHBITMAP() , NULL ) ;
+
+ register unsigned char* data = GetData();
+
+ int index = 0;
+ for (int y = 0; y < height; y++)
+ {
+#if 0
+ unsigned char lastr = 0 ;
+ unsigned char lastg = 0 ;
+ unsigned char lastb = 0 ;
+ RGBColor lastcolor ;
+
+ MoveTo( 0 , y ) ;
+ for (int x = 0; x < width; x++)
+ {
+ unsigned char r = data[index++];
+ unsigned char g = data[index++];
+ unsigned char b = data[index++];
+
+ if ( r != lastr || g != lastg || b != lastb )
+ {
+ lastcolor.red = ( lastr << 8 ) + lastr ;
+ lastcolor.green = ( lastg << 8 ) + lastg ;
+ lastcolor.blue = ( lastb << 8 ) + lastb ;
+ RGBForeColor( &lastcolor ) ;
+ LineTo( x , y ) ;
+ lastr = r ;
+ lastg = g ;
+ lastb = b ;
+ }
+ } // for width
+ lastcolor.red = ( lastr << 8 ) + lastr ;
+ lastcolor.green = ( lastg << 8 ) + lastg ;
+ lastcolor.blue = ( lastb << 8 ) + lastb ;
+ RGBForeColor( &lastcolor ) ;
+ LineTo( width - 1 , y ) ;
+#else
+ for (int x = 0; x < width; x++)
+ {
+ unsigned char r = data[index++];
+ unsigned char g = data[index++];
+ unsigned char b = data[index++];
+ RGBColor color ;
+ color.red = ( r << 8 ) + r ;
+ color.green = ( g << 8 ) + g ;
+ color.blue = ( b << 8 ) + b ;
+ SetCPixel( x , y , &color ) ;
+ }
+#endif
+ } // for height
+
+ SetGWorld( origPort , origDevice ) ;
+
+ return bitmap;
+
+}
+
+wxImage::wxImage( const wxBitmap &bitmap )
+{
+ // check the bitmap
+ if( !bitmap.Ok() )
+ {
+ wxFAIL_MSG( "invalid bitmap" );
+ return;
+ }
+
+ // create an wxImage object
+ int width = bitmap.GetWidth();
+ int height = bitmap.GetHeight();
+ Create( width, height );
+ /*
+ unsigned char *data = GetData();
+ if( !data )
+ {
+ wxFAIL_MSG( "could not allocate data for image" );
+ return;
+ }
+
+ // calc the number of bytes per scanline and padding in the DIB
+ int bytePerLine = width*3;
+ int sizeDWORD = sizeof( DWORD );
+ div_t lineBoundary = div( bytePerLine, sizeDWORD );
+ int padding = 0;
+ if( lineBoundary.rem > 0 )
+ {
+ padding = sizeDWORD - lineBoundary.rem;
+ bytePerLine += padding;
+ }
+
+ // create a DIB header
+ int headersize = sizeof(BITMAPINFOHEADER);
+ LPBITMAPINFO lpDIBh = (BITMAPINFO *) malloc( headersize );
+ if( !lpDIBh )
+ {
+ wxFAIL_MSG( "could not allocate data for DIB header" );
+ free( data );
+ return;
+ }
+ // Fill in the DIB header
+ lpDIBh->bmiHeader.biSize = headersize;
+ lpDIBh->bmiHeader.biWidth = width;
+ lpDIBh->bmiHeader.biHeight = -height;
+ lpDIBh->bmiHeader.biSizeImage = bytePerLine * height;
+ lpDIBh->bmiHeader.biPlanes = 1;
+ lpDIBh->bmiHeader.biBitCount = 24;
+ lpDIBh->bmiHeader.biCompression = BI_RGB;
+ lpDIBh->bmiHeader.biClrUsed = 0;
+ // These seem not really needed for our purpose here.
+ lpDIBh->bmiHeader.biClrImportant = 0;
+ lpDIBh->bmiHeader.biXPelsPerMeter = 0;
+ lpDIBh->bmiHeader.biYPelsPerMeter = 0;
+ // memory for DIB data
+ unsigned char *lpBits;
+ lpBits = (unsigned char *) malloc( lpDIBh->bmiHeader.biSizeImage );
+ if( !lpBits )
+ {
+ wxFAIL_MSG( "could not allocate data for DIB" );
+ free( data );
+ free( lpDIBh );
+ return;
+ }
+
+ // copy data from the device-dependent bitmap to the DIB
+ HDC hdc = ::GetDC(NULL);
+ HBITMAP hbitmap;
+ hbitmap = (HBITMAP) bitmap.GetHBITMAP();
+ ::GetDIBits( hdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
+
+ // copy DIB data into the wxImage object
+ int i, j;
+ unsigned char *ptdata = data;
+ unsigned char *ptbits = lpBits;
+ for( i=0; i<height; i++ )
+ {
+ for( j=0; j<width; j++ )
+ {
+ *(ptdata++) = *(ptbits+2);
+ *(ptdata++) = *(ptbits+1);
+ *(ptdata++) = *(ptbits );
+ ptbits += 3;
+ }
+ ptbits += padding;
+ }
+
+ // similarly, set data according to the possible mask bitmap
+ if( bitmap.GetMask() && bitmap.GetMask()->GetMaskBitmap() )
+ {
+ hbitmap = (HBITMAP) bitmap.GetMask()->GetMaskBitmap();
+ // memory DC created, color set, data copied, and memory DC deleted
+ HDC memdc = ::CreateCompatibleDC( hdc );
+ ::SetTextColor( memdc, RGB( 0, 0, 0 ) );
+ ::SetBkColor( memdc, RGB( 255, 255, 255 ) );
+ ::GetDIBits( memdc, hbitmap, 0, height, lpBits, lpDIBh, DIB_RGB_COLORS );
+ ::DeleteDC( memdc );
+ // background color set to RGB(16,16,16) in consistent with wxGTK
+ unsigned char r=16, g=16, b=16;
+ ptdata = data;
+ ptbits = lpBits;
+ for( i=0; i<height; i++ )
+ {
+ for( j=0; j<width; j++ )
+ {
+ if( *ptbits != 0 )
+ ptdata += 3;
+ else
+ {
+ *(ptdata++) = r;
+ *(ptdata++) = g;
+ *(ptdata++) = b;
+ }
+ ptbits += 3;
+ }
+ ptbits += padding;
+ }
+ SetMaskColour( r, g, b );
+ SetMask( TRUE );
+ }
+ else
+ {
+ SetMask( FALSE );
+ }
+ // free allocated resources
+ ::ReleaseDC(NULL, hdc);
+ free(lpDIBh);
+ free(lpBits);
+ */
+}
+
+#endif
+
//-----------------------------------------------------------------------------
// GTK conversion routines
//-----------------------------------------------------------------------------
wxArrayFileTypeInfo m_fallbacks;
};
+#elif defined( __WXMAC__ )
+
+WX_DECLARE_EXPORTED_OBJARRAY(wxFileTypeInfo, wxArrayFileTypeInfo);
+#include "wx/arrimpl.cpp"
+WX_DEFINE_OBJARRAY(wxArrayFileTypeInfo);
+
+class wxMimeTypesManagerImpl
+{
+public :
+ wxMimeTypesManagerImpl() { }
+
+ // implement containing class functions
+ wxFileType *GetFileTypeFromExtension(const wxString& ext);
+ wxFileType *GetFileTypeFromMimeType(const wxString& mimeType);
+
+ // this are NOPs under MacOS
+ bool ReadMailcap(const wxString& filename, bool fallback = TRUE) { return TRUE; }
+ bool ReadMimeTypes(const wxString& filename) { return TRUE; }
+
+ void AddFallback(const wxFileTypeInfo& ft) { m_fallbacks.Add(ft); }
+
+private:
+ wxArrayFileTypeInfo m_fallbacks;
+};
+
+class wxFileTypeImpl
+{
+public:
+ // initialize us with our file type name
+ void SetFileType(const wxString& strFileType)
+ { m_strFileType = strFileType; }
+ void SetExt(const wxString& ext)
+ { m_ext = ext; }
+
+ // implement accessor functions
+ bool GetExtensions(wxArrayString& extensions);
+ bool GetMimeType(wxString *mimeType) const;
+ bool GetIcon(wxIcon *icon) const;
+ bool GetDescription(wxString *desc) const;
+ bool GetOpenCommand(wxString *openCmd,
+ const wxFileType::MessageParameters&) const
+ { return GetCommand(openCmd, "open"); }
+ bool GetPrintCommand(wxString *printCmd,
+ const wxFileType::MessageParameters&) const
+ { return GetCommand(printCmd, "print"); }
+
+private:
+ // helper function
+ bool GetCommand(wxString *command, const char *verb) const;
+
+ wxString m_strFileType, m_ext;
+};
+
#else // Unix
// this class uses both mailcap and mime.types to gather information about file
return NULL;
}
+#elif defined ( __WXMAC__ )
+
+
+bool wxFileTypeImpl::GetCommand(wxString *command, const char *verb) const
+{
+ return FALSE;
+}
+
+// @@ this function is half implemented
+bool wxFileTypeImpl::GetExtensions(wxArrayString& extensions)
+{
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetMimeType(wxString *mimeType) const
+{
+ if ( m_strFileType.Length() > 0 )
+ {
+ *mimeType = m_strFileType ;
+ return TRUE ;
+ }
+ else
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetIcon(wxIcon *icon) const
+{
+ // no such file type or no value or incorrect icon entry
+ return FALSE;
+}
+
+bool wxFileTypeImpl::GetDescription(wxString *desc) const
+{
+ return FALSE;
+}
+
+// extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& e)
+{
+ wxString ext = e ;
+ ext = ext.Lower() ;
+ if ( ext == "txt" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/text");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "htm" || ext == "html" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("text/html");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "gif" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/gif");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "png" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/png");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "jpg" || ext == "jpeg" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/jpeg");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "bmp" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/bmp");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "tif" || ext == "tiff" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/tiff");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xpm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xpm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ else if ( ext == "xbm" )
+ {
+ wxFileType *fileType = new wxFileType;
+ fileType->m_impl->SetFileType("image/xbm");
+ fileType->m_impl->SetExt(ext);
+ return fileType;
+ }
+ // unknown extension
+ return NULL;
+}
+
+// MIME type -> extension -> file type
+wxFileType *
+wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
+{
+ return NULL;
+}
#else // Unix
MailCapEntry *
#endif
// Cause problems for VC++ - crashes
-#if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS
+#if (!defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS ) || defined(__MWERKS__)
void * wxObject::operator new[] (size_t size, wxChar * fileName, int lineNum)
{
return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE);
SetClientSize(sz.x, sz.y);
wxPoint pt = ConvertDialogToPixels(wxPoint(x, y));
+ #ifdef __WXMAC__
+ int mbarheight = 2 * LMGetMBarHeight() ;
+ pt.y += mbarheight ;
+ #endif
Move(pt.x, pt.y);
}
{
wxExprDatabase db;
+#ifdef __WXMAC__
+ FILE *fd = fopen(wxUnix2MacFilename(filename.fn_str()), "r");
+#else
FILE *fd = fopen(filename.fn_str(), "r");
+#endif
if (!fd)
return FALSE;
bool eof = FALSE;
return uPosFound;
}
+#ifdef __WXMAC__
+void wxUnix2MacFilename (char *s) ;
+void
+wxUnix2MacFilename (char *s)
+{
+ if (s)
+ {
+ if ( *s == '.' )
+ {
+ // relative path , since it goes on with slash which is translated to a :
+ memmove( s , s+1 ,strlen( s ) ) ;
+ }
+ else if ( *s == '/' )
+ {
+ // absolute path -> on mac just start with the drive name
+ memmove( s , s+1 ,strlen( s ) ) ;
+ }
+ else
+ {
+// wxASSERT_MSG( 1 , "unkown path beginning" ) ;
+ }
+ while (*s)
+ {
+ if (*s == '/' || *s == '\\')
+ {
+ // convert any back-directory situations
+ if ( *(s+1) == '.' && *(s+2) == '.' && ( (*(s+3) == '/' || *(s+3) == '\\') ) )
+ {
+ *s = ':';
+ memmove( s+1 , s+3 ,strlen( s+3 ) + 1 ) ;
+ }
+ else
+ *s = ':';
+ }
+
+ s++ ;
+ }
+ }
+}
+extern char * wxBuffer ;
+#endif
+
/*
Open a Zip file. path contain the full pathname (by example,
on a Windows NT computer "c:\\test\\zlib109.zip" or on an Unix computer
if (unz_copyright[0]!=' ')
return NULL;
+#ifdef __WXMAC__
+ strcpy( wxBuffer , path ) ;
+ wxUnix2MacFilename( wxBuffer ) ;
+ fin=fopen(wxBuffer,"rb");
+#else
fin=fopen(path,"rb");
+#endif
if (fin==NULL)
return NULL;
m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_BTNFACE);
m_foregroundColour = *wxBLACK; // TODO take this from sys settings too?
+#ifndef __WXMAC__
m_font = *wxSWISS_FONT; // and this?
-
+#else
+ m_font = settings.GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+#endif
// no style bits
m_windowStyle = 0;
#include "wx/listctrl.h"
#include "wx/generic/imaglist.h"
+#ifndef wxUSE_GENERIC_LIST_EXTENSIONS
+#define wxUSE_GENERIC_LIST_EXTENSIONS 0
+#endif
+
//-----------------------------------------------------------------------------
// wxListItemData
//-----------------------------------------------------------------------------
wxString s;
item->GetText( s );
if (s.IsNull()) s = "H";
- long lh;
- dc->GetTextExtent( s, (long*) NULL, &lh );
+ long lw,lh;
+ dc->GetTextExtent( s, &lw, &lh );
item->SetSize( item->GetWidth(), lh );
+ m_bound_all.width += lw;
m_bound_all.height = lh;
node = node->Next();
}
{
wxPaintDC dc( this );
PrepareDC( dc );
-
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ if ( m_owner->GetMode() & wxLC_REPORT )
+ {
+ int x , y ;
+ int xpix , ypix ;
+
+ m_owner->GetScrollPixelsPerUnit( &xpix , &ypix ) ;
+ m_owner->ViewStart( &x, &y ) ;
+ dc.SetDeviceOrigin( -x * xpix, 0 );
+ }
+#endif
dc.BeginDrawing();
dc.SetFont( GetFont() );
{
m_owner->GetColumn( i, item );
int cw = item.m_width-2;
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ if ((i+1 == numColumns) || ( dc.LogicalToDeviceX(x+item.m_width) > w-5))
+ cw = dc.DeviceToLogicalX(w)-x-1;
+#else
if ((i+1 == numColumns) || (x+item.m_width > w-5)) cw = w-x-1;
+#endif
dc.SetPen( *wxWHITE_PEN );
DoDrawRect( &dc, x, y, cw, h-2 );
dc.DrawText( item.m_text, x+4, y+3 );
dc.DestroyClippingRegion();
x += item.m_width;
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ if (dc.LogicalToDeviceX(x) > w+5) break;
+#else
if (x > w+5) break;
+#endif
}
dc.EndDrawing();
}
EVT_KEY_DOWN (wxListMainWindow::OnKeyDown)
EVT_SET_FOCUS (wxListMainWindow::OnSetFocus)
EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus)
+ EVT_SCROLLWIN (wxListMainWindow::OnScroll)
END_EVENT_TABLE()
wxListMainWindow::wxListMainWindow()
if (m_mode & wxLC_REPORT)
{
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ m_xScroll = 15;
+#else
m_xScroll = 0;
+#endif
m_yScroll = 15;
}
else
if (m_mode & wxLC_REPORT)
{
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ m_xScroll = 15;
+#else
m_xScroll = 0;
+#endif
m_yScroll = 15;
}
else
int y = 1;
int entireHeight = m_lines.Number() * lineSpacing + 2;
int scroll_pos = GetScrollPos( wxVERTICAL );
+ int x_scroll_pos = GetScrollPos( wxHORIZONTAL );
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+#else
SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+15) / m_yScroll, 0, scroll_pos, TRUE );
+#endif
GetClientSize( &clientWidth, &clientHeight );
wxNode* node = m_lines.First();
+ int entireWidth = 0 ;
while (node)
{
wxListLineData *line = (wxListLineData*)node->Data();
line->SetColumnPosition( i, col_x );
col_x += GetColumnWidth( i );
}
+ entireWidth = wxMax( entireWidth , col_x ) ;
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ line->SetPosition( &dc, x, y, col_x );
+#endif
y += lineSpacing; // one pixel blank line between items
node = node->Next();
}
- m_visibleLines = clientHeight / lineSpacing;
+ m_visibleLines = clientHeight / lineSpacing;
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+ SetScrollbars( m_xScroll, m_yScroll, entireWidth / m_xScroll , (entireHeight+15) / m_yScroll, x_scroll_pos , scroll_pos, TRUE );
+#endif
}
else
{
m_lines.Sort( list_ctrl_compare_func_1 );
}
+void wxListMainWindow::OnScroll(wxScrollWinEvent& event)
+{
+ wxScrolledWindow::OnScroll( event ) ;
+#if wxUSE_GENERIC_LIST_EXTENSIONS
+
+ if (event.GetOrientation() == wxHORIZONTAL && ( m_mode & wxLC_REPORT ))
+ {
+ wxListCtrl* lc = wxDynamicCast( GetParent() , wxListCtrl ) ;
+ if ( lc )
+ {
+ lc->m_headerWin->Refresh() ;
+#ifdef __WXMAC__
+ lc->m_headerWin->MacUpdateImmediately() ;
+#endif
+ }
+ }
+#endif
+}
+
// -------------------------------------------------------------------------------------
// wxListItem
// -------------------------------------------------------------------------------------
// Update the display (especially on X, GTK)
wxYield();
+ #ifdef __WXMAC__
+ MacUpdateImmediately() ;
+ #endif
}
wxStaticText *wxProgressDialog::CreateLabel(const wxString& text,
// update the display
wxYield();
}
+ #ifdef __WXMAC__
+ MacUpdateImmediately() ;
+ #endif
return m_state != Canceled;
}
#ifdef __WXMSW__
// Necessary?
- UpdateWindow ((HWND) GetHWND());
+ UpdateWindow ((HWND) m_targetWindow->GetHWND());
+#endif
+#ifdef __WXMAC__
+ m_targetWindow->MacUpdateImmediately() ;
#endif
}
else
m_targetWindow->Refresh();
}
+#ifdef __WXMAC__
+ m_targetWindow->MacUpdateImmediately() ;
+#endif
}
int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event)
#else
// Refresh();
#endif
+#ifdef __WXMAC__
+ m_targetWindow->MacUpdateImmediately() ;
+#endif
}
void wxScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll)
bool success = wxWindow::Create(parent, id, pos, size, style | wxTAB_TRAVERSAL, name);
// Don't wish this to be found as a child
+#ifndef __WXMAC__
parent->GetChildren().DeleteObject(this);
-
+#endif
InitColours();
SetFont(m_defaultStatusBarFont);
int xpos = rect.x + leftMargin;
int ypos = (int) (((rect.height - y) / 2 ) + rect.y + 0.5) ;
-#ifdef __WXGTK__
+#if defined( __WXGTK__ ) || defined(__WXMAC__)
xpos++;
ypos++;
#endif
return wxSize(wBtn, hBtn);
}
+wxSize wxButton::GetDefaultSize()
+{
+ int wBtn = 15 * 8 + 12 + 2 * 2;
+ int hBtn = 13 + 2 * 2;
+
+ return wxSize(wBtn, hBtn);
+}
+
void wxButton::Command (wxCommandEvent & event)
{
ProcessCommand (event);
return wxSize(wBtn, hBtn);
}
+wxSize wxButton::GetDefaultSize()
+{
+ int wBtn = 15 * 8 + 12 + 2 * 2;
+ int hBtn = 13 + 2 * 2;
+
+ return wxSize(wBtn, hBtn);
+}
+
void wxButton::Command (wxCommandEvent & event)
{
ProcessCommand (event);
#include <string.h>
+// open/close
bool wxOpenClipboard()
{
return TRUE;
bool wxCloseClipboard()
{
- return FALSE;
+ return TRUE;
}
-bool wxEmptyClipboard()
+bool wxIsClipboardOpened()
{
- ZeroScrap() ;
- return FALSE;
+ return TRUE;
}
-bool wxClipboardOpen()
+// get/set data
+
+bool wxEmptyClipboard()
{
- // TODO
- return FALSE;
+ ZeroScrap() ;
+ return TRUE;
}
-bool wxIsClipboardFormatAvailable(int dataFormat)
+bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
{
- // TODO
return FALSE;
}
-bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
+void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
- // TODO
- return FALSE;
+ return NULL;
}
-wxObject *wxGetClipboardData(int dataFormat, long *len)
+
+// clipboard formats
+
+bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- // TODO
- return NULL;
+ return FALSE;
}
-int wxEnumClipboardFormats(int dataFormat)
+wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
- // TODO
- return 0;
+ return wxDataFormat();
}
-int wxRegisterClipboardFormat(char *formatName)
+int wxRegisterClipboardFormat(wxChar *formatName)
{
- // TODO
return 0;
}
-bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
+bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int maxCount)
{
- // TODO
return FALSE;
}
* Generalized clipboard implementation by Matthew Flatt
*/
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
+
wxClipboard::wxClipboard()
{
m_clearOnExit = FALSE;
long x1 = XLOG2DEV(m_clipX1);
long y1 = YLOG2DEV(m_clipY1);
long x2 = XLOG2DEV(m_clipX2);
- long y2 = XLOG2DEV(m_clipY2);
+ long y2 = YLOG2DEV(m_clipY2);
Rect clip = { y1 , x1 , y2 , x2 } ;
m_macPort = UMAGetWindowPort( windowref ) ;
MacSetupPort() ;
m_ok = TRUE ;
- SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
-
+ SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
+ SetFont( window->GetFont() ) ;
}
wxClientDC::~wxClientDC(void)
window->GetUpdateRegion().GetBox( x , y , w , h ) ;
SetClippingRegion( x , y , w , h ) ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
+ SetFont(window->GetFont() ) ;
}
wxPaintDC::~wxPaintDC()
}
}
+void wxDialog::OnPaint(wxPaintEvent& event)
+{
+ // No: if you call the default procedure, it makes
+ // the following painting code not work.
+// wxWindow::OnPaint(event);
+}
+
void wxDialog::OnCloseWindow(wxCloseEvent& event)
{
// We'll send a Cancel message by default,
return pt;
}
-void wxFrame::GetClientSize(int *x, int *y) const
+void wxFrame::DoGetClientSize(int *x, int *y) const
{
- wxWindow::GetClientSize( x , y ) ;
+ wxWindow::DoGetClientSize( x , y ) ;
if ( GetStatusBar() )
{
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
- event.m_commandInt = aSelections[0] ;
- if ( HasClientObjectData() )
+ n = aSelections[0];
+ if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
}
// Get size *available for subwindows* i.e. excluding menu bar.
-void wxMDIParentFrame::GetClientSize(int *x, int *y) const
+void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
{
- // TODO
+ wxFrame::DoGetClientSize( x , y ) ;
}
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
}
event.SetPosition(new_pos);
event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
+ wxWindow* window = GetParent() ;
+ if (window && window->MacIsWindowScrollbar(this) )
+ {
+ // this is hardcoded
+ window->MacOnScroll(event);
+ }
+ else
+ GetEventHandler()->ProcessEvent(event);
}
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
EVT_IDLE(wxWindow::OnIdle)
+// EVT_SCROLL(wxWindow::OnScroll)
END_EVENT_TABLE()
#endif
const wxFont *fontToUse = theFont;
if ( !fontToUse )
fontToUse = &m_font;
-/*
- if ( x )
- *x = sizeRect.cx;
- if ( y )
- *y = sizeRect.cy;
- if ( descent )
- *descent = tm.tmDescent;
- if ( externalLeading )
- *externalLeading = tm.tmExternalLeading;
-*/
-
+
+ wxClientDC dc( this ) ;
+ long lx,ly,ld,le ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ;
+ *externalLeading = le ;
+ *descent = ld ;
+ *x = lx ;
+ *y = ly ;
}
void wxWindow::MacEraseBackground( Rect *rect )
}
}
+void wxWindow::MacOnScroll(wxScrollEvent &event )
+{
+ if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar )
+ {
+ wxScrollWinEvent wevent;
+ wevent.SetPosition(event.GetPosition());
+ wevent.SetOrientation(event.GetOrientation());
+ wevent.m_eventObject = this;
+
+ switch ( event.m_eventType )
+ {
+ case wxEVT_SCROLL_TOP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_TOP;
+ break;
+
+ case wxEVT_SCROLL_BOTTOM:
+ wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
+ break;
+
+ case wxEVT_SCROLL_LINEUP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
+ break;
+
+ case wxEVT_SCROLL_LINEDOWN:
+ wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
+ break;
+
+ case wxEVT_SCROLL_PAGEUP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
+ break;
+
+ case wxEVT_SCROLL_PAGEDOWN:
+ wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
+ break;
+
+ case wxEVT_SCROLL_THUMBTRACK:
+ wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
+ break;
+
+ }
+
+ GetEventHandler()->ProcessEvent(wevent);
+ }
+}
+
bool wxWindow::SetFont(const wxFont& font)
{
if ( !wxWindowBase::SetFont(font) )
{
m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0),
wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL);
+// m_vScrollBar->PushEventHandler( this ) ;
}
if ( style & wxHSCROLL )
{
m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ),
wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL);
+// m_hScrollBar->PushEventHandler( this ) ;
}
+
// because the create does not take into account the client area origin
MacRepositionScrollBars() ; // we might have a real position shift
}
#include <string.h>
+// open/close
bool wxOpenClipboard()
{
return TRUE;
bool wxCloseClipboard()
{
- return FALSE;
+ return TRUE;
}
-bool wxEmptyClipboard()
+bool wxIsClipboardOpened()
{
- ZeroScrap() ;
- return FALSE;
+ return TRUE;
}
-bool wxClipboardOpen()
+// get/set data
+
+bool wxEmptyClipboard()
{
- // TODO
- return FALSE;
+ ZeroScrap() ;
+ return TRUE;
}
-bool wxIsClipboardFormatAvailable(int dataFormat)
+bool wxSetClipboardData(wxDataFormat dataFormat,const void *data,int width , int height)
{
- // TODO
return FALSE;
}
-bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
+void *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
- // TODO
- return FALSE;
+ return NULL;
}
-wxObject *wxGetClipboardData(int dataFormat, long *len)
+
+// clipboard formats
+
+bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- // TODO
- return NULL;
+ return FALSE;
}
-int wxEnumClipboardFormats(int dataFormat)
+wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
- // TODO
- return 0;
+ return wxDataFormat();
}
-int wxRegisterClipboardFormat(char *formatName)
+int wxRegisterClipboardFormat(wxChar *formatName)
{
- // TODO
return 0;
}
-bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
+bool wxGetClipboardFormatName(wxDataFormat dataFormat, wxChar *formatName, int maxCount)
{
- // TODO
return FALSE;
}
* Generalized clipboard implementation by Matthew Flatt
*/
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
+
wxClipboard::wxClipboard()
{
m_clearOnExit = FALSE;
long x1 = XLOG2DEV(m_clipX1);
long y1 = YLOG2DEV(m_clipY1);
long x2 = XLOG2DEV(m_clipX2);
- long y2 = XLOG2DEV(m_clipY2);
+ long y2 = YLOG2DEV(m_clipY2);
Rect clip = { y1 , x1 , y2 , x2 } ;
m_macPort = UMAGetWindowPort( windowref ) ;
MacSetupPort() ;
m_ok = TRUE ;
- SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
-
+ SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
+ SetFont( window->GetFont() ) ;
}
wxClientDC::~wxClientDC(void)
window->GetUpdateRegion().GetBox( x , y , w , h ) ;
SetClippingRegion( x , y , w , h ) ;
SetBackground(wxBrush(window->GetBackgroundColour(), wxSOLID));
+ SetFont(window->GetFont() ) ;
}
wxPaintDC::~wxPaintDC()
}
}
+void wxDialog::OnPaint(wxPaintEvent& event)
+{
+ // No: if you call the default procedure, it makes
+ // the following painting code not work.
+// wxWindow::OnPaint(event);
+}
+
void wxDialog::OnCloseWindow(wxCloseEvent& event)
{
// We'll send a Cancel message by default,
return pt;
}
-void wxFrame::GetClientSize(int *x, int *y) const
+void wxFrame::DoGetClientSize(int *x, int *y) const
{
- wxWindow::GetClientSize( x , y ) ;
+ wxWindow::DoGetClientSize( x , y ) ;
if ( GetStatusBar() )
{
int n, count = GetSelections(aSelections);
if ( count > 0 )
{
- event.m_commandInt = aSelections[0] ;
- if ( HasClientObjectData() )
+ n = aSelections[0];
+ if ( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if ( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
}
// Get size *available for subwindows* i.e. excluding menu bar.
-void wxMDIParentFrame::GetClientSize(int *x, int *y) const
+void wxMDIParentFrame::DoGetClientSize(int *x, int *y) const
{
- // TODO
+ wxFrame::DoGetClientSize( x , y ) ;
}
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
}
event.SetPosition(new_pos);
event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
+ wxWindow* window = GetParent() ;
+ if (window && window->MacIsWindowScrollbar(this) )
+ {
+ // this is hardcoded
+ window->MacOnScroll(event);
+ }
+ else
+ GetEventHandler()->ProcessEvent(event);
}
EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
EVT_INIT_DIALOG(wxWindow::OnInitDialog)
EVT_IDLE(wxWindow::OnIdle)
+// EVT_SCROLL(wxWindow::OnScroll)
END_EVENT_TABLE()
#endif
const wxFont *fontToUse = theFont;
if ( !fontToUse )
fontToUse = &m_font;
-/*
- if ( x )
- *x = sizeRect.cx;
- if ( y )
- *y = sizeRect.cy;
- if ( descent )
- *descent = tm.tmDescent;
- if ( externalLeading )
- *externalLeading = tm.tmExternalLeading;
-*/
-
+
+ wxClientDC dc( this ) ;
+ long lx,ly,ld,le ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, fontToUse ) ;
+ *externalLeading = le ;
+ *descent = ld ;
+ *x = lx ;
+ *y = ly ;
}
void wxWindow::MacEraseBackground( Rect *rect )
}
}
+void wxWindow::MacOnScroll(wxScrollEvent &event )
+{
+ if ( event.m_eventObject == m_vScrollBar || event.m_eventObject == m_hScrollBar )
+ {
+ wxScrollWinEvent wevent;
+ wevent.SetPosition(event.GetPosition());
+ wevent.SetOrientation(event.GetOrientation());
+ wevent.m_eventObject = this;
+
+ switch ( event.m_eventType )
+ {
+ case wxEVT_SCROLL_TOP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_TOP;
+ break;
+
+ case wxEVT_SCROLL_BOTTOM:
+ wevent.m_eventType = wxEVT_SCROLLWIN_BOTTOM;
+ break;
+
+ case wxEVT_SCROLL_LINEUP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_LINEUP;
+ break;
+
+ case wxEVT_SCROLL_LINEDOWN:
+ wevent.m_eventType = wxEVT_SCROLLWIN_LINEDOWN;
+ break;
+
+ case wxEVT_SCROLL_PAGEUP:
+ wevent.m_eventType = wxEVT_SCROLLWIN_PAGEUP;
+ break;
+
+ case wxEVT_SCROLL_PAGEDOWN:
+ wevent.m_eventType = wxEVT_SCROLLWIN_PAGEDOWN;
+ break;
+
+ case wxEVT_SCROLL_THUMBTRACK:
+ wevent.m_eventType = wxEVT_SCROLLWIN_THUMBTRACK;
+ break;
+
+ }
+
+ GetEventHandler()->ProcessEvent(wevent);
+ }
+}
+
bool wxWindow::SetFont(const wxFont& font)
{
if ( !wxWindowBase::SetFont(font) )
{
m_vScrollBar = new wxScrollBar(this, wxWINDOW_VSCROLL, wxPoint(m_width-MAC_SCROLLBAR_SIZE, 0),
wxSize(MAC_SCROLLBAR_SIZE, m_height - adjust), wxVERTICAL);
+// m_vScrollBar->PushEventHandler( this ) ;
}
if ( style & wxHSCROLL )
{
m_hScrollBar = new wxScrollBar(this, wxWINDOW_HSCROLL, wxPoint(0 , m_height-MAC_SCROLLBAR_SIZE ),
wxSize( m_width - adjust, MAC_SCROLLBAR_SIZE), wxHORIZONTAL);
+// m_hScrollBar->PushEventHandler( this ) ;
}
+
// because the create does not take into account the client area origin
MacRepositionScrollBars() ; // we might have a real position shift
}