- CGrafPtr origPort ;
- GDHandle origDev ;
-
- PicHandle pict; // this is the Picture we give back
-
- RGBColor gray = { 0xCCCC ,0xCCCC , 0xCCCC } ;
-
- GetGWorld( &origPort , &origDev ) ;
- SetGWorld( wp , NULL ) ;
-
- pict = OpenPicture(&wp->portRect); // open a picture, this disables drawing
- if(!pict)
- return NULL;
-
- RGBBackColor( &gray ) ;
- EraseRect(&wp->portRect) ;
- CopyBits((BitMap*)*wp->portPixMap, // src PixMap - we copy image over itself -
- (BitMap*)*wp->portPixMap, // dst PixMap - no drawing occurs -
- &wp->portRect, // srcRect - it will be recorded and compressed -
- &wp->portRect, // dstRect - into the picture that is open -
- srcCopy,NULL); // copyMode and no clip region
-
- ClosePicture(); // We are done recording the picture
- SetGWorld( origPort , origDev ) ;
- return pict; // return our groovy pict handle
+ if (m_tools.GetCount() == 0)
+ return FALSE;
+
+ Point localOrigin ;
+ // Rect clipRect ;
+ WindowRef window = (WindowRef) MacGetRootWindow() ;
+ // wxWindow *win ;
+
+ int lx , ly ;
+ lx = ly = 0 ;
+ MacWindowToRootWindow( &lx , &ly ) ;
+ localOrigin.v = ly ;
+ localOrigin.h = lx ;
+
+// GetParent()->MacGetPortParams( &localOrigin , &clipRect , &window , &win ) ;
+
+ Rect toolbarrect = { localOrigin.v ,localOrigin.h ,
+ m_height + localOrigin.v , m_width + localOrigin.h} ;
+ ControlFontStyleRec controlstyle ;
+
+ controlstyle.flags = kControlUseFontMask ;
+ controlstyle.font = kControlFontSmallSystemFont ;
+
+ wxToolBarToolsList::Node *node = m_tools.GetFirst();
+ int noButtons = 0;
+ int x = 0 ;
+ int y = 0 ;
+ wxSize toolSize = GetToolSize() ;
+ int tw, th;
+ GetSize(& tw, & th);
+
+ int maxWidth = 0 ;
+ int maxHeight = 0 ;
+
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
+
+ if( !tool->IsSeparator() )
+ {
+ Rect toolrect = { toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin,
+ toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
+ toolrect.right = toolrect.left + toolSize.x ;
+ toolrect.bottom = toolrect.top + toolSize.y ;
+
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , tool->GetNormalBitmap() ) ;
+ ControlHandle m_macToolHandle ;
+
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( tool->CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+
+ if ( info.contentType != kControlNoContent )
+ {
+ m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
+ behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+
+ ::SetControlData( m_macToolHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
+ else
+ {
+ m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ }
+ UMAShowControl( m_macToolHandle ) ;
+ m_macToolHandles.Add( m_macToolHandle ) ;
+ tool->m_index = m_macToolHandles.Count() -1 ;
+ if ( !tool->IsEnabled() )
+ {
+ UMADeactivateControl( m_macToolHandle ) ;
+ }
+ if ( tool->CanBeToggled() && tool->IsToggled() )
+ {
+ ::SetControl32BitValue( m_macToolHandle , 1 ) ;
+ }
+ else
+ {
+ ::SetControl32BitValue( m_macToolHandle , 0 ) ;
+ }
+ /*
+ ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ;
+ */
+ ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
+ wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
+ ::EmbedControl( m_macToolHandle , container ) ;
+
+ if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ {
+ y += (int)toolSize.y;
+ }
+ else
+ {
+ x += (int)toolSize.x;
+ }
+ noButtons ++;
+ }
+ else
+ {
+ m_macToolHandles.Add( NULL ) ;
+
+ if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ {
+ y += (int)toolSize.y / 4;
+ }
+ else
+ {
+ x += (int)toolSize.x / 4;
+ }
+ }
+ if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h > maxWidth) {
+ maxWidth = toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h;
+ }
+ if (toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) {
+ maxHeight = toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v ;
+ }
+ node = node->GetNext();
+ }
+
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ {
+ if ( m_maxRows == 0 )
+ {
+ // if not set yet, only one row
+ SetRows(1);
+ }
+ maxWidth = tw ;
+ maxHeight += toolSize.y;
+ maxHeight += m_yMargin + kwxMacToolBarTopMargin;
+ m_maxHeight = maxHeight ;
+ }
+ else
+ {
+ if ( noButtons > 0 && m_maxRows == 0 )
+ {
+ // if not set yet, have one column
+ SetRows(noButtons);
+ }
+ maxHeight = th ;
+ maxWidth += toolSize.x;
+ maxWidth += m_xMargin + kwxMacToolBarLeftMargin;
+ m_maxWidth = maxWidth ;
+ }
+
+ SetSize(maxWidth, maxHeight);
+
+ return TRUE;