osx-cocoa updates
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55411 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mac/carbon/bmpbuttn.cpp
|
||||
// Name: src/osx/carbon/bmpbuttn.cpp
|
||||
// Purpose: wxBitmapButton
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
@@ -37,7 +37,7 @@ wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer,
|
||||
wxNSButton* v = [[wxNSButton alloc] initWithFrame:r];
|
||||
|
||||
[v setBezelStyle:NSRegularSquareBezelStyle];
|
||||
|
||||
[v setImage:bitmap.GetNSImage() ];
|
||||
[v setButtonType:NSMomentaryPushInButton];
|
||||
[sv addSubview:v];
|
||||
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
|
||||
|
80
src/osx/cocoa/dirdlg.mm
Normal file
80
src/osx/cocoa/dirdlg.mm
Normal file
@@ -0,0 +1,80 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/osx/cocoa/dirdlg.mm
|
||||
// Purpose: wxDirDialog
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 2008-08-30
|
||||
// RCS-ID: $Id: dirdlg.mm 40007 2006-07-05 13:10:46Z SC $
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if wxUSE_DIRDLG && !defined(__WXUNIVERSAL__)
|
||||
|
||||
#include "wx/dirdlg.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/filedlg.h"
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
IMPLEMENT_CLASS(wxDirDialog, wxDialog)
|
||||
|
||||
wxDirDialog::wxDirDialog(wxWindow *parent, const wxString& message,
|
||||
const wxString& defaultPath, long style, const wxPoint& pos,
|
||||
const wxSize& size, const wxString& name)
|
||||
{
|
||||
m_parent = parent;
|
||||
|
||||
SetMessage( message );
|
||||
SetWindowStyle(style);
|
||||
SetPath(defaultPath);
|
||||
}
|
||||
|
||||
|
||||
int wxDirDialog::ShowModal()
|
||||
{
|
||||
int result = wxID_CANCEL;
|
||||
|
||||
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
|
||||
[oPanel setCanChooseDirectories:YES];
|
||||
[oPanel setResolvesAliases:YES];
|
||||
[oPanel setCanChooseFiles:NO];
|
||||
|
||||
wxCFStringRef cf( m_message );
|
||||
[oPanel setMessage:cf.AsNSString()];
|
||||
|
||||
if ( HasFlag(wxDD_NEW_DIR_BUTTON) )
|
||||
[oPanel setCanCreateDirectories:YES];
|
||||
|
||||
wxCFStringRef dir( m_path );
|
||||
|
||||
m_path = wxEmptyString;
|
||||
|
||||
if ( [oPanel runModalForDirectory:dir.AsNSString() file:nil types:nil] == NSOKButton )
|
||||
{
|
||||
wxCFStringRef resultpath( [[[oPanel filenames] objectAtIndex:0] retain] );
|
||||
|
||||
SetPath( resultpath.AsString() );
|
||||
result = wxID_OK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif // wxUSE_DIRDLG
|
386
src/osx/cocoa/filedlg.mm
Normal file
386
src/osx/cocoa/filedlg.mm
Normal file
@@ -0,0 +1,386 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/cocoa/filedlg.mm
|
||||
// Purpose: wxFileDialog for wxCocoa
|
||||
// Author: Ryan Norton
|
||||
// Modified by:
|
||||
// Created: 2004-10-02
|
||||
// RCS-ID: $Id: filedlg.mm 40007 2006-07-05 13:10:46Z SC $
|
||||
// Copyright: (c) Ryan Norton
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if wxUSE_FILEDLG
|
||||
|
||||
#include "wx/filedlg.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/app.h"
|
||||
#endif
|
||||
|
||||
#include "wx/filename.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
|
||||
|
||||
wxFileDialog::wxFileDialog(
|
||||
wxWindow *parent, const wxString& message,
|
||||
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
||||
long style, const wxPoint& pos, const wxSize& sz, const wxString& name)
|
||||
: wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos, sz, name)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NSArray* GetTypesFromFilter( const wxString filter )
|
||||
{
|
||||
NSMutableArray* types = nil;
|
||||
if ( !filter.empty() )
|
||||
{
|
||||
wxArrayString names ;
|
||||
wxArrayString extensions;
|
||||
|
||||
wxString filter2(filter) ;
|
||||
int filterIndex = 0;
|
||||
bool isName = true ;
|
||||
wxString current ;
|
||||
|
||||
for ( unsigned int i = 0; i < filter2.length() ; i++ )
|
||||
{
|
||||
if ( filter2.GetChar(i) == wxT('|') )
|
||||
{
|
||||
if ( isName )
|
||||
{
|
||||
names.Add( current ) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
extensions.Add( current ) ;
|
||||
++filterIndex ;
|
||||
}
|
||||
|
||||
isName = !isName ;
|
||||
current = wxEmptyString ;
|
||||
}
|
||||
else
|
||||
{
|
||||
current += filter2.GetChar(i) ;
|
||||
}
|
||||
}
|
||||
// we allow for compatibility reason to have a single filter expression (like *.*) without
|
||||
// an explanatory text, in that case the first part is name and extension at the same time
|
||||
|
||||
wxASSERT_MSG( filterIndex == 0 || !isName , wxT("incorrect format of format string") ) ;
|
||||
if ( current.empty() )
|
||||
extensions.Add( names[filterIndex] ) ;
|
||||
else
|
||||
extensions.Add( current ) ;
|
||||
if ( filterIndex == 0 || isName )
|
||||
names.Add( current ) ;
|
||||
|
||||
++filterIndex ;
|
||||
|
||||
const size_t extCount = extensions.GetCount();
|
||||
for ( size_t i = 0 ; i < extCount; i++ )
|
||||
{
|
||||
wxString extension = extensions[i];
|
||||
|
||||
// Remove leading '*'
|
||||
if (extension.length() && (extension.GetChar(0) == '*'))
|
||||
extension = extension.Mid( 1 );
|
||||
|
||||
// Remove leading '.'
|
||||
if (extension.length() && (extension.GetChar(0) == '.'))
|
||||
extension = extension.Mid( 1 );
|
||||
|
||||
if ( extension.IsEmpty() )
|
||||
{
|
||||
if ( types != nil )
|
||||
[types release];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
if ( types == nil )
|
||||
types = [[NSMutableArray alloc] init];
|
||||
|
||||
wxCFStringRef cfext(extension);
|
||||
[types addObject: (NSString*)cfext.AsNSString() ];
|
||||
#if 0
|
||||
wxUint32 fileType, creator;
|
||||
|
||||
// extension -> mactypes
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
int wxFileDialog::ShowModal()
|
||||
{
|
||||
int result = wxID_CANCEL;
|
||||
|
||||
NSSavePanel *panel = nil;
|
||||
|
||||
wxCFStringRef cf( m_message );
|
||||
|
||||
wxCFStringRef dir( m_path );
|
||||
wxCFStringRef file( m_fileName );
|
||||
|
||||
m_path = wxEmptyString;
|
||||
m_fileNames.Clear();
|
||||
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
{
|
||||
NSSavePanel* sPanel = [NSSavePanel savePanel];
|
||||
// makes things more convenient:
|
||||
[sPanel setCanCreateDirectories:YES];
|
||||
[sPanel setMessage:cf.AsNSString()];
|
||||
[sPanel setTreatsFilePackagesAsDirectories:NO];
|
||||
|
||||
if ( HasFlag(wxFD_OVERWRITE_PROMPT) )
|
||||
{
|
||||
}
|
||||
|
||||
if ( [sPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() ] == NSOKButton )
|
||||
{
|
||||
panel = sPanel;
|
||||
result = wxID_OK;
|
||||
|
||||
wxCFStringRef filename( [[sPanel filename] retain] );
|
||||
|
||||
m_path = filename.AsString();
|
||||
m_fileName = wxFileNameFromPath(m_path);
|
||||
m_dir = wxPathOnly( m_path );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray* types = GetTypesFromFilter( m_wildCard ) ;
|
||||
NSOpenPanel* oPanel = [NSOpenPanel openPanel];
|
||||
[oPanel setTreatsFilePackagesAsDirectories:NO];
|
||||
[oPanel setCanChooseDirectories:NO];
|
||||
[oPanel setResolvesAliases:YES];
|
||||
[oPanel setCanChooseFiles:YES];
|
||||
[oPanel setMessage:cf.AsNSString()];
|
||||
|
||||
if ( [oPanel runModalForDirectory:dir.AsNSString() file:file.AsNSString() types:types] == NSOKButton )
|
||||
{
|
||||
panel = oPanel;
|
||||
result = wxID_OK;
|
||||
NSArray* filenames = [oPanel filenames];
|
||||
for ( size_t i = 0 ; i < [filenames count] ; ++ i )
|
||||
{
|
||||
wxCFStringRef filename( [(NSString*) [filenames objectAtIndex:i] retain] );
|
||||
wxString fnstr = filename.AsString();
|
||||
m_paths.Add( fnstr );
|
||||
m_fileNames.Add( wxFileNameFromPath(fnstr) );
|
||||
if ( i == 0 )
|
||||
{
|
||||
m_path = fnstr;
|
||||
m_fileName = wxFileNameFromPath(fnstr);
|
||||
m_dir = wxPathOnly( fnstr );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( types != nil )
|
||||
[types release];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
wxASSERT(CreateBase(parent,wxID_ANY,pos,wxDefaultSize,style,wxDefaultValidator,wxDialogNameStr));
|
||||
|
||||
if ( parent )
|
||||
parent->AddChild(this);
|
||||
|
||||
m_cocoaNSWindow = nil;
|
||||
m_cocoaNSView = nil;
|
||||
|
||||
//Init the wildcard array
|
||||
m_wildcards = [[NSMutableArray alloc] initWithCapacity:0];
|
||||
|
||||
//If the user requests to save - use a NSSavePanel
|
||||
//else use a NSOpenPanel
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
{
|
||||
SetNSPanel([NSSavePanel savePanel]);
|
||||
|
||||
[GetNSSavePanel() setTitle:wxNSStringWithWxString(message)];
|
||||
|
||||
[GetNSSavePanel() setPrompt:@"Save"];
|
||||
[GetNSSavePanel() setTreatsFilePackagesAsDirectories:YES];
|
||||
[GetNSSavePanel() setCanSelectHiddenExtension:YES];
|
||||
|
||||
// Cached as per-app in obj-c
|
||||
// [GetNSSavePanel() setExtensionHidden:YES];
|
||||
|
||||
//
|
||||
// NB: Note that only Panther supports wildcards
|
||||
// with save dialogs - not that wildcards in save
|
||||
// dialogs are all that useful, anyway :)
|
||||
//
|
||||
}
|
||||
else //m_dialogStyle & wxFD_OPEN
|
||||
{
|
||||
SetNSPanel([NSOpenPanel openPanel]);
|
||||
[m_cocoaNSWindow setTitle:wxNSStringWithWxString(message)];
|
||||
|
||||
[(NSOpenPanel*)m_cocoaNSWindow setAllowsMultipleSelection:(HasFlag(wxFD_MULTIPLE))];
|
||||
[(NSOpenPanel*)m_cocoaNSWindow setResolvesAliases:YES];
|
||||
[(NSOpenPanel*)m_cocoaNSWindow setCanChooseFiles:YES];
|
||||
[(NSOpenPanel*)m_cocoaNSWindow setCanChooseDirectories:NO];
|
||||
[GetNSSavePanel() setPrompt:@"Open"];
|
||||
|
||||
//convert wildcards - open panel only takes file extensions -
|
||||
//no actual wildcards here :)
|
||||
size_t lastwcpos = 0;
|
||||
bool bDescription = true;
|
||||
size_t i;
|
||||
for(i = wildCard.find('|');
|
||||
i != wxString::npos;
|
||||
i = wildCard.find('|', lastwcpos+1))
|
||||
{
|
||||
size_t oldi = i;
|
||||
|
||||
if(!bDescription)
|
||||
{
|
||||
bDescription = !bDescription;
|
||||
|
||||
//work backwards looking for a period
|
||||
while(i != lastwcpos && wildCard[--i] != '.') {}
|
||||
|
||||
if(i == lastwcpos)
|
||||
{
|
||||
//no extension - can't use this wildcard
|
||||
lastwcpos = oldi;
|
||||
continue;
|
||||
}
|
||||
|
||||
[m_wildcards addObject:wxNSStringWithWxString(wildCard.substr(i+1, oldi-i-1))];
|
||||
}
|
||||
else
|
||||
bDescription = !bDescription;
|
||||
lastwcpos = oldi;
|
||||
}
|
||||
|
||||
if (!bDescription)
|
||||
{
|
||||
//get last wildcard
|
||||
size_t oldi = wildCard.length();
|
||||
i = oldi;
|
||||
|
||||
//work backwards looking for a period
|
||||
while(i != lastwcpos && wildCard[--i] != '.') {}
|
||||
|
||||
if(i != lastwcpos)
|
||||
[m_wildcards addObject:wxNSStringWithWxString(wildCard.substr(i+1, oldi-i-1))];
|
||||
}
|
||||
|
||||
if ([m_wildcards count] == 0)
|
||||
{
|
||||
[m_wildcards release];
|
||||
m_wildcards = nil;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wxFileDialog::~wxFileDialog()
|
||||
{
|
||||
[m_wildcards release];
|
||||
}
|
||||
|
||||
void wxFileDialog::GetPaths(wxArrayString& paths) const
|
||||
{
|
||||
paths.Empty();
|
||||
|
||||
wxString dir(m_dir);
|
||||
if ( m_dir.Last() != _T('\\') )
|
||||
dir += _T('\\');
|
||||
|
||||
size_t count = m_fileNames.GetCount();
|
||||
for ( size_t n = 0; n < count; n++ )
|
||||
{
|
||||
if (wxFileName(m_fileNames[n]).IsAbsolute())
|
||||
paths.Add(m_fileNames[n]);
|
||||
else
|
||||
paths.Add(dir + m_fileNames[n]);
|
||||
}
|
||||
}
|
||||
|
||||
void wxFileDialog::GetFilenames(wxArrayString& files) const
|
||||
{
|
||||
files = m_fileNames;
|
||||
}
|
||||
|
||||
void wxFileDialog::SetPath(const wxString& path)
|
||||
{
|
||||
wxString ext;
|
||||
wxSplitPath(path, &m_dir, &m_fileName, &ext);
|
||||
if ( !ext.empty() )
|
||||
m_fileName << _T('.') << ext;
|
||||
}
|
||||
|
||||
int wxFileDialog::ShowModal()
|
||||
{
|
||||
wxAutoNSAutoreleasePool thePool;
|
||||
|
||||
m_fileNames.Empty();
|
||||
|
||||
int nResult;
|
||||
|
||||
if (HasFlag(wxFD_SAVE))
|
||||
{
|
||||
nResult = [GetNSSavePanel()
|
||||
runModalForDirectory:wxNSStringWithWxString(m_dir)
|
||||
file:wxNSStringWithWxString(m_fileName)];
|
||||
|
||||
if (nResult == NSOKButton)
|
||||
{
|
||||
m_fileNames.Add(wxStringWithNSString([GetNSSavePanel() filename]));
|
||||
m_path = m_fileNames[0];
|
||||
}
|
||||
}
|
||||
else //m_dialogStyle & wxFD_OPEN
|
||||
{
|
||||
nResult = [(NSOpenPanel*)m_cocoaNSWindow
|
||||
runModalForDirectory:wxNSStringWithWxString(m_dir)
|
||||
file:wxNSStringWithWxString(m_fileName)
|
||||
types:m_wildcards];
|
||||
|
||||
if (nResult == NSOKButton)
|
||||
{
|
||||
for(unsigned i = 0; i < [[(NSOpenPanel*)m_cocoaNSWindow filenames] count]; ++i)
|
||||
{
|
||||
m_fileNames.Add(wxStringWithNSString([[(NSOpenPanel*)m_cocoaNSWindow filenames] objectAtIndex:(i)]));
|
||||
}
|
||||
|
||||
m_path = m_fileNames[0];
|
||||
}
|
||||
}
|
||||
|
||||
return nResult == NSOKButton ? wxID_OK : wxID_CANCEL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_FILEDLG
|
302
src/osx/cocoa/glcanvas.mm
Normal file
302
src/osx/cocoa/glcanvas.mm
Normal file
@@ -0,0 +1,302 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/osx/cocoa/glcanvas.mm
|
||||
// Purpose: wxGLCanvas, for using OpenGL with wxWidgets under Macintosh
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id: glcanvas.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if defined(__BORLANDC__)
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_GLCANVAS
|
||||
|
||||
#include "wx/glcanvas.h"
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/frame.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/settings.h"
|
||||
#endif
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
|
||||
WXGLContext WXGLCreateContext( WXGLPixelFormat pixelFormat, WXGLContext shareContext )
|
||||
{
|
||||
WXGLContext context = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext: shareContext];
|
||||
if ( !context )
|
||||
wxFAIL_MSG("NSOpenGLContext creation failed");
|
||||
return context ;
|
||||
}
|
||||
|
||||
void WXGLDestroyContext( WXGLContext context )
|
||||
{
|
||||
if ( context )
|
||||
{
|
||||
[context release];
|
||||
}
|
||||
}
|
||||
|
||||
void WXGLSwapBuffers( WXGLContext context )
|
||||
{
|
||||
[context flushBuffer];
|
||||
}
|
||||
|
||||
WXGLContext WXGLGetCurrentContext()
|
||||
{
|
||||
return [NSOpenGLContext currentContext];
|
||||
}
|
||||
|
||||
void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat )
|
||||
{
|
||||
if ( pixelFormat )
|
||||
{
|
||||
[pixelFormat release];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute data[512];
|
||||
const NSOpenGLPixelFormatAttribute defaultAttribs[] =
|
||||
{
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
(NSOpenGLPixelFormatAttribute)nil
|
||||
};
|
||||
|
||||
const NSOpenGLPixelFormatAttribute *attribs;
|
||||
if ( !attribList )
|
||||
{
|
||||
attribs = defaultAttribs;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned p = 0;
|
||||
data[p++] = NSOpenGLPFAMinimumPolicy; // make _SIZE tags behave more like GLX
|
||||
|
||||
for ( unsigned arg = 0; attribList[arg] !=0 && p < WXSIZEOF(data); )
|
||||
{
|
||||
switch ( attribList[arg++] )
|
||||
{
|
||||
case WX_GL_RGBA:
|
||||
//data[p++] = AGL_RGBA;
|
||||
break;
|
||||
|
||||
case WX_GL_BUFFER_SIZE:
|
||||
//data[p++] = AGL_BUFFER_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_LEVEL:
|
||||
//data[p++]=AGL_LEVEL;
|
||||
//data[p++]=attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_DOUBLEBUFFER:
|
||||
data[p++] = NSOpenGLPFADoubleBuffer;
|
||||
break;
|
||||
|
||||
case WX_GL_STEREO:
|
||||
data[p++] = NSOpenGLPFAStereo;
|
||||
break;
|
||||
|
||||
case WX_GL_AUX_BUFFERS:
|
||||
data[p++] = NSOpenGLPFAAuxBuffers;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_RED:
|
||||
data[p++] = NSOpenGLPFAColorSize;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_GREEN:
|
||||
//data[p++] = AGL_GREEN_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_BLUE:
|
||||
//data[p++] = AGL_BLUE_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_ALPHA:
|
||||
data[p++] = NSOpenGLPFAAlphaSize;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_DEPTH_SIZE:
|
||||
data[p++] = NSOpenGLPFADepthSize;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_STENCIL_SIZE:
|
||||
data[p++] = NSOpenGLPFAStencilSize;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_ACCUM_RED:
|
||||
data[p++] = NSOpenGLPFAAccumSize;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_ACCUM_GREEN:
|
||||
//data[p++] = AGL_ACCUM_GREEN_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_ACCUM_BLUE:
|
||||
//data[p++] = AGL_ACCUM_BLUE_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_MIN_ACCUM_ALPHA:
|
||||
//data[p++] = AGL_ACCUM_ALPHA_SIZE;
|
||||
//data[p++] = attribList[arg++];
|
||||
break;
|
||||
|
||||
case WX_GL_SAMPLE_BUFFERS:
|
||||
if ( !wxGLCanvas::IsAGLMultiSampleAvailable() )
|
||||
{
|
||||
if ( !attribList[arg++] )
|
||||
break;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
data[p++] = NSOpenGLPFASampleBuffers;
|
||||
if ( (data[p++] = attribList[arg++]) == true )
|
||||
{
|
||||
// don't use software fallback
|
||||
data[p++] = NSOpenGLPFANoRecovery;
|
||||
}
|
||||
break;
|
||||
|
||||
case WX_GL_SAMPLES:
|
||||
if ( !wxGLCanvas::IsAGLMultiSampleAvailable() )
|
||||
{
|
||||
if ( !attribList[arg++] )
|
||||
break;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
data[p++] = NSOpenGLPFASamples;
|
||||
data[p++] = attribList[arg++];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
data[p] = (NSOpenGLPixelFormatAttribute)nil;
|
||||
|
||||
attribs = data;
|
||||
}
|
||||
|
||||
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs];
|
||||
}
|
||||
|
||||
bool wxGLContext::SetCurrent(const wxGLCanvas& win) const
|
||||
{
|
||||
if ( !m_glContext )
|
||||
return false;
|
||||
|
||||
[m_glContext setView: win.GetHandle() ];
|
||||
|
||||
[m_glContext makeCurrentContext];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@interface wxNSCustomOpenGLView : NSView
|
||||
{
|
||||
wxWidgetImpl* impl;
|
||||
NSOpenGLContext* context;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame;
|
||||
- (void)setImplementation: (wxWidgetImpl *) theImplementation;
|
||||
- (wxWidgetImpl*) implementation;
|
||||
- (BOOL) isFlipped;
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSCustomOpenGLView
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
[super initWithFrame:frame];
|
||||
impl = NULL;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setImplementation: (wxWidgetImpl *) theImplementation
|
||||
{
|
||||
impl = theImplementation;
|
||||
}
|
||||
|
||||
- (wxWidgetImpl*) implementation
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isOpaque
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
bool wxGLCanvas::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name,
|
||||
const int *attribList,
|
||||
const wxPalette& WXUNUSED(palette))
|
||||
{
|
||||
m_glFormat = WXGLChoosePixelFormat(attribList);
|
||||
if ( !m_glFormat )
|
||||
return false;
|
||||
|
||||
m_macIsUserPane = false ;
|
||||
|
||||
if ( !wxWindow::Create(parent, id, pos, size, style, name) )
|
||||
return false;
|
||||
|
||||
|
||||
NSView* sv = (parent->GetHandle() );
|
||||
|
||||
NSRect r = wxOSXGetFrameForControl( this, pos , size ) ;
|
||||
wxNSCustomOpenGLView* v = [[wxNSCustomOpenGLView alloc] initWithFrame:r];
|
||||
[sv addSubview:v];
|
||||
m_peer = new wxWidgetCocoaImpl( this, v );
|
||||
[v setImplementation:m_peer];
|
||||
|
||||
MacPostControlCreate(pos, size) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif // wxUSE_GLCANVAS
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mac/cocoa/nonownedwnd.mm
|
||||
// Name: src/osx/cocoa/nonownedwnd.mm
|
||||
// Purpose: non owned window for cocoa
|
||||
// Author: DavidStefan Csomor
|
||||
// Modified by:
|
||||
|
98
src/osx/cocoa/spinbutt.mm
Normal file
98
src/osx/cocoa/spinbutt.mm
Normal file
@@ -0,0 +1,98 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: spinbutt.cpp
|
||||
// Purpose: wxSpinButton
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
// Created: 1998-01-01
|
||||
// RCS-ID: $Id: spinbutt.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||
// Copyright: (c) Stefan Csomor
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if wxUSE_SPINBTN
|
||||
|
||||
#include "wx/spinbutt.h"
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
@interface wxNSStepper : NSStepper
|
||||
{
|
||||
wxWidgetImpl* impl;
|
||||
}
|
||||
|
||||
- (void)setImplementation: (wxWidgetImpl *) theImplementation;
|
||||
- (wxWidgetImpl*) implementation;
|
||||
- (BOOL) isFlipped;
|
||||
- (void) clickedAction: (id) sender;
|
||||
|
||||
@end
|
||||
|
||||
@implementation wxNSStepper
|
||||
|
||||
- (id)initWithFrame:(NSRect)frame
|
||||
{
|
||||
[super initWithFrame:frame];
|
||||
impl = NULL;
|
||||
[self setTarget: self];
|
||||
[self setAction: @selector(clickedAction:)];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) clickedAction: (id) sender
|
||||
{
|
||||
if ( impl )
|
||||
{
|
||||
wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
|
||||
if ( wxpeer )
|
||||
wxpeer->HandleClicked(0);
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setImplementation: (wxWidgetImpl *) theImplementation
|
||||
{
|
||||
impl = theImplementation;
|
||||
}
|
||||
|
||||
- (wxWidgetImpl*) implementation
|
||||
{
|
||||
return impl;
|
||||
}
|
||||
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer,
|
||||
wxWindowMac* parent,
|
||||
wxWindowID id,
|
||||
wxInt32 value,
|
||||
wxInt32 minimum,
|
||||
wxInt32 maximum,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
long extraStyle)
|
||||
{
|
||||
NSView* sv = (wxpeer->GetParent()->GetHandle() );
|
||||
|
||||
NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
|
||||
wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r];
|
||||
|
||||
[v setMinValue: minimum];
|
||||
[v setMaxValue: maximum];
|
||||
[v setIntValue: value];
|
||||
|
||||
if ( style & wxSP_WRAP )
|
||||
[v setValueWraps:YES];
|
||||
|
||||
[sv addSubview:v];
|
||||
wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
|
||||
[v setImplementation:c];
|
||||
return c;
|
||||
}
|
||||
|
||||
#endif // wxUSE_SPINBTN
|
1397
src/osx/cocoa/toolbar.mm
Normal file
1397
src/osx/cocoa/toolbar.mm
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: src/mac/cocoa/utils.mm
|
||||
// Name: src/osx/cocoa/utils.mm
|
||||
// Purpose: various cocoa utility functions
|
||||
// Author: Stefan Csomor
|
||||
// Modified by:
|
||||
|
@@ -532,12 +532,15 @@ void wxWidgetCocoaImpl::GetBestRect( wxRect *r ) const
|
||||
|
||||
bool wxWidgetCocoaImpl::IsEnabled() const
|
||||
{
|
||||
return [m_osxView enable];
|
||||
if ( [m_osxView respondsToSelector:@selector(isEnabled) ] )
|
||||
return [m_osxView isEnabled];
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::Enable( bool enable )
|
||||
{
|
||||
[m_osxView setEnabled:enable];
|
||||
if ( [m_osxView respondsToSelector:@selector(setEnabled:) ] )
|
||||
[m_osxView setEnabled:enable];
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::PulseGauge()
|
||||
@@ -548,6 +551,36 @@ void wxWidgetCocoaImpl::SetScrollThumb( wxInt32 val, wxInt32 view )
|
||||
{
|
||||
}
|
||||
|
||||
void wxWidgetCocoaImpl::SetControlSize( wxWindowVariant variant )
|
||||
{
|
||||
NSControlSize size = NSRegularControlSize;
|
||||
|
||||
switch ( variant )
|
||||
{
|
||||
case wxWINDOW_VARIANT_NORMAL :
|
||||
size = NSRegularControlSize;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_SMALL :
|
||||
size = NSSmallControlSize;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_MINI :
|
||||
size = NSMiniControlSize;
|
||||
break ;
|
||||
|
||||
case wxWINDOW_VARIANT_LARGE :
|
||||
size = NSRegularControlSize;
|
||||
break ;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(_T("unexpected window variant"));
|
||||
break ;
|
||||
}
|
||||
if ( [m_osxView respondsToSelector:@selector(setControlSize:)] )
|
||||
[m_osxView setControlSize:size];
|
||||
}
|
||||
|
||||
//
|
||||
// Factory methods
|
||||
//
|
||||
|
Reference in New Issue
Block a user