//begin wxmac
GrafPtr m_macPort ;
+ GWorldPtr m_macMask ;
// in order to preserve the const inheritance of the virtual functions, we have to
// use mutable variables starting from CWPro 5
// --------------
bool IsModalShowing() const { return m_modalShowing; }
+ virtual bool IsTopLevel() const { return TRUE; }
// tooltip management
#if wxUSE_TOOLTIPS
const wxString& name = wxFrameNameStr);
virtual bool Destroy();
+ virtual bool IsTopLevel() const { return TRUE; }
void OnSize(wxSizeEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
// operations
virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
+ // events
+ void OnPaint( wxPaintEvent &event ) ;
+ wxSize DoGetBestSize() const ;
+ private :
+ wxString m_label ;
+
+ DECLARE_EVENT_TABLE()
};
#endif
virtual void MacFireMouseEvent( EventRecord *ev ) ;
virtual bool MacDispatchMouseEvent(wxMouseEvent& event ) ;
virtual void MacEraseBackground( Rect *rect ) ;
+ virtual void MacPaint( wxPaintEvent &event ) ;
WindowRef GetMacRootWindow() const ;
virtual ControlHandle MacGetContainerForEmbedding() ;
virtual void MacSuperChangedPosition() ;
+ virtual void MacSuperShown( bool show ) ;
bool MacSetupFocusPort() ;
bool MacSetupDrawingPort() ;
virtual ~wxBitmap();
// GRG, Dic/99
- wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect ) const;
+ wxBitmap GetSubBitmap( const wxRect& rect ) const;
// copies the contents and mask of the given (colour) icon to the bitmap
bool CopyFromIcon(const wxIcon& icon);
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame((wxFrame *)NULL, -1, title, pos, size)
{
+#ifdef __WXMAC__
+ // we need this in order to allow the about menu relocation, since ABOUT is not the default id of the about menu
+ wxApp::s_macAboutMenuItemId = Minimal_About ;
+#endif
+
// set the frame icon
SetIcon(wxICON(mondrian));
// create a menu bar
wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
+#ifdef __WXMAC__
+ // since the about should be in the help menu for auto-relocation we have to do a little more...
+ wxMenu *helpMenu = new wxMenu("", wxMENU_TEAROFF);
+ helpMenu->Append(Minimal_About, "&About...\tCntrl+A", "Show about dialog");
+#else
menuFile->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
menuFile->AppendSeparator();
- menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
+#endif
+ menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
// now append the freshly created menu to the menu bar...
wxMenuBar *menuBar = new wxMenuBar();
menuBar->Append(menuFile, "&File");
+#ifdef __WXMAC__
+ menuBar->Append(helpMenu, "&Help");
+#endif
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
#ifndef WX_TIMEZONE
#if defined(__BORLANDC__) || defined(__MINGW32__) || defined(__VISAGECPP__)
#define WX_TIMEZONE _timezone
- #elif defined(__WXMAC__)
- long wxmac_timezone = 28800;
- #define WX_TIMEZONE wxmac_timezone ;
+ #elif defined(__MWERKS__)
+ long wxmw_timezone = 28800;
+ #define WX_TIMEZONE wxmw_timezone ;
#else // unknown platform - try timezone
#define WX_TIMEZONE timezone
#endif
{
for(i=0; i<width; i++ )
{
- if( (*(ptdata++)!=r) | (*(ptdata++)!=g) | (*(ptdata++)!=b) )
+ // was causing a code gen bug in cw : if( ( cr !=r) || (cg!=g) || (cb!=b) )
+ unsigned char cr = (*(ptdata++)) ;
+ unsigned char cg = (*(ptdata++)) ;
+ unsigned char cb = (*(ptdata++)) ;
+
+ if( ( cr !=r) || (cg!=g) || (cb!=b) )
{
*(ptbits++) = one;
*(ptbits++) = one;
SetGWorld( origPort , origDevice ) ;
+ if ( HasMask() )
+ {
+ wxColour colour( GetMaskRed(), GetMaskGreen(), GetMaskBlue());
+ wxMask *mask = new wxMask( bitmap, colour );
+ bitmap.SetMask( mask );
+ }
return bitmap;
}
wxMask::wxMask()
{
-/* TODO
m_maskBitmap = 0;
-*/
}
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
{
-/* TODO
m_maskBitmap = 0;
-*/
Create(bitmap, colour);
}
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
{
-/* TODO
m_maskBitmap = 0;
-*/
-
Create(bitmap, paletteIndex);
}
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask::wxMask(const wxBitmap& bitmap)
{
-/* TODO
m_maskBitmap = 0;
-*/
-
Create(bitmap);
}
wxMask::~wxMask()
{
-// TODO: delete mask bitmap
+ if ( m_maskBitmap )
+ {
+ wxMacDestroyGWorld( m_maskBitmap ) ;
+ m_maskBitmap = NULL ;
+ }
}
// Create a mask from a mono bitmap (copies the bitmap).
// the transparent area
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
{
-// TODO
- return FALSE;
+ if ( m_maskBitmap )
+ {
+ wxMacDestroyGWorld( m_maskBitmap ) ;
+ m_maskBitmap = NULL ;
+ }
+ wxASSERT( ((wxBitmapRefData*) bitmap.GetRefData())->m_bitmapType == kMacBitmapTypeGrafWorld ) ;
+ // other types would require a temporary bitmap. not yet implemented
+
+ if (!bitmap.Ok())
+ {
+ return FALSE;
+ }
+
+ m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
+ RGBColor maskColor = colour.GetPixel() ;
+
+ // this is not very efficient, but I can't think
+ // of a better way of doing it
+ CGrafPtr origPort ;
+ GDHandle origDevice ;
+
+ GetGWorld( &origPort , &origDevice ) ;
+ for (int w = 0; w < bitmap.GetWidth(); w++)
+ {
+ for (int h = 0; h < bitmap.GetHeight(); h++)
+ {
+ RGBColor colors[2] = {
+ { 0xFFFF , 0xFFFF , 0xFFFF } ,
+ { 0, 0 , 0 }
+ } ;
+
+ SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
+ RGBColor col ;
+ GetCPixel( w , h , &col ) ;
+ SetGWorld( m_maskBitmap , NULL ) ;
+ if (col.red == maskColor.red && col.blue == maskColor.blue && col.green == maskColor.green)
+ {
+ SetCPixel( w , h , &colors[0] ) ;
+ }
+ else
+ {
+ SetCPixel( w , h , &colors[1] ) ;
+ }
+ }
+ }
+ SetGWorld( origPort , origDevice ) ;
+
+ return TRUE;
}
/*
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
- m_macHorizontalBorder = 2 ; // additional pixels around the real control
- m_macVerticalBorder = 2 ;
+ m_macHorizontalBorder = 0 ; // additional pixels around the real control
+ m_macVerticalBorder = 0 ;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
wxMask::wxMask()
{
-/* TODO
m_maskBitmap = 0;
-*/
}
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
{
-/* TODO
m_maskBitmap = 0;
-*/
Create(bitmap, colour);
}
// the transparent area
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
{
-/* TODO
m_maskBitmap = 0;
-*/
-
Create(bitmap, paletteIndex);
}
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask::wxMask(const wxBitmap& bitmap)
{
-/* TODO
m_maskBitmap = 0;
-*/
-
Create(bitmap);
}
wxMask::~wxMask()
{
-// TODO: delete mask bitmap
+ if ( m_maskBitmap )
+ {
+ wxMacDestroyGWorld( m_maskBitmap ) ;
+ m_maskBitmap = NULL ;
+ }
}
// Create a mask from a mono bitmap (copies the bitmap).
// the transparent area
bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
{
-// TODO
- return FALSE;
+ if ( m_maskBitmap )
+ {
+ wxMacDestroyGWorld( m_maskBitmap ) ;
+ m_maskBitmap = NULL ;
+ }
+ wxASSERT( ((wxBitmapRefData*) bitmap.GetRefData())->m_bitmapType == kMacBitmapTypeGrafWorld ) ;
+ // other types would require a temporary bitmap. not yet implemented
+
+ if (!bitmap.Ok())
+ {
+ return FALSE;
+ }
+
+ m_maskBitmap = wxMacCreateGWorld( bitmap.GetWidth() , bitmap.GetHeight() , 1 ) ;
+ RGBColor maskColor = colour.GetPixel() ;
+
+ // this is not very efficient, but I can't think
+ // of a better way of doing it
+ CGrafPtr origPort ;
+ GDHandle origDevice ;
+
+ GetGWorld( &origPort , &origDevice ) ;
+ for (int w = 0; w < bitmap.GetWidth(); w++)
+ {
+ for (int h = 0; h < bitmap.GetHeight(); h++)
+ {
+ RGBColor colors[2] = {
+ { 0xFFFF , 0xFFFF , 0xFFFF } ,
+ { 0, 0 , 0 }
+ } ;
+
+ SetGWorld( ((wxBitmapRefData*) bitmap.GetRefData())->m_hBitmap , NULL ) ;
+ RGBColor col ;
+ GetCPixel( w , h , &col ) ;
+ SetGWorld( m_maskBitmap , NULL ) ;
+ if (col.red == maskColor.red && col.blue == maskColor.blue && col.green == maskColor.green)
+ {
+ SetCPixel( w , h , &colors[0] ) ;
+ }
+ else
+ {
+ SetCPixel( w , h , &colors[1] ) ;
+ }
+ }
+ }
+ SetGWorld( origPort , origDevice ) ;
+
+ return TRUE;
}
/*
if ( height == -1 && bitmap.Ok())
height = bitmap.GetHeight() + 2*m_marginY;
- m_macHorizontalBorder = 2 ; // additional pixels around the real control
- m_macVerticalBorder = 2 ;
+ m_macHorizontalBorder = 0 ; // additional pixels around the real control
+ m_macVerticalBorder = 0 ;
Rect bounds ;
Str255 title ;
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
void wxCheckBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
{
SetValue( !GetValue() ) ;
+ wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
+ event.SetInt(GetValue());
+ event.SetEventObject(this);
+ ProcessCommand(event);
}
// Bitmap checkbox
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0,
- kControlPopupButtonProc , (long) this ) ;
+ m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
+ kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
#include "wx/tabctrl.h"
#include "wx/spinbutt.h"
-IMPLEMENT_ABSTRACT_CLASS(wxControl, wxControlBase)
+IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxControlBase)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
void wxControl::MacSuperShown( bool show )
{
- /*
if ( m_macControl )
{
if ( !show )
}
else
{
- if ( m_macShown )
+ if ( m_isShown )
::UMAShowControl( m_macControl ) ;
}
}
wxWindow::MacSuperShown( show ) ;
- */
}
void wxControl::DoSetSize(int x, int y,
wxColour wxNullColour;
// Default window names
-const char *wxButtonNameStr = "button";
-const char *wxCanvasNameStr = "canvas";
-const char *wxCheckBoxNameStr = "check";
-const char *wxChoiceNameStr = "choice";
-const char *wxComboBoxNameStr = "comboBox";
-const char *wxDialogNameStr = "dialog";
-const char *wxFrameNameStr = "frame";
-const char *wxGaugeNameStr = "gauge";
-const char *wxStaticBoxNameStr = "groupBox";
-const char *wxListBoxNameStr = "listBox";
-const char *wxStaticTextNameStr = "message";
-const char *wxStaticBitmapNameStr = "message";
-const char *wxMultiTextNameStr = "multitext";
-const char *wxPanelNameStr = "panel";
-const char *wxRadioBoxNameStr = "radioBox";
-const char *wxRadioButtonNameStr = "radioButton";
-const char *wxBitmapRadioButtonNameStr = "radioButton";
-const char *wxScrollBarNameStr = "scrollBar";
-const char *wxSliderNameStr = "slider";
-const char *wxStaticNameStr = "static";
-const char *wxTextCtrlWindowNameStr = "textWindow";
-const char *wxTextCtrlNameStr = "text";
-const char *wxVirtListBoxNameStr = "virtListBox";
-const char *wxButtonBarNameStr = "buttonbar";
-const char *wxEnhDialogNameStr = "Shell";
-const char *wxToolBarNameStr = "toolbar";
-const char *wxStatusLineNameStr = "status_line";
-
-const char *wxGetTextFromUserPromptStr = "Input Text";
-const char *wxMessageBoxCaptionStr = "Message";
-const char *wxFileSelectorPromptStr = "Select a file";
-const char *wxFileSelectorDefaultWildcardStr = "*.*";
-const char *wxInternalErrorStr = "wxWindows Internal Error";
-const char *wxFatalErrorStr = "wxWindows Fatal Error";
+const wxChar *wxButtonNameStr = wxT("button");
+const wxChar *wxCanvasNameStr = wxT("canvas");
+const wxChar *wxCheckBoxNameStr = wxT("check");
+const wxChar *wxChoiceNameStr = wxT("choice");
+const wxChar *wxComboBoxNameStr = wxT("comboBox");
+const wxChar *wxDialogNameStr = wxT("dialog");
+const wxChar *wxFrameNameStr = wxT("frame");
+const wxChar *wxGaugeNameStr = wxT("gauge");
+const wxChar *wxStaticBoxNameStr = wxT("groupBox");
+const wxChar *wxListBoxNameStr = wxT("listBox");
+const wxChar *wxStaticTextNameStr = wxT("message");
+const wxChar *wxStaticBitmapNameStr = wxT("message");
+const wxChar *wxMultiTextNameStr = wxT("multitext");
+const wxChar *wxPanelNameStr = wxT("panel");
+const wxChar *wxRadioBoxNameStr = wxT("radioBox");
+const wxChar *wxRadioButtonNameStr = wxT("radioButton");
+const wxChar *wxBitmapRadioButtonNameStr = wxT("radioButton");
+const wxChar *wxScrollBarNameStr = wxT("scrollBar");
+const wxChar *wxSliderNameStr = wxT("slider");
+const wxChar *wxStaticNameStr = wxT("static");
+const wxChar *wxTextCtrlWindowNameStr = wxT("textWindow");
+const wxChar *wxTextCtrlNameStr = wxT("text");
+const wxChar *wxVirtListBoxNameStr = wxT("virtListBox");
+const wxChar *wxButtonBarNameStr = wxT("buttonbar");
+const wxChar *wxEnhDialogNameStr = wxT("Shell");
+const wxChar *wxToolBarNameStr = wxT("toolbar");
+const wxChar *wxStatusLineNameStr = wxT("status_line");
+
+const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text");
+const wxChar *wxMessageBoxCaptionStr = wxT("Message");
+const wxChar *wxFileSelectorPromptStr = wxT("Select a file");
+const wxChar *wxFileSelectorDefaultWildcardStr = wxT("*.*");
+const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
+const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
+const wxChar *wxTreeCtrlNameStr = wxT("treeCtrl");
+const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
+const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
// See wx/utils.h
-const char *wxFloatToStringStr = "%.2f";
-const char *wxDoubleToStringStr = "%.2f";
+const wxChar *wxFloatToStringStr = wxT("%.2f");
+const wxChar *wxDoubleToStringStr = wxT("%.2f");
const wxSize wxDefaultSize(-1, -1);
const wxPoint wxDefaultPosition(-1, -1);
// m_palette = wxAPP_COLOURMAP;
m_macPort = NULL ;
+ m_macMask = NULL ;
m_ok = FALSE ;
m_macFontInstalled = false ;
RGBColor black = { 0,0,0} ;
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
- // RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
- // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
bmappixels = GetGWorldPixMap( bmapworld ) ;
if ( LockPixels(bmappixels) )
dest.left = XLOG2DEV(x) ;
dest.bottom = YLOG2DEV(y + bmap->m_height ) ;
dest.right = XLOG2DEV(x + bmap->m_width ) ;
- // ::ClipRect(&m_macClipRect);
- CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
- &source, &dest, srcCopy, NULL ) ;
- /*
- if ( m_clipping )
- {
- long x1 = XLOG2DEV(m_clipX1);
- long y1 = YLOG2DEV(m_clipY1);
- long x2 = XLOG2DEV(m_clipX2);
- long y2 = YLOG2DEV(m_clipY2);
- Rect clip = { y1 , x1 , y2 , x2 } ;
- ::ClipRect(&clip);
+ if ( useMask && bmp.GetMask() )
+ {
+ if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) )
+ {
+ CopyMask( &GrafPtr( bmapworld )->portBits , &GrafPtr( bmp.GetMask()->GetMaskBitmap( ) )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &source, &source , &dest ) ;
+ UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
+ }
}
- */
+ else
+ CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &source, &dest, srcCopy, NULL ) ;
+
UnlockPixels( bmappixels ) ;
}
m_macPenInstalled = false ;
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
RGBColor black = { 0,0,0} ;
-// RGBForeColor( &black ) ;
-// RGBBackColor( &white ) ;
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
dstrect.left = XLOG2DEV(xdest) ;
dstrect.bottom = YLOG2DEV(ydest + height ) ;
dstrect.right = XLOG2DEV(xdest + width ) ;
-// ::ClipRect(&m_macClipRect);
+
+ short mode = (logical_func == wxCOPY ? srcCopy :
+ // logical_func == wxCLEAR ? WHITENESS :
+ // logical_func == wxSET ? BLACKNESS :
+ logical_func == wxINVERT ? hilite :
+ // logical_func == wxAND ? MERGECOPY :
+ logical_func == wxOR ? srcOr :
+ logical_func == wxSRC_INVERT ? notSrcCopy :
+ logical_func == wxXOR ? srcXor :
+ // logical_func == wxOR_REVERSE ? MERGEPAINT :
+ // logical_func == wxAND_REVERSE ? SRCERASE :
+ logical_func == wxSRC_OR ? srcOr :
+ // logical_func == wxSRC_AND ? SRCAND :
+ srcCopy );
+
+ if ( useMask && source->m_macMask )
+ {
+ wxASSERT( mode == srcCopy ) ;
+ if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) )
+ {
+ CopyMask( &GrafPtr( sourcePort )->portBits , &GrafPtr( source->m_macMask )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &srcrect, &srcrect , &dstrect ) ;
+ UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
+ }
+ }
+ else
+ {
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits ,
- &srcrect, &dstrect, srcCopy, NULL ) ;
-/*
- if ( m_clipping )
- {
- long x1 = XLOG2DEV(m_clipX1);
- long y1 = YLOG2DEV(m_clipY1);
- long x2 = XLOG2DEV(m_clipX2);
- long y2 = YLOG2DEV(m_clipY2);
-
- Rect clip = { y1 , x1 , y2 , x2 } ;
- ::ClipRect(&clip);
- }
-*/
+ &srcrect, &dstrect, mode, NULL ) ;
+ }
UnlockPixels( bmappixels ) ;
}
if ( bmap->m_hBitmap )
{
m_macPort = (GrafPtr) bmap->m_hBitmap ;
+ wxMask * mask = bitmap.GetMask() ;
+ if ( mask )
+ {
+ m_macMask = mask->GetMaskBitmap() ;
+ }
MacSetupPort() ;
m_ok = TRUE ;
// SetBackground(wxBrush(*wxWHITE, wxSOLID));
UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
- (**m_macList).selFlags = lOnlyOne ;
- if ( style & wxLB_MULTIPLE )
+ (**m_macList).selFlags = 0 ;
+ if ( style & wxLB_MULTIPLE )
{
(**m_macList).selFlags += lNoExtend ;
}
{
(**m_macList).selFlags += lExtendDrag ;
}
+ else
+ {
+ (**m_macList).selFlags = lOnlyOne ;
+ }
Point pt = (**m_macList).cellSize ;
pt.v = 14 ;
LCellSize( pt , m_macList ) ;
}
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
m_stringArray.Remove( N ) ;
+ m_dataArray.Remove( N ) ;
m_noItems --;
MacDelete( N ) ;
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
- Append( choices[i] , clientData[0] ) ;
+ Append( choices[i] , clientData[i] ) ;
#endif
}
else
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
}
#endif // wxUSE_OWNER_DRAWN
- m_dataArray[N] = (char*) Client_data ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
+
+ if ( m_dataArray.GetCount() > N )
+ {
+ m_dataArray[N] = (char*) Client_data ;
+ }
+ else
+ {
+ m_dataArray.Add( (char*) Client_data ) ;
+ }
}
void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
-void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts )
+void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemText , bool useShortcuts )
{
char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ;
char macShortCut = 0 ;
+ const char *inItemName ;
+ wxString inItemTextMac ;
+
+ if (wxApp::s_macDefaultEncodingIsPC)
+ {
+ inItemTextMac = wxMacMakeMacStringFromPC( inItemText ) ;
+ inItemName = inItemTextMac ;
+ }
+ else
+ {
+ inItemName = inItemText ;
+ }
if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts )
useShortcuts = false ;
inItemName = inItemName + 5;
macShortCut = *inItemName;
}
+ else if (strncmp("Cntrl", inItemName, 5) == 0)
+ {
+ inItemName = inItemName + 6;
+ macShortCut = *inItemName;
+ }
else if (strncmp("Alt", inItemName, 3) == 0)
{
inItemName = inItemName + 4;
wxMenu* menu = m_menus[i] , *subMenu = NULL ;
- if( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
+ if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
{
MenuHandle mh = NULL ;
if ( HMGetHelpMenuHandle( &mh ) != noErr )
}
else
{
- Str255 label ;
- wxMacBuildMenuString( label , NULL , NULL , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
- if ( label[0] == 0 )
+ if ( item->IsSeparator() )
{
- // we cannot add empty menus on mac
- label[0] = 1 ;
- label[1] = ' ' ;
+ if ( mh )
+ ::AppendMenu(mh, "\p-" );
}
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
- // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- }
else
{
- if ( mh )
- ::AppendMenu(mh, label );
+ Str255 label ;
+ wxMacBuildMenuString( label , NULL , NULL , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
+ if ( label[0] == 0 )
+ {
+ // we cannot add empty menus on mac
+ label[0] = 1 ;
+ label[1] = ' ' ;
+ }
+ if ( item->GetId() == wxApp::s_macAboutMenuItemId )
+ {
+ ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
+ // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
+ ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
+ }
+ else
+ {
+ if ( mh )
+ ::AppendMenu(mh, label );
+ }
}
}
}
for (int i = 0; i < m_menus.GetCount() ; i++)
{
if ( m_menus[i]->MacGetMenuId() == macMenuId ||
- ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) )
+ ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) )
)
{
if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) )
Str255 pascalTitle ;
Str255 pascalText ;
- strcpy( (char*) pascalTitle , m_caption ) ;
+
+ if (wxApp::s_macDefaultEncodingIsPC)
+ {
+ strcpy( (char*) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
+ strcpy( (char*) pascalText , wxMacMakeMacStringFromPC( m_message) ) ;
+ }
+ else
+ {
+ strcpy( (char*) pascalTitle , m_caption ) ;
+ strcpy( (char*) pascalText , m_message ) ;
+ }
+
c2pstr( (char*) pascalTitle ) ;
- strcpy( (char*) pascalText , m_message ) ;
wxMacConvertNewlines( (char*)pascalText ,(char*) pascalText) ;
c2pstr( (char*) pascalText ) ;
+ wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ;
+
if ( !UMAHasAppearance() )
{
int resourceID ;
//-------------------------------------------------------------------------------------
// Simulates the effect of the user issuing a command to the item
-#define RADIO_SIZE 20
+#define RADIO_SIZE 40
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
int x_current, y_current;
int x_offset,y_offset;
+ int widthOld, heightOld;
+ GetSize(&widthOld, &heightOld);
x_offset = x;
y_offset = y;
totHeight = GetNumVer() * (maxHeight + charHeight/2) + charHeight*3/2;
totWidth = GetNumHor() * (maxWidth + charWidth) + charWidth;
- wxControl::DoSetSize(x_offset,y_offset,totWidth,totHeight,wxSIZE_AUTO);
+ // only change our width/height if asked for
+ if ( width == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ width = totWidth ;
+ else
+ width = widthOld;
+ }
+
+ if ( height == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ height = totHeight ;
+ else
+ height = heightOld;
+ }
+
+ wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
// arrange radiobuttons
void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
{
SetValue(true) ;
+ wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
+ event.SetEventObject(this);
+ ProcessCommand(event);
}
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
#include <wx/mac/uma.h>
+BEGIN_EVENT_TABLE(wxStaticText, wxControl)
+ EVT_PAINT(wxStaticText::OnPaint)
+END_EVENT_TABLE()
+
+bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
+ const wxString& label,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ SetName(name);
+ m_backgroundColour = parent->GetBackgroundColour() ;
+ m_foregroundColour = parent->GetForegroundColour() ;
+
+ if ( id == -1 )
+ m_windowId = (int)NewControlId();
+ else
+ m_windowId = id;
+
+ m_windowStyle = style;
+ m_label = label ;
+
+ bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
+ SetSizeOrDefault( size ) ;
+
+ return ret;
+}
+
+void wxStaticText::OnPaint( wxPaintEvent &event )
+{
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+ dc.Clear() ;
+ dc.DrawText( m_label , 0 , 0 ) ;
+}
+
+wxSize wxStaticText::DoGetBestSize() const
+{
+ int x , y ;
+ GetTextExtent( m_label , &x , &y ) ;
+ return wxSize( x , y ) ;
+}
+
+void wxStaticText::SetLabel(const wxString& st , bool resize )
+{
+ SetTitle( st ) ;
+ m_label = st ;
+ if ( resize )
+ SetSizeOrDefault() ;
+ else
+ Refresh() ;
+}
+/*
+void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ wxControl::SetSize( x , y , width , height , sizeFlags ) ;
+}
+
bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ;
Refresh() ;
}
+*/
ControlHandle m_macToolHandle ;
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( tool->CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+
if ( icon )
{
m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 ,
- kControlBehaviorOffsetContents + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ behaviour + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
ControlButtonContentInfo info ;
info.contentType = kControlContentPictHandle ;
else
{
m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 ,
- kControlBehaviorOffsetContents , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
}
m_macToolHandles.Add( m_macToolHandle ) ;
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
{
wxToolBarTool *tool = (wxToolBarTool *)t;
+ ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
+ if ( UMAHasAppearance() )
+ {
+ if ( enable )
+ ::ActivateControl( control ) ;
+ else
+ ::DeactivateControl( control ) ;
+ }
+ else
+ {
+ if ( enable )
+ ::HiliteControl( control , 0 ) ;
+ else
+ ::HiliteControl( control , 255 ) ;
+ }
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{
wxToolBarTool *tool = (wxToolBarTool *)t;
- // TODO: set toggle state
+
+ ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
+ ::SetControlValue( control , toggle ) ;
}
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
UMAHideWindow( m_macWindowData->m_macWindow ) ;
}
}
+ MacSuperShown( show ) ;
Refresh() ;
return TRUE;
}
+void wxWindow::MacSuperShown( bool show )
+{
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ if ( child->m_isShown )
+ child->MacSuperShown( show ) ;
+ node = node->Next();
+ }
+}
+
int wxWindow::GetCharHeight() const
{
wxClientDC dc ( (wxWindow*)this ) ;
}
}
+void wxWindow::MacPaint( wxPaintEvent &event )
+{
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) )
+ {
+ bool sunken = HasFlag( wxSUNKEN_BORDER ) ;
+
+ wxPen m_penButton3DShadow( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DSHADOW ), 1, wxSOLID ) ;
+ wxPen m_penButton3DFace( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DFACE ), 1, wxSOLID ) ;
+
+ wxPen wxPen1 = sunken ? *wxWHITE_PEN : *wxBLACK_PEN;
+ wxPen wxPen2 = sunken ? m_penButton3DShadow : m_penButton3DShadow;
+ wxPen wxPen3 = sunken ? m_penButton3DFace : m_penButton3DShadow;
+ wxPen wxPen4 = sunken ? *wxBLACK_PEN : *wxWHITE_PEN;
+
+ dc.SetPen(wxPen1);
+ dc.DrawRectangle(0, 0, m_width, m_height); // outer - right and button
+
+ dc.SetPen(wxPen2);
+ dc.DrawRectangle(1, 1, m_width-1, m_height-1); // outer - left and top
+
+ dc.SetPen(wxPen3);
+ dc.DrawRectangle(0, 0, m_width-2, m_height-2); // inner - right and button
+
+ dc.SetPen(wxPen4);
+ dc.DrawLine(0, 0, m_width-3, 0); // inner - left and top
+ dc.DrawLine(0, 0, 0, m_height-3);
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
+ dc.SetPen(*wxBLACK_PEN);
+ dc.DrawRectangle(0, 0, m_width, m_height);
+ }
+}
+
// New function that will replace some of the above.
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh)
event.m_timeStamp = time ;
event.SetEventObject(this);
+ wxPaintEvent event2( event ) ;
GetEventHandler()->ProcessEvent(event);
+ MacPaint( event2 ) ;
RgnHandle childupdate = NewRgn() ;
void wxCheckBox::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
{
SetValue( !GetValue() ) ;
+ wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
+ event.SetInt(GetValue());
+ event.SetEventObject(this);
+ ProcessCommand(event);
}
// Bitmap checkbox
MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
- m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0,
- kControlPopupButtonProc , (long) this ) ;
+ m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , -12345 , 0 ,
+ kControlPopupButtonProc + kControlPopupFixedWidthVariant , (long) this ) ;
m_macPopUpMenuHandle = NewMenu( 1 , "\pPopUp Menu" ) ;
SetControlData( m_macControl , kControlNoPart , kControlPopupButtonMenuHandleTag , sizeof( MenuHandle ) , (char*) &m_macPopUpMenuHandle) ;
#include "wx/tabctrl.h"
#include "wx/spinbutt.h"
-IMPLEMENT_ABSTRACT_CLASS(wxControl, wxControlBase)
+IMPLEMENT_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxControlBase)
EVT_MOUSE_EVENTS( wxControl::OnMouseEvent )
void wxControl::MacSuperShown( bool show )
{
- /*
if ( m_macControl )
{
if ( !show )
}
else
{
- if ( m_macShown )
+ if ( m_isShown )
::UMAShowControl( m_macControl ) ;
}
}
wxWindow::MacSuperShown( show ) ;
- */
}
void wxControl::DoSetSize(int x, int y,
wxColour wxNullColour;
// Default window names
-const char *wxButtonNameStr = "button";
-const char *wxCanvasNameStr = "canvas";
-const char *wxCheckBoxNameStr = "check";
-const char *wxChoiceNameStr = "choice";
-const char *wxComboBoxNameStr = "comboBox";
-const char *wxDialogNameStr = "dialog";
-const char *wxFrameNameStr = "frame";
-const char *wxGaugeNameStr = "gauge";
-const char *wxStaticBoxNameStr = "groupBox";
-const char *wxListBoxNameStr = "listBox";
-const char *wxStaticTextNameStr = "message";
-const char *wxStaticBitmapNameStr = "message";
-const char *wxMultiTextNameStr = "multitext";
-const char *wxPanelNameStr = "panel";
-const char *wxRadioBoxNameStr = "radioBox";
-const char *wxRadioButtonNameStr = "radioButton";
-const char *wxBitmapRadioButtonNameStr = "radioButton";
-const char *wxScrollBarNameStr = "scrollBar";
-const char *wxSliderNameStr = "slider";
-const char *wxStaticNameStr = "static";
-const char *wxTextCtrlWindowNameStr = "textWindow";
-const char *wxTextCtrlNameStr = "text";
-const char *wxVirtListBoxNameStr = "virtListBox";
-const char *wxButtonBarNameStr = "buttonbar";
-const char *wxEnhDialogNameStr = "Shell";
-const char *wxToolBarNameStr = "toolbar";
-const char *wxStatusLineNameStr = "status_line";
-
-const char *wxGetTextFromUserPromptStr = "Input Text";
-const char *wxMessageBoxCaptionStr = "Message";
-const char *wxFileSelectorPromptStr = "Select a file";
-const char *wxFileSelectorDefaultWildcardStr = "*.*";
-const char *wxInternalErrorStr = "wxWindows Internal Error";
-const char *wxFatalErrorStr = "wxWindows Fatal Error";
+const wxChar *wxButtonNameStr = wxT("button");
+const wxChar *wxCanvasNameStr = wxT("canvas");
+const wxChar *wxCheckBoxNameStr = wxT("check");
+const wxChar *wxChoiceNameStr = wxT("choice");
+const wxChar *wxComboBoxNameStr = wxT("comboBox");
+const wxChar *wxDialogNameStr = wxT("dialog");
+const wxChar *wxFrameNameStr = wxT("frame");
+const wxChar *wxGaugeNameStr = wxT("gauge");
+const wxChar *wxStaticBoxNameStr = wxT("groupBox");
+const wxChar *wxListBoxNameStr = wxT("listBox");
+const wxChar *wxStaticTextNameStr = wxT("message");
+const wxChar *wxStaticBitmapNameStr = wxT("message");
+const wxChar *wxMultiTextNameStr = wxT("multitext");
+const wxChar *wxPanelNameStr = wxT("panel");
+const wxChar *wxRadioBoxNameStr = wxT("radioBox");
+const wxChar *wxRadioButtonNameStr = wxT("radioButton");
+const wxChar *wxBitmapRadioButtonNameStr = wxT("radioButton");
+const wxChar *wxScrollBarNameStr = wxT("scrollBar");
+const wxChar *wxSliderNameStr = wxT("slider");
+const wxChar *wxStaticNameStr = wxT("static");
+const wxChar *wxTextCtrlWindowNameStr = wxT("textWindow");
+const wxChar *wxTextCtrlNameStr = wxT("text");
+const wxChar *wxVirtListBoxNameStr = wxT("virtListBox");
+const wxChar *wxButtonBarNameStr = wxT("buttonbar");
+const wxChar *wxEnhDialogNameStr = wxT("Shell");
+const wxChar *wxToolBarNameStr = wxT("toolbar");
+const wxChar *wxStatusLineNameStr = wxT("status_line");
+
+const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text");
+const wxChar *wxMessageBoxCaptionStr = wxT("Message");
+const wxChar *wxFileSelectorPromptStr = wxT("Select a file");
+const wxChar *wxFileSelectorDefaultWildcardStr = wxT("*.*");
+const wxChar *wxInternalErrorStr = wxT("wxWindows Internal Error");
+const wxChar *wxFatalErrorStr = wxT("wxWindows Fatal Error");
+const wxChar *wxTreeCtrlNameStr = wxT("treeCtrl");
+const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl");
+const wxChar *wxDirDialogDefaultFolderStr = wxT("/");
// See wx/utils.h
-const char *wxFloatToStringStr = "%.2f";
-const char *wxDoubleToStringStr = "%.2f";
+const wxChar *wxFloatToStringStr = wxT("%.2f");
+const wxChar *wxDoubleToStringStr = wxT("%.2f");
const wxSize wxDefaultSize(-1, -1);
const wxPoint wxDefaultPosition(-1, -1);
// m_palette = wxAPP_COLOURMAP;
m_macPort = NULL ;
+ m_macMask = NULL ;
m_ok = FALSE ;
m_macFontInstalled = false ;
RGBColor black = { 0,0,0} ;
RGBForeColor( &black ) ;
RGBBackColor( &white ) ;
- // RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
- // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
bmappixels = GetGWorldPixMap( bmapworld ) ;
if ( LockPixels(bmappixels) )
dest.left = XLOG2DEV(x) ;
dest.bottom = YLOG2DEV(y + bmap->m_height ) ;
dest.right = XLOG2DEV(x + bmap->m_width ) ;
- // ::ClipRect(&m_macClipRect);
- CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
- &source, &dest, srcCopy, NULL ) ;
- /*
- if ( m_clipping )
- {
- long x1 = XLOG2DEV(m_clipX1);
- long y1 = YLOG2DEV(m_clipY1);
- long x2 = XLOG2DEV(m_clipX2);
- long y2 = YLOG2DEV(m_clipY2);
- Rect clip = { y1 , x1 , y2 , x2 } ;
- ::ClipRect(&clip);
+ if ( useMask && bmp.GetMask() )
+ {
+ if ( LockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) )
+ {
+ CopyMask( &GrafPtr( bmapworld )->portBits , &GrafPtr( bmp.GetMask()->GetMaskBitmap( ) )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &source, &source , &dest ) ;
+ UnlockPixels( GetGWorldPixMap( bmp.GetMask()->GetMaskBitmap( ) ) ) ;
+ }
}
- */
+ else
+ CopyBits( &GrafPtr( bmapworld )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &source, &dest, srcCopy, NULL ) ;
+
UnlockPixels( bmappixels ) ;
}
m_macPenInstalled = false ;
PixMapHandle bmappixels = GetGWorldPixMap( sourcePort ) ;
RGBColor white = { 0xFFFF, 0xFFFF,0xFFFF} ;
RGBColor black = { 0,0,0} ;
-// RGBForeColor( &black ) ;
-// RGBBackColor( &white ) ;
RGBForeColor( &m_textForegroundColour.GetPixel() ) ;
RGBBackColor( &m_textBackgroundColour.GetPixel() ) ;
dstrect.left = XLOG2DEV(xdest) ;
dstrect.bottom = YLOG2DEV(ydest + height ) ;
dstrect.right = XLOG2DEV(xdest + width ) ;
-// ::ClipRect(&m_macClipRect);
+
+ short mode = (logical_func == wxCOPY ? srcCopy :
+ // logical_func == wxCLEAR ? WHITENESS :
+ // logical_func == wxSET ? BLACKNESS :
+ logical_func == wxINVERT ? hilite :
+ // logical_func == wxAND ? MERGECOPY :
+ logical_func == wxOR ? srcOr :
+ logical_func == wxSRC_INVERT ? notSrcCopy :
+ logical_func == wxXOR ? srcXor :
+ // logical_func == wxOR_REVERSE ? MERGEPAINT :
+ // logical_func == wxAND_REVERSE ? SRCERASE :
+ logical_func == wxSRC_OR ? srcOr :
+ // logical_func == wxSRC_AND ? SRCAND :
+ srcCopy );
+
+ if ( useMask && source->m_macMask )
+ {
+ wxASSERT( mode == srcCopy ) ;
+ if ( LockPixels( GetGWorldPixMap( source->m_macMask ) ) )
+ {
+ CopyMask( &GrafPtr( sourcePort )->portBits , &GrafPtr( source->m_macMask )->portBits , &GrafPtr( m_macPort )->portBits ,
+ &srcrect, &srcrect , &dstrect ) ;
+ UnlockPixels( GetGWorldPixMap( source->m_macMask ) ) ;
+ }
+ }
+ else
+ {
CopyBits( &GrafPtr( sourcePort )->portBits , &GrafPtr( m_macPort )->portBits ,
- &srcrect, &dstrect, srcCopy, NULL ) ;
-/*
- if ( m_clipping )
- {
- long x1 = XLOG2DEV(m_clipX1);
- long y1 = YLOG2DEV(m_clipY1);
- long x2 = XLOG2DEV(m_clipX2);
- long y2 = YLOG2DEV(m_clipY2);
-
- Rect clip = { y1 , x1 , y2 , x2 } ;
- ::ClipRect(&clip);
- }
-*/
+ &srcrect, &dstrect, mode, NULL ) ;
+ }
UnlockPixels( bmappixels ) ;
}
if ( bmap->m_hBitmap )
{
m_macPort = (GrafPtr) bmap->m_hBitmap ;
+ wxMask * mask = bitmap.GetMask() ;
+ if ( mask )
+ {
+ m_macMask = mask->GetMaskBitmap() ;
+ }
MacSetupPort() ;
m_ok = TRUE ;
// SetBackground(wxBrush(*wxWHITE, wxSOLID));
UMAGetControlData( m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
NewExtLDEFInfo( m_macList , MacDrawStringCell , (long) this ) ;
- (**m_macList).selFlags = lOnlyOne ;
- if ( style & wxLB_MULTIPLE )
+ (**m_macList).selFlags = 0 ;
+ if ( style & wxLB_MULTIPLE )
{
(**m_macList).selFlags += lNoExtend ;
}
{
(**m_macList).selFlags += lExtendDrag ;
}
+ else
+ {
+ (**m_macList).selFlags = lOnlyOne ;
+ }
Point pt = (**m_macList).cellSize ;
pt.v = 14 ;
LCellSize( pt , m_macList ) ;
}
#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
m_stringArray.Remove( N ) ;
+ m_dataArray.Remove( N ) ;
m_noItems --;
MacDelete( N ) ;
wxASSERT_MSG(clientData[i] == NULL,
wxT("Can't use client data with owner-drawn listboxes"));
#else // !wxUSE_OWNER_DRAWN
- Append( choices[i] , clientData[0] ) ;
+ Append( choices[i] , clientData[i] ) ;
#endif
}
else
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
}
#endif // wxUSE_OWNER_DRAWN
- m_dataArray[N] = (char*) Client_data ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
+
+ if ( m_dataArray.GetCount() > N )
+ {
+ m_dataArray[N] = (char*) Client_data ;
+ }
+ else
+ {
+ m_dataArray.Add( (char*) Client_data ) ;
+ }
}
void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData)
// remove inappropriate characters, if useShortcuts is false, the ampersand will not auto-generate a mac menu-shortcut
-void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemName , bool useShortcuts )
+void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , short *outMacModifiers , const char *inItemText , bool useShortcuts )
{
char *p = (char *) &outMacItemText[1] ;
short macModifiers = 0 ;
char macShortCut = 0 ;
+ const char *inItemName ;
+ wxString inItemTextMac ;
+
+ if (wxApp::s_macDefaultEncodingIsPC)
+ {
+ inItemTextMac = wxMacMakeMacStringFromPC( inItemText ) ;
+ inItemName = inItemTextMac ;
+ }
+ else
+ {
+ inItemName = inItemText ;
+ }
if ( useShortcuts && !wxApp::s_macSupportPCMenuShortcuts )
useShortcuts = false ;
inItemName = inItemName + 5;
macShortCut = *inItemName;
}
+ else if (strncmp("Cntrl", inItemName, 5) == 0)
+ {
+ inItemName = inItemName + 6;
+ macShortCut = *inItemName;
+ }
else if (strncmp("Alt", inItemName, 3) == 0)
{
inItemName = inItemName + 4;
wxMenu* menu = m_menus[i] , *subMenu = NULL ;
- if( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
+ if( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName )
{
MenuHandle mh = NULL ;
if ( HMGetHelpMenuHandle( &mh ) != noErr )
}
else
{
- Str255 label ;
- wxMacBuildMenuString( label , NULL , NULL , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
- if ( label[0] == 0 )
+ if ( item->IsSeparator() )
{
- // we cannot add empty menus on mac
- label[0] = 1 ;
- label[1] = ' ' ;
+ if ( mh )
+ ::AppendMenu(mh, "\p-" );
}
- if ( item->GetId() == wxApp::s_macAboutMenuItemId )
- {
- ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
- // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
- }
else
{
- if ( mh )
- ::AppendMenu(mh, label );
+ Str255 label ;
+ wxMacBuildMenuString( label , NULL , NULL , item->GetText(), item->GetId() != wxApp::s_macAboutMenuItemId); // no shortcut in about menu
+ if ( label[0] == 0 )
+ {
+ // we cannot add empty menus on mac
+ label[0] = 1 ;
+ label[1] = ' ' ;
+ }
+ if ( item->GetId() == wxApp::s_macAboutMenuItemId )
+ {
+ ::SetMenuItemText( GetMenuHandle( kwxMacAppleMenuId ) , 1 , label );
+ // ::EnableMenuItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
+ ::EnableItem( GetMenuHandle( kwxMacAppleMenuId ) , 1 );
+ }
+ else
+ {
+ if ( mh )
+ ::AppendMenu(mh, label );
+ }
}
}
}
for (int i = 0; i < m_menus.GetCount() ; i++)
{
if ( m_menus[i]->MacGetMenuId() == macMenuId ||
- ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) )
+ ( macMenuId == kHMHelpMenuID && ( m_titles[i] == "?" || m_titles[i] == "&?" || m_titles[i] == wxApp::s_macHelpMenuTitleName ) )
)
{
if ( m_menus[i]->MacMenuSelect( handler , when , macMenuId , macMenuItemNum ) )
Str255 pascalTitle ;
Str255 pascalText ;
- strcpy( (char*) pascalTitle , m_caption ) ;
+
+ if (wxApp::s_macDefaultEncodingIsPC)
+ {
+ strcpy( (char*) pascalTitle , wxMacMakeMacStringFromPC( m_caption ) ) ;
+ strcpy( (char*) pascalText , wxMacMakeMacStringFromPC( m_message) ) ;
+ }
+ else
+ {
+ strcpy( (char*) pascalTitle , m_caption ) ;
+ strcpy( (char*) pascalText , m_message ) ;
+ }
+
c2pstr( (char*) pascalTitle ) ;
- strcpy( (char*) pascalText , m_message ) ;
wxMacConvertNewlines( (char*)pascalText ,(char*) pascalText) ;
c2pstr( (char*) pascalText ) ;
+ wxASSERT_MSG( ( m_dialogStyle & 0x3F ) != wxYES , "this style is not supported on mac" ) ;
+
if ( !UMAHasAppearance() )
{
int resourceID ;
//-------------------------------------------------------------------------------------
// Simulates the effect of the user issuing a command to the item
-#define RADIO_SIZE 20
+#define RADIO_SIZE 40
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
int x_current, y_current;
int x_offset,y_offset;
+ int widthOld, heightOld;
+ GetSize(&widthOld, &heightOld);
x_offset = x;
y_offset = y;
totHeight = GetNumVer() * (maxHeight + charHeight/2) + charHeight*3/2;
totWidth = GetNumHor() * (maxWidth + charWidth) + charWidth;
- wxControl::DoSetSize(x_offset,y_offset,totWidth,totHeight,wxSIZE_AUTO);
+ // only change our width/height if asked for
+ if ( width == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ width = totWidth ;
+ else
+ width = widthOld;
+ }
+
+ if ( height == -1 )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ height = totHeight ;
+ else
+ height = heightOld;
+ }
+
+ wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
// arrange radiobuttons
void wxRadioButton::MacHandleControlClick( ControlHandle control , SInt16 controlpart )
{
SetValue(true) ;
+ wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
+ event.SetEventObject(this);
+ ProcessCommand(event);
}
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
#include <wx/mac/uma.h>
+BEGIN_EVENT_TABLE(wxStaticText, wxControl)
+ EVT_PAINT(wxStaticText::OnPaint)
+END_EVENT_TABLE()
+
+bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
+ const wxString& label,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
+{
+ SetName(name);
+ m_backgroundColour = parent->GetBackgroundColour() ;
+ m_foregroundColour = parent->GetForegroundColour() ;
+
+ if ( id == -1 )
+ m_windowId = (int)NewControlId();
+ else
+ m_windowId = id;
+
+ m_windowStyle = style;
+ m_label = label ;
+
+ bool ret = wxControl::Create( parent, id, pos, size, style , wxDefaultValidator , name );
+ SetSizeOrDefault( size ) ;
+
+ return ret;
+}
+
+void wxStaticText::OnPaint( wxPaintEvent &event )
+{
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+ dc.Clear() ;
+ dc.DrawText( m_label , 0 , 0 ) ;
+}
+
+wxSize wxStaticText::DoGetBestSize() const
+{
+ int x , y ;
+ GetTextExtent( m_label , &x , &y ) ;
+ return wxSize( x , y ) ;
+}
+
+void wxStaticText::SetLabel(const wxString& st , bool resize )
+{
+ SetTitle( st ) ;
+ m_label = st ;
+ if ( resize )
+ SetSizeOrDefault() ;
+ else
+ Refresh() ;
+}
+/*
+void wxStaticText::SetSize(int x, int y, int width, int height, int sizeFlags)
+{
+ wxControl::SetSize( x , y , width , height , sizeFlags ) ;
+}
+
bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ;
Refresh() ;
}
+*/
ControlHandle m_macToolHandle ;
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( tool->CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+
if ( icon )
{
m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 ,
- kControlBehaviorOffsetContents + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ behaviour + kControlContentPictHandle , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
ControlButtonContentInfo info ;
info.contentType = kControlContentPictHandle ;
else
{
m_macToolHandle = UMANewControl( window , &toolrect , "\p" , true , 0 ,
- kControlBehaviorOffsetContents , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
}
m_macToolHandles.Add( m_macToolHandle ) ;
UMASetControlFontStyle( m_macToolHandle , &controlstyle ) ;
void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable)
{
wxToolBarTool *tool = (wxToolBarTool *)t;
+ ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
+ if ( UMAHasAppearance() )
+ {
+ if ( enable )
+ ::ActivateControl( control ) ;
+ else
+ ::DeactivateControl( control ) ;
+ }
+ else
+ {
+ if ( enable )
+ ::HiliteControl( control , 0 ) ;
+ else
+ ::HiliteControl( control , 255 ) ;
+ }
}
void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle)
{
wxToolBarTool *tool = (wxToolBarTool *)t;
- // TODO: set toggle state
+
+ ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ;
+ ::SetControlValue( control , toggle ) ;
}
bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
UMAHideWindow( m_macWindowData->m_macWindow ) ;
}
}
+ MacSuperShown( show ) ;
Refresh() ;
return TRUE;
}
+void wxWindow::MacSuperShown( bool show )
+{
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ if ( child->m_isShown )
+ child->MacSuperShown( show ) ;
+ node = node->Next();
+ }
+}
+
int wxWindow::GetCharHeight() const
{
wxClientDC dc ( (wxWindow*)this ) ;
}
}
+void wxWindow::MacPaint( wxPaintEvent &event )
+{
+ wxPaintDC dc(this);
+ PrepareDC(dc);
+
+ if (HasFlag(wxRAISED_BORDER) || HasFlag( wxSUNKEN_BORDER) )
+ {
+ bool sunken = HasFlag( wxSUNKEN_BORDER ) ;
+
+ wxPen m_penButton3DShadow( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DSHADOW ), 1, wxSOLID ) ;
+ wxPen m_penButton3DFace( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_3DFACE ), 1, wxSOLID ) ;
+
+ wxPen wxPen1 = sunken ? *wxWHITE_PEN : *wxBLACK_PEN;
+ wxPen wxPen2 = sunken ? m_penButton3DShadow : m_penButton3DShadow;
+ wxPen wxPen3 = sunken ? m_penButton3DFace : m_penButton3DShadow;
+ wxPen wxPen4 = sunken ? *wxBLACK_PEN : *wxWHITE_PEN;
+
+ dc.SetPen(wxPen1);
+ dc.DrawRectangle(0, 0, m_width, m_height); // outer - right and button
+
+ dc.SetPen(wxPen2);
+ dc.DrawRectangle(1, 1, m_width-1, m_height-1); // outer - left and top
+
+ dc.SetPen(wxPen3);
+ dc.DrawRectangle(0, 0, m_width-2, m_height-2); // inner - right and button
+
+ dc.SetPen(wxPen4);
+ dc.DrawLine(0, 0, m_width-3, 0); // inner - left and top
+ dc.DrawLine(0, 0, 0, m_height-3);
+ }
+ else if (HasFlag(wxSIMPLE_BORDER))
+ {
+ dc.SetPen(*wxBLACK_PEN);
+ dc.DrawRectangle(0, 0, m_width, m_height);
+ }
+}
+
// New function that will replace some of the above.
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
int range, bool refresh)
event.m_timeStamp = time ;
event.SetEventObject(this);
+ wxPaintEvent event2( event ) ;
GetEventHandler()->ProcessEvent(event);
+ MacPaint( event2 ) ;
RgnHandle childupdate = NewRgn() ;
if (!bmp.Ok())
return;
+ bool needsPixelCopy = false ;
+ bool isPrinter = false ;
+ if (IsKindOf(CLASSINFO(wxPrinterDC)) )
+ {
+ isPrinter = true ;
+ if ( ::GetDeviceCaps((HDC) m_hDC, RASTERCAPS) & RC_STRETCHDIB )
+ {
+ }
+ else
+ {
+ needsPixelCopy = true ;
+ }
+ }
// If we're not drawing transparently, and not drawing to a printer,
// optimize this function to use Windows functions.
- if (!useMask && !IsKindOf(CLASSINFO(wxPrinterDC)))
+ if (!useMask && !needsPixelCopy)
{
- HDC cdc = GetHdc();
- HDC memdc = ::CreateCompatibleDC( cdc );
- HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( );
-
- wxASSERT_MSG( hbitmap, wxT("bitmap is ok but HBITMAP is NULL?") );
-
- ::SelectObject( memdc, hbitmap );
- ::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY);
- ::DeleteDC( memdc );
+ if ( isPrinter )
+ {
+ BITMAPINFO *info = (BITMAPINFO *) malloc( sizeof( BITMAPINFOHEADER ) + 256 * sizeof(RGBQUAD ) ) ;
+ int iBitsSize = ((bmp.GetWidth() + 3 ) & ~3 ) * bmp.GetHeight() ;
+
+ void* bits = malloc( iBitsSize ) ;
+
+ memset( info , 0 , sizeof( BITMAPINFOHEADER ) ) ;
+
+ info->bmiHeader.biSize = sizeof( BITMAPINFOHEADER ) ;
+ info->bmiHeader.biWidth = bmp.GetWidth() ;
+ info->bmiHeader.biHeight = bmp.GetHeight() ;
+ info->bmiHeader.biPlanes = 1 ;
+ info->bmiHeader.biBitCount = 8 ;
+ info->bmiHeader.biCompression = BI_RGB ;
+
+ HDC display = GetDC( NULL ) ;
+ if ( GetDIBits( display , (HBITMAP) bmp.GetHBITMAP( ) , 0 , bmp.GetHeight() , bits , info , DIB_RGB_COLORS ) )
+ {
+ StretchDIBits( (HDC) m_hDC,
+ x, y, bmp.GetWidth(), bmp.GetHeight() ,
+ 0 , 0 ,bmp.GetWidth(), bmp.GetHeight() ,
+ bits , info , DIB_RGB_COLORS , SRCCOPY ) ;
+ }
+ ReleaseDC( NULL , display ) ;
+ free ( bits ) ;
+ free( info ) ;
+ }
+ else
+ {
+ HDC cdc = GetHdc();
+ HDC memdc = ::CreateCompatibleDC( cdc );
+ HBITMAP hbitmap = (HBITMAP) bmp.GetHBITMAP( );
+
+ wxASSERT_MSG( hbitmap, wxT("bitmap is ok but HBITMAP is NULL?") );
+
+ ::SelectObject( memdc, hbitmap );
+ ::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY);
+ ::DeleteDC( memdc );
+ }
}
else
{