diff --git a/include/wx/mac/dc.h b/include/wx/mac/dc.h index 82c959b4c7..dd55252573 100644 --- a/include/wx/mac/dc.h +++ b/include/wx/mac/dc.h @@ -382,6 +382,7 @@ class WXDLLEXPORT wxDC: public wxObject //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 diff --git a/include/wx/mac/dialog.h b/include/wx/mac/dialog.h index 1aa01b36f0..d725df8d57 100644 --- a/include/wx/mac/dialog.h +++ b/include/wx/mac/dialog.h @@ -111,6 +111,7 @@ public: // -------------- bool IsModalShowing() const { return m_modalShowing; } + virtual bool IsTopLevel() const { return TRUE; } // tooltip management #if wxUSE_TOOLTIPS diff --git a/include/wx/mac/frame.h b/include/wx/mac/frame.h index 3d6a52941d..c342d83c90 100644 --- a/include/wx/mac/frame.h +++ b/include/wx/mac/frame.h @@ -56,6 +56,7 @@ public: const wxString& name = wxFrameNameStr); virtual bool Destroy(); + virtual bool IsTopLevel() const { return TRUE; } void OnSize(wxSizeEvent& event); void OnMenuHighlight(wxMenuEvent& event); diff --git a/include/wx/mac/stattext.h b/include/wx/mac/stattext.h index 1117b6fc9a..5cf88232a2 100644 --- a/include/wx/mac/stattext.h +++ b/include/wx/mac/stattext.h @@ -49,6 +49,13 @@ class WXDLLEXPORT wxStaticText: public wxControl // 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 diff --git a/include/wx/mac/window.h b/include/wx/mac/window.h index c7c6bd43b0..ba8b50315f 100644 --- a/include/wx/mac/window.h +++ b/include/wx/mac/window.h @@ -236,10 +236,12 @@ public : 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() ; diff --git a/include/wx/msw/bitmap.h b/include/wx/msw/bitmap.h index 82b5d30251..d71506f944 100644 --- a/include/wx/msw/bitmap.h +++ b/include/wx/msw/bitmap.h @@ -117,7 +117,7 @@ public: 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); diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp index a66bb77444..84a4ff0a09 100644 --- a/samples/minimal/minimal.cpp +++ b/samples/minimal/minimal.cpp @@ -140,19 +140,33 @@ bool MyApp::OnInit() 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); diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index 4d22420581..5326de0e31 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -95,9 +95,9 @@ #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 diff --git a/src/common/image.cpp b/src/common/image.cpp index bbd261d3cf..627e7ab6ad 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -883,7 +883,12 @@ wxBitmap wxImage::ConvertToBitmap() const { for(i=0; im_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; } /* diff --git a/src/mac/bmpbuttn.cpp b/src/mac/bmpbuttn.cpp index f435ab2b32..569a2cd338 100644 --- a/src/mac/bmpbuttn.cpp +++ b/src/mac/bmpbuttn.cpp @@ -48,8 +48,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit 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 ) ; diff --git a/src/mac/carbon/bitmap.cpp b/src/mac/carbon/bitmap.cpp index d14b15ba7f..1ae5a445d4 100644 --- a/src/mac/carbon/bitmap.cpp +++ b/src/mac/carbon/bitmap.cpp @@ -446,18 +446,14 @@ wxBitmapHandler *wxBitmap::FindHandler(long bitmapType) 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); } @@ -465,26 +461,24 @@ wxMask::wxMask(const wxBitmap& bitmap, const wxColour& 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). @@ -506,8 +500,54 @@ bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) // 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; } /* diff --git a/src/mac/carbon/bmpbuttn.cpp b/src/mac/carbon/bmpbuttn.cpp index f435ab2b32..569a2cd338 100644 --- a/src/mac/carbon/bmpbuttn.cpp +++ b/src/mac/carbon/bmpbuttn.cpp @@ -48,8 +48,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit 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 ) ; diff --git a/src/mac/carbon/checkbox.cpp b/src/mac/carbon/checkbox.cpp index aa589bd32d..df3424b88f 100644 --- a/src/mac/carbon/checkbox.cpp +++ b/src/mac/carbon/checkbox.cpp @@ -59,6 +59,10 @@ void wxCheckBox::Command (wxCommandEvent & event) 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 diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 301b0731a8..343f3d239e 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -34,8 +34,8 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, 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) ; diff --git a/src/mac/carbon/control.cpp b/src/mac/carbon/control.cpp index 122f58de8f..f6fa56cb91 100644 --- a/src/mac/carbon/control.cpp +++ b/src/mac/carbon/control.cpp @@ -18,7 +18,7 @@ #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 ) @@ -383,7 +383,6 @@ void wxControl::MacSuperEnabled( bool enabled ) void wxControl::MacSuperShown( bool show ) { - /* if ( m_macControl ) { if ( !show ) @@ -392,13 +391,12 @@ void wxControl::MacSuperShown( bool show ) } else { - if ( m_macShown ) + if ( m_isShown ) ::UMAShowControl( m_macControl ) ; } } wxWindow::MacSuperShown( show ) ; - */ } void wxControl::DoSetSize(int x, int y, diff --git a/src/mac/carbon/data.cpp b/src/mac/carbon/data.cpp index bdabb51e99..fab57c49fe 100644 --- a/src/mac/carbon/data.cpp +++ b/src/mac/carbon/data.cpp @@ -92,44 +92,47 @@ wxFont wxNullFont; 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 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 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 *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); diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index 0043d823fb..ecbb3ca703 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -84,6 +84,7 @@ wxDC::wxDC(void) // m_palette = wxAPP_COLOURMAP; m_macPort = NULL ; + m_macMask = NULL ; m_ok = FALSE ; m_macFontInstalled = false ; @@ -153,8 +154,6 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) RGBColor black = { 0,0,0} ; RGBForeColor( &black ) ; RGBBackColor( &white ) ; - // RGBForeColor( &m_textForegroundColour.GetPixel() ) ; - // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; bmappixels = GetGWorldPixMap( bmapworld ) ; if ( LockPixels(bmappixels) ) @@ -168,21 +167,20 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) 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 ; @@ -1071,8 +1069,6 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, 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() ) ; @@ -1087,21 +1083,36 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, 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 ) ; } diff --git a/src/mac/carbon/dcmemory.cpp b/src/mac/carbon/dcmemory.cpp index 28a652368a..fe88bf806c 100644 --- a/src/mac/carbon/dcmemory.cpp +++ b/src/mac/carbon/dcmemory.cpp @@ -44,6 +44,11 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) 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)); diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 3b062f04e5..c518ad035c 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -68,8 +68,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, 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 ; } @@ -77,6 +77,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, { (**m_macList).selFlags += lExtendDrag ; } + else + { + (**m_macList).selFlags = lOnlyOne ; + } Point pt = (**m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , m_macList ) ; @@ -151,6 +155,7 @@ void wxListBox::Delete(int N) } #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN m_stringArray.Remove( N ) ; + m_dataArray.Remove( N ) ; m_noItems --; MacDelete( N ) ; @@ -185,7 +190,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) 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 @@ -298,7 +303,16 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) 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) diff --git a/src/mac/carbon/menu.cpp b/src/mac/carbon/menu.cpp index b52790b67d..427db90852 100644 --- a/src/mac/carbon/menu.cpp +++ b/src/mac/carbon/menu.cpp @@ -55,11 +55,23 @@ void wxMacCtoPString(const char* theCString, Str255 thePString); // 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 ; @@ -120,6 +132,11 @@ void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , s 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; @@ -876,7 +893,7 @@ void wxMenuBar::MacInstallMenuBar() 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 ) @@ -899,24 +916,32 @@ void wxMenuBar::MacInstallMenuBar() } else { - 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 ( item->IsSeparator() ) { if ( mh ) - ::AppendMenu(mh, label ); + ::AppendMenu(mh, "\p-" ); + } + else + { + 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 ); + } } } } @@ -1094,7 +1119,7 @@ void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, 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 ) ) diff --git a/src/mac/carbon/msgdlg.cpp b/src/mac/carbon/msgdlg.cpp index f19da7bb4f..cf229e5200 100644 --- a/src/mac/carbon/msgdlg.cpp +++ b/src/mac/carbon/msgdlg.cpp @@ -70,12 +70,24 @@ int wxMessageDialog::ShowModal() 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 ; diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 70da0df49c..416ba0b18f 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -418,7 +418,7 @@ void wxRadioBox::SetFocus() //------------------------------------------------------------------------------------- // 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) { @@ -429,6 +429,8 @@ 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; @@ -463,7 +465,24 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) 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 diff --git a/src/mac/carbon/radiobut.cpp b/src/mac/carbon/radiobut.cpp index a2fc26d840..f5f95dfab2 100644 --- a/src/mac/carbon/radiobut.cpp +++ b/src/mac/carbon/radiobut.cpp @@ -73,6 +73,9 @@ void wxRadioButton::Command (wxCommandEvent & event) 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) diff --git a/src/mac/carbon/stattext.cpp b/src/mac/carbon/stattext.cpp index ec4de7cc31..b249fc0e11 100644 --- a/src/mac/carbon/stattext.cpp +++ b/src/mac/carbon/stattext.cpp @@ -22,6 +22,65 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) #include +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, @@ -56,4 +115,5 @@ void wxStaticText::SetLabel(const wxString& st , bool resize ) ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ; Refresh() ; } +*/ diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 26f3a748cb..e4bd0aff79 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -245,10 +245,14 @@ bool wxToolBar::Realize() 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 ; @@ -259,7 +263,7 @@ bool wxToolBar::Realize() 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 ) ; @@ -353,12 +357,29 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const 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), diff --git a/src/mac/carbon/window.cpp b/src/mac/carbon/window.cpp index 516e3ba7b7..f8099265a2 100644 --- a/src/mac/carbon/window.cpp +++ b/src/mac/carbon/window.cpp @@ -642,11 +642,24 @@ bool wxWindow::Show(bool show) 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 ) ; @@ -914,6 +927,43 @@ void wxWindow::SetScrollPos(int orient, int pos, bool refresh) } } +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) @@ -1433,7 +1483,9 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) event.m_timeStamp = time ; event.SetEventObject(this); + wxPaintEvent event2( event ) ; GetEventHandler()->ProcessEvent(event); + MacPaint( event2 ) ; RgnHandle childupdate = NewRgn() ; diff --git a/src/mac/checkbox.cpp b/src/mac/checkbox.cpp index aa589bd32d..df3424b88f 100644 --- a/src/mac/checkbox.cpp +++ b/src/mac/checkbox.cpp @@ -59,6 +59,10 @@ void wxCheckBox::Command (wxCommandEvent & event) 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 diff --git a/src/mac/choice.cpp b/src/mac/choice.cpp index 301b0731a8..343f3d239e 100644 --- a/src/mac/choice.cpp +++ b/src/mac/choice.cpp @@ -34,8 +34,8 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id, 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) ; diff --git a/src/mac/control.cpp b/src/mac/control.cpp index 122f58de8f..f6fa56cb91 100644 --- a/src/mac/control.cpp +++ b/src/mac/control.cpp @@ -18,7 +18,7 @@ #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 ) @@ -383,7 +383,6 @@ void wxControl::MacSuperEnabled( bool enabled ) void wxControl::MacSuperShown( bool show ) { - /* if ( m_macControl ) { if ( !show ) @@ -392,13 +391,12 @@ void wxControl::MacSuperShown( bool show ) } else { - if ( m_macShown ) + if ( m_isShown ) ::UMAShowControl( m_macControl ) ; } } wxWindow::MacSuperShown( show ) ; - */ } void wxControl::DoSetSize(int x, int y, diff --git a/src/mac/data.cpp b/src/mac/data.cpp index bdabb51e99..fab57c49fe 100644 --- a/src/mac/data.cpp +++ b/src/mac/data.cpp @@ -92,44 +92,47 @@ wxFont wxNullFont; 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 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 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 *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); diff --git a/src/mac/dc.cpp b/src/mac/dc.cpp index 0043d823fb..ecbb3ca703 100644 --- a/src/mac/dc.cpp +++ b/src/mac/dc.cpp @@ -84,6 +84,7 @@ wxDC::wxDC(void) // m_palette = wxAPP_COLOURMAP; m_macPort = NULL ; + m_macMask = NULL ; m_ok = FALSE ; m_macFontInstalled = false ; @@ -153,8 +154,6 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) RGBColor black = { 0,0,0} ; RGBForeColor( &black ) ; RGBBackColor( &white ) ; - // RGBForeColor( &m_textForegroundColour.GetPixel() ) ; - // RGBBackColor( &m_textBackgroundColour.GetPixel() ) ; bmappixels = GetGWorldPixMap( bmapworld ) ; if ( LockPixels(bmappixels) ) @@ -168,21 +167,20 @@ void wxDC::DrawBitmap( const wxBitmap &bmp, long x, long y, bool useMask ) 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 ; @@ -1071,8 +1069,6 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, 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() ) ; @@ -1087,21 +1083,36 @@ bool wxDC::Blit( long xdest, long ydest, long width, long height, 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 ) ; } diff --git a/src/mac/dcmemory.cpp b/src/mac/dcmemory.cpp index 28a652368a..fe88bf806c 100644 --- a/src/mac/dcmemory.cpp +++ b/src/mac/dcmemory.cpp @@ -44,6 +44,11 @@ void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) 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)); diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index 3b062f04e5..c518ad035c 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -68,8 +68,8 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, 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 ; } @@ -77,6 +77,10 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, { (**m_macList).selFlags += lExtendDrag ; } + else + { + (**m_macList).selFlags = lOnlyOne ; + } Point pt = (**m_macList).cellSize ; pt.v = 14 ; LCellSize( pt , m_macList ) ; @@ -151,6 +155,7 @@ void wxListBox::Delete(int N) } #endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN m_stringArray.Remove( N ) ; + m_dataArray.Remove( N ) ; m_noItems --; MacDelete( N ) ; @@ -185,7 +190,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) 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 @@ -298,7 +303,16 @@ void wxListBox::DoSetItemClientData(int N, void *Client_data) 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) diff --git a/src/mac/menu.cpp b/src/mac/menu.cpp index b52790b67d..427db90852 100644 --- a/src/mac/menu.cpp +++ b/src/mac/menu.cpp @@ -55,11 +55,23 @@ void wxMacCtoPString(const char* theCString, Str255 thePString); // 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 ; @@ -120,6 +132,11 @@ void wxMacBuildMenuString(StringPtr outMacItemText, char *outMacShortcutChar , s 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; @@ -876,7 +893,7 @@ void wxMenuBar::MacInstallMenuBar() 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 ) @@ -899,24 +916,32 @@ void wxMenuBar::MacInstallMenuBar() } else { - 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 ( item->IsSeparator() ) { if ( mh ) - ::AppendMenu(mh, label ); + ::AppendMenu(mh, "\p-" ); + } + else + { + 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 ); + } } } } @@ -1094,7 +1119,7 @@ void wxMenuBar::MacMenuSelect(wxEvtHandler* handler, long when , int macMenuId, 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 ) ) diff --git a/src/mac/msgdlg.cpp b/src/mac/msgdlg.cpp index f19da7bb4f..cf229e5200 100644 --- a/src/mac/msgdlg.cpp +++ b/src/mac/msgdlg.cpp @@ -70,12 +70,24 @@ int wxMessageDialog::ShowModal() 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 ; diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index 70da0df49c..416ba0b18f 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -418,7 +418,7 @@ void wxRadioBox::SetFocus() //------------------------------------------------------------------------------------- // 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) { @@ -429,6 +429,8 @@ 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; @@ -463,7 +465,24 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) 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 diff --git a/src/mac/radiobut.cpp b/src/mac/radiobut.cpp index a2fc26d840..f5f95dfab2 100644 --- a/src/mac/radiobut.cpp +++ b/src/mac/radiobut.cpp @@ -73,6 +73,9 @@ void wxRadioButton::Command (wxCommandEvent & event) 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) diff --git a/src/mac/stattext.cpp b/src/mac/stattext.cpp index ec4de7cc31..b249fc0e11 100644 --- a/src/mac/stattext.cpp +++ b/src/mac/stattext.cpp @@ -22,6 +22,65 @@ IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl) #include +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, @@ -56,4 +115,5 @@ void wxStaticText::SetLabel(const wxString& st , bool resize ) ::UMASetControlData( m_macControl, kControlLabelPart, kControlStaticTextTextTag , (long) label.Length() , (char*)(const char*) label ) ; Refresh() ; } +*/ diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 26f3a748cb..e4bd0aff79 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -245,10 +245,14 @@ bool wxToolBar::Realize() 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 ; @@ -259,7 +263,7 @@ bool wxToolBar::Realize() 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 ) ; @@ -353,12 +357,29 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const 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), diff --git a/src/mac/window.cpp b/src/mac/window.cpp index 516e3ba7b7..f8099265a2 100644 --- a/src/mac/window.cpp +++ b/src/mac/window.cpp @@ -642,11 +642,24 @@ bool wxWindow::Show(bool show) 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 ) ; @@ -914,6 +927,43 @@ void wxWindow::SetScrollPos(int orient, int pos, bool refresh) } } +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) @@ -1433,7 +1483,9 @@ void wxWindow::MacRedraw( RgnHandle updatergn , long time) event.m_timeStamp = time ; event.SetEventObject(this); + wxPaintEvent event2( event ) ; GetEventHandler()->ProcessEvent(event); + MacPaint( event2 ) ; RgnHandle childupdate = NewRgn() ; diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 45c51e9417..3cffc336ee 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -600,19 +600,63 @@ void wxDC::DoDrawBitmap( const wxBitmap &bmp, wxCoord x, wxCoord y, bool useMask 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( ); + 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?") ); + 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 ); + ::SelectObject( memdc, hbitmap ); + ::BitBlt( cdc, x, y, bmp.GetWidth(), bmp.GetHeight(), memdc, 0, 0, SRCCOPY); + ::DeleteDC( memdc ); + } } else {