+ if (m_tools.Number() == 0)
+ return FALSE;
+
+ HBITMAP oldToolBarBitmap = (HBITMAP) m_hBitmap;
+
+ int totalBitmapWidth = (int)(m_defaultWidth * m_tools.Number());
+ int totalBitmapHeight = (int)m_defaultHeight;
+
+// TODO:
+/*
+ // 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())
+ {
+// wxPalette *palette = tool->m_bitmap1->GetPalette();
+
+ HBITMAP oldBitmap2 = (HBITMAP) ::SelectObject(memoryDC2, (HBITMAP) tool->m_bitmap1.GetHBITMAP());
+ // int bltResult =
+ BitBlt(memoryDC, x, 0, (int) m_defaultWidth, (int) m_defaultHeight, memoryDC2,
+ 0, 0, SRCCOPY);
+ ::SelectObject(memoryDC2, oldBitmap2);
+ x += (int)m_defaultWidth;
+ noButtons ++;
+ }
+ node = node->Next();
+ }
+ ::SelectObject(memoryDC, oldBitmap);
+ ::DeleteDC(memoryDC);
+ ::DeleteDC(memoryDC2);
+
+ // Map to system colours
+ wxMapBitmap((HBITMAP) m_hBitmap, totalBitmapWidth, totalBitmapHeight);
+
+ if ( oldToolBarBitmap )
+ {
+ TBREPLACEBITMAP replaceBitmap;
+ replaceBitmap.hInstOld = NULL;
+ replaceBitmap.hInstNew = NULL;
+ replaceBitmap.nIDOld = (UINT) oldToolBarBitmap;
+ replaceBitmap.nIDNew = (UINT) (HBITMAP) m_hBitmap;
+ replaceBitmap.nButtons = noButtons;
+ if (::SendMessage((HWND) GetHWND(), TB_REPLACEBITMAP, (WPARAM) 0, (LPARAM) &replaceBitmap) == -1)
+ {
+ wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
+ }
+
+ ::DeleteObject((HBITMAP) oldToolBarBitmap);
+
+ // Now delete all the buttons
+ int i = 0;
+ while ( TRUE )
+ {
+ // TODO: What about separators???? They don't have an id!
+ if ( ! ::SendMessage( (HWND) GetHWND(), TB_DELETEBUTTON, i, 0 ) )
+ break;
+ }
+ }
+ else
+ {
+ TBADDBITMAP addBitmap;
+ addBitmap.hInst = 0;
+ addBitmap.nID = (UINT)m_hBitmap;
+ if (::SendMessage((HWND) GetHWND(), TB_ADDBITMAP, (WPARAM) noButtons, (LPARAM) &addBitmap) == -1)
+ {
+ wxFAIL_MSG(wxT("Could not add bitmap to toolbar"));
+ }
+ }
+
+ // Now add the buttons.
+ TBBUTTON buttons[50];
+
+ node = m_tools.First();
+ int i = 0;
+ int bitmapId = 0;
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+ if (tool->m_toolStyle == wxTOOL_STYLE_SEPARATOR)
+ {
+ buttons[i].iBitmap = 0;
+ buttons[i].idCommand = 0;
+
+ buttons[i].fsState = TBSTATE_ENABLED;
+ buttons[i].fsStyle = TBSTYLE_SEP;
+ buttons[i].dwData = 0L;
+ buttons[i].iString = 0;
+ }
+ else
+ {
+ buttons[i].iBitmap = bitmapId;
+ buttons[i].idCommand = tool->m_index;
+
+ buttons[i].fsState = 0;
+ if (tool->m_enabled)
+ buttons[i].fsState |= TBSTATE_ENABLED;
+ if (tool->m_toggleState)
+ buttons[i].fsState |= TBSTATE_CHECKED;
+ buttons[i].fsStyle = tool->m_isToggle ? TBSTYLE_CHECK : TBSTYLE_BUTTON;
+ buttons[i].dwData = 0L;
+ buttons[i].iString = 0;
+
+ bitmapId ++;
+ }
+
+ i ++;
+ node = node->Next();
+ }
+
+ long rc = ::SendMessage((HWND) GetHWND(), TB_ADDBUTTONS, (WPARAM)i, (LPARAM)& buttons);
+
+ wxCHECK_MSG( rc, FALSE, wxT("failed to add buttons to the toolbar") );
+
+ (void)::SendMessage((HWND) GetHWND(), TB_AUTOSIZE, (WPARAM)0, (LPARAM) 0);
+
+ SetRows(m_maxRows);
+*/
+ return TRUE;
+}
+
+bool wxToolBar::OS2Command(WXUINT cmd, WXWORD id)
+{
+ wxNode *node = m_tools.Find((long)id);
+ if (!node)
+ return FALSE;
+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+// TODO:
+/*
+ if (tool->m_isToggle)
+ tool->m_toggleState = (1 == (1 & (int)::SendMessage((HWND) GetHWND(), TB_GETSTATE, (WPARAM) id, (LPARAM) 0)));
+
+ BOOL ret = OnLeftClick((int)id, tool->m_toggleState);
+ if (ret == FALSE && tool->m_isToggle)
+ {
+ tool->m_toggleState = !tool->m_toggleState;
+ ::SendMessage((HWND) GetHWND(), TB_CHECKBUTTON, (WPARAM)id, (LPARAM)MAKELONG(tool->m_toggleState, 0));
+ }
+ return TRUE;
+*/
+ return FALSE;
+}
+
+bool wxToolBar::OS2OnNotify(int WXUNUSED(idCtrl),
+ WXLPARAM lParam,
+ WXLPARAM *result)
+{
+// TODO:
+/*
+ // First check if this applies to us
+ NMHDR *hdr = (NMHDR *)lParam;
+
+ // the tooltips control created by the toolbar is sometimes Unicode, even in
+ // an ANSI application
+ int code = (int)hdr->code;
+ if ( (code != TTN_NEEDTEXTA) && (code != TTN_NEEDTEXTW) )