- // Create a bitmap for all the tool bitmaps
- HDC dc = ::GetDC(NULL);
- m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc, totalBitmapWidth, totalBitmapHeight);
- ::ReleaseDC(NULL, dc);
-
- // Now blit all the tools onto this bitmap
- HDC memoryDC = ::CreateCompatibleDC(NULL);
- HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP) m_hBitmap);
-
- HDC memoryDC2 = ::CreateCompatibleDC(NULL);
- int x = 0;
- wxNode *node = m_tools.First();
- int noButtons = 0;
- while (node)
- {
- wxToolBarTool *tool = (wxToolBarTool *)node->Data();
- if ((tool->m_toolStyle != wxTOOL_STYLE_SEPARATOR) && tool->m_bitmap1.Ok() && tool->m_bitmap1.GetHBITMAP())
+ wxCHECK_MSG( control->GetParent() == this, FALSE,
+ _T("control must have toolbar as parent") );
+
+ wxToolBarTool *tool = new wxToolBarTool(control);
+
+ m_tools.Append(control->GetId(), tool);
+
+ return TRUE;
+}
+
+wxToolBarTool *wxToolBar95::AddTool(int index,
+ const wxBitmap& bitmap,
+ const wxBitmap& pushedBitmap,
+ bool toggle,
+ long xPos, long yPos,
+ wxObject *clientData,
+ const wxString& helpString1,
+ const wxString& helpString2)
+{
+ wxToolBarTool *tool = new wxToolBarTool(index, bitmap, wxNullBitmap,
+ toggle, xPos, yPos,
+ helpString1, helpString2);
+ tool->m_clientData = clientData;
+
+ if (xPos > -1)
+ tool->m_x = xPos;
+ else
+ tool->m_x = m_xMargin;
+
+ if (yPos > -1)
+ tool->m_y = yPos;
+ else
+ tool->m_y = m_yMargin;
+
+ tool->SetSize(GetToolSize().x, GetToolSize().y);
+
+ m_tools.Append((long)index, tool);
+
+ return tool;
+}
+
+bool wxToolBar95::CreateTools()
+{
+ size_t nTools = m_tools.GetCount();
+ if ( nTools == 0 )
+ return FALSE;
+
+ HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
+
+ int totalBitmapWidth = (int)(m_defaultWidth * nTools);
+ int totalBitmapHeight = (int)m_defaultHeight;
+
+ // Create a bitmap for all the tool bitmaps
+ HDC dc = ::GetDC(NULL);
+ m_hBitmap = (WXHBITMAP) ::CreateCompatibleBitmap(dc,
+ totalBitmapWidth,
+ totalBitmapHeight);
+ ::ReleaseDC(NULL, dc);
+
+ // Now blit all the tools onto this bitmap
+ HDC memoryDC = ::CreateCompatibleDC(NULL);
+ HBITMAP oldBitmap = (HBITMAP) ::SelectObject(memoryDC, (HBITMAP)m_hBitmap);
+
+ HDC memoryDC2 = ::CreateCompatibleDC(NULL);
+
+ // the button position
+ wxCoord x = 0;
+
+ // the number of buttons (not separators)
+ int noButtons = 0;
+
+ wxNode *node = m_tools.First();
+ while (node)