]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/radiobox.cpp
Applied patch #876969: "Fixes to Borland warnings"; Minor code cleanup.
[wxWidgets.git] / src / mac / carbon / radiobox.cpp
index 15ac067af755ea432c02602078fc028bb05af95c..9ef60f55940169502ca6b111a60cb7a172b4935a 100644 (file)
@@ -28,9 +28,6 @@
 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
 #endif
 
-#pragma mark -
-#pragma mark ### Constructors & destructor ###
-
 //-------------------------------------------------------------------------------------
 //         ¥ wxRadioBox()
 //-------------------------------------------------------------------------------------
@@ -77,6 +74,8 @@ wxRadioBox::wxRadioBox()
 
 wxRadioBox::~wxRadioBox()
 {
+    m_isBeingDeleted = TRUE;
+
     wxRadioButton *next,*current;
     
     current=m_radioButtonCycle->NextInCycle();
@@ -100,6 +99,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
                         int majorDim, long style,
                         const wxValidator& val, const wxString& name)
 {
+    if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
+        return false;
+
     int i;
     
     m_noItems = n;
@@ -122,8 +124,15 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
     
     for (i = 0; i < n; i++)
     {
-        wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10),
-            wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ;
+        wxRadioButton *radBtn = new wxRadioButton
+                                    (
+                                        this,
+                                        wxID_ANY,
+                                        wxStripMenuCodes(choices[i]),
+                                        wxPoint(5,20*i+10),
+                                        wxDefaultSize,
+                                        i == 0 ? wxRB_GROUP : 0
+                                    );
         if ( i == 0 )
             m_radioButtonCycle = radBtn ;
         //        m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);
@@ -136,9 +145,6 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
 }
 
 
-#pragma mark -
-#pragma mark ### Specific functions (reference v2) ###
-
 //-------------------------------------------------------------------------------------
 //         ¥ Enable(bool)
 //-------------------------------------------------------------------------------------
@@ -203,7 +209,7 @@ wxString wxRadioBox::GetString(int item) const
     wxRadioButton *current;
     
     if ((item < 0) || (item >= m_noItems))
-        return wxString("");
+        return wxEmptyString;
     
     i = 0;
     current = m_radioButtonCycle;
@@ -337,9 +343,6 @@ void wxRadioBox::Show(int item, bool show)
     current->Show(show);
 }
 
-#pragma mark -
-#pragma mark ### Other external functions ###
-
 //-------------------------------------------------------------------------------------
 //         ¥ Command
 //-------------------------------------------------------------------------------------
@@ -371,15 +374,12 @@ void wxRadioBox::SetFocus()
 }
 
 
-#pragma mark -
-#pragma mark ### Internal functions ###
-
 //-------------------------------------------------------------------------------------
 //         ¥ DoSetSize
 //-------------------------------------------------------------------------------------
 // Simulates the effect of the user issuing a command to the item
 
-#define RADIO_SIZE 40
+#define RADIO_SIZE 20
 
 void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
 {
@@ -409,7 +409,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     int totWidth,totHeight;
     
     SetFont(GetParent()->GetFont());
-    GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
+    GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
     charWidth/=52;
     
     maxWidth=-1;
@@ -423,7 +423,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
         if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
           }
     
-    totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight*3/2;
+    totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
     totWidth  = GetColumnCount() * (maxWidth + charWidth) + charWidth;
     
     // only change our width/height if asked for
@@ -452,6 +452,11 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
     
     x_start = charWidth;
     y_start = 15 ;
+    if ( UMAGetSystemVersion() >= 0x1030 )
+    {
+               //need to add a few more pixels for the top border on panther
+               y_start = y_start + 5; //how many exactly should this be to meet the HIG?
+    }
     x_offset = x_start;
     y_offset = y_start;
     
@@ -490,7 +495,7 @@ wxSize wxRadioBox::DoGetBestSize() const
     int totWidth, totHeight;
     
     wxFont font = GetParent()->GetFont();
-    GetTextExtent(wxString("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
+    GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
         &charWidth, &charHeight, NULL, NULL, &font);
     charWidth /= 52;
     
@@ -506,9 +511,14 @@ wxSize wxRadioBox::DoGetBestSize() const
         if (maxHeight < eachHeight)   maxHeight = eachHeight;
     }
     
-    totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight * 3/2;
+    totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
     totWidth  = GetColumnCount() * (maxWidth + charWidth) + charWidth;
     
+    if ( UMAGetSystemVersion() >= 0x1030 )
+    {
+        //need to add a few more pixels for the static boxborder on panther
+        totHeight = totHeight + 10; //how many exactly should this be to meet the HIG?
+    }
     // handle radio box title as well
     GetTextExtent(GetTitle(), &eachWidth, NULL);
     eachWidth  = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;