#include "precomp.h"
+/* FIXME, I can't include windowsx because it conflicts with some #defines */
+#define GET_X_LPARAM(lp) ((int)(short)LOWORD(lp))
+#define GET_Y_LPARAM(lp) ((int)(short)HIWORD(lp))
+
#define USE_CUSTOM_MENUBAND 1
// navigation controls and menubar just send a message to parent window
HRESULT CDockSite::Initialize(IUnknown *containedBand, CInternetToolbar *browser, HWND hwnd, int bandID, int flags)
{
- CComPtr<IObjectWithSite> site;
+ CComPtr<IObjectWithSite> child;
CComPtr<IOleWindow> oleWindow;
CComPtr<IDeskBand> deskBand;
TCHAR textBuffer[40];
REBARBANDINFOW bandInfo;
HRESULT hResult;
- hResult = containedBand->QueryInterface(IID_PPV_ARG(IObjectWithSite, &site));
+ hResult = containedBand->QueryInterface(IID_PPV_ARG(IObjectWithSite, &child));
if (FAILED(hResult))
return hResult;
hResult = containedBand->QueryInterface(IID_PPV_ARG(IOleWindow, &oleWindow));
fRebarWindow = hwnd;
fBandID = bandID;
fFlags = flags;
- hResult = site->SetSite(static_cast<IOleWindow *>(this));
+ hResult = child->SetSite(static_cast<IOleWindow *>(this));
if (FAILED(hResult))
return hResult;
hResult = oleWindow->GetWindow(&fChildWindow);
newSite->Initialize(newItem, this, fMainReBar, bandID, flags);
}
-HRESULT CInternetToolbar::ReserveBorderSpace()
+HRESULT CInternetToolbar::ReserveBorderSpace(LONG maxHeight)
{
CComPtr<IDockingWindowSite> dockingWindowSite;
RECT availableBorderSpace;
- RECT neededBorderSpace;
- HRESULT hResult;
- hResult = fSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &dockingWindowSite));
+ HRESULT hResult = fSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &dockingWindowSite));
if (FAILED(hResult))
return hResult;
hResult = dockingWindowSite->GetBorderDW(static_cast<IDockingWindow *>(this), &availableBorderSpace);
if (FAILED(hResult))
return hResult;
- SendMessage(fMainReBar, RB_SIZETORECT, RBSTR_CHANGERECT, reinterpret_cast<LPARAM>(&availableBorderSpace));
- neededBorderSpace.left = 0;
- neededBorderSpace.top = availableBorderSpace.bottom - availableBorderSpace.top;
- if (!fLocked)
- neededBorderSpace.top += 3;
- neededBorderSpace.right = 0;
- neededBorderSpace.bottom = 0;
- hResult = dockingWindowSite->SetBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
- if (FAILED(hResult))
- return hResult;
- return S_OK;
+
+ if (availableBorderSpace.top > maxHeight)
+ {
+ availableBorderSpace.top = maxHeight;
+ }
+
+ return ResizeBorderDW(&availableBorderSpace, fSite, FALSE);
}
HRESULT CInternetToolbar::CreateMenuBar(IShellMenu **menuBar)
}
}
hResult = ReserveBorderSpace();
+
+ // TODO: refresh view menu?
}
return S_OK;
}
break;
case 1:
// forward
- hResult = SetState(&CLSID_CommonButtons, gForwardCommandID, newValue ? TBSTATE_ENABLED : 0);
+ hResult = SetState(&CLSID_CommonButtons, IDM_GOTO_FORWARD, newValue ? TBSTATE_ENABLED : 0);
break;
case 2:
// back
- hResult = SetState(&CLSID_CommonButtons, gBackCommandID, newValue ? TBSTATE_ENABLED : 0);
+ hResult = SetState(&CLSID_CommonButtons, IDM_GOTO_BACK, newValue ? TBSTATE_ENABLED : 0);
break;
}
return hResult;
HRESULT STDMETHODCALLTYPE CInternetToolbar::ResizeBorderDW(LPCRECT prcBorder,
IUnknown *punkToolbarSite, BOOL fReserved)
{
- return E_NOTIMPL;
+ RECT neededBorderSpace;
+ RECT availableBorderSpace = *prcBorder;
+
+ SendMessage(fMainReBar, RB_SIZETORECT, RBSTR_CHANGERECT, reinterpret_cast<LPARAM>(&availableBorderSpace));
+
+ // RBSTR_CHANGERECT does not seem to set the proper size in the rect.
+ // Let's make sure we fetch the actual size properly.
+ GetWindowRect(fMainReBar, &availableBorderSpace);
+ neededBorderSpace.left = 0;
+ neededBorderSpace.top = availableBorderSpace.bottom - availableBorderSpace.top;
+ if (!fLocked)
+ neededBorderSpace.top += 3;
+ neededBorderSpace.right = 0;
+ neededBorderSpace.bottom = 0;
+
+ CComPtr<IDockingWindowSite> dockingWindowSite;
+
+ HRESULT hResult = fSite->QueryInterface(IID_PPV_ARG(IDockingWindowSite, &dockingWindowSite));
+ if (FAILED(hResult))
+ return hResult;
+
+ hResult = dockingWindowSite->RequestBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
+ if (FAILED(hResult))
+ return hResult;
+
+ hResult = dockingWindowSite->SetBorderSpaceDW(static_cast<IDockingWindow *>(this), &neededBorderSpace);
+ if (FAILED(hResult))
+ return hResult;
+
+ return S_OK;
}
HRESULT STDMETHODCALLTYPE CInternetToolbar::GetClassID(CLSID *pClassID)
hResult = CreateMenuBar(&menuBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(menuBar, ITBBID_MENUBAND,
- CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
+ AddDockItem(menuBar, ITBBID_MENUBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
hResult = menuBar->QueryInterface(IID_PPV_ARG(IOleWindow, &menuOleWindow));
hResult = menuOleWindow->GetWindow(&fMenuBandWindow);
fMenuBar.Attach(menuBar.Detach()); // transfer the ref count
+ // FIXME: The ros Rebar does not properly support fixed-size items such as the brandband,
+ // and it will put them in their own row, sized to take up the whole row.
+#if 0
/* Create and attach the brand/logo to the rebar */
hResult = CreateBrandBand(&logoBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(logoBar, ITBBID_BRANDBAND,
- CDockSite::ITF_NOGRIPPER | CDockSite::ITF_NOTITLE | CDockSite::ITF_FIXEDSIZE);
+ AddDockItem(logoBar, ITBBID_BRANDBAND, CDockSite::ITF_NOGRIPPER | CDockSite::ITF_NOTITLE | CDockSite::ITF_FIXEDSIZE);
fLogoBar.Attach(logoBar.Detach()); // transfer the ref count
+#endif
/* Create and attach the standard toolbar to the rebar */
hResult = CreateToolsBar(&toolsBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(toolsBar, ITBBID_TOOLSBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS);
+ AddDockItem(toolsBar, ITBBID_TOOLSBAND, CDockSite::ITF_NOTITLE | CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
fControlsBar.Attach(toolsBar.Detach()); // transfer the ref count
hResult = fControlsBar->QueryInterface(IID_PPV_ARG(IOleWindow, &toolbarOleWindow));
if (FAILED(hResult))
hResult = CreateAddressBand(&navigationBar);
if (FAILED(hResult))
return hResult;
- AddDockItem(navigationBar, ITBBID_ADDRESSBAND, CDockSite::ITF_NEWBANDALWAYS);
+ AddDockItem(navigationBar, ITBBID_ADDRESSBAND, CDockSite::ITF_NEWBANDALWAYS | CDockSite::ITF_GRIPPERALWAYS);
hResult = navigationBar->QueryInterface(IID_PPV_ARG(IOleWindow, &navigationOleWindow));
hResult = navigationOleWindow->GetWindow(&fNavigationWindow);
fNavigationBar.Attach(navigationBar.Detach());
HWND ownerWindow;
HWND dockContainer;
HRESULT hResult;
- DWORD style;
if (pUnkSite == NULL)
{
SubclassWindow(dockContainer);
// create rebar in dock container
- style = WS_VISIBLE | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | RBS_VARHEIGHT |
- RBS_BANDBORDERS | RBS_REGISTERDROP | RBS_AUTOSIZE | CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_TOP;
- fMainReBar = CreateWindow(REBARCLASSNAMEW, NULL, style,
+ DWORD style = WS_VISIBLE | WS_BORDER | WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
+ RBS_VARHEIGHT | RBS_BANDBORDERS | RBS_REGISTERDROP | RBS_AUTOSIZE | RBS_DBLCLKTOGGLE |
+ CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_TOP;
+ DWORD exStyle = WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR | WS_EX_TOOLWINDOW;
+ fMainReBar = CreateWindowEx(exStyle, REBARCLASSNAMEW, NULL, style,
0, 0, 700, 60, dockContainer, NULL, _AtlBaseModule.GetModuleInstance(), NULL);
if (fMainReBar == NULL)
return E_FAIL;
if (fMenuBar)
{
hResult = fMenuBar->QueryInterface(IID_PPV_ARG(IWinEventHandler, &menuWinEventHandler));
- if (menuWinEventHandler->IsWindowOwner(hWnd))
+ if (menuWinEventHandler->IsWindowOwner(hWnd) == S_OK)
{
return menuWinEventHandler->OnWinEvent(fMenuBandWindow, uMsg, wParam, lParam, theResult);
}
::MapWindowPoints(fToolbarWindow, NULL, reinterpret_cast<POINT *>(&bounds), 2);
switch (notifyInfo->iItem)
{
- case gBackCommandID:
+ case IDM_GOTO_BACK:
newMenu = CreatePopupMenu();
hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
hResult = serviceProvider->QueryService(
hResult = travelLog->Travel(browserService, -selectedItem);
DestroyMenu(newMenu);
break;
- case gForwardCommandID:
+ case IDM_GOTO_FORWARD:
newMenu = CreatePopupMenu();
hResult = fSite->QueryInterface(IID_PPV_ARG(IServiceProvider, &serviceProvider));
hResult = serviceProvider->QueryService(SID_SShellBrowser, IID_PPV_ARG(IBrowserService, &browserService));
default:
break;
}
+
+ MENUITEMINFO mii;
+ mii.cbSize = sizeof(mii);
+ mii.fMask = MIIM_STATE;
+ mii.fState = fLocked ? MFS_CHECKED : MFS_UNCHECKED;
+ command = SetMenuItemInfo(contextMenu, IDM_TOOLBARS_LOCKTOOLBARS, FALSE, &mii);
+
// TODO: use GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine menu alignment
command = TrackPopupMenu(contextMenu, TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
clickLocation.x, clickLocation.y, 0, m_hWnd, NULL);
if (nID != 0)
{
- if (nID == (UINT)gBackCommandID || nID == (UINT)gForwardCommandID)
+ if (nID == (UINT)IDM_GOTO_BACK || nID == (UINT)IDM_GOTO_FORWARD)
{
// TODO: Should this call QueryService?
hResult = fSite->QueryInterface(IID_PPV_ARG(IBrowserService, &browserService));
hResult = browserService->GetTravelLog(&travelLog);
hResult = travelLog->GetToolTipText(browserService,
- (nID == (UINT)gBackCommandID) ? TLOG_BACK : TLOG_FORE,
+ (nID == (UINT)IDM_GOTO_BACK) ? TLOG_BACK : TLOG_FORE,
0, tempString, 299);
if (FAILED(hResult))
{
return 0;
}
+LRESULT CInternetToolbar::OnLDown(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (fLocked)
+ return 0;
+
+ if (wParam & MK_CONTROL)
+ return 0;
+
+ fSizing = TRUE;
+
+ DWORD msgp = GetMessagePos();
+
+ fStartPosition.x = GET_X_LPARAM(msgp);
+ fStartPosition.y = GET_Y_LPARAM(msgp);
+
+ RECT rc;
+ GetWindowRect(m_hWnd, &rc);
+
+ fStartHeight = rc.bottom - rc.top;
+
+ SetCapture();
+
+ bHandled = TRUE;
+ return 0;
+}
+
+LRESULT CInternetToolbar::OnMouseMove(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (!fSizing)
+ return 0;
+
+ DWORD msgp = GetMessagePos();
+
+ POINT pt;
+ pt.x = GET_X_LPARAM(msgp);
+ pt.y = GET_Y_LPARAM(msgp);
+
+ ReserveBorderSpace(fStartHeight - fStartPosition.y + pt.y);
+
+ bHandled = TRUE;
+ return 0;
+}
+
+LRESULT CInternetToolbar::OnLUp(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
+{
+ bHandled = FALSE;
+ if (!fSizing)
+ return 0;
+
+ OnMouseMove(uMsg, wParam, lParam, bHandled);
+
+ fSizing = FALSE;
+
+ ReleaseCapture();
+
+ return 0;
+}
+
HRESULT CreateInternetToolbar(REFIID riid, void **ppv)
{
CComObject<CInternetToolbar> *theToolbar;