src/mac/carbon/dnd.cpp
src/mac/carbon/filedlg.cpp
src/mac/carbon/font.cpp
- src/mac/carbon/fontdlg.mm
+ src/mac/carbon/fontdlg.cpp
src/mac/carbon/fontenum.cpp
src/mac/carbon/fontutil.cpp
src/mac/carbon/frame.cpp
src/cocoa/checklst.mm
src/cocoa/choice.mm
src/cocoa/clipbrd.mm
+ src/cocoa/colordlg.mm
src/cocoa/colour.mm
src/cocoa/combobox.mm
src/cocoa/control.mm
src/cocoa/dcmemory.mm
src/cocoa/dcscreen.cpp
src/cocoa/dialog.mm
+ src/cocoa/display.mm
+ src/cocoa/drawer.mm
src/cocoa/evtloop.mm
+ src/cocoa/filedlg.mm
src/cocoa/font.cpp
+ src/cocoa/fontdlg.mm
src/cocoa/fontenum.mm
src/cocoa/fontutil.cpp
src/cocoa/frame.mm
src/cocoa/mdi.mm
src/cocoa/menu.mm
src/cocoa/menuitem.mm
+ src/cocoa/msgdlg.mm
src/cocoa/notebook.mm
src/cocoa/pen.mm
src/cocoa/radiobox.mm
src/cocoa/scrolbar.mm
src/cocoa/settings.cpp
src/cocoa/slider.mm
+ src/cocoa/sound.mm
src/cocoa/spinbutt.mm
src/cocoa/statbmp.mm
src/cocoa/statbox.mm
src/cocoa/statline2.mm
src/cocoa/stattext.mm
+ src/cocoa/taskbar.mm
src/cocoa/textctrl.mm
src/cocoa/toolbar.mm
src/cocoa/toplevel.mm
src/cocoa/utils.cpp
- src/cocoa/utilsexc.cpp
+ src/cocoa/utilsexc.mm
src/cocoa/window.mm
<!-- Generic implementations used by wxCocoa: -->
src/generic/accel.cpp
wx/cocoa/checklst.h
wx/cocoa/choice.h
wx/cocoa/clipbrd.h
+ wx/cocoa/colordlg.h
wx/cocoa/colour.h
wx/cocoa/combobox.h
wx/cocoa/control.h
wx/cocoa/dcmemory.h
wx/cocoa/dcscreen.h
wx/cocoa/dialog.h
+ wx/cocoa/display.h
+ wx/cocoa/drawer.h
+ wx/cocoa/filedlg.h
wx/cocoa/font.h
+ wx/cocoa/fontdlg.h
wx/cocoa/frame.h
wx/cocoa/gauge.h
wx/cocoa/gdiobj.h
wx/cocoa/mdi.h
wx/cocoa/menu.h
wx/cocoa/menuitem.h
+ wx/cocoa/msgdlg.h
wx/cocoa/notebook.h
wx/cocoa/pen.h
wx/cocoa/radiobox.h
wx/cocoa/region.h
wx/cocoa/scrolbar.h
wx/cocoa/slider.h
+ wx/cocoa/sound.h
wx/cocoa/spinbutt.h
wx/cocoa/statbmp.h
wx/cocoa/statbox.h
wx/cocoa/statline.h
wx/cocoa/stattext.h
+ wx/cocoa/taskbar.h
wx/cocoa/textctrl.h
wx/cocoa/toolbar.h
wx/cocoa/toplevel.h
element type is not a pointer itself and, although it still works, this
provokes warnings from some compilers and to avoid them you should use the
{\tt \_PTR} versions of the macros above. For example, to define an array of
-pointers to {\tt double} you should use
+pointers to {\tt double} you should use.
+
+If that isn't complicated enough, the above macros are generally only useful for
+wxObject types. There are seperate macros for declaring an array of a simple type,
+such as an int.
+
+The following simple types are supported:
+int\\
+long\\
+size_t\\
+double
+
+To create an array of a simple type, simply append the type you want in CAPS to
+the array definition.
+
+For example, for an integer array, you'd use one of the following variants:
+
+\helpref{WX\_DEFINE\_ARRAY\_INT}{wxdefinearray}\\
+\helpref{WX\_DEFINE\_EXPORTED\_ARRAY\_INT}{wxdefinearray}\\
+\helpref{WX\_DEFINE\_USER\_EXPORTED\_ARRAY\_INT}{wxdefinearray}\\
+\helpref{WX\_DEFINE\_SORTED\_ARRAY\_INT}{wxdefinesortedarray}\\
+\helpref{WX\_DEFINE\_SORTED\_EXPORTED\_ARRAY\_INT}{wxdefinesortedarray}\\
+\helpref{WX\_DEFINE\_SORTED\_USER\_EXPORTED\_ARRAY\_INT}{wxdefinesortedarray}\\
\begin{verbatim}
WX_DEFINE_ARRAY_PTR(double *, MyArrayOfDoublePointers);
Example:
\begin{verbatim}
-WX_DEFINE_ARRAY(int, wxArrayInt);
+WX_DEFINE_ARRAY_INT(wxArrayInt);
class MyClass;
WX_DEFINE_ARRAY(MyClass *, wxArrayOfMyClass);
Example:
\begin{verbatim}
-WX_DEFINE_SORTED_ARRAY(int, wxSortedArrayInt);
+WX_DEFINE_SORTED_ARRAY_INT(wxSortedArrayInt);
class MyClass;
WX_DEFINE_SORTED_ARRAY(MyClass *, wxArrayOfMyClass);
DECLARE_WXCOCOA_OBJC_CLASS(NSBox);
DECLARE_WXCOCOA_OBJC_CLASS(NSButton);
DECLARE_WXCOCOA_OBJC_CLASS(NSColor);
+DECLARE_WXCOCOA_OBJC_CLASS(NSColorPanel);
DECLARE_WXCOCOA_OBJC_CLASS(NSControl);
+DECLARE_WXCOCOA_OBJC_CLASS(NSCursor);
DECLARE_WXCOCOA_OBJC_CLASS(NSEvent);
+DECLARE_WXCOCOA_OBJC_CLASS(NSFontPanel);
DECLARE_WXCOCOA_OBJC_CLASS(NSImage);
DECLARE_WXCOCOA_OBJC_CLASS(NSLayoutManager);
DECLARE_WXCOCOA_OBJC_CLASS(NSMenu);
+DECLARE_WXCOCOA_OBJC_CLASS(NSMenuExtra);
DECLARE_WXCOCOA_OBJC_CLASS(NSMenuItem);
DECLARE_WXCOCOA_OBJC_CLASS(NSMutableArray);
DECLARE_WXCOCOA_OBJC_CLASS(NSNotification);
+DECLARE_WXCOCOA_OBJC_CLASS(NSObject);
DECLARE_WXCOCOA_OBJC_CLASS(NSPanel);
DECLARE_WXCOCOA_OBJC_CLASS(NSScrollView);
+DECLARE_WXCOCOA_OBJC_CLASS(NSSound);
+DECLARE_WXCOCOA_OBJC_CLASS(NSStatusItem);
DECLARE_WXCOCOA_OBJC_CLASS(NSTableColumn);
DECLARE_WXCOCOA_OBJC_CLASS(NSTableView);
DECLARE_WXCOCOA_OBJC_CLASS(NSTextContainer);
// ctors
- wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, int id = wxID_ANY)
- { Init(parent, id, wxPROCESS_DEFAULT); }
+ wxProcess(wxEvtHandler *parent = (wxEvtHandler *) NULL, int nId = wxID_ANY)
+ { Init(parent, nId, wxPROCESS_DEFAULT); }
wxProcess(int flags) { Init(NULL, wxID_ANY, flags); }
class WXDLLIMPEXP_BASE wxProcessEvent : public wxEvent
{
public:
- wxProcessEvent(int id = 0, int pid = 0, int exitcode = 0) : wxEvent(id)
+ wxProcessEvent(int nId = 0, int pid = 0, int exitcode = 0) : wxEvent(nId)
{
m_eventType = wxEVT_END_PROCESS;
m_pid = pid;
// All compare functions return -1, 0 or 1 if the [sub]string is less,
// equal or greater than the compare() argument.
- // just like strcmp()
- int compare(const wxStringBase& str) const
- { return wxStrcmp(c_str(), str.c_str()); }
+ // comparison with another string
+ int compare(const wxStringBase& str) const;
// comparison with a substring
int compare(size_t nStart, size_t nLen, const wxStringBase& str) const;
// comparison of 2 substrings
int compare(size_t nStart, size_t nLen,
const wxStringBase& str, size_t nStart2, size_t nLen2) const;
- // just like strcmp()
- int compare(const wxChar* sz) const
- { return wxStrcmp(c_str(), sz); }
+ // comparison with a c string
+ int compare(const wxChar* sz) const;
// substring comparison with first nCount characters of sz
int compare(size_t nStart, size_t nLen,
const wxChar* sz, size_t nCount = npos) const;
// string comparison
// case-sensitive comparison (returns a value < 0, = 0 or > 0)
- int Cmp(const wxChar *psz) const { return wxStrcmp(c_str(), psz); }
+ int Cmp(const wxChar *psz) const;
+ int Cmp(const wxString& s) const;
// same as Cmp() but not case-sensitive
- int CmpNoCase(const wxChar *psz) const { return wxStricmp(c_str(), psz); }
+ int CmpNoCase(const wxChar *psz) const;
+ int CmpNoCase(const wxString& s) const;
// test for the string equality, either considering case or not
// (if compareWithCase then the case matters)
bool IsSameAs(const wxChar *psz, bool compareWithCase = true) const
#define wxAsctime _tasctime
#define wxCtime _tctime
#else /* !TCHAR-aware compilers */
- #if wxUSE_UNICODE
+
+ /* No UNICODE in the c library except wchar_t typedef on mac OSX 10.2 and less - roll our own */
+ #if wxUSE_UNICODE && __DARWIN__ && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 ) && !defined(__MWERKS__)
+
+ /* we need everything! */
+ #define wxNEED_WX_STRING_H
+ #define wxNEED_WX_CTYPE_H
+
+ #define wxFgetchar(c) wxFgetc(c, stdin)
+ #define wxFputc wxPutc
+ #define wxFputchar(c) wxPutc(c, stdout)
+ #define wxGetc wxFgetc
+ #define wxGetchar(c) wxFgetc(c, stdin)
+
+ #include <stdio.h>
+
+ #define wxNEED_FGETC
+ #define wxNEED_FGETS
+ #define wxNEED_GETS
+ #define wxNEED_UNGETC
+
+ #define wxNEED_FPUTS
+ #define wxNEED_PUTC
+
+ int wxFputs(const wxChar *ch, FILE *stream);
+ int wxPutc(wxChar ch, FILE *stream);
+
+ WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
+
+ #define wxPutchar(wch) wxPutc(wch, stdout)
+ #define wxPuts(ws) wxFputs(ws, stdout)
+
+ #define wxNEED_PRINTF_CONVERSION
+ #define wxNEED_WX_STDIO_H
+ #define wxNEED_WX_STDLIB_H
+ #define wxNEED_WX_TIME_H
+
+ /* even though they are defined and "implemented", they are bad and just
+ stubs so we need our own */
+ #define mbstowcs wxInternalMbstowcs
+ #define wcstombs wxInternalWcstombs
+
+ WXDLLIMPEXP_BASE size_t wxInternalMbstowcs (wchar_t *, const char *, size_t);
+ WXDLLIMPEXP_BASE size_t wxInternalWcstombs (char *, const wchar_t *, size_t);
+
+ #elif wxUSE_UNICODE
#include <wctype.h>
/* this is probably glibc-specific */
/* ctype.h functions */
-/* VZ: note that this is never defined currently */
+/* RN: Used only under OSX <= 10.2 currently */
#ifdef wxNEED_WX_CTYPE_H
WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
#define wxIsctrl wxIscntrl
/* string.h functions */
-
#ifndef strdup
#if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
#define wxNEED_STRDUP
WXDLLIMPEXP_BASE char *strdup(const char* s);
#endif
-/* VZ: this is never defined neither currently */
+/* RN: Used only under OSX <= 10.2 currently */
#ifdef wxNEED_WX_STRING_H
WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
- WXDLLIMPEXP_BASE wxChar * wxStrchr(wxChar *s, wxChar c)
+ inline wxChar * wxStrchr(wxChar *s, wxChar c)
{ return (wxChar *)wxStrchr((const wxChar *)s, c); }
WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
- WXDLLIMPEXP_BASE size_t wxStrlen(const wxChar *s);
WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
- WXDLLIMPEXP_BASE wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
+ inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
{ return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
- WXDLLIMPEXP_BASE wxChar * wxStrrchr(wxChar *s, wxChar c)
+ inline wxChar * wxStrrchr(wxChar *s, wxChar c)
{ return (wxChar *)wxStrrchr((const wxChar *)s, c); }
WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
- WXDLLIMPEXP_BASE wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
+ inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
{ return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
#define wxWX2WC wxMB2WC
#endif
#else /* !wxUSE_UNICODE */
+#error ha
/* No wxUSE_WCHAR_T: we have to do something (JACS) */
#define wxMB2WC wxStrncpy
#define wxWC2MB wxStrncpy
#define wxWX2WC wxMB2WC
#endif
+//
+// RN: The following are not normal versions of memcpy et al., rather
+// these are either char or widechar versions depending on
+// if unicode is used or not.
+//
+
+#ifdef __cplusplus
+
+ //
+ // RN: We could do the usual tricky compiler detection here,
+ // and use their variant (such as wmemchr, etc.). The problem
+ // is that these functions are quite rare, even though they are
+ // part of the current POSIX standard. In addition, most compilers
+ // (including even MSC) inline them just like we do right in their
+ // headers.
+ //
+ #if wxUSE_UNICODE
+ #include <string.h> //for mem funcs
+
+ //implement our own wmem variants
+ inline wxChar* wxMemchr(const wxChar* s, wxChar c, size_t l)
+ {
+ for(;l && *s != c;--l, ++s) {}
+
+ if(l)
+ return (wxChar*)s;
+ return NULL;
+ }
+
+ inline int wxMemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
+ {
+ for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
+
+ if(len)
+ return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
+ else
+ return 0;
+ }
+
+ inline wxChar* wxMemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
+ {
+ return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
+ }
+
+ inline wxChar* wxMemmove(wxChar* szOut, const wxChar* szIn, size_t len)
+ {
+ return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
+ }
+
+ inline wxChar* wxMemset(wxChar* szOut, const wxChar cIn, size_t len)
+ {
+ wxChar* szRet = szOut;
+
+ while (len--)
+ *szOut++ = cIn;
+
+ return szRet;
+ }
+
+ #else //!wxUSE_UNICODE
+ # define wxMemchr memchr
+ # define wxMemcmp memcmp
+ # define wxMemcpy memcpy
+ # define wxMemmove memmove
+ # define wxMemset memset
+ #endif
+
+#endif /*__cplusplus*/
+
+
#endif /* _WX_WXCHAR_H_ */
// Created: 2002/11/27
// RCS-ID: $Id$
// Copyright: (c) David Elliott
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/defs.h"
#include "wx/app.h"
+ #include "wx/frame.h"
+ #include "wx/dialog.h"
#include "wx/dc.h"
#include "wx/intl.h"
#include "wx/log.h"
#include "wx/cocoa/ObjcPose.h"
#include "wx/cocoa/autorelease.h"
#include "wx/cocoa/mbarman.h"
-#include "wx/cocoa/NSApplication.h"
#if wxUSE_WX_RESOURCES
# include "wx/resource.h"
#import <AppKit/NSApplication.h>
#import <Foundation/NSRunLoop.h>
+#import <Foundation/NSArray.h>
+#import <Foundation/NSAutoreleasePool.h>
#import <Foundation/NSThread.h>
#import <AppKit/NSEvent.h>
#import <Foundation/NSString.h>
-#import <Foundation/NSNotification.h>
-#import <AppKit/NSCell.h>
// ========================================================================
// wxPoseAsInitializer
plan on stopping the event loop, it is wise to send an event through
the queue to ensure this method will return.
See wxEventLoop::Exit() for more information.
+
+ RN: We used to use nil as the untilDate in previous versions since nil
+ is a shorter and more concise way of specifying an infinite amount of
+ time than [NSDate distantPast]. However, Apple neglects to mention in
+ their documentation that nil is not handled correctly in OSX 10.2
+ (and possibly lower) and when the call is reached the system comes to
+ a screeching halt, therefore we need to specify [NSDate distantPast]
+ explicitly so that wxCocoa will work correctly in OSX 10.2.
*/
- (NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)expiration inMode:(NSString *)mode dequeue:(BOOL)flag
{
// Get the same events except don't block
- NSEvent *event = [super nextEventMatchingMask:mask untilDate:nil/* equivalent to [NSDate distantPast] */ inMode:mode dequeue:flag];
+ NSEvent *event = [super nextEventMatchingMask:mask untilDate:[NSDate distantPast] inMode:mode dequeue:flag];
// If we got one, simply return it
if(event)
return event;
// No events, try doing some idle stuff
- if(sg_needIdle
-#ifdef __WXDEBUG__
- && !wxTheApp->IsInAssert()
-#endif
- && ([NSDefaultRunLoopMode isEqualToString:mode] || [NSModalPanelRunLoopMode isEqualToString:mode]))
+ if(sg_needIdle /*&& !wxTheApp->IsInAssert()*/ && ([NSDefaultRunLoopMode isEqualToString:mode] || [NSModalPanelRunLoopMode isEqualToString:mode]))
{
sg_needIdle = false;
- wxLogTrace(wxTRACE_COCOA,wxT("Processing idle events"));
+ wxLogDebug(wxT("Processing idle events"));
while(wxTheApp->ProcessIdle())
{
// Get the same events except don't block
- NSEvent *event = [super nextEventMatchingMask:mask untilDate:nil/* equivalent to [NSDate distantPast] */ inMode:mode dequeue:flag];
+ NSEvent *event = [super nextEventMatchingMask:mask untilDate:[NSDate distantPast]/* equivalent to [NSDate distantPast] */ inMode:mode dequeue:flag];
// If we got one, simply return it
if(event)
return event;
// we didn't get one, do some idle work
- wxLogTrace(wxTRACE_COCOA,wxT("Looping idle events"));
+ wxLogDebug(wxT("Looping idle events"));
}
// No more idle work requested, block
- wxLogTrace(wxTRACE_COCOA,wxT("Finished idle processing"));
+ wxLogDebug(wxT("Finished idle processing"));
}
else
- wxLogTrace(wxTRACE_COCOA,wxT("Avoiding idle processing sg_needIdle=%d"),sg_needIdle);
+ wxLogDebug(wxT("Avoiding idle processing sg_needIdle=%d"),sg_needIdle);
return [super nextEventMatchingMask:mask untilDate:expiration inMode:mode dequeue:flag];
}
- (void)sendEvent: (NSEvent*)anEvent
{
- wxLogTrace(wxTRACE_COCOA,wxT("SendEvent"));
+ wxLogDebug(wxT("SendEvent"));
sg_needIdle = true;
[super sendEvent: anEvent];
}
// ========================================================================
// wxNSApplicationDelegate
// ========================================================================
+@interface wxNSApplicationDelegate : NSObject
+{
+}
+
+// Delegate methods
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
+- (void)applicationWillBecomeActive:(NSNotification *)notification;
+- (void)applicationDidBecomeActive:(NSNotification *)notification;
+- (void)applicationWillResignActive:(NSNotification *)notification;
+- (void)applicationDidResignActive:(NSNotification *)notification;
+@end // interface wxNSApplicationDelegate : NSObject
+
@implementation wxNSApplicationDelegate : NSObject
// NOTE: Terminate means that the event loop does NOT return and thus
-// cleanup code doesn't properly execute. Furthermore, wxWidgets has its
+// cleanup code doesn't properly execute. Furthermore, wxWindows has its
// own exit on frame delete mechanism.
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
wxTheApp->CocoaDelegate_applicationDidResignActive();
}
-- (void)controlTintChanged:(NSNotification *)notification
-{
- wxLogDebug("TODO: send EVT_SYS_COLOUR_CHANGED as appropriate");
-}
-
@end // implementation wxNSApplicationDelegate : NSObject
// ========================================================================
wxMenuBarManager::DestroyInstance();
[m_cocoaApp setDelegate:nil];
- [[NSNotificationCenter defaultCenter] removeObserver:m_cocoaAppDelegate
- name:NSControlTintDidChangeNotification object:nil];
[m_cocoaAppDelegate release];
m_cocoaAppDelegate = NULL;
m_cocoaApp = [NSApplication sharedApplication];
m_cocoaAppDelegate = [[wxNSApplicationDelegate alloc] init];
[m_cocoaApp setDelegate:m_cocoaAppDelegate];
- [[NSNotificationCenter defaultCenter] addObserver:m_cocoaAppDelegate
- selector:@selector(controlTintChanged:)
- name:NSControlTintDidChangeNotification object:nil];
wxMenuBarManager::CreateInstance();
wxDC::CocoaInitializeTextSystem();
+// [ m_cocoaApp setDelegate:m_cocoaApp ];
return TRUE;
}
s_inYield = true;
// Run the event loop until it is out of events
- while(1)
- {
- wxAutoNSAutoreleasePool pool;
- NSEvent *event = [GetNSApplication()
+ while(NSEvent *event = [GetNSApplication()
nextEventMatchingMask:NSAnyEventMask
- untilDate:nil /* ==[NSDate distantPast] */
+ untilDate:[NSDate distantPast]
inMode:NSDefaultRunLoopMode
- dequeue: YES];
- if(!event)
- break;
+ dequeue: YES])
+ {
[GetNSApplication() sendEvent: event];
}
--- /dev/null
+/////////////////////////////////////////////////////////////////////////////
+// Name: utilsexec.mm
+// Purpose: Execution-related utilities for wxCocoa
+// Author: Ryan Norton
+// Modified by:
+// Created: 2004-10-05
+// RCS-ID: $Id$
+// Copyright: (c) Ryan Norton
+// Licence: wxWindows licence
+/////////////////////////////////////////////////////////////////////////////
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "wx/utils.h"
+
+#include "wx/process.h"
+#include "wx/stream.h"
+
+#include "wx/cocoa/string.h"
+
+#import <Foundation/Foundation.h>
+#import <AppKit/NSWorkspace.h>
+
+class wxPipeInputStream : public wxInputStream
+{
+public:
+ wxPipeInputStream(NSPipe* thePipe) :
+ m_thePipe(thePipe),
+ m_theHandle([m_thePipe fileHandleForReading])
+ {
+ }
+
+ ~wxPipeInputStream()
+ {
+ [m_thePipe release];
+ }
+
+protected:
+ virtual size_t OnSysRead(void *buffer, size_t size)
+ {
+ NSData* theData = [m_theHandle readDataOfLength:size];
+ memcpy(buffer, [theData bytes], [theData length]);
+ return [theData length];
+ }
+
+
+ NSPipe* m_thePipe;
+ NSFileHandle* m_theHandle;
+};
+
+class wxPipeOutputStream : public wxOutputStream
+{
+public:
+ wxPipeOutputStream(NSPipe* thePipe) :
+ m_thePipe(thePipe),
+ m_theHandle([m_thePipe fileHandleForWriting])
+ {
+ }
+
+ ~wxPipeOutputStream()
+ {
+ [m_thePipe release];
+ }
+
+protected:
+
+ virtual size_t OnSysWrite(const void *buffer, size_t bufsize)
+ {
+ NSData* theData = [NSData dataWithBytesNoCopy:(void*)buffer
+ length:bufsize];
+ [m_theHandle writeData:theData];
+ return bufsize;
+ }
+
+ NSPipe* m_thePipe;
+ NSFileHandle* m_theHandle;
+};
+
+@interface wxTaskHandler : NSObject
+{
+ long m_pid;
+ void* m_handle;
+}
+-(id)init:(void*)handle processIdentifier:(long)pid;
+- (void)termHandler:(NSNotification *)aNotification;
+@end
+
+@implementation wxTaskHandler : NSObject
+
+-(id)init:(void*)handle processIdentifier:(long)pid
+{
+ self = [super init];
+
+ m_handle = handle;
+ m_pid = pid;
+
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(termHandler:)
+ name:NSTaskDidTerminateNotification
+ object:nil];
+ return self;
+}
+
+- (void)termHandler:(NSNotification *)aNotification
+{
+ NSTask* theTask = [aNotification object];
+
+ if ([theTask processIdentifier] == m_pid)
+ {
+ ((wxProcess*)m_handle)->OnTerminate([theTask processIdentifier],
+ [theTask terminationStatus]);
+
+ [self release];
+ }
+}
+
+@end
+
+long wxExecute(const wxString& command,
+ int sync = wxEXEC_ASYNC,
+ wxProcess *handle = NULL)
+{
+ NSTask* theTask = [[NSTask alloc] init];
+
+ if (handle && handle->IsRedirected())
+ {
+ NSPipe* theStdinPipe = [[NSPipe alloc] init];
+ NSPipe* theStderrPipe = [[NSPipe alloc] init];
+ NSPipe* theStdoutPipe = [[NSPipe alloc] init];
+
+ [theTask setStandardInput:theStdinPipe];
+ [theTask setStandardError:theStderrPipe];
+ [theTask setStandardOutput:theStdoutPipe];
+
+ handle->SetPipeStreams(new wxPipeInputStream(theStdoutPipe),
+ new wxPipeOutputStream(theStdinPipe),
+ new wxPipeInputStream(theStderrPipe) );
+ }
+
+ NSArray* theQuoteArguments =
+ [wxNSStringWithWxString(command) componentsSeparatedByString:@"\""];
+
+ NSMutableArray* theSeperatedArguments =
+ [NSMutableArray arrayWithCapacity:10];
+
+ for (unsigned i = 0; i < [theQuoteArguments count]; ++i)
+ {
+ [theSeperatedArguments addObjectsFromArray:
+ [[theQuoteArguments objectAtIndex:i] componentsSeparatedByString:@" "]
+ ];
+
+ if(++i < [theQuoteArguments count])
+ [theSeperatedArguments addObject:[theQuoteArguments objectAtIndex:i]];
+ }
+
+ [theTask setLaunchPath:[theSeperatedArguments objectAtIndex:0]];
+ [theTask setArguments:theSeperatedArguments];
+ [theTask launch];
+
+ if(sync & wxEXEC_ASYNC)
+ {
+ [[wxTaskHandler alloc]init:handle
+ processIdentifier:[theTask processIdentifier]];
+
+ return 0;
+ }
+ else
+ {
+ [theTask waitUntilExit];
+
+ return [theTask terminationStatus];
+ }
+}
\ No newline at end of file
}
// Get the window with the focus
-wxWindow *wxWindowBase::FindFocus()
+wxWindow *wxWindowBase::DoFindFocus()
{
// TODO
return NULL;
wxASSERT( str.GetStringData()->IsValid() );
wxASSERT( nStart <= length() );
- const wxChar *p = wxStrstr(c_str() + nStart, str.c_str());
+ //anchor
+ const wxChar* p = wxMemchr(c_str() + nStart,
+ str.c_str()[0],
+ length() - nStart);
+
+ if(!p)
+ return npos;
+
+ while(p - c_str() + str.length() <= length() &&
+ wxMemcmp(p, str.c_str(), str.length()) )
+ {
+ //anchor again
+ p = wxMemchr(++p,
+ str.c_str()[0],
+ length() - (p - c_str()));
- return p == NULL ? npos : p - c_str();
+ if(!p)
+ return npos;
+ }
+
+ return (p - c_str() + str.length() <= length()) ? p - c_str() : npos;
}
size_t wxStringBase::find(const wxChar* sz, size_t nStart, size_t n) const
{
wxASSERT( nStart <= length() );
- const wxChar *p = wxStrchr(c_str() + nStart, ch);
+ const wxChar *p = wxMemchr(c_str() + nStart, ch, length() - nStart);
return p == NULL ? npos : p - c_str();
}
const wxChar *cursor = c_str() + top;
do
{
- if ( memcmp(cursor, str.c_str(),
- str.length() * sizeof(wxChar)) == 0 )
+ if ( wxMemcmp(cursor, str.c_str(),
+ str.length()) == 0 )
{
return cursor - c_str();
}
size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart) const
{
- const wxChar *start = c_str() + nStart;
- const wxChar *firstOf = wxStrpbrk(start, sz);
- if ( firstOf )
- return firstOf - c_str();
- else
+ wxASSERT(nStart <= length());
+
+ size_t len = wxStrlen(sz);
+
+ size_t i;
+ for(i = nStart; i < this->length(); ++i)
+ {
+ if (wxMemchr(sz, *(c_str() + i), len))
+ break;
+ }
+
+ if(i == this->length())
return npos;
+ else
+ return i;
}
size_t wxStringBase::find_first_of(const wxChar* sz, size_t nStart,
_T("invalid index in find_last_of()") );
}
+ size_t len = wxStrlen(sz);
+
for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p )
{
- if ( wxStrchr(sz, *p) )
+ if ( wxMemchr(sz, *p, len) )
return p - c_str();
}
wxASSERT( nStart <= length() );
}
- size_t nAccept = wxStrspn(c_str() + nStart, sz);
- if ( nAccept >= length() - nStart )
- return npos;
- else
- return nStart + nAccept;
+ size_t len = wxStrlen(sz);
+
+ size_t i;
+ for(i = nStart; i < this->length(); ++i)
+ {
+ if (!wxMemchr(sz, *(c_str() + i), len))
+ break;
+ }
+
+ if(i == this->length())
+ return npos;
+ else
+ return i;
}
size_t wxStringBase::find_first_not_of(const wxChar* sz, size_t nStart,
wxASSERT( nStart <= length() );
}
+ size_t len = wxStrlen(sz);
+
for ( const wxChar *p = c_str() + nStart; p >= c_str(); --p )
{
- if ( !wxStrchr(sz, *p) )
- return p - c_str();
+ if ( !wxMemchr(sz, *p,len) )
+ return p - c_str();
}
return npos;
const wxChar* s2, size_t l2)
{
if( l1 == l2 )
- return wxStrncmp(s1, s2, l1);
+ return wxMemcmp(s1, s2, l1);
else if( l1 < l2 )
{
- int ret = wxStrncmp(s1, s2, l1);
+ int ret = wxMemcmp(s1, s2, l1);
return ret == 0 ? -1 : ret;
}
else if( l1 > l2 )
{
- int ret = wxStrncmp(s1, s2, l2);
+ int ret = wxMemcmp(s1, s2, l2);
return ret == 0 ? +1 : ret;
}
return 0; // quiet compilers
}
-#if wxUSE_STL
-
int STRINGCLASS::compare(const wxStringBase& str) const
{
return ::wxDoCmp(data(), length(), str.data(), str.length());
}
-#endif
-
int STRINGCLASS::compare(size_t nStart, size_t nLen,
const wxStringBase& str) const
{
return ::wxDoCmp(data() + nStart, nLen, str.data() + nStart2, nLen2);
}
-#if wxUSE_STL
-
int STRINGCLASS::compare(const wxChar* sz) const
{
size_t nLen = wxStrlen(sz);
return ::wxDoCmp(data(), length(), sz, nLen);
}
-#endif
-
int STRINGCLASS::compare(size_t nStart, size_t nLen,
const wxChar* sz, size_t nCount) const
{
// other common string functions
// ===========================================================================
+int wxString::Cmp(const wxString& s) const
+{
+ return compare(s);
+}
+
+int wxString::Cmp(const wxChar* psz) const
+{
+ return compare(psz);
+}
+
+static inline int wxDoCmpNoCase(const wxChar* s1, size_t l1,
+ const wxChar* s2, size_t l2)
+{
+ size_t i;
+
+ if( l1 == l2 )
+ {
+ for(i = 0; i < l1; ++i)
+ {
+ if(wxTolower(s1[i]) != wxTolower(s2[i]))
+ break;
+ }
+ return i == l1 ? 0 : s1[i] < s2[i] ? -1 : 1;
+ }
+ else if( l1 < l2 )
+ {
+ for(i = 0; i < l1; ++i)
+ {
+ if(wxTolower(s1[i]) != wxTolower(s2[i]))
+ break;
+ }
+ return i == l1 ? -1 : s1[i] < s2[i] ? -1 : 1;
+ }
+ else if( l1 > l2 )
+ {
+ for(i = 0; i < l2; ++i)
+ {
+ if(wxTolower(s1[i]) != wxTolower(s2[i]))
+ break;
+ }
+ return i == l2 ? 1 : s1[i] < s2[i] ? -1 : 1;
+ }
+
+ wxFAIL; // must never get there
+ return 0; // quiet compilers
+}
+
+int wxString::CmpNoCase(const wxString& s) const
+{
+ return wxDoCmpNoCase(data(), length(), s.data(), s.length());
+}
+
+int wxString::CmpNoCase(const wxChar* psz) const
+{
+ int nLen = wxStrlen(psz);
+
+ return wxDoCmpNoCase(data(), length(), psz, nLen);
+}
+
+
#if wxUSE_UNICODE
#ifdef __MWERKS__
while ( lo < hi ) {
i = (lo + hi)/2;
- res = wxStrcmp(str, m_pItems[i]);
+ res = str.Cmp(m_pItems[i]);
if ( res < 0 )
hi = i;
else if ( res > 0 )
}
else {
// maybe we should use wxStrcoll
- int result = wxStrcmp(strFirst->c_str(), strSecond->c_str());
+ int result = strFirst->Cmp(*strSecond);
return gs_sortAscending ? result : -result;
}
int wxCMPFUNC_CONV wxStringSortAscending(wxString* s1, wxString* s2)
{
- return wxStrcmp(s1->c_str(), s2->c_str());
+ return s1->Cmp(*s2);
}
int wxCMPFUNC_CONV wxStringSortDescending(wxString* s1, wxString* s2)
{
- return -wxStrcmp(s1->c_str(), s2->c_str());
+ return -s1->Cmp(*s2);
}
WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)CharUpper((LPTSTR)(ch)); }
#endif
+#if wxUSE_UNICODE && __DARWIN__ && ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
+
+WXDLLEXPORT size_t wxInternalMbstowcs (wchar_t * out, const char * in, size_t outlen)
+{
+ if (!out)
+ {
+ size_t outsize = 0;
+ while(*in++)
+ outsize++;
+ return outsize;
+ }
+
+ const char* origin = in;
+
+ while (outlen-- && *in)
+ {
+ *out++ = (wchar_t) *in++;
+ }
+
+ *out = '\0';
+
+ return in - origin;
+}
+
+WXDLLEXPORT size_t wxInternalWcstombs (char * out, const wchar_t * in, size_t outlen)
+{
+ if (!out)
+ {
+ size_t outsize = 0;
+ while(*in++)
+ outsize++;
+ return outsize;
+ }
+
+ const wchar_t* origin = in;
+
+ while (outlen-- && *in)
+ {
+ *out++ = (char) *in++;
+ }
+
+ *out = '\0';
+
+ return in - origin;
+}
+
+#if defined(wxNEED_WX_CTYPE_H)
+
+#include <CoreFoundation/CoreFoundation.h>
+
+CFCharacterSetRef cfalnumset = CFCharacterSetGetPredefined(kCFCharacterSetAlphaNumeric);
+CFCharacterSetRef cfalphaset = CFCharacterSetGetPredefined(kCFCharacterSetLetter);
+CFCharacterSetRef cfcntrlset = CFCharacterSetGetPredefined(kCFCharacterSetControl);
+CFCharacterSetRef cfdigitset = CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit);
+//CFCharacterSetRef cfgraphset = kCFCharacterSetControl && !' '
+CFCharacterSetRef cflowerset = CFCharacterSetGetPredefined(kCFCharacterSetLowercaseLetter);
+//CFCharacterSetRef cfprintset = !kCFCharacterSetControl
+CFCharacterSetRef cfpunctset = CFCharacterSetGetPredefined(kCFCharacterSetPunctuation);
+CFCharacterSetRef cfspaceset = CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline);
+CFCharacterSetRef cfupperset = CFCharacterSetGetPredefined(kCFCharacterSetUppercaseLetter);
+
+WXDLLEXPORT int wxIsalnum(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalnumset, ch); }
+WXDLLEXPORT int wxIsalpha(wxChar ch) { return CFCharacterSetIsCharacterMember(cfalphaset, ch); }
+WXDLLEXPORT int wxIscntrl(wxChar ch) { return CFCharacterSetIsCharacterMember(cfcntrlset, ch); }
+WXDLLEXPORT int wxIsdigit(wxChar ch) { return CFCharacterSetIsCharacterMember(cfdigitset, ch); }
+WXDLLEXPORT int wxIsgraph(wxChar ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch) && ch != ' '; }
+WXDLLEXPORT int wxIslower(wxChar ch) { return CFCharacterSetIsCharacterMember(cflowerset, ch); }
+WXDLLEXPORT int wxIsprint(wxChar ch) { return !CFCharacterSetIsCharacterMember(cfcntrlset, ch); }
+WXDLLEXPORT int wxIspunct(wxChar ch) { return CFCharacterSetIsCharacterMember(cfpunctset, ch); }
+WXDLLEXPORT int wxIsspace(wxChar ch) { return CFCharacterSetIsCharacterMember(cfspaceset, ch); }
+WXDLLEXPORT int wxIsupper(wxChar ch) { return CFCharacterSetIsCharacterMember(cfupperset, ch); }
+WXDLLEXPORT int wxIsxdigit(wxChar ch) { return wxIsdigit(ch) || (ch>='a' && ch<='f') || (ch>='A' && ch<='F'); }
+WXDLLEXPORT int wxTolower(wxChar ch) { return (wxChar)tolower((char)(ch)); }
+WXDLLEXPORT int wxToupper(wxChar ch) { return (wxChar)toupper((char)(ch)); }
+#endif
+
+#endif
+
#ifndef wxStrdupA
WXDLLEXPORT char *wxStrdupA(const char *s)
return ret;
}
+WXDLLEXPORT size_t wxStrlen_(const wxChar *s)
+{
+ size_t n = 0;
+ while ( *s++ )
+ n++;
+
+ return n;
+}
+
+
WXDLLEXPORT wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n)
{
wxChar *ret = dest;
WXDLLEXPORT const wxChar *wxStrstr(const wxChar *haystack, const wxChar *needle)
{
- wxCHECK_RET( needle, NULL, _T("NULL argument in wxStrstr") );
+ wxASSERT_MSG( needle != NULL, _T("NULL argument in wxStrstr") );
// VZ: this is not exactly the most efficient string search algorithm...
while ((wxIsdigit(*nptr) && (*nptr - wxT('0') < base)) ||
(wxIsalpha(*nptr) && (wxToupper(*nptr) - wxT('A') + 10 < base))) nptr++;
- wxString data(nptr, nptr-start);
+ wxString data(start, nptr-start);
wxWX2MBbuf dat = data.mb_str(wxConvLocal);
char *rdat = wxMBSTRINGCAST dat;
long int ret = strtol(dat, &rdat, base);
return ret;
}
+
+WXDLLEXPORT unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base)
+{
+ return (unsigned long int) wxStrtol(nptr, endptr, base);
+}
+
#endif // wxNEED_WX_STRING_H
#ifdef wxNEED_WX_STDIO_H
strcpy( dest , s ) ;
return dest ;
}
-
#endif // wxNEED_STRDUP
#if defined(__WXWINCE__) && (_WIN32_WCE <= 211)
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: fontdlg.cpp
-// Purpose: wxFontDialog class.
-// Author: Ryan Norton
-// Modified by:
-// Created: 2004-10-03
-// RCS-ID: $Id$
-// Copyright: (c) Ryan Norton
-// Licence: wxWindows licence
-/////////////////////////////////////////////////////////////////////////////
-
-// ===========================================================================
-// declarations
-// ===========================================================================
-
-// ---------------------------------------------------------------------------
-// headers
-// ---------------------------------------------------------------------------
-
-#ifdef __GNUG__
-#pragma implementation "fontdlg.h"
-#endif
-
-// For compilers that support precompilation, includes "wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-#ifndef WX_PRECOMP
- #include "wx/cmndata.h"
- #include "wx/fontdlg.h"
- #include "wx/fontutil.h"
- #include "wx/log.h"
-#endif
-
-#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
-#endif
-
-// ============================================================================
-// implementation
-// ============================================================================
-
-//Mac OSX 10.2+ only
-#if defined( __WXMAC_OSX__ ) && ( MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_2 )
-
-// Cocoa headers
-#include "wx/cocoa/autorelease.h"
-#include "wx/cocoa/string.h"
-
-#import <AppKit/NSFont.h>
-#import <AppKit/NSFontManager.h>
-#import <AppKit/NSFontPanel.h>
-#import <AppKit/NSColor.h>
-#import <AppKit/NSColorPanel.h>
-
-// ---------------------------------------------------------------------------
-// wxWCDelegate - Window Closed delegate
-// ---------------------------------------------------------------------------
-
-@interface wxWCDelegate : NSObject
-{
- bool m_bIsClosed;
-}
-
-// Delegate methods
-- (id)init;
-- (BOOL)windowShouldClose:(id)sender;
-- (BOOL)isClosed;
-@end // interface wxNSFontPanelDelegate : NSObject
-
-@implementation wxWCDelegate : NSObject
-
-- (id)init
-{
- [super init];
- m_bIsClosed = false;
-
- return self;
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
- m_bIsClosed = true;
-
- [NSApp abortModal];
- [NSApp stopModal];
- return YES;
-}
-
-- (BOOL)isClosed
-{
- return m_bIsClosed;
-}
-
-@end // wxNSFontPanelDelegate
-
-// ---------------------------------------------------------------------------
-// wxWCODelegate - Window Closed or Open delegate
-// ---------------------------------------------------------------------------
-
-@interface wxWCODelegate : NSObject
-{
- bool m_bIsClosed;
- bool m_bIsOpen;
-}
-
-// Delegate methods
-- (id)init;
-- (BOOL)windowShouldClose:(id)sender;
-- (void)windowDidUpdate:(NSNotification *)aNotification;
-- (BOOL)isClosed;
-- (BOOL)isOpen;
-@end // interface wxNSFontPanelDelegate : NSObject
-
-@implementation wxWCODelegate : NSObject
-
-- (id)init
-{
- [super init];
- m_bIsClosed = false;
- m_bIsOpen = false;
-
- return self;
-}
-
-- (BOOL)windowShouldClose:(id)sender
-{
- m_bIsClosed = true;
- m_bIsOpen = false;
-
- [NSApp abortModal];
- [NSApp stopModal];
- return YES;
-}
-
-- (void)windowDidUpdate:(NSNotification *)aNotification
-{
- if (m_bIsOpen == NO)
- {
- m_bIsClosed = false;
- m_bIsOpen = true;
-
- [NSApp abortModal];
- [NSApp stopModal];
- }
-}
-
-- (BOOL)isClosed
-{
- return m_bIsClosed;
-}
-
-- (BOOL)isOpen
-{
- return m_bIsOpen;
-}
-
-@end // wxNSFontPanelDelegate
-
-// ---------------------------------------------------------------------------
-// wxFontDialog
-// ---------------------------------------------------------------------------
-
-wxFontDialog::wxFontDialog()
-{
-}
-
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data)
-{
- Create(parent, data);
-}
-
-wxFontDialog::~wxFontDialog()
-{
-}
-
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
-{
- m_fontData = data;
-
- //
- // This is the key call - this initializes
- // events and window stuff for cocoa for carbon
- // applications.
- //
- // This is also the only call here that is
- // 10.2+ specific (the rest is OSX only),
- // which, ironically, the carbon font
- // panel requires.
- //
- bool bOK = NSApplicationLoad();
-
- //autorelease pool - req'd for carbon
- NSAutoreleasePool *thePool;
- thePool = [[NSAutoreleasePool alloc] init];
-
- //Get the initial wx font
- wxFont& thewxfont = m_fontData.m_initialFont;
-
- //if the font is valid set the default (selected) font of the
- //NSFontDialog to that font
- if (thewxfont.Ok())
- {
- NSFontTraitMask theMask = 0;
-
- if(thewxfont.GetStyle() == wxFONTSTYLE_ITALIC)
- theMask |= NSItalicFontMask;
-
- if(thewxfont.IsFixedWidth())
- theMask |= NSFixedPitchFontMask;
-
- NSFont* theDefaultFont =
- [[NSFontManager sharedFontManager] fontWithFamily:
- wxNSStringWithWxString(thewxfont.GetFaceName())
- traits:theMask
- weight:thewxfont.GetWeight() == wxBOLD ? 9 :
- thewxfont.GetWeight() == wxLIGHT ? 0 : 5
- size: (float)(thewxfont.GetPointSize())
- ];
-
- wxASSERT_MSG(theDefaultFont, wxT("Invalid default font for wxCocoaFontDialog!"));
-
- //set the initial font of the NSFontPanel
- //(the font manager calls the appropriate NSFontPanel method)
- [[NSFontManager sharedFontManager] setSelectedFont:theDefaultFont isMultiple:NO];
-
- }
-
- if([NSColorPanel sharedColorPanelExists] == NO)
- {
- //The color panel has an annoying tendancy to start
- //out at a WHITE color - so when the user
- //chooses his first font he would probably be in
- //for an unpleasent surprise if we didn't setup
- //the color panel to use black :)
- [[NSColorPanel sharedColorPanel] setColor:[NSColor blackColor]];
- }
-
- //We're done - free up the pool
- [thePool release];
-
- return bOK;
-}
-
-int wxFontDialog::ShowModal()
-{
- //Start the pool. Required for carbon interaction
- //(For those curious, the only thing that happens
- //if you don't do this is a bunch of error
- //messages about leaks on the console,
- //with no windows shown or anything).
- NSAutoreleasePool *thePool;
- thePool = [[NSAutoreleasePool alloc] init];
-
- //Get the shared color and font panel
- NSFontPanel* theFontPanel = [NSFontPanel sharedFontPanel];
- NSColorPanel* theColorPanel = [NSColorPanel sharedColorPanel];
-
- //Create and assign the delegates (cocoa event handlers) so
- //we can tell if a window has closed/open or not
- wxWCDelegate* theFPDelegate = [[wxWCDelegate alloc] init];
- [theFontPanel setDelegate:theFPDelegate];
-
- wxWCODelegate* theCPDelegate = [[wxWCODelegate alloc] init];
- [theColorPanel setDelegate:theCPDelegate];
-
- //
- // Begin the modal loop for the font and color panels
- //
- // The idea is that we first make the font panel modal,
- // but if the color panel is opened, unless we stop the
- // modal loop the color panel opens behind the font panel
- // with no input acceptable to it - which makes it useless.
- //
- // So we set up delegates for both the color and font panels,
- // and the if the font panel opens the color panel, we
- // stop the modal loop, and start a seperate modal loop for
- // the color panel until the color panel closes, switching
- // back to the font panel modal loop once it does close.
- //
- do
- {
- //
- // Start the font panel modal loop
- //
- NSModalSession session = [NSApp beginModalSessionForWindow:theFontPanel];
- for (;;)
- {
- [NSApp runModalSession:session];
-
- //If the font panel is closed or the font panel
- //opened the color panel, break
- if ([theFPDelegate isClosed] || [theCPDelegate isOpen])
- break;
- }
- [NSApp endModalSession:session];
-
- //is the color panel open?
- if ([theCPDelegate isOpen])
- {
- //
- // Start the color panel modal loop
- //
- NSModalSession session = [NSApp beginModalSessionForWindow:theColorPanel];
- for (;;)
- {
- [NSApp runModalSession:session];
-
- //If the color panel is closed, return the font panel modal loop
- if ([theCPDelegate isClosed])
- break;
- }
- [NSApp endModalSession:session];
- }
- //If the font panel is still alive (I.E. we broke
- //out of its modal loop because the color panel was
- //opened) return the font panel modal loop
- }while([theFPDelegate isClosed] == NO);
-
- //free up the memory for the delegates - we don't need them anymore
- [theFPDelegate release];
- [theCPDelegate release];
-
- //Get the font the user selected
- NSFont* theFont = [theFontPanel panelConvertFont:[NSFont userFontOfSize:0]];
-
- //Get more information about the user's chosen font
- NSFontTraitMask theTraits = [[NSFontManager sharedFontManager] traitsOfFont:theFont];
- int theFontWeight = [[NSFontManager sharedFontManager] weightOfFont:theFont];
- int theFontSize = (int) [theFont pointSize];
-
- //Set the wx font to the appropriate data
- if(theTraits & NSFixedPitchFontMask)
- m_fontData.m_chosenFont.SetFamily(wxTELETYPE);
-
- m_fontData.m_chosenFont.SetFaceName(wxStringWithNSString([theFont familyName]));
- m_fontData.m_chosenFont.SetPointSize(theFontSize);
- m_fontData.m_chosenFont.SetStyle(theTraits & NSItalicFontMask ? wxFONTSTYLE_ITALIC : 0);
- m_fontData.m_chosenFont.SetWeight(theFontWeight < 5 ? wxLIGHT :
- theFontWeight >= 9 ? wxBOLD : wxNORMAL);
-
- //Get the shared color panel along with the chosen color and set the chosen color
- NSColor* theColor = [[theColorPanel color] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
-
- m_fontData.m_fontColour.Set((unsigned char) ([theColor redComponent] * 255.0),
- (unsigned char) ([theColor greenComponent] * 255.0),
- (unsigned char) ([theColor blueComponent] * 255.0));
-
- //Friendly debug stuff
-#ifdef FONTDLGDEBUG
- wxPrintf(wxT("---Font Panel---\n--NS--\nSize:%f\nWeight:%i\nTraits:%i\n--WX--\nFaceName:%s\nPointSize:%i\nStyle:%i\nWeight:%i\nColor:%i,%i,%i\n---END Font Panel---\n"),
-
- (float) theFontSize,
- theFontWeight,
- theTraits,
-
- m_fontData.m_chosenFont.GetFaceName().c_str(),
- m_fontData.m_chosenFont.GetPointSize(),
- m_fontData.m_chosenFont.GetStyle(),
- m_fontData.m_chosenFont.GetWeight(),
- m_fontData.m_fontColour.Red(),
- m_fontData.m_fontColour.Green(),
- m_fontData.m_fontColour.Blue() );
-#endif
-
- //Release the pool, we're done :)
- [thePool release];
-
- //Return ID_OK - there are no "apply" buttons or the like
- //on either the font or color panel
- return wxID_OK;
-}
-
-//old api stuff (REMOVE ME)
-bool wxFontDialog::IsShown() const
-{
- return false;
-}
-
-#else
- //10.2+ only
-
-// ---------------------------------------------------------------------------
-// wxFontDialog stub for mac OS's without a native font dialog
-// ---------------------------------------------------------------------------
-
-wxFontDialog::wxFontDialog()
-{
- m_dialogParent = NULL;
-}
-
-wxFontDialog::wxFontDialog(wxWindow *parent, const wxFontData& data)
-{
- Create(parent, data);
-}
-
-void wxFontDialog::SetData(wxFontData& fontdata)
-{
- m_fontData = fontdata;
-}
-
-bool wxFontDialog::Create(wxWindow *parent, const wxFontData& data)
-{
- m_dialogParent = parent;
-
- m_fontData = data;
-
- // TODO: you may need to do dialog creation here, unless it's
- // done in ShowModal.
- return TRUE;
-}
-
-bool wxFontDialog::IsShown() const
-{
- return false;
-}
-
-int wxFontDialog::ShowModal()
-{
- // TODO: show (maybe create) the dialog
- return wxID_CANCEL;
-}
-
-#endif // 10.2+
wxASSERT_MSG(!(flags & wxSOUND_LOOP), wxT("Can't loop and play syncronously at the same time"));
//Play movie until it ends, then exit
+ //Note that due to quicktime caching this may not always
+ //work 100% correctly
while (!IsMovieDone(movie))
- MoviesTask(movie, 0);
+ MoviesTask(movie, 1);
DisposeMovie(movie);
}
CPPUNIT_ASSERT( s1.find(s2) == 6u );
CPPUNIT_ASSERT( s1.find(s2, 7) == wxString::npos );
CPPUNIT_ASSERT( s1.find(s2, 6) == 6u );
+
+ // 0 1 2
+ // 0123456 78901234567 8901234567
+ //wxString _s1 = _T("abcdefg\0ABCDEFGabc\0ABCabcABC");
+ //wxString _s2 = _T("g\0AB");
+ wxString _s1 = _T("abcdefgABCDEFGabcABCabcABC");
+ wxString _s2 = _T("gAB");
+
+ _s1.insert(7, 1, '\0');
+ _s1.insert(18, 1, '\0');
+ _s2.insert(1, 1, '\0');
+
+ CPPUNIT_ASSERT( _s1.find(_T('A')) == 8u );
+ CPPUNIT_ASSERT( _s1.find(_T('A'), 8) == 8u );
+ CPPUNIT_ASSERT( _s1.find(_T('Z')) == wxString::npos );
+ CPPUNIT_ASSERT( _s1.find(_T('C'), 22) == 27u );
+
+ CPPUNIT_ASSERT( _s1.find(_T("AB")) == 8u );
+ CPPUNIT_ASSERT( _s1.find(_T("AB"), 26) == wxString::npos );
+ CPPUNIT_ASSERT( _s1.find(_T("AB"), 23) == 25u );
+
+ CPPUNIT_ASSERT( _s1.find(_T("ABZZZ"), 2, 2) == 8u );
+ CPPUNIT_ASSERT( _s1.find(_T("ABZZZ"), 26, 2) == wxString::npos );
+
+ CPPUNIT_ASSERT( _s1.find(_s2) == 6u );
+ CPPUNIT_ASSERT( _s1.find(_s2, 7) == wxString::npos );
+ CPPUNIT_ASSERT( _s1.find(_s2, 6) == 6u );
}
void StdStringTestCase::StdFindFirst()
CPPUNIT_ASSERT( s1.rfind(s2, 5) == wxString::npos );
CPPUNIT_ASSERT( s1.rfind(s2, 6) == 6u );
CPPUNIT_ASSERT( s1.rfind(s3, 1) == 0u );
+
+
+ // 0 1 2
+ // 01234 56789012 345678901234567
+// wxString s1 = _T("abcde\0fgABCDE\0FGabcABCabcABC");
+// wxString s2 = _T("gAB");
+// wxString s3 = _T("ab");
+
+ s1.insert(5,1,'\0');
+ s1.insert(13,1,'\0');
+
+ CPPUNIT_ASSERT( s1.rfind(_T('A')) == 25u );
+ CPPUNIT_ASSERT( s1.rfind(_T('A'), 8) == 8u );
+ CPPUNIT_ASSERT( s1.rfind(_T('Z')) == wxString::npos );
+ CPPUNIT_ASSERT( s1.rfind(_T('C'), 22) == 21u );
+
+ CPPUNIT_ASSERT( s1.rfind(_T("cAB")) == 24u );
+ CPPUNIT_ASSERT( s1.rfind(_T("cAB"), 15) == wxString::npos );
+ CPPUNIT_ASSERT( s1.rfind(_T("cAB"), 21) == 18u );
+
+ CPPUNIT_ASSERT( s1.rfind(_T("gABZZZ"), 8, 3) == 7u );
+ CPPUNIT_ASSERT( s1.rfind(_T("gABZZZ"), 5, 3) == wxString::npos );
}
void StdStringTestCase::StdResize()
CPPUNIT_ASSERT( s1.substr( 1, 13 ) == _T("bcdefgABCDEFG") );
CPPUNIT_ASSERT( s1.substr( 1, 20 ) == _T("bcdefgABCDEFG") );
CPPUNIT_ASSERT( s1.substr( 14, 30 ) == _T("") );
+
+
+// 1
+// 012 34567 89012 3456
+// wxString s1 = _T("abc\0defg\0ABCD\0EFG");
+
+ s1.insert(3,1,'\0');
+ s1.insert(8,1,'\0');
+ s1.insert(13,1,'\0');
+
+ wxString s2 = wxT("bcdefgABCDEFG");
+ s2.insert(2,1,'\0');
+ s2.insert(7,1,'\0');
+ s2.insert(12,1,'\0');
+
+ CPPUNIT_ASSERT( s1.substr( 0, 17 ) == s1 );
+ CPPUNIT_ASSERT( s1.substr( 1, 17 ) == s2 );
+ CPPUNIT_ASSERT( s1.substr( 1, 20 ) == s2 );
+ CPPUNIT_ASSERT( s1.substr( 17, 30 ) == _T("") );
}
CPPUNIT_TEST( Replace );
CPPUNIT_TEST( Match );
CPPUNIT_TEST( CaseChanges );
+ CPPUNIT_TEST( Compare );
+ CPPUNIT_TEST( CompareNoCase );
CPPUNIT_TEST_SUITE_END();
void String();
void Replace();
void Match();
void CaseChanges();
+ void Compare();
+ void CompareNoCase();
DECLARE_NO_COPY_CLASS(StringTestCase)
};
}
#endif // !wxUSE_UNICODE
}
+
+void StringTestCase::Compare()
+{
+ wxString s1 = wxT("AHH");
+ wxString eq = wxT("AHH");
+ wxString neq1 = wxT("HAH");
+ wxString neq2 = wxT("AH");
+ wxString neq3 = wxT("AHHH");
+ wxString neq4 = wxT("AhH");
+
+ CPPUNIT_ASSERT( s1 == eq );
+ CPPUNIT_ASSERT( s1 != neq1 );
+ CPPUNIT_ASSERT( s1 != neq2 );
+ CPPUNIT_ASSERT( s1 != neq3 );
+ CPPUNIT_ASSERT( s1 != neq4 );
+
+// wxString _s1 = wxT("A\0HH");
+// wxString _eq = wxT("A\0HH");
+// wxString _neq1 = wxT("H\0AH");
+// wxString _neq2 = wxT("A\0H");
+// wxString _neq3 = wxT("A\0HHH");
+// wxString _neq4 = wxT("A\0hH");
+ s1.insert(1,1,'\0');
+ eq.insert(1,1,'\0');
+ neq1.insert(1,1,'\0');
+ neq2.insert(1,1,'\0');
+ neq3.insert(1,1,'\0');
+ neq4.insert(1,1,'\0');
+
+ CPPUNIT_ASSERT( s1 == eq );
+ CPPUNIT_ASSERT( s1 != neq1 );
+ CPPUNIT_ASSERT( s1 != neq2 );
+ CPPUNIT_ASSERT( s1 != neq3 );
+ CPPUNIT_ASSERT( s1 != neq4 );
+}
+
+void StringTestCase::CompareNoCase()
+{
+ wxString s1 = wxT("AHH");
+ wxString eq = wxT("AHH");
+ wxString eq2 = wxT("AhH");
+ wxString eq3 = wxT("ahh");
+ wxString neq = wxT("HAH");
+ wxString neq2 = wxT("AH");
+ wxString neq3 = wxT("AHHH");
+
+ #define CPPUNIT_CNCEQ_ASSERT(s1, s2) CPPUNIT_ASSERT( s1.CmpNoCase(s2) == 0)
+ #define CPPUNIT_CNCNEQ_ASSERT(s1, s2) CPPUNIT_ASSERT( s1.CmpNoCase(s2) != 0)
+
+ CPPUNIT_CNCEQ_ASSERT( s1, eq );
+ CPPUNIT_CNCEQ_ASSERT( s1, eq2 );
+ CPPUNIT_CNCEQ_ASSERT( s1, eq3 );
+
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq );
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq2 );
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq3 );
+
+
+// wxString _s1 = wxT("A\0HH");
+// wxString _eq = wxT("A\0HH");
+// wxString _eq2 = wxT("A\0hH");
+// wxString _eq3 = wxT("a\0hh");
+// wxString _neq = wxT("H\0AH");
+// wxString _neq2 = wxT("A\0H");
+// wxString _neq3 = wxT("A\0HHH");
+
+ s1.insert(1,1,'\0');
+ eq.insert(1,1,'\0');
+ eq2.insert(1,1,'\0');
+ eq3.insert(1,1,'\0');
+ neq.insert(1,1,'\0');
+ neq2.insert(1,1,'\0');
+ neq3.insert(1,1,'\0');
+
+ CPPUNIT_CNCEQ_ASSERT( s1, eq );
+ CPPUNIT_CNCEQ_ASSERT( s1, eq2 );
+ CPPUNIT_CNCEQ_ASSERT( s1, eq3 );
+
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq );
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq2 );
+ CPPUNIT_CNCNEQ_ASSERT( s1, neq3 );
+}
\ No newline at end of file