From 093c33bb4610568cd217551142acad39dddf6562 Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Thu, 23 Jul 1998 17:48:39 +0000 Subject: [PATCH] Landing the WinFE RDF branch. git-svn-id: svn://10.0.0.236/trunk@6254 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/cmd/winfe/apichrom.h | 2 + mozilla/cmd/winfe/cfe.cpp | 27 +- mozilla/cmd/winfe/csttlbr2.cpp | 34 +- mozilla/cmd/winfe/csttlbr2.h | 24 +- mozilla/cmd/winfe/cxabstra.cpp | 4 +- mozilla/cmd/winfe/cxdc.cpp | 11 + mozilla/cmd/winfe/cxdc.h | 2 + mozilla/cmd/winfe/cxicon.cpp | 66 +- mozilla/cmd/winfe/cxpane.cpp | 43 + mozilla/cmd/winfe/cxpane.h | 2 + mozilla/cmd/winfe/cxstubs.cpp | 6 + mozilla/cmd/winfe/cxwin.cpp | 22 +- mozilla/cmd/winfe/dragbar.cpp | 2 +- mozilla/cmd/winfe/dropmenu.cpp | 18 +- mozilla/cmd/winfe/framinit.cpp | 89 +- mozilla/cmd/winfe/genchrom.cpp | 51 +- mozilla/cmd/winfe/genchrom.h | 4 + mozilla/cmd/winfe/genfram2.cpp | 2 +- mozilla/cmd/winfe/genframe.cpp | 51 +- mozilla/cmd/winfe/genframe.h | 2 - mozilla/cmd/winfe/mainfrm.h | 2 + mozilla/cmd/winfe/mkfiles32/mozilla.mak | 1 + mozilla/cmd/winfe/mozilla.cpp | 40 +- mozilla/cmd/winfe/mozilla.h | 3 + mozilla/cmd/winfe/mozilla.rc | 9 - mozilla/cmd/winfe/navbar.cpp | 317 ++--- mozilla/cmd/winfe/navbar.h | 34 +- mozilla/cmd/winfe/navcntr.cpp | 244 ++-- mozilla/cmd/winfe/navcntr.h | 74 +- mozilla/cmd/winfe/navcontv.h | 6 +- mozilla/cmd/winfe/navfram.cpp | 333 +++--- mozilla/cmd/winfe/navfram.h | 35 +- mozilla/cmd/winfe/outliner.cpp | 27 + mozilla/cmd/winfe/outliner.h | 4 +- mozilla/cmd/winfe/pain.cpp | 3 +- mozilla/cmd/winfe/pain.h | 2 +- mozilla/cmd/winfe/rdfacc.h | 39 +- mozilla/cmd/winfe/rdfliner.cpp | 542 +++++++-- mozilla/cmd/winfe/rdfliner.h | 107 +- mozilla/cmd/winfe/res/mozilla.rc2 | 2 - mozilla/cmd/winfe/resource.h | 4 - mozilla/cmd/winfe/statbar.cpp | 1 + mozilla/cmd/winfe/tlbutton.cpp | 56 +- mozilla/cmd/winfe/tlbutton.h | 10 +- mozilla/cmd/winfe/toolbar2.cpp | 14 +- mozilla/cmd/winfe/toolbar2.h | 2 + mozilla/cmd/winfe/tooltip.cpp | 12 + mozilla/cmd/winfe/tooltip.h | 12 +- mozilla/cmd/winfe/urlbar.cpp | 401 +++---- mozilla/cmd/winfe/urlbar.h | 64 +- mozilla/cmd/winfe/usertlbr.cpp | 1455 ++++++++++++++++++++--- mozilla/cmd/winfe/usertlbr.h | 149 ++- 52 files changed, 3050 insertions(+), 1416 deletions(-) diff --git a/mozilla/cmd/winfe/apichrom.h b/mozilla/cmd/winfe/apichrom.h index 39d86644fff..f5c6860fbe9 100755 --- a/mozilla/cmd/winfe/apichrom.h +++ b/mozilla/cmd/winfe/apichrom.h @@ -131,6 +131,7 @@ public: virtual void SetMenu( UINT ) = 0; // General Toolbar functionality + virtual void UpdateURLBars(char* url) = 0; virtual void ShowToolbar(UINT nToolbarID, BOOL bShow = TRUE) = 0; virtual BOOL GetToolbarVisible(UINT nToolbarID) = 0; virtual CWnd *GetToolbar(UINT nToolbarID) = 0; @@ -146,6 +147,7 @@ public: virtual void StopAnimation() = 0; // Configurable Toolbar Manager stuff + virtual int CreateRDFToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation)=0; virtual int CreateCustomizableToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation)=0; virtual int CreateCustomizableToolbar(UINT nStringID, int nMaxToolbars, BOOL bHasAnimation) = 0; virtual CString GetCustToolbarString() = 0; diff --git a/mozilla/cmd/winfe/cfe.cpp b/mozilla/cmd/winfe/cfe.cpp index 3be23dd4751..d456ed8025e 100644 --- a/mozilla/cmd/winfe/cfe.cpp +++ b/mozilla/cmd/winfe/cfe.cpp @@ -245,6 +245,12 @@ MWContext *CFE_CreateNewDocWindow(MWContext *pContext, URL_Struct *pURL) { } pFrame = (CMainFrame *) pGenFrame; + + // Now that we have the frame, dynamically create the toolbars (We won't enter this function + // from JavaScript. FE_MakeNewWindow is used instead.) + if (!pFrame->IsEditFrame()) + pFrame->BeginStreamingOfRDFToolbars(); + MWContext *pNewContext = pFrame->GetMainContext()->GetContext(); // Appropriate assignment of options/prefs can only happen if we are also @@ -1517,14 +1523,25 @@ extern "C" MWContext *FE_IsNetcasterRunning(void) { return theApp.m_pNetcasterWindow; } -#ifdef SHACK void CFE_DisplayBuiltin(MWContext *context, int iLocation, LO_BuiltinStruct *builtin_struct) { - return; + if(ABSTRACTCX(context)->IsDestroyed()) + { + // Don't allow this to happen if the context has been destroyed... + TRACE("Context %p Destroyed :: DisplayBuiltin Blocking\n", context); + return; + } + + ABSTRACTCX(context)->DisplayBuiltin(context, iLocation, builtin_struct); } -void CFE_FreeBuiltinElement(MWContext *context, LO_BuiltinStruct *builtin_struct) +void CFE_FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *builtin_struct) { - return; + if(ABSTRACTCX(pContext)->IsDestroyed()) { + // Don't allow this to happen if the context has been destroyed... + TRACE("Context %p Destroyed :: FreeBuiltinElement Blocking\n", pContext); + return; + } + + ABSTRACTCX(pContext)->FreeBuiltinElement(pContext, builtin_struct); } -#endif //SHACK diff --git a/mozilla/cmd/winfe/csttlbr2.cpp b/mozilla/cmd/winfe/csttlbr2.cpp index e42d033d73b..86709487876 100644 --- a/mozilla/cmd/winfe/csttlbr2.cpp +++ b/mozilla/cmd/winfe/csttlbr2.cpp @@ -112,6 +112,11 @@ void CButtonToolbarWindow::OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoH ((CNSToolbar2*)GetToolbar())->OnUpdateCmdUI(pTarget, bDisableIfNoHndler); } +void CButtonToolbarWindow::UpdateURLBars(char* url) +{ + ((CNSToolbar2*)GetToolbar())->UpdateURLBars(url); +} + void CButtonToolbarWindow::SetToolbarStyle(int nToolbarStyle) { @@ -221,7 +226,11 @@ int CDragToolbar::Create(CWnd *pParent, CToolbarWindow *pToolbar) CBrush brush; - if (!CWnd::Create(theApp.NSToolBarClass, NULL, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, rect, + DWORD shouldClipChildren = 0; + if (ShouldClipChildren()) + shouldClipChildren = WS_CLIPCHILDREN; + + if (!CWnd::Create(theApp.NSToolBarClass, NULL, shouldClipChildren | WS_CHILD | WS_CLIPSIBLINGS, rect, pParent, 0)) { return 0; @@ -386,6 +395,11 @@ void CDragToolbar::OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ) m_pToolbar->OnUpdateCmdUI(pTarget, bDisableIfNoHndler); } +void CDragToolbar::UpdateURLBars(char* url) +{ + m_pToolbar->UpdateURLBars(url); +} + ////////////////////////////////////////////////////////////////////////// // Messages for CDragToolbar ////////////////////////////////////////////////////////////////////////// @@ -908,6 +922,11 @@ int CCustToolbar::Create(CFrameWnd* pParent, BOOL bHasAnimation) return 1; } +CDragToolbar* CCustToolbar::CreateDragBar() +{ + return new CDragToolbar(); +} + void CCustToolbar::AddNewWindow(UINT nToolbarID, CToolbarWindow* pWindow, int nPosition, int nNoviceHeight, int nAdvancedHeight, UINT nTabBitmapIndex, CString tabTip, BOOL bIsNoviceMode, BOOL bIsOpen, BOOL bIsAnimation) { @@ -915,7 +934,7 @@ void CCustToolbar::AddNewWindow(UINT nToolbarID, CToolbarWindow* pWindow, int nP if(m_pToolbarArray[nPosition] != NULL || nPosition < 0 || nPosition >= m_nNumToolbars) nPosition = FindFirstAvailablePosition(); - CDragToolbar *pDragToolbar = new CDragToolbar; + CDragToolbar *pDragToolbar = CreateDragBar(); if(pDragToolbar->Create(this, pWindow)) { @@ -1185,6 +1204,17 @@ void CCustToolbar::OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ) } } +void CCustToolbar::UpdateURLBars(char* url) +{ + for (int i = 0; i < m_nNumToolbars; i++) + { + if(m_pToolbarArray[i] != NULL) + { + m_pToolbarArray[i]->UpdateURLBars(url); + } + } +} + void CCustToolbar::Customize(CRDFToolbar *pLinkToolbar, int nSelectedButton) { } diff --git a/mozilla/cmd/winfe/csttlbr2.h b/mozilla/cmd/winfe/csttlbr2.h index 14e46735a13..7af7c281bff 100644 --- a/mozilla/cmd/winfe/csttlbr2.h +++ b/mozilla/cmd/winfe/csttlbr2.h @@ -81,7 +81,7 @@ public: HTAB_BITMAP GetHTab(void) { return m_nHTab; } virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ){} - + virtual void UpdateURLBars(char* url) {} }; // Class: CButtonToolbarWindow @@ -94,6 +94,7 @@ public: HTAB_BITMAP nHTab); virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ); + virtual void UpdateURLBars(char* url); virtual void SetToolbarStyle(int nToolbarStyle); virtual int GetHeight(void); virtual CWnd* GetNSToolbar() { return GetToolbar(); } @@ -118,7 +119,7 @@ public: class CDragToolbar : public CWnd { -private: +protected: CToolbarWindow * m_pToolbar; BOOL m_bIsOpen; BOOL m_bIsShowing; @@ -140,6 +141,8 @@ public: ~CDragToolbar(); int Create(CWnd *pParent, CToolbarWindow *pToolbar); + virtual BOOL ShouldClipChildren() { return TRUE; } + CWnd *GetToolbar(void); int GetToolbarHeight(void); int GetMouseOffsetWithinToolbar(void) { return m_mouseDownPoint.y; } @@ -158,6 +161,8 @@ public: void SetAnimation(CAnimationBar2 *pAnimation); HTAB_BITMAP GetHTabType(void) { return m_eHTabType;} void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ); + virtual void UpdateURLBars(char* url); + // Generated message map functions //{{AFX_MSG(CDragToolbar) afx_msg void OnSize( UINT nType, int cx, int cy ); @@ -236,7 +241,7 @@ public: //Construction/destruction CCustToolbar(int nNumToolbars); - ~CCustToolbar(); + virtual ~CCustToolbar(); //Creation int Create(CFrameWnd* pParent, BOOL bHasAnimation); @@ -248,6 +253,8 @@ public: // customizable toolbar. void FinishedAddingNewWindows(void){} + CDragToolbar** GetVisibleToolbarArray() { return m_pToolbarArray; }; + //Controlling the animated icon void StopAnimation(); void StartAnimation(); @@ -270,6 +277,7 @@ public: CSize CalcDynamicLayout(int nLength, DWORD dwMode ); virtual void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ); + virtual void UpdateURLBars(char* url); void Customize(CRDFToolbar *pRDFToolbar = NULL, int nSelectedButton = 0); BOOL GetSaveToolbarInfo(void); @@ -286,6 +294,10 @@ public: void RemoveExternalTab(UINT nTabID); void SetBottomBorder(BOOL bBottomBorder); + + int FindDragToolbarFromWindow(CWnd *pWindow, CDragToolbar **pToolbarArray); + int FindDragToolbarFromID(UINT nToolbarID, CDragToolbar **pToolbarArray); + // Generated message map functions //{{AFX_MSG(CCustToolbar) afx_msg void OnSize( UINT nType, int cx, int cy ); @@ -310,8 +322,6 @@ public: protected: // virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult ); - -private: int CheckOpenButtons(CPoint point); int CheckClosedButtons(CPoint point); BOOL PointInClosedTab(CPoint point, HTAB_BITMAP tabType, int nNumClosedButtons, int nStartX, @@ -325,8 +335,6 @@ private: int GetNextClosedButtonX(HTAB_BITMAP tabType, int nNumClosedButtons, int nClosedStartX); void GetClosedButtonRegion(HTAB_BITMAP tabType, int nNumClosedButtons, CRgn &rgn); HBITMAP CreateHorizTab(UINT nID); - int FindDragToolbarFromWindow(CWnd *pWindow, CDragToolbar **pToolbarArray); - int FindDragToolbarFromID(UINT nToolbarID, CDragToolbar **pToolbarArray); void ShowDragToolbar(int nIndex, BOOL bShow); void OpenDragToolbar(int nIndex); void OpenExternalTab(int nIndex); @@ -337,6 +345,8 @@ private: void DrawClosedTab(HDC hCompatibleDC, HDC hDestDC, HTAB_BITMAP tabType, int nNumClosedButtons, BOOL bMouseOver, int nStartX, int nBottom); + virtual CDragToolbar* CreateDragBar(); + DECLARE_MESSAGE_MAP() }; diff --git a/mozilla/cmd/winfe/cxabstra.cpp b/mozilla/cmd/winfe/cxabstra.cpp index ffd9e74903d..1d03aa8366e 100755 --- a/mozilla/cmd/winfe/cxabstra.cpp +++ b/mozilla/cmd/winfe/cxabstra.cpp @@ -707,9 +707,7 @@ int CAbstractCX::GetUrl(URL_Struct *pUrl, FO_Present_Types iFormatOut, BOOL bRea CFrameGlue *pFrame = pWinCX->GetFrame(); if(pFrame){ - CURLBar *pUrlBar = (CURLBar *)pFrame->GetChrome()->GetToolbar(ID_LOCATION_TOOLBAR); - if(pUrlBar) - pUrlBar->UpdateFields(pUrl->address); + pFrame->GetChrome()->UpdateURLBars(pUrl->address); } } } diff --git a/mozilla/cmd/winfe/cxdc.cpp b/mozilla/cmd/winfe/cxdc.cpp index 6af47800b41..3c701189ff2 100644 --- a/mozilla/cmd/winfe/cxdc.cpp +++ b/mozilla/cmd/winfe/cxdc.cpp @@ -2747,6 +2747,12 @@ void CDCCX::DisplayPlugin(MWContext *pContext, LO_EmbedStruct *pEmbed, } #ifndef MOZ_NGLAYOUT + +void CDCCX::DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin) +{ + return; +} + void CDCCX::DisplayEmbed(MWContext *pContext, int iLocation, LO_EmbedStruct *pEmbed) { NPEmbeddedApp* pEmbeddedApp = (NPEmbeddedApp*)pEmbed->objTag.FE_Data; @@ -3759,6 +3765,11 @@ moved into DrawTextPostDecoration() } // void CDCCX::DisplayText() #ifndef MOZ_NGLAYOUT + +void CDCCX::FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin) { + return; +} + void CDCCX::FreeEmbedElement(MWContext *pContext, LO_EmbedStruct *pEmbed) { // We have our OLE document handle this. GetDocument()->FreeEmbedElement(pContext, pEmbed); diff --git a/mozilla/cmd/winfe/cxdc.h b/mozilla/cmd/winfe/cxdc.h index f4771ed7a0e..07d77551794 100644 --- a/mozilla/cmd/winfe/cxdc.h +++ b/mozilla/cmd/winfe/cxdc.h @@ -685,6 +685,7 @@ public: #ifndef MOZ_NGLAYOUT virtual void DisplayEmbed(MWContext *pContext, int iLocation, LO_EmbedStruct *pEmbed); #endif + virtual void DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin); virtual void DisplayBorder(MWContext *pContext, int iLocation, int x, int y, int width, int height, int bw, LO_Color *color, LO_LineStyle style); virtual void DisplayHR(MWContext *pContext, int iLocation, LO_HorizRuleStruct *pHorizRule); virtual BITMAPINFO* NewPixmap(NI_Pixmap* pImage, BOOL mask = FALSE); @@ -711,6 +712,7 @@ public: #endif #ifndef MOZ_NGLAYOUT virtual void FreeEmbedElement(MWContext *pContext, LO_EmbedStruct *pEmbed); + virtual void FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin); virtual void GetEmbedSize(MWContext *pContext, LO_EmbedStruct *pEmbed, NET_ReloadMethod bReload); #endif /* MOZ_NGLAYOUT */ #ifdef LAYERS diff --git a/mozilla/cmd/winfe/cxicon.cpp b/mozilla/cmd/winfe/cxicon.cpp index c802026d8ff..9ed9cc3146d 100644 --- a/mozilla/cmd/winfe/cxicon.cpp +++ b/mozilla/cmd/winfe/cxicon.cpp @@ -325,14 +325,72 @@ BITMAPINFO * CXIcon::NewPixmap(NI_Pixmap *pImage, BOOL isMask) int CXIcon::DisplayPixmap(NI_Pixmap* image, NI_Pixmap* mask, int32 x, int32 y, int32 x_offset, int32 y_offset, int32 width, int32 height, int32 lScaleWidth, int32 lScaleHeight, LTRB& Rect) { +/* + if (m_image) + { + CDCCX::HugeFree(m_image->bits); + m_image->bits = NULL; + FEBitmapInfo *imageInfo = (FEBitmapInfo*)m_image->client_data; + delete imageInfo; + m_image->client_data = NULL; + m_image = NULL; + } + + if (m_mask) + { + CDCCX::HugeFree(m_mask->bits); + m_mask->bits = NULL; + FEBitmapInfo *imageInfo = (FEBitmapInfo*)m_mask->client_data; + delete imageInfo; + m_mask->client_data = NULL; + m_mask = NULL; + } +*/ + + if (m_icon->bits) + { + // Free the old pixmap to make way for the new. + CDCCX::HugeFree(m_icon->bits); + m_icon->bits = NULL; + } + + if (m_icon->maskbits) + { + // Free the old mask to make way for the new. + CDCCX::HugeFree(m_icon->maskbits); + m_icon->maskbits = NULL; + } + + if (m_icon->bmpInfo) + { + XP_FREE(m_icon->bmpInfo); + m_icon->bmpInfo = NULL; + } + + // Get the new pixmap. m_image = image; m_mask = mask; + // Fill in our header. m_icon->bmpInfo = FillBitmapInfoHeader(image); - m_icon->bits = image->bits; - if (mask) - m_icon->maskbits = mask->bits; + // Copy our bits if we have any. + if (m_image->bits) + { + FEBitmapInfo* imageInfo = (FEBitmapInfo*) m_image->client_data; + BITMAPINFOHEADER* header = (BITMAPINFOHEADER*)imageInfo->bmpInfo; + m_icon->bits = HugeAlloc(header->biSizeImage, 1); + memcpy( m_icon->bits, m_image->bits, header->biSizeImage ); + } + + if (mask && m_mask->bits) + { + FEBitmapInfo* imageInfo = (FEBitmapInfo*) m_mask->client_data; + BITMAPINFOHEADER* header = (BITMAPINFOHEADER*)imageInfo->bmpInfo; + m_icon->maskbits = HugeAlloc(header->biSizeImage, 1); + memcpy( m_icon->maskbits, m_mask->bits, header->biSizeImage ); + } + m_icon->CompleteFrameCallback(); return 1; } @@ -342,9 +400,9 @@ void CXIcon::ImageComplete(NI_Pixmap* image) // Will get a call for both the mask and for the image. if (m_image && m_mask) { + m_icon->pairCount++; if (m_icon->pairCount == 2) m_icon->CompleteCallback(); - else m_icon->pairCount++; } else { diff --git a/mozilla/cmd/winfe/cxpane.cpp b/mozilla/cmd/winfe/cxpane.cpp index 9f51fe1203b..43776b44fe6 100644 --- a/mozilla/cmd/winfe/cxpane.cpp +++ b/mozilla/cmd/winfe/cxpane.cpp @@ -22,6 +22,7 @@ #include "intelli.h" #endif #include "navcontv.h" +#include "rdfliner.h" // What is CPaneCX? // A pane is part of a complete window. @@ -1528,3 +1529,45 @@ BOOL CPaneCX::SubClass(HWND hWnd, BOOL bSubClass) #endif } +char* getBuiltInAttribute (LO_BuiltinStruct *builtin_struct, char* att) { + int n = 0; + + while (n < builtin_struct->attribute_cnt) { + char* attName = *(builtin_struct->attribute_list + n); + char* attValue = *(builtin_struct->value_list + n); + if (attName && (stricmp(attName, att) == 0)) { + return attValue; + } + n++; + } + return NULL; +} + +void CPaneCX::DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *builtin_struct) +{ + // This code assumes a type of builtin/tree. Will have to be changed. + HWND cView = PANECX(pContext)->GetPane(); + + // Ok, we have the parent window. we need to know where to display it. + int xPos = builtin_struct->x; + int yPos = builtin_struct->y; + int width = builtin_struct->width; + int height = builtin_struct->height; + char* url = getBuiltInAttribute(builtin_struct, "data"); + char* target = getBuiltInAttribute(builtin_struct, "target"); + + if (builtin_struct->FE_Data == NULL) + { + CRDFContentView* pWnd = CRDFContentView::DisplayRDFTreeFromSHACK(CWnd::FromHandle(cView), xPos, yPos, width, height, url, builtin_struct->attribute_cnt, builtin_struct->attribute_list, builtin_struct->value_list); + ((CRDFOutliner*)pWnd->GetOutlinerParent()->GetOutliner())->SetWindowTarget(target); + builtin_struct->FE_Data = pWnd; + } +} + +void CPaneCX::FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin) +{ + // This code assumed a type of builtin/tree. Will have to be changed. + + CRDFContentView* pWnd = (CRDFContentView*)pBuiltin->FE_Data; + pWnd->DestroyWindow(); +} diff --git a/mozilla/cmd/winfe/cxpane.h b/mozilla/cmd/winfe/cxpane.h index f6c78c0ac91..c5a61fe6aa7 100644 --- a/mozilla/cmd/winfe/cxpane.h +++ b/mozilla/cmd/winfe/cxpane.h @@ -189,6 +189,8 @@ public: virtual void LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWidth, int32 *pHeight, int32 *pmWidth, int32 *pmHeight); virtual void FinishedLayout(MWContext *pContext); virtual void SetDocDimension(MWContext *pContext, int iLocation, int32 lWidth, int32 lLength); + virtual void DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin); + virtual void FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin); }; inline HWND CPaneCX::GetPane() const diff --git a/mozilla/cmd/winfe/cxstubs.cpp b/mozilla/cmd/winfe/cxstubs.cpp index 97fee2fa391..cb6d5cd54cb 100755 --- a/mozilla/cmd/winfe/cxstubs.cpp +++ b/mozilla/cmd/winfe/cxstubs.cpp @@ -287,6 +287,9 @@ void CStubsCX::DisplayEdge(MWContext *pContext, int iLocation, LO_EdgeStruct *pE void CStubsCX::DisplayEmbed(MWContext *pContext, int iLocation, LO_EmbedStruct *pEmbed) { } +void CStubsCX::DisplayBuiltin(MWContext *pContext, int iLocation, LO_BuiltinStruct *pBuiltin) { +} + void CStubsCX::DisplayFormElement(MWContext *pContext, int iLocation, LO_FormElementStruct *pFormElement) { } #endif @@ -362,6 +365,9 @@ void CStubsCX::DestroyEmbedWindow(MWContext *pContext, NPEmbeddedApp *pApp) { void CStubsCX::FreeEmbedElement(MWContext *pContext, LO_EmbedStruct *pEmbed) { } +void CStubsCX::FreeBuiltinElement(MWContext *pContext, LO_BuiltinStruct *pBuiltin) { +} + void CStubsCX::GetEmbedSize(MWContext *pContext, LO_EmbedStruct *pEmbed, NET_ReloadMethod Reload) { } diff --git a/mozilla/cmd/winfe/cxwin.cpp b/mozilla/cmd/winfe/cxwin.cpp index 06ab8091566..cea6dbcd1ff 100644 --- a/mozilla/cmd/winfe/cxwin.cpp +++ b/mozilla/cmd/winfe/cxwin.cpp @@ -4540,20 +4540,11 @@ void CWinCX::LayoutNewDocument(MWContext *pContext, URL_Struct *pURL, int32 *pWi if(GetContext()->type == MWContextBrowser && !EDT_IS_EDITOR(GetContext())) { LPCHROME pChrome = GetFrame()->GetChrome(); - if(pChrome) { - CWnd *pWnd = pChrome->GetToolbar(ID_LOCATION_TOOLBAR); - - if (pWnd && pWnd->IsKindOf(RUNTIME_CLASS(CURLBar))){ - CURLBar *pUrlBar = (CURLBar *) pWnd; - - if(pUrlBar != NULL) { - pUrlBar->m_pBox->GetWindowText(csText); - if(m_csSaveLocationBarText == csText && IsGridCell() == FALSE) { - pUrlBar->UpdateFields(pURL->address); - } - } - else - csText.Empty(); + if(pChrome) + { + if(IsGridCell() == FALSE) + { + pChrome->UpdateURLBars(pURL->address); } else csText.Empty(); @@ -4787,11 +4778,14 @@ void CWinCX::SetInternetKeyword(const char *keyword) { return; // Only if we're the main context + /* Disabled. Needs to be fixed so that the chrome is searched and all URL bars get + their tooltips updated. if( GetFrame()->GetMainContext() == this ) { CURLBar *urlBar = (CURLBar *) GetFrame()->GetChrome()->GetToolbar(ID_LOCATION_TOOLBAR); if (urlBar) urlBar->SetToolTip(keyword); } + */ } void CWinCX::ClearView(MWContext *pContext, int iView) { diff --git a/mozilla/cmd/winfe/dragbar.cpp b/mozilla/cmd/winfe/dragbar.cpp index 4b8f4757427..50b348b0a29 100644 --- a/mozilla/cmd/winfe/dragbar.cpp +++ b/mozilla/cmd/winfe/dragbar.cpp @@ -207,7 +207,7 @@ void CDragBar::EndDrag() GetDesktopWindow()->MapWindowPoints( m_parentView, &tempRect); MoveWindow(tempRect); Invalidate(); - m_dockedFrame->m_pSelector->Invalidate(); + //m_dockedFrame->m_pSelector->Invalidate(); m_parentView->RecalcLayout(); } diff --git a/mozilla/cmd/winfe/dropmenu.cpp b/mozilla/cmd/winfe/dropmenu.cpp index cbd55381df2..a5fadca8ace 100644 --- a/mozilla/cmd/winfe/dropmenu.cpp +++ b/mozilla/cmd/winfe/dropmenu.cpp @@ -2602,8 +2602,22 @@ void CDropMenu::LoadComplete(HT_Resource r) // invalidated. int childIndex = HT_GetNodeIndex(HT_GetView(r), r); int parentIndex = HT_GetNodeIndex(HT_GetView(parent), parent); - int actualIndex = childIndex - parentIndex - 1; - CDropMenuItem *item = (CDropMenuItem*)m_pMenuItemArray[actualIndex]; + + if (parent == HT_TopNode(HT_GetView(r))) + parentIndex = -1; + + // Need to count up from the parent index to the child index and only include nodes + // with indentation equal to the child index. + int indentation = HT_GetItemIndentation(r); + int offset = 0; + for (int i = parentIndex + 1; i < childIndex; i++) + { + int otherIndentation = HT_GetItemIndentation(HT_GetNthItem(HT_GetView(r), i)); + if (otherIndentation == indentation) + offset++; + } + + CDropMenuItem *item = (CDropMenuItem*)m_pMenuItemArray[offset]; InvalidateMenuItemIconRect(item); } } diff --git a/mozilla/cmd/winfe/framinit.cpp b/mozilla/cmd/winfe/framinit.cpp index d110d3ece06..96897c9459a 100755 --- a/mozilla/cmd/winfe/framinit.cpp +++ b/mozilla/cmd/winfe/framinit.cpp @@ -33,6 +33,7 @@ #include "libevent.h" #include "navfram.h" #include "edview.h" +#include "vocab.h" #ifdef _DEBUG #undef THIS_FILE @@ -100,8 +101,7 @@ BEGIN_MESSAGE_MAP(CMainFrame, CGenericFrame) ON_UPDATE_COMMAND_UI(ID_VIEW_COMMANDTOOLBAR, OnUpdateViewCommandToolbar) ON_UPDATE_COMMAND_UI(ID_VIEW_LOCATIONTOOLBAR, OnUpdateViewLocationToolbar) ON_UPDATE_COMMAND_UI(ID_VIEW_CUSTOMTOOLBAR, OnUpdateViewCustomToolbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_NAVCENTER, OnUpdateViewNavCenter) - + //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -259,6 +259,22 @@ int colorCubeSize = 216; #define TEXT_WIDTH 49 #endif +// The Event Handler for the top-level bookmarks menu in a frame. +static void qfNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened, + void *token, uint32 tokenType) +{ + if (whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED) + { + // The node was opened. + PRBool openState; + HT_GetOpenState(n, &openState); + if (openState) + { + CGenericFrame* pFrame = (CGenericFrame*)ns->data; + pFrame->FinishMenuExpansion(n); + } + } +} int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { @@ -275,16 +291,19 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) pIStatusBar->Create( this ); pIStatusBar->Release(); } - } else { - - //I'm hardcoding string since I don't want it translated. - GetChrome()->CreateCustomizableToolbar("Browser", 5, TRUE); - // Now that the application palette has been created (if - // appropriate) we can create the url bar. The animation - // might need custom colors so we need the palette to be around - // - + if (!theApp.m_bInGetCriticalFiles) + { + // Get the top level menu going. + // Construct the notification struct used by HT + HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); + ns->notifyProc = qfNotifyProcedure; + ns->data = this; + m_BookmarkMenuPane = theApp.m_bInGetCriticalFiles ? NULL : HT_NewQuickFilePane(ns); + } + } else { + LPNSSTATUSBAR pIStatusBar = NULL; GetChrome()->QueryInterface( IID_INSStatusBar, (LPVOID *) &pIStatusBar ); if( pIStatusBar ) @@ -295,14 +314,6 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) pIStatusBar->Show(FALSE); } - CreateMainToolbar(); - - if (!theApp.m_bInGetCriticalFiles) { // if we are here, don't show link bar - CreateLocationBar(); - CreateLinkBar(); - GetChrome()->FinishedAddingBrowserToolbars(); - } - if(!IsEditFrame()) { AddToMenuMap(FILEMENU, IDM_MAINFRAMEFILEMENU); @@ -330,8 +341,8 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) int CMainFrame::CreateLocationBar() { - - +/* +>>>>>>> 3.3.2.11 m_barLocation=new CURLBar(); if (!m_barLocation->Create(this, CURLBar::IDD, CBRS_TOP,CURLBar::IDD)) { @@ -359,13 +370,14 @@ int CMainFrame::CreateLocationBar() m_barLocation->SetContext((LPUNKNOWN)GetMainContext()); RecalcLayout(); - +*/ return TRUE; + } int CMainFrame::CreateLinkBar(void) { - m_barLinks = CRDFToolbar::CreateUserToolbar(this); + m_barLinks = CRDFToolbar::CreateUserToolbar(NULL, this); CButtonToolbarWindow *pWindow = new CButtonToolbarWindow(m_barLinks, theApp.m_pToolbarStyle, 43, 27, eSMALL_HTAB); @@ -486,6 +498,33 @@ int CMainFrame::CreateMainToolbar(void) return TRUE; } +void CMainFrame::BeginStreamingOfRDFToolbars() +{ + GetChrome()->CreateRDFToolbar("Browser", 5, TRUE); + + if (!theApp.m_bInGetCriticalFiles) + { + // Get the top level menu going. + // Construct the notification struct used by HT + HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); + ns->notifyProc = qfNotifyProcedure; + ns->data = this; + m_BookmarkMenuPane = theApp.m_bInGetCriticalFiles ? NULL : HT_NewQuickFilePane(ns); + } +/* + if (!theApp.m_bInGetCriticalFiles && AllowDocking() && + !theApp.m_ParentAppWindow && !theApp.m_bKioskMode) + { + // Show the selector if the pref says we should. + BOOL bSelVisible; + PREF_GetBoolPref(gPrefSelectorVisible, &bSelVisible); + if (bSelVisible) + theApp.CreateNewNavCenter(this); + } + */ +} + void CMainFrame::OnShowWindow (BOOL bShow, UINT nStatus) { CGenericFrame::OnShowWindow(bShow,nStatus); @@ -599,9 +638,7 @@ void CMainFrame::OnLoadHomePage() if (nStartup != 0){ GetMainContext()->NormalGetUrl(lpszHomePage); - CURLBar *pUrlBar = (CURLBar *)GetChrome()->GetToolbar(ID_LOCATION_TOOLBAR); - if(pUrlBar != NULL) - pUrlBar->UpdateFields(lpszHomePage); + GetChrome()->UpdateURLBars((char*)lpszHomePage); } } } diff --git a/mozilla/cmd/winfe/genchrom.cpp b/mozilla/cmd/winfe/genchrom.cpp index 1574bf81bad..60f03e6c0fa 100755 --- a/mozilla/cmd/winfe/genchrom.cpp +++ b/mozilla/cmd/winfe/genchrom.cpp @@ -785,34 +785,8 @@ BOOL CGenericChrome::procTabNavigation( UINT nChar, UINT firstTime, UINT control void CGenericChrome::ShowToolbar(UINT nToolbarID, BOOL bShow) { if(m_pCustToolbar) - m_pCustToolbar->ShowToolbar(nToolbarID, bShow); - - if (nToolbarID == ID_PERSONAL_TOOLBAR) // Hack. Show Aurora if and only if a personal toolbar is shown. { - if (m_pParent->IsKindOf(RUNTIME_CLASS(CGenericFrame))) - { - CGenericFrame* genFrame = (CGenericFrame*)m_pParent; - - // Create NavCenter unless bShow is FALSE... then we hide it. HACK! - // THIS CODE WILL BE REMOVED! JUST TEMPORARILY HACKED TO PREVENT NAVCENTER - // FROM SHOWING UP EVERYWHERE! - if (!theApp.m_bInGetCriticalFiles && genFrame->AllowDocking() && - !theApp.m_ParentAppWindow && !theApp.m_bKioskMode) - { - // Show the selector if the pref says we should. - BOOL bSelVisible; - PREF_GetBoolPref(gPrefSelectorVisible, &bSelVisible); - if (bSelVisible && bShow) - theApp.CreateNewNavCenter(genFrame); - } - - CNSNavFrame* navFrame = genFrame->GetDockedNavCenter(); - if (navFrame && !bShow) - { - // Destroy the Nav Center. - navFrame->DeleteNavCenter(); - } - } + m_pCustToolbar->ShowToolbar(nToolbarID, bShow); } } @@ -978,6 +952,22 @@ void CGenericChrome::StopAnimation() } } +int CGenericChrome::CreateRDFToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation) +{ + CRDFToolbarHolder* pHolder = new CRDFToolbarHolder(nMaxToolbars, m_pParent); + m_pCustToolbar = pHolder; + + if(! m_pCustToolbar->Create(m_pParent, bHasAnimation)) + return FALSE; + + m_toolbarName = toolbarName; + + // Toolbars will start coming in here. + pHolder->InitializeRDFData(); + + return TRUE; +} + int CGenericChrome::CreateCustomizableToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation) { m_pCustToolbar=new CCustToolbar(nMaxToolbars); @@ -1072,6 +1062,13 @@ void CGenericChrome::ImagesButton(BOOL bShowImagesButton) } } +// URL Bar Stuff +void CGenericChrome::UpdateURLBars(char* url) +{ + if(m_pCustToolbar) + m_pCustToolbar->UpdateURLBars(url); +} + // Window Title Stuff void CGenericChrome::SetWindowTitle(const char *lpszText) { diff --git a/mozilla/cmd/winfe/genchrom.h b/mozilla/cmd/winfe/genchrom.h index 96632bcd034..871f9e4e6d7 100755 --- a/mozilla/cmd/winfe/genchrom.h +++ b/mozilla/cmd/winfe/genchrom.h @@ -242,6 +242,9 @@ public: virtual void SaveToolbarConfiguration(UINT nToolbarID, CString &csToolbarName); virtual void SetSaveToolbarInfo(BOOL bSaveToolbarInfo); +// URL bars stuff + virtual void UpdateURLBars(char* url); + // Animation Stuff virtual void StartAnimation(); virtual void StopAnimation(); @@ -251,6 +254,7 @@ public: virtual void SetDocumentTitle(const char*); // ToolbarManager Stuff + virtual int CreateRDFToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation); virtual int CreateCustomizableToolbar(CString toolbarName, int nMaxToolbars, BOOL bHasAnimation); virtual int CreateCustomizableToolbar(UINT nStringID, int nMaxToolbars, BOOL bHasAnimation); virtual CString GetCustToolbarString(); diff --git a/mozilla/cmd/winfe/genfram2.cpp b/mozilla/cmd/winfe/genfram2.cpp index 67ab36d5098..5faecc88a02 100644 --- a/mozilla/cmd/winfe/genfram2.cpp +++ b/mozilla/cmd/winfe/genfram2.cpp @@ -330,7 +330,7 @@ void CGenericFrame::OnFilePageSetup() void CGenericFrame::OnGoHistory() { - theApp.CreateNewNavCenter(NULL, TRUE, HT_VIEW_HISTORY); + //theApp.CreateNewNavCenter(NULL, TRUE, HT_VIEW_HISTORY); } void CGenericFrame::OnPageFromWizard() diff --git a/mozilla/cmd/winfe/genframe.cpp b/mozilla/cmd/winfe/genframe.cpp index ef7318186f3..72fbb2a27f4 100644 --- a/mozilla/cmd/winfe/genframe.cpp +++ b/mozilla/cmd/winfe/genframe.cpp @@ -150,30 +150,9 @@ IMPLEMENT_DYNCREATE(CGenericFrame, CNSGenFrame) #define new DEBUG_NEW #endif -// The Event Handler -static void qfNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) -{ - if (whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED) - { - // The node was opened. - PRBool openState; - HT_GetOpenState(n, &openState); - if (openState) - { - CGenericFrame* pFrame = (CGenericFrame*)ns->data; - pFrame->FinishMenuExpansion(n); - } - } -} - CGenericFrame::CGenericFrame() { - // Construct the notification struct used by HT - HT_Notification ns = new HT_NotificationStruct; - ns->notifyProc = qfNotifyProcedure; - ns->data = this; - - m_BookmarkMenuPane = theApp.m_bInGetCriticalFiles ? NULL : HT_NewQuickFilePane(ns); + m_BookmarkMenuPane = NULL; m_nBookmarkItems = 0; m_nFileBookmarkItems = 0; m_pHotlistMenuMap = new CMapWordToPtr(); @@ -855,8 +834,6 @@ BEGIN_MESSAGE_MAP(CGenericFrame, CFrameWnd) ON_COMMAND(ID_VIEW_LOCATIONTOOLBAR, OnViewLocationToolbar) ON_UPDATE_COMMAND_UI(ID_VIEW_CUSTOMTOOLBAR, OnUpdateViewCustomToolbar) ON_COMMAND(ID_VIEW_CUSTOMTOOLBAR, OnViewCustomToolbar) - ON_UPDATE_COMMAND_UI(ID_VIEW_NAVCENTER, OnUpdateViewNavCenter) - ON_COMMAND(ID_VIEW_NAVCENTER, OnViewNavCenter) ON_UPDATE_COMMAND_UI(ID_CUSTOMIZE_TOOLBAR, OnUpdateCustomizeToolbar) ON_COMMAND(ID_CUSTOMIZE_TOOLBAR, OnCustomizeToolbar) ON_UPDATE_COMMAND_UI(ID_PLACES, OnUpdatePlaces) @@ -2252,7 +2229,7 @@ void CGenericFrame::OnAbout() void CGenericFrame::OnShowBookmarkWindow() { - theApp.CreateNewNavCenter(NULL, TRUE, HT_VIEW_BOOKMARK); + //theApp.CreateNewNavCenter(NULL, TRUE, HT_VIEW_BOOKMARK); } /////////////////////////////////////////////////////////////////////////////// @@ -2565,30 +2542,6 @@ void CGenericFrame::OnUpdateViewCommandToolbar(CCmdUI *pCmdUI) } } -void CGenericFrame::OnViewNavCenter() -{ - CNSNavFrame* pFrame = GetDockedNavCenter(); - if (pFrame) - pFrame->DeleteNavCenter(); - else theApp.CreateNewNavCenter(this); -} - -void CGenericFrame::OnUpdateViewNavCenter(CCmdUI *pCmdUI) -{ - CNSNavFrame* pFrame = GetDockedNavCenter(); - BOOL bShow = (pFrame != NULL); - - if( pCmdUI->m_pMenu ) - { - pCmdUI->m_pMenu->ModifyMenu(CASTUINT(ID_VIEW_NAVCENTER), CASTUINT(MF_BYCOMMAND | MF_STRING), CASTUINT(ID_VIEW_NAVCENTER), - szLoadString(CASTUINT(bShow ? IDS_HIDE_NAVCENTER : IDS_SHOW_NAVCENTER)) ); - } - else - { - pCmdUI->SetCheck(bShow); - } -} - void CGenericFrame::OnViewLocationToolbar() { GetChrome()->ShowToolbar(ID_LOCATION_TOOLBAR, !GetChrome()->GetToolbarVisible(ID_LOCATION_TOOLBAR)); diff --git a/mozilla/cmd/winfe/genframe.h b/mozilla/cmd/winfe/genframe.h index 9d5525ef42a..1079cce3c48 100644 --- a/mozilla/cmd/winfe/genframe.h +++ b/mozilla/cmd/winfe/genframe.h @@ -295,8 +295,6 @@ protected: afx_msg void OnUpdateViewLocationToolbar(CCmdUI* pCmdUI); afx_msg void OnViewCustomToolbar(); afx_msg void OnUpdateViewCustomToolbar(CCmdUI* pCmdUI); - afx_msg void OnViewNavCenter(); - afx_msg void OnUpdateViewNavCenter(CCmdUI* pCmdUI); afx_msg void OnUpdatePlaces(CCmdUI* pCmdUI); afx_msg void OnUpdateCustomizeToolbar(CCmdUI *pCmdUI); afx_msg void OnCustomizeToolbar(); diff --git a/mozilla/cmd/winfe/mainfrm.h b/mozilla/cmd/winfe/mainfrm.h index 8b973b45452..887cf406242 100644 --- a/mozilla/cmd/winfe/mainfrm.h +++ b/mozilla/cmd/winfe/mainfrm.h @@ -116,6 +116,8 @@ public: #endif virtual BOOL AllowDocking() {return TRUE;} + virtual void BeginStreamingOfRDFToolbars(); + // Generated message map functions protected: //{{AFX_MSG(CMainFrame) diff --git a/mozilla/cmd/winfe/mkfiles32/mozilla.mak b/mozilla/cmd/winfe/mkfiles32/mozilla.mak index 2d997bb2782..2e69cc2f8a7 100644 --- a/mozilla/cmd/winfe/mkfiles32/mozilla.mak +++ b/mozilla/cmd/winfe/mkfiles32/mozilla.mak @@ -816,6 +816,7 @@ $(OUTDIR)\mozilla.dep: $(DEPTH)\cmd\winfe\mkfiles32\mozilla.mak $(DEPTH)\lib\layout\fsfile.cpp $(DEPTH)\lib\layout\streams.cpp $(DEPTH)\lib\layout\layarena.c + $(DEPTH)\lib\layout\laybuiltin.c $(DEPTH)\lib\layout\layblock.c $(DEPTH)\lib\layout\laycell.c $(DEPTH)\lib\layout\laycols.c diff --git a/mozilla/cmd/winfe/mozilla.cpp b/mozilla/cmd/winfe/mozilla.cpp index 42a21801638..1c30e3cc032 100644 --- a/mozilla/cmd/winfe/mozilla.cpp +++ b/mozilla/cmd/winfe/mozilla.cpp @@ -1467,6 +1467,9 @@ BOOL CNetscapeApp::InitInstance() RDF_Init(&initStruct); // TODO: Can this fail? Want to bail if so. + // Initialize the command map used by RDF configurable UI. + m_pBrowserCommandMap = CIsomorphicCommandMap::InitializeCommandMap("Browser Commands"); + m_pCommandToolbarIndices = CIsomorphicCommandMap::InitializeCommandMap("Command Toolbar Bitmap Indices"); // RDF INITIALIZATION ENDS HERE @@ -2063,34 +2066,27 @@ BOOL CNetscapeApp::InitInstance() #endif /* MOZ_MAIL_NEWS */ #ifdef EDITOR - if ( (bIsGold && (iStartupMode & STARTUP_EDITOR)) && !(iStartupMode & STARTUP_BROWSER)) - { //start the editor - theApp.m_EditTmplate->OpenDocumentFile(NULL); + if (bIsGold && (iStartupMode & STARTUP_EDITOR)) + { //start the editor + theApp.m_EditTmplate->OpenDocumentFile(NULL); CMainFrame *pMainFrame = (CMainFrame *)FEU_GetLastActiveFrame(MWContextBrowser, TRUE); if(pMainFrame) pMainFrame->OnLoadHomePage();//suppose to load what ever was on the command line } - else #endif // EDITOR - if ((iStartupMode & STARTUP_BROWSER) && !(iStartupMode & STARTUP_EDITOR) ) - { //start the browser - theApp.m_ViewTmplate->OpenDocumentFile(NULL); - CMainFrame *pMainFrame = (CMainFrame *)FEU_GetLastActiveFrame(MWContextBrowser, FALSE); - if(pMainFrame) pMainFrame->OnLoadHomePage(); //suppose to load what ever was on the command line - } -#ifdef EDITOR - else if ((iStartupMode & STARTUP_BROWSER) && (iStartupMode & STARTUP_EDITOR) ) + + if (iStartupMode & STARTUP_BROWSER) + { + theApp.m_ViewTmplate->OpenDocumentFile(NULL); //open browser window + CGenericFrame *pFrame = (CGenericFrame *)FEU_GetLastActiveFrame(MWContextBrowser, FALSE); + if (pFrame) { - //start both of these guys since there preferences were set - //theApp.m_EditTmplate->OpenDocumentFile(NULL); - theApp.m_ViewTmplate->OpenDocumentFile(NULL); //open browser window - CGenericFrame *pFrame = (CGenericFrame *)FEU_GetLastActiveFrame(MWContextBrowser, FALSE); - if (pFrame){ - CMainFrame *pMainFrame = (CMainFrame*)pFrame; - pMainFrame->OnLoadHomePage(); - pFrame->OnOpenComposerWindow(); - } + CMainFrame *pMainFrame = (CMainFrame*)pFrame; + pMainFrame->OnLoadHomePage(); + // Now that we have the frame, dynamically create the toolbars (We won't enter this function + // from JavaScript. FE_MakeNewWindow is used instead.) + pMainFrame->BeginStreamingOfRDFToolbars(); } -#endif // EDITOR + } } if(m_pFrameList && m_pFrameList->GetMainContext()) diff --git a/mozilla/cmd/winfe/mozilla.h b/mozilla/cmd/winfe/mozilla.h index ef891fccbbd..a4ecbbd2361 100644 --- a/mozilla/cmd/winfe/mozilla.h +++ b/mozilla/cmd/winfe/mozilla.h @@ -276,6 +276,9 @@ public: HWND m_ParentAppWindow; BOOL m_bChildWindow; + CIsomorphicCommandMap* m_pBrowserCommandMap; + CIsomorphicCommandMap* m_pCommandToolbarIndices; + // Our very own run/pump/idle implementation. public: int Run(); diff --git a/mozilla/cmd/winfe/mozilla.rc b/mozilla/cmd/winfe/mozilla.rc index 3ca825e172c..eba6782308e 100644 --- a/mozilla/cmd/winfe/mozilla.rc +++ b/mozilla/cmd/winfe/mozilla.rc @@ -351,13 +351,6 @@ BEGIN EDITTEXT IDC_PROMPT_ANS,10,39,229,14,ES_AUTOHSCROLL END -IDD_URLTITLEBAR DIALOG DISCARDABLE 0, 0, 338, 21 -STYLE WS_CHILD | WS_CLIPCHILDREN -FONT 8, "MS Sans Serif" -BEGIN - RTEXT "Location:",IDC_URLTEXT,94,5,33,8 -END - IDD_INTERNETSHORTCUT DIALOG DISCARDABLE 0, 0, 248, 69 STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU CAPTION "Create Internet Shortcut" @@ -3756,8 +3749,6 @@ BEGIN IDS_MAIL_THISFOLDER "This Folder" IDS_HIDE_COMMANDTOOLBAR "Hide &Navigation Toolbar" IDS_SHOW_COMMANDTOOLBAR "Show &Navigation Toolbar" - IDS_HIDE_NAVCENTER "Hide Navi&gation Center" - IDS_SHOW_NAVCENTER "Show Navi&gation Center" IDS_EXPANDO "WHS" END diff --git a/mozilla/cmd/winfe/navbar.cpp b/mozilla/cmd/winfe/navbar.cpp index 0de2ec1eb9b..1507db1c27e 100644 --- a/mozilla/cmd/winfe/navbar.cpp +++ b/mozilla/cmd/winfe/navbar.cpp @@ -31,129 +31,10 @@ // The Nav Center vocab element extern "C" RDF_NCVocab gNavCenter; -/* This class may yet be of use. For now comment it out. -BEGIN_MESSAGE_MAP(CNavMenuButton, CRDFToolbarButton) - ON_MESSAGE(NSDRAGMENUOPEN, OnDragMenuOpen) -END_MESSAGE_MAP() - -CNavMenuButton::CNavMenuButton() -:m_HTView(NULL) -{ - m_bShouldShowRMMenu = FALSE; -} - -LRESULT CNavMenuButton::OnDragMenuOpen(WPARAM wParam, LPARAM lParam) -{ -// Set the focus to the tree view. - if (!m_HTView) - return 1; - - CSelectorButton* pSelectorButton = (CSelectorButton*)HT_GetViewFEData(m_HTView); - if (!pSelectorButton) - return 1; - - // Get the tree view and set focus to it. - CRDFContentView* pView = pSelectorButton->GetTreeView(); - if (pView) - pView->SetFocus(); - -// Set our drop menu's user data. - m_pCachedDropMenu = (CDropMenu *)lParam; // Set our drop menu - - m_MenuCommandMap.Clear(); - HT_View theView = m_HTView; - HT_Resource node = NULL; - node = HT_GetNextSelection(theView, node); - BOOL bg = (node == NULL); - - HT_Cursor theCursor = HT_NewContextualMenuCursor(theView, PR_FALSE, (PRBool)bg); - if (theCursor != NULL) - { - // We have a cursor. Attempt to iterate - HT_MenuCmd theCommand; - while (HT_NextContextMenuItem(theCursor, &theCommand)) - { - char* menuName = HT_GetMenuCmdName(theCommand); - if (theCommand == HT_CMD_SEPARATOR) - m_pCachedDropMenu->AppendMenu(MF_SEPARATOR, 0, TRUE, NULL, NULL); - else - { - // Add the command to our command map - CRDFMenuCommand* rdfCommand = new CRDFMenuCommand(menuName, theCommand); - int index = m_MenuCommandMap.AddCommand(rdfCommand); - m_pCachedDropMenu->AppendMenu(MF_STRING, index+FIRST_HT_MENU_ID, menuName, TRUE, NULL, NULL, NULL); - } - } - HT_DeleteCursor(theCursor); - } - return 1; -} - -BOOL CNavMenuButton::OnCommand(UINT wParam, LONG lParam) -{ - BOOL bRtn = TRUE; - - if (wParam >= FIRST_HT_MENU_ID && wParam <= LAST_HT_MENU_ID) - { - // A selection was made from the context menu. - // Use the menu map to get the HT command value - CRDFMenuCommand* theCommand = (CRDFMenuCommand*)(m_MenuCommandMap.GetCommand((int)wParam-FIRST_HT_MENU_ID)); - if (theCommand) - { - HT_MenuCmd htCommand = theCommand->GetHTCommand(); - HT_DoMenuCmd(HT_GetPane(m_HTView), htCommand); - } - - } - - return bRtn; -} - -void CNavMenuButton::UpdateView(HT_View v) -{ - m_HTView = v; - if (v == NULL) - SetText("No View Selected."); - else SetText(HT_GetNodeName(HT_TopNode(m_HTView))); -} - -void CNavMenuButton::UpdateButtonText(CRect rect) -{ - CString originalText = "No View Selected."; - if (m_HTView != NULL) - originalText = HT_GetNodeName(HT_TopNode(m_HTView)); - - int currCount = originalText.GetLength(); - - // Start off at the maximal string - CString strTxt = originalText; - - CSize theSize = GetButtonSizeFromChars(originalText, currCount); - int horExtent = theSize.cx; - int width = horExtent; - int cutoff = rect.right - NAVBAR_CLOSEBOX - 9; - if (width > cutoff && cutoff > 0) - width = cutoff; - - while (horExtent > width) - { - strTxt = originalText.Left(currCount-3) + "..."; - theSize = GetButtonSizeFromChars(strTxt, currCount); - horExtent = theSize.cx; - currCount--; - } - - SetTextWithoutResize(strTxt); - - int height = GetRequiredButtonSize().cy; - MoveWindow(2, (rect.Height()-height)/2, width, height); -} -*/ - extern void DrawUpButton(HDC dc, CRect& rect); -BEGIN_MESSAGE_MAP(CNavMenuBar, CWnd) - //{{AFX_MSG_MAP(CNavMenuBar) +BEGIN_MESSAGE_MAP(CNavTitleBar, CWnd) + //{{AFX_MSG_MAP(CNavTitleBar) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! ON_WM_CREATE() @@ -165,19 +46,19 @@ BEGIN_MESSAGE_MAP(CNavMenuBar, CWnd) //}}AFX_MSG_MAP END_MESSAGE_MAP() -CNavMenuBar::CNavMenuBar() -:m_pSelectorButton(NULL), m_bHasFocus(FALSE) // ,m_pMenuButton(NULL) +CNavTitleBar::CNavTitleBar() +:m_bHasFocus(FALSE) { m_pBackgroundImage = NULL; m_View = NULL; } -CNavMenuBar::~CNavMenuBar() +CNavTitleBar::~CNavTitleBar() { // delete m_pMenuButton; } -void CNavMenuBar::OnPaint( ) +void CNavTitleBar::OnPaint( ) { CPaintDC dc(this); CRect rect; @@ -190,25 +71,36 @@ void CNavMenuBar::OnPaint( ) // Read in all the properties if (!m_View) return; - HT_Resource top = HT_TopNode(m_View); + HT_Resource topNode = HT_TopNode(m_View); void* data; PRBool foundData = FALSE; + CRDFOutliner* pOutliner = (CRDFOutliner*)HT_GetViewFEData(m_View); + if (pOutliner->InNavigationMode()) + { + m_ForegroundColor = pOutliner->GetForegroundColor(); + m_BackgroundColor = pOutliner->GetBackgroundColor(); + m_BackgroundImageURL = pOutliner->GetBackgroundImageURL(); + } + else + { + m_ForegroundColor = RGB(255,255,255); + m_BackgroundColor = RGB(64,64,64); + m_BackgroundImageURL = ""; + } + // Foreground color - HT_GetNodeData(top, gNavCenter->titleBarFGColor, HT_COLUMN_STRING, &data); + HT_GetNodeData(topNode, gNavCenter->titleBarFGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_ForegroundColor); - else m_ForegroundColor = RGB(255,255,255); - + // background color - HT_GetNodeData(top, gNavCenter->titleBarBGColor, HT_COLUMN_STRING, &data); + HT_GetNodeData(topNode, gNavCenter->titleBarBGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_BackgroundColor); - else m_BackgroundColor = RGB(64,64,64); - + // Background image URL - m_BackgroundImageURL = ""; - HT_GetNodeData(top, gNavCenter->titleBarBGURL, HT_COLUMN_STRING, &data); + HT_GetNodeData(topNode, gNavCenter->titleBarBGURL, HT_COLUMN_STRING, &data); if (data) m_BackgroundImageURL = (char*)data; m_pBackgroundImage = NULL; // Clear out the BG image. @@ -246,9 +138,18 @@ void CNavMenuBar::OnPaint( ) } // Draw the text. - HFONT font = WFE_GetUIFont(dc.m_hDC); + //HFONT font = WFE_GetUIFont(dc.m_hDC); + CFont arialFont; + LOGFONT lf; + XP_MEMSET(&lf,0,sizeof(LOGFONT)); + lf.lfHeight = 120; + lf.lfWeight = 700; + strcpy(lf.lfFaceName, "Arial"); + arialFont.CreatePointFontIndirect(&lf, &dc); + HFONT font = (HFONT)arialFont.GetSafeHandle(); + HFONT hOldFont = (HFONT)::SelectObject(dc.m_hDC, font); - CRect sizeRect(0,0,150,0); + CRect sizeRect(0,0,10000,0); int height = ::DrawText(dc.m_hDC, titleText, titleText.GetLength(), &sizeRect, DT_CALCRECT | DT_WORDBREAK); if (sizeRect.Width() > rect.Width() - NAVBAR_CLOSEBOX - 9) @@ -256,8 +157,8 @@ void CNavMenuBar::OnPaint( ) // Don't write into the close box area! sizeRect.right = sizeRect.left + (rect.Width() - NAVBAR_CLOSEBOX - 9); } - sizeRect.left += 2; // indent slightly horizontally - sizeRect.right += 5; + sizeRect.left += 4; // indent slightly horizontally + sizeRect.right += 4; // Center the text vertically. sizeRect.top = (rect.Height() - height) / 2; @@ -266,72 +167,37 @@ void CNavMenuBar::OnPaint( ) // Draw the text int nOldBkMode = dc.SetBkMode(TRANSPARENT); - UINT nFormat = DT_SINGLELINE | DT_VCENTER; + UINT nFormat = DT_SINGLELINE | DT_VCENTER | DT_EXTERNALLEADING; COLORREF oldColor; oldColor = dc.SetTextColor(m_ForegroundColor); - dc.DrawText((LPCSTR)titleText, -1, &sizeRect, DT_CENTER | DT_EXTERNALLEADING | nFormat); + dc.DrawText((LPCSTR)titleText, -1, &sizeRect, nFormat); dc.SetTextColor(oldColor); dc.SetBkMode(nOldBkMode); - - // Draw the close box at the edge of the bar. - CNSNavFrame* navFrameParent = (CNSNavFrame*)GetParentFrame(); - if (XP_IsNavCenterDocked(navFrameParent->GetHTPane())) - { - int left = rect.right - NAVBAR_CLOSEBOX - 5; - int right = left + NAVBAR_CLOSEBOX; - int top = rect.top + (rect.Height() - NAVBAR_CLOSEBOX)/2; - int bottom = top + NAVBAR_CLOSEBOX; - - CRect edgeRect(left, top, right, bottom); - CBrush* closeBoxBrush = CBrush::FromHandle(sysInfo.m_hbrBtnFace); - dc.FillRect(&edgeRect, closeBoxBrush); - - DrawUpButton(dc.m_hDC, edgeRect); - - HPEN hPen = (HPEN)::CreatePen(PS_SOLID, 1, RGB(0,0,0)); - HPEN hOldPen = (HPEN)(dc.SelectObject(hPen)); - - dc.MoveTo(edgeRect.left+4, edgeRect.top+4); - dc.LineTo(edgeRect.right-5, edgeRect.bottom-4); - dc.MoveTo(edgeRect.right-6, edgeRect.top+4); - dc.LineTo(edgeRect.left+3, edgeRect.bottom-4); - dc.SelectObject(hOldPen); - - VERIFY(::DeleteObject(hPen)); - } - - if (sysInfo.m_iBitsPerPixel < 16 && (::GetDeviceCaps(dc.m_hDC, RASTERCAPS) & RC_PALETTE)) - { - ::SelectPalette(dc.m_hDC, pOldPalette, FALSE); - } - -/* HPEN hShadowPen = ::CreatePen(PS_SOLID, 1, ::GetSysColor(COLOR_3DSHADOW)); - - dc.SelectObject(hShadowPen); - dc.MoveTo(rect.left, rect.bottom-1); - dc.LineTo(rect.right, rect.bottom-1); + int top = rect.top + (rect.Height() - NAVBAR_CLOSEBOX)/2; + int left = rect.right - (3*(NAVBAR_CLOSEBOX+1)) - 4; - VERIFY(::DeleteObject(hShadowPen)); -*/ + HDC hDC = dc.m_hDC; + CRDFImage* pImage = LookupImage("http://rdf.netscape.com/rdf/closebox.gif", NULL); + DrawRDFImage(pImage, left, top, 16, 16, hDC, m_BackgroundColor); + left += NAVBAR_CLOSEBOX+1; + pImage = LookupImage("http://rdf.netscape.com/rdf/closebox.gif", NULL); + DrawRDFImage(pImage, left, top, 16, 16, hDC, m_BackgroundColor); + + left += NAVBAR_CLOSEBOX+1; + pImage = LookupImage("http://rdf.netscape.com/rdf/closebox.gif", NULL); + DrawRDFImage(pImage, left, top, 16, 16, hDC, m_BackgroundColor); } -int CNavMenuBar::OnCreate(LPCREATESTRUCT lpCreateStruct) +int CNavTitleBar::OnCreate(LPCREATESTRUCT lpCreateStruct) { -// m_pMenuButton = new CNavMenuButton(); -// BOOKMARKITEM dummy; - -// m_pMenuButton->Create(this, FALSE, CSize(32, 21), CSize(32, 21), "No view selected.", -// "Click here to view the options menu.", -// "Click on the button to view the options menu.", CSize(0,0), 100, 15, dummy, -// NULL, TB_HAS_IMMEDIATE_MENU | TB_HAS_DRAGABLE_MENU); return 0; } -void CNavMenuBar::OnLButtonDown (UINT nFlags, CPoint point ) +void CNavTitleBar::OnLButtonDown (UINT nFlags, CPoint point ) { // Called when the user clicks on the menu bar. Start a drag or collapse the view. CRect rect; @@ -342,30 +208,41 @@ void CNavMenuBar::OnLButtonDown (UINT nFlags, CPoint point ) int top = rect.top + (rect.Height() - NAVBAR_CLOSEBOX)/2; int bottom = top + NAVBAR_CLOSEBOX; - CRect edgeRect(left, top, right, bottom); - if (edgeRect.PtInRect(point)) + CRect closeBoxRect(left, top, right, bottom); + left -= NAVBAR_CLOSEBOX; + right -= NAVBAR_CLOSEBOX; + CRect modeBoxRect(left, top, right, bottom); + left -= NAVBAR_CLOSEBOX; + right -= NAVBAR_CLOSEBOX; + CRect sortBoxRect(left, top, right, bottom); + + if (closeBoxRect.PtInRect(point)) { - // Collapse the view - if (m_pSelectorButton) - m_pSelectorButton->OnAction(); + // Destroy the window. + CFrameWnd* pFrameWnd = GetParentFrame(); + if (pFrameWnd->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) + ((CNSNavFrame*)pFrameWnd)->DeleteNavCenter(); + } + else if (modeBoxRect.PtInRect(point)) + { + CRDFOutliner* pOutliner = (CRDFOutliner*)HT_GetViewFEData(m_View); + pOutliner->SetNavigationMode(!pOutliner->InNavigationMode()); + } + else if (sortBoxRect.PtInRect(point)) + { + } else { - // Set the focus. - if (m_pSelectorButton) - { - CRDFContentView* pView = m_pSelectorButton->GetTreeView(); - if (pView) - pView->SetFocus(); - } - m_PointHit = point; - SetCapture(); + CFrameWnd* pFrameWnd = GetParentFrame(); + if (pFrameWnd->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) + SetCapture(); } } -void CNavMenuBar::OnMouseMove(UINT nFlags, CPoint point) +void CNavTitleBar::OnMouseMove(UINT nFlags, CPoint point) { if (GetCapture() == this) { @@ -377,13 +254,14 @@ void CNavMenuBar::OnMouseMove(UINT nFlags, CPoint point) ReleaseCapture(); // Start a drag + CRDFOutliner* pOutliner = (CRDFOutliner*)HT_GetViewFEData(m_View); MapWindowPoints(navFrameParent, &point, 1); navFrameParent->StartDrag(point); } } } -void CNavMenuBar::OnLButtonUp(UINT nFlags, CPoint point) +void CNavTitleBar::OnLButtonUp(UINT nFlags, CPoint point) { if (GetCapture() == this) { @@ -391,35 +269,14 @@ void CNavMenuBar::OnLButtonUp(UINT nFlags, CPoint point) } } -void CNavMenuBar::OnSize( UINT nType, int cx, int cy ) +void CNavTitleBar::OnSize( UINT nType, int cx, int cy ) { -/* if (m_pMenuButton) - { - CRect rect; - GetClientRect(&rect); - m_pMenuButton->UpdateButtonText(rect); - } -*/ } -void CNavMenuBar::UpdateView(CSelectorButton* pButton, HT_View view) -{ - m_pSelectorButton = pButton; -/* - if (m_pMenuButton) - { - CRect rect; - GetClientRect(&rect); - m_pMenuButton->UpdateView(view); - m_pMenuButton->UpdateButtonText(rect); - } -*/ - if (pButton && pButton->GetTreeView()) - { - ((CRDFOutliner*)(pButton->GetTreeView()->GetOutlinerParent()->GetOutliner()))->SetDockedMenuBar(this); - } - titleText = "No View Selected."; +void CNavTitleBar::SetHTView(HT_View view) +{ + titleText = ""; m_View = view; if (view) { diff --git a/mozilla/cmd/winfe/navbar.h b/mozilla/cmd/winfe/navbar.h index bea1a4d659f..94e22cb7b46 100644 --- a/mozilla/cmd/winfe/navbar.h +++ b/mozilla/cmd/winfe/navbar.h @@ -23,33 +23,11 @@ #include "usertlbr.h" #define NAVBAR_HEIGHT 23 -#define NAVBAR_CLOSEBOX 15 +#define NAVBAR_CLOSEBOX 16 -class CSelectorButton; -/* This class may yet be of use. For now comment it out. -class CNavMenuButton : public CRDFToolbarButton +class CNavTitleBar : public CWnd, public CCustomImageObject { -protected: - HT_View m_HTView; // Pointer to HT_View if one exists. - -public: - CNavMenuButton(); - - void UpdateView(HT_View v); - void UpdateButtonText(CRect target); - - afx_msg LRESULT OnDragMenuOpen(WPARAM wParam, LPARAM lParam); - afx_msg BOOL OnCommand(UINT wParam, LONG lParam); - - DECLARE_MESSAGE_MAP() -}; -*/ - -class CNavMenuBar : public CWnd, public CCustomImageObject -{ - //CNavMenuButton* m_pMenuButton; // Pointer to the button - CSelectorButton* m_pSelectorButton; // Selector button BOOL m_bHasFocus; // Determines what colors to use for the caption CPoint m_PointHit; // MouseDown tracking CString titleText; // Name of the current workspace @@ -61,15 +39,15 @@ class CNavMenuBar : public CWnd, public CCustomImageObject HT_View m_View; // The current HT_View. public: - CNavMenuBar(); - ~CNavMenuBar(); + CNavTitleBar(); + ~CNavTitleBar(); - void UpdateView(CSelectorButton* pButton, HT_View view); + void SetHTView(HT_View theView); void NotifyFocus(BOOL hasFocus) { m_bHasFocus = hasFocus; Invalidate(); } void LoadComplete(HT_Resource r) { Invalidate(); } - //{{AFX_MSG(CNavMenuBar) + //{{AFX_MSG(CNavTitleBar) // NOTE - the ClassWizard will add and remove member functions here. // DO NOT EDIT what you see in these blocks of generated code! diff --git a/mozilla/cmd/winfe/navcntr.cpp b/mozilla/cmd/winfe/navcntr.cpp index b356e06f282..192cf5601b2 100644 --- a/mozilla/cmd/winfe/navcntr.cpp +++ b/mozilla/cmd/winfe/navcntr.cpp @@ -49,7 +49,8 @@ static char THIS_FILE[] = __FILE__; // The Main Event Handler for the NavCenter. Handles events on the selector bar AND within the tree // views. -void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) +void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened, + void *token, uint32 tokenType) { CSelector* theSelector = (CSelector*)ns->data; if (theSelector == NULL) @@ -60,11 +61,10 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) // The pane has to handle some events. These will go here. if (whatHappened == HT_EVENT_VIEW_SELECTED) { - CView* pView = theSelector->GetCurrentView(); CSelectorButton* pButton = theSelector->GetCurrentButton(); // If the new selected view is NULL, then we need to make sure our pane is closed. - if (theView == NULL && pView != NULL) + if (theView == NULL && pButton != NULL) { // We're open. Close the pane. ((CNSNavFrame*)theSelector->GetParentFrame())->CollapseWindow(); @@ -72,10 +72,10 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) else if (theView != NULL) { // We have a view. Select it. - CSelectorButton* pButton = (CSelectorButton*)HT_GetViewFEData(theView); - theSelector->SetCurrentView(pButton); - - if (pView == NULL) + CSelectorButton* pNewButton = (CSelectorButton*)HT_GetViewFEData(theView); + theSelector->SetCurrentButton(pNewButton); + + if (pButton == NULL) { // Need to open the pane. ((CNSNavFrame*)theSelector->GetParentFrame())->ExpandWindow(); @@ -89,9 +89,8 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) if (whatHappened == HT_EVENT_VIEW_ADDED) { - theSelector->ConstructView(theView); + theSelector->AddButton(theView); theSelector->RearrangeIcons(); - CSelectorButton* pButton = (CSelectorButton*)HT_GetViewFEData(theView); } else if (whatHappened == HT_EVENT_VIEW_DELETED) { @@ -99,8 +98,6 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) CSelectorButton* pButton = (CSelectorButton*)HT_GetViewFEData(theView); if (pButton) { - pButton->GetView()->DestroyWindow(); - // Delete the button delete pButton; @@ -118,6 +115,11 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) // Invalidate the button. pButton->Invalidate(); + // The remaining invalidation only happens if the selected view is the one that was just + // changed. + if (theSelector->GetCurrentButton() != pButton) + return; + // Invalidate the title bar. CFrameWnd* pFrame = pButton->GetParentFrame(); if (pFrame->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) @@ -126,12 +128,12 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) if (pNavFrame) { // Invalidate the title bar. - CNavMenuBar* pBar = pNavFrame->GetNavMenuBar(); + CNavTitleBar* pBar = pNavFrame->GetNavTitleBar(); if (pBar) pBar->Invalidate(); // Invalidate the tree view. - CRDFContentView* theOutlinerView = (CRDFContentView*)pButton->GetTreeView(); + CRDFContentView* theOutlinerView = theSelector->GetContentView(); if (theOutlinerView) { CRDFOutlinerParent* pParent = (CRDFOutlinerParent*)(theOutlinerView->GetOutlinerParent()); @@ -154,51 +156,38 @@ void notifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) else if (whatHappened == HT_EVENT_VIEW_WORKSPACE_REFRESH) theSelector->RearrangeIcons(); // Redraw the selector. - // If the pane doesn't handle the event, then a view does. - else + // If the pane doesn't handle the event, then the tree view does, but only if this button is the current + // selected button on the selector bar. + else { // View needs to exist in order for us to send this event to it. CSelectorButton* pButton = (CSelectorButton*)HT_GetViewFEData(theView); - if (pButton) + if (pButton && (pButton == theSelector->GetCurrentButton())) { - CRDFContentView* theOutlinerView = (CRDFContentView*)pButton->GetTreeView(); + CRDFContentView* theOutlinerView = theSelector->GetContentView(); if (theOutlinerView) { CRDFOutliner* theOutliner = (CRDFOutliner*)(theOutlinerView->GetOutlinerParent()->GetOutliner()); - theOutliner->HandleEvent(ns, n, whatHappened); + if (theOutliner) + theOutliner->HandleEvent(ns, n, whatHappened); } } + else if (pButton && whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED && + (pButton->GetDropMenu() != NULL)) + { + // We opened or closed a node in the popup menu. + PRBool openState; + HT_GetOpenState(n, &openState); + if (openState) + pButton->FillInMenu(n); + } } } -// The Event Handler for selector popup menus -static void selectorPopupNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) -{ - // We respond only to open/closed events. This procedure is only entered when the user clicks - // and holds on a selector bar button to bring up a popup menu. - CSelectorButton* theButton = (CSelectorButton*)ns->data; - if (n != NULL) - { - HT_View theView = HT_GetView(n); - if (theView != NULL && (whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED)) - { - PRBool openState; - HT_GetOpenState(n, &openState); - if (openState) - { - theButton->FillInMenu(n); - } - } - } -} - // SelectorButton CSelectorButton::~CSelectorButton() { - if (m_Pane) - HT_DeletePane(m_Pane); - m_Node = NULL; } @@ -208,27 +197,18 @@ int CSelectorButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButton LPCTSTR pStatusText, CSize bitmapSize, int nMaxTextChars, int nMinTextChars, HT_Resource pNode, - DWORD dwButtonStyle, CView* view, CPaneCX* pane) -{ - pView = view; - m_pPane = pane; - - // Construct the notification struct used by HT - HT_Notification ns = new HT_NotificationStruct; - ns->notifyProc = selectorPopupNotifyProcedure; - ns->data = this; - - // Construct the pane and give it our notification struct - m_Pane = HT_PaneFromResource(HT_GetRDFResource(pNode), ns, (PRBool)TRUE); - HT_SetPaneFEData(m_Pane, this); - - HT_Resource pEntry = NULL; - HT_View theView = HT_GetSelectedView(m_Pane); - + DWORD dwButtonStyle) +{ BOOKMARKITEM bookmark; // For now, create with the pictures style. No text ever. - return CRDFToolbarButton::Create(pParent, TB_PICTURES, noviceButtonSize, advancedButtonSize, + BOOL bResult = CRDFToolbarButton::Create(pParent, TB_PICTURES, noviceButtonSize, advancedButtonSize, pButtonText, pToolTipText, pStatusText, bitmapSize, nMaxTextChars, nMinTextChars, - bookmark, HT_TopNode(theView), dwButtonStyle); + bookmark, pNode, dwButtonStyle); + return bResult; +} + +CRDFContentView* CSelectorButton::GetContentView() +{ + return m_pSelector->GetContentView(); } void CSelectorButton::OnAction() @@ -398,9 +378,9 @@ BEGIN_MESSAGE_MAP(CSelector, CView) //}}AFX_MSG_MAP END_MESSAGE_MAP() -CSelector::CSelector() +CSelector::CSelector(CRDFContentView* pContent) { - m_pCurView = NULL; + m_pContentView = pContent; m_xpos = ICONXPOS; m_ypos = ICONYPOS; m_pDropTarget = NULL; @@ -499,59 +479,36 @@ void CSelector::SelectNthView(int i) BOOL CSelector::IsTreeVisible() { - return m_pCurView != NULL; + return m_pCurButton != NULL; } -void CSelector::SetCurrentView(CSelectorButton* pButton) +void CSelector::SetCurrentButton(CSelectorButton* pButton) { - CView* pView = pButton->GetView(); - - if (m_pCurButton) + // Deselect the old button. + if (m_pCurButton) { m_pCurButton->SetDepressed(FALSE); } + + // Selecting the button. m_pCurButton = pButton; m_pCurButton->SetDepressed(TRUE); - if (m_pCurView != pView ) - { - if (m_pCurView) - m_pCurView->ShowWindow(SW_HIDE); - m_pCurView = pView; - GetParentFrame()->SetActiveView( m_pCurView); - - ((CNSNavFrame*)GetParentFrame())->GetNavMenuBar()->UpdateView(m_pCurButton, m_pCurButton->GetHTView()); - ((CNSNavFrame*)GetParentFrame())->UpdateTitleBar(m_pCurButton->GetHTView()); - } // adjust the window. here. - m_pCurView->ShowWindow(SW_SHOW); - if(m_pCurView->GetParent()->IsKindOf(RUNTIME_CLASS(CContentView))) - { - CContentView* contentView = (CContentView*)m_pCurView->GetParent(); - contentView->CalcChildSizes(); - } - - m_pCurView->SetFocus(); + m_pContentView->SwitchHTViews(m_pCurButton->GetHTView()); + m_pContentView->SetFocus(); } void CSelector::UnSelectAll() { if (m_pCurButton) m_pCurButton->SetDepressed(FALSE); - m_pCurButton = 0; - if (m_pCurView) - { - m_pCurView->ShowWindow(SW_HIDE); - m_pCurView = 0; - GetParentFrame()->SetActiveView( m_pCurView); - } - - ((CNSNavFrame*)GetParentFrame())->GetNavMenuBar()->UpdateView(NULL, NULL); + m_pCurButton = NULL; } -CView* CSelector::GetCurrentView() +CRDFContentView* CSelector::GetContentView() { - return m_pCurView; + return m_pContentView; } CSelectorButton* CSelector::GetCurrentButton() @@ -627,26 +584,26 @@ void CSelector::ShowScrollButton(CSelectorButton* button) } -void CSelector::AddViewContext(const char* pTitle, CView* pView, CRDFContentView* pTree, - CPaneCX* htmlPane, HT_View theView) +void CSelector::AddButton(HT_View theView) { + // Create the selector button. CSelectorButton* theNSViewButton = new CSelectorButton(this); - // Button meets the view. View meets the button. + // Set the HT view for the button. theNSViewButton->SetHTView(theView); - theNSViewButton->SetTreeView(pTree); - + HT_SetViewFEData(theView, theNSViewButton); - HT_Resource node = theView ? HT_TopNode(theView) : NULL; - char* pNodeURL = node ? HT_GetNodeURL(node) : ""; + HT_Resource node = HT_TopNode(theView); + char* pNodeURL = HT_GetNodeURL(node); + char* pTitle = HT_GetNodeName(node); theNSViewButton->Create(this, theApp.m_pToolbarStyle, CSize(60,42), CSize(85, 25), pTitle, pTitle, pNodeURL, CSize(23,23), 10, 5, node, - TB_HAS_DRAGABLE_MENU | TB_HAS_TIMED_MENU, pView, htmlPane); + TB_HAS_DRAGABLE_MENU | TB_HAS_TIMED_MENU); CRect rect; rect.left = (long)m_xpos; @@ -669,35 +626,15 @@ void CSelector::AddViewContext(const char* pTitle, CView* pView, CRDFContentView m_ypos += buttonSize.cy + 2; rect.right = rect.left + BUTTON_WIDTH; } -/* - CString originalText = HT_GetNodeName(theNSViewButton->GetNode()); - int currCount = originalText.GetLength(); - - // Start off at the maximal string - CString strTxt = originalText; - - CSize theSize = theNSViewButton->GetButtonSizeFromChars(originalText, currCount); - int horExtent = theSize.cx; - - while (horExtent > BUTTON_WIDTH) - { - strTxt = originalText.Left(currCount-3) + "..."; - theSize = theNSViewButton->GetButtonSizeFromChars(strTxt, currCount); - horExtent = theSize.cx; - currCount--; - } - - theNSViewButton->SetTextWithoutResize(strTxt); -*/ ShowScrollButton(theNSViewButton); } - void CSelector::PopulatePane() { // Construct the notification struct used by HT HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); ns->notifyProc = notifyProcedure; ns->data = this; m_Notification = ns; @@ -709,6 +646,7 @@ void CSelector::PopulatePane() // Inform our XP layer of the new nav center. MWContext *pDockedCX = NULL; CNSNavFrame *pParentFrame = GetParentFrame()->IsKindOf(RUNTIME_CLASS(CNSNavFrame)) ? (CNSNavFrame*)GetParentFrame() : NULL; + // Since the XP layer isn't set up yet, we can't use // XP_IsNavCenterDocked in order to tell // if the window is docked. Use instead wether or @@ -727,51 +665,6 @@ void CSelector::PopulatePane() RearrangeIcons(); } -void CSelector::ConstructView(HT_View theView) -{ - if (theView == NULL) - return; - - CString viewName = HT_GetNodeName(HT_TopNode(theView)); - - // Construct the RDF view - CWnd *theParent = (CWnd *)(((CNSNavFrame*)GetParentFrame())->GetContentView()); - - DWORD dwCurrentStyle = WS_CHILD; - - // Parent may change depending on view (need more panes). - CRect rClient(0, 0, 100, 100); - CContentView *pAltParent = NULL; - CPaneCX *pCX = NULL; - if(HT_HasHTMLPane(theView)) - { - pAltParent = new CContentView(); - pAltParent->Create(NULL, "", WS_CHILD, rClient, theParent, NC_IDW_MISCVIEW, NULL); - pCX = wfe_CreateNavCenterHTMLPain(theView, pAltParent->m_hWnd); - - // Make all other children visible now (we control visibility by being the parent). - dwCurrentStyle |= WS_VISIBLE; - } - if(pAltParent) { - theParent = (CWnd *)pAltParent; - } - theParent->GetClientRect(&rClient); - - // Can't use CSelector's m_Pane, because it might not have been initialized yet. Calls - // HT_GetPane instead. - CRDFOutlinerParent* newParent = new CRDFOutlinerParent(HT_GetPane(theView), theView); - CRDFContentView* newView = new CRDFContentView(newParent); - - // Create the windows - newView->Create( NULL, "", dwCurrentStyle, rClient, theParent, NC_IDW_OUTLINER); - - // Initialize the columns, etc. - newParent->Initialize(); - - // Name and icon for the view correspond to the name/icon of the top node in the view. - AddViewContext(viewName, pAltParent ? (CView *)pAltParent : (CView *)newView, newView, pCX, theView); -} - void CSelector::DestroyViews() { int viewCount = HT_GetViewListCount(m_Pane); @@ -861,10 +754,10 @@ void CSelector::RearrangeIcons() if (dockStyle == DOCKSTYLE_HORZTOP || dockStyle == DOCKSTYLE_HORZBOTTOM) { m_xpos = ICONXPOS; - m_ypos = 2; + m_ypos = 1; } else { - m_xpos = 2; + m_xpos = 1; m_ypos = ICONYPOS; } CRect parentRect; @@ -983,9 +876,8 @@ void CSelector::OnLButtonDown (UINT nFlags, CPoint point ) // Called when the user clicks on the menu bar. Start a drag or collapse the view. if (m_pCurButton) { - CRDFContentView* pView = m_pCurButton->GetTreeView(); - if (pView) - pView->SetFocus(); + if (m_pContentView) + m_pContentView->SetFocus(); } m_PointHit = point; diff --git a/mozilla/cmd/winfe/navcntr.h b/mozilla/cmd/winfe/navcntr.h index 00216852a22..e44ea142b76 100644 --- a/mozilla/cmd/winfe/navcntr.h +++ b/mozilla/cmd/winfe/navcntr.h @@ -68,50 +68,35 @@ class CSelectorButton : public CRDFToolbarButton friend class CSelector; protected: - CView* pView; // View including the HTML pane - CRDFContentView* m_pTreeView; // Pointer straight to the RDF Tree view. - CPaneCX* m_pPane; CSelector* m_pSelector; HT_View m_HTView; // Pointer to HT_View if one exists. Could be NULL. - HT_Pane m_Pane; // This is the button's popup menu pane. - // The Selector Button actually has two HT_Nodes, two HT_Views, and two HT_Panes. One set is the pane in - // which the button is found (along with all the other buttons). The second set is for the popup menu - // that comes up on a timed mouse down on the button. - // m_HTView is used with the pane that contains all the buttons. - // m_Pane is used for the popup menu. - // The base class has an m_Node member variable. This is the popup variable's top node in its selected - // HT_View. -- Dave H. public: CSelectorButton(CSelector* pSelector) - :m_pSelector(pSelector), pView(NULL), m_pPane(NULL), - m_HTView(NULL) {}; + :m_pSelector(pSelector), m_HTView(NULL) {}; ~CSelectorButton(); void SetHTView(HT_View v) { m_HTView = v; } virtual HT_View GetHTView() { return m_HTView; } - CView* GetView() { return pView; } + CRDFContentView* GetContentView(); virtual BOOL UseLargeIcons() { return TRUE; } - virtual void DisplayAndTrackMenu(void); - + virtual UINT GetBitmapID() { return 0; } virtual void OnAction(void); int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize, LPCTSTR pButtonText, LPCTSTR pToolTipText, LPCTSTR pStatusText, - CSize bitmapSize, int nMaxTextChars, int nMinTextChars, - HT_Resource pNode, DWORD dwButtonStyle = 0, CView* view = NULL, CPaneCX* pane = NULL); + CSize bitmapSize, int nMaxTextChars, int nMinTextChars, + HT_Resource pNode, DWORD dwButtonStyle = 0); + + virtual BOOL foundOnRDFToolbar() { return FALSE; } // buttons sit on a selector bar and not on a toolbar void SetDepressed(BOOL b) { m_bDepressed = b; Invalidate(); } - CRDFContentView* GetTreeView() { return m_pTreeView; } // Returns only the tree - - void SetTreeView(CRDFContentView* tree) { m_pTreeView = tree; } // Sets the tree view - virtual void DrawPicturesMode(HDC hDC, CRect rect); // Overridden because LinkToolbarButtons draw text with the pictures always. We // want to revert to ToolbarButton behavior. @@ -195,30 +180,47 @@ public: class CSelector : public CView { - friend class CSelectorButton; + public: DECLARE_DYNAMIC(CSelector) - CSelector(); - virtual ~CSelector(); - void AddViewContext(const char* pTitle, CView* pView, CRDFContentView* pTree, - CPaneCX* htmlPane, HT_View theView); - CView* GetCurrentView(); // Gets the view including the HTML pane - CSelectorButton* GetCurrentButton(); - - void SetCurrentView(CSelectorButton* pButton); - void SelectNthView(int i); + CSelector(CRDFContentView* pContent); + virtual ~CSelector(); + + void AddButton(HT_View theView); + // Add a new view to the selector bar. + + CRDFContentView* GetContentView(); + // Gets the content area associated with this selector bar. + + CSelectorButton* GetCurrentButton(); + // Gets the current pressed button (if there is one). + + void SetCurrentButton(CSelectorButton* pButton); + // Sets the current button. + + void SelectNthView(int i); + // Select the nth HT view. + void PopulatePane(); + // Function that fills the selector bar. + void DestroyViews(); - void ConstructView(HT_View v); + // Function that destroys the HT views + HT_Pane GetHTPane() {return m_Pane;} + // Gets the pane associated with this selector bar. + + void UnSelectAll(); + // Function that deselects all buttons. + void ShowScrollButton(CSelectorButton* button); void OnDraw( CDC* pDC ); int GetScrollDirection() {return m_scrollDirection;} void ScrollSelector(); void StopScrolling() {m_scrollDirection = NOSCROLL;} - void UnSelectAll(); + HBRUSH GetNormalBrush() {return hBrush;} HBRUSH GetHtBrush() {return hHtBrush;} @@ -249,8 +251,8 @@ public: protected: int m_scrollDirection; - CSelectorButton * m_pCurButton; - CView* m_pCurView; // The entire view (including the HTML pane) + CSelectorButton * m_pCurButton; // The current selected button. + CRDFContentView* m_pContentView; // The entire view (including the HTML pane) CRDFCommandMap m_MenuCommandMap; // Command map for back-end generated right mouse menu commands. CSelectorDropTarget * m_pDropTarget; diff --git a/mozilla/cmd/winfe/navcontv.h b/mozilla/cmd/winfe/navcontv.h index fa91f602934..debf5eb488b 100644 --- a/mozilla/cmd/winfe/navcontv.h +++ b/mozilla/cmd/winfe/navcontv.h @@ -47,13 +47,9 @@ public: void CalcChildSizes(); void AddChildSizeInfo(NAVCENTPOS *pPreference); - // drag and drop operation for the nav center content view. If there is a child window - // that has ID == NC_IDW_OUTLINER. The drag and drop message will get pass onto - // this child. If not, the drag and drop message will get pass onto the parent window. - protected: - virtual void OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView ); //{{AFX_MSG(CMainFrame) + afx_msg void CContentView::OnActivateView( BOOL bActivate, CView* pActivateView, CView* pDeactiveView ); afx_msg void OnSize( UINT nType, int cx, int cy ); afx_msg void OnSetFocus(CWnd* pWnd); afx_msg void OnMouseMove( UINT nFlags, CPoint point ); diff --git a/mozilla/cmd/winfe/navfram.cpp b/mozilla/cmd/winfe/navfram.cpp index a8b5642be1b..616314fe0f2 100644 --- a/mozilla/cmd/winfe/navfram.cpp +++ b/mozilla/cmd/winfe/navfram.cpp @@ -20,7 +20,7 @@ // #include "stdafx.h" - +#include "rdfliner.h" #include "navfram.h" #include "feimage.h" #include "cxicon.h" @@ -72,26 +72,27 @@ END_MESSAGE_MAP() CNSNavFrame::CNSNavFrame() { - m_pSelector = 0; - m_nsContent= 0; + m_pSelector = NULL; + m_nsContent= NULL; m_bDragging = FALSE; - m_DragWnd = 0; - m_dockingState = unknown; + m_DragWnd = NULL; + m_Node = NULL; + m_pButton = NULL; } CNSNavFrame::~CNSNavFrame() { - if (m_dwOverDockStyle != DOCKSTYLE_FLOATING) - { - PREF_SetIntPref(gPrefDockPercentage, m_DockSize); - PREF_SetIntPref(gPrefDockOrientation, m_dwOverDockStyle); - } - else - { - PREF_SetRectPref(gPrefFloatRect, (int16)m_rectFloat.left, (int16)m_rectFloat.top, (int16)m_rectFloat.right, (int16)m_rectFloat.bottom); - } + if (m_dwOverDockStyle != DOCKSTYLE_FLOATING) + { + PREF_SetIntPref(gPrefDockPercentage, m_DockSize); + PREF_SetIntPref(gPrefDockOrientation, m_dwOverDockStyle); + } + else + { + PREF_SetRectPref(gPrefFloatRect, (int16)m_rectFloat.left, (int16)m_rectFloat.top, (int16)m_rectFloat.right, (int16)m_rectFloat.bottom); + } - delete m_pNavMenu; + // delete m_pNavTitle; } void CNSNavFrame::UpdateTitleBar(HT_View pView) @@ -140,11 +141,7 @@ void CNSNavFrame::CreateNewNavCenter(CNSGenFrame* pParentFrame, BOOL useViewType // Create the window there. m_rectFloat.SetRect(left, top, right, bottom); -// Don't reset this if being undocked. - if ( m_dockingState != beingUndocked ) - { - m_rectDrag = m_rectFloat; - } + m_rectDrag = m_rectFloat; CString title = "Navigation Center"; Create( NULL, title, WS_OVERLAPPEDWINDOW, m_rectFloat, NULL); @@ -167,19 +164,11 @@ void CNSNavFrame::CreateNewNavCenter(CNSGenFrame* pParentFrame, BOOL useViewType { // create a docked window DockFrame(pParentFrame, m_dwOverDockStyle); - m_dockingState = docked; } else { // Create a floating window m_dwOverDockStyle = DOCKSTYLE_FLOATING; - - // Position to where user requested, if being undocked. - if ( m_dockingState == beingUndocked ) - { - MoveWindow( m_rectDrag ); - } - m_dockingState = undocked; } // Put the selector buttons into the pane. @@ -203,19 +192,29 @@ void CNSNavFrame::DeleteNavCenter() // Tell ParentFrame that we are not docked anymore. if (pLayout) - pLayout->RecalcLayout(); + pLayout->RecalcLayout(); if (m_DragWnd) m_DragWnd->DestroyWindow(); - DestroyWindow(); + PostMessage(WM_CLOSE); + + if (m_pButton) + { + m_pButton->SetDepressed(FALSE); + m_pButton->Invalidate(); + CRDFToolbarHolder* pHolder = (CRDFToolbarHolder*)(m_pButton->GetParent()->GetParent()->GetParent()); + pHolder->SetCurrentButton(NULL); + m_pButton = NULL; + } } BOOL CNSNavFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) { - m_pSelector = new CSelector(); - m_nsContent = new CContentView(); - m_pNavMenu = new CNavMenuBar(); +/* + m_nsContent = new CRDFContentView(); + m_pSelector = new CSelector(m_nsContent); + m_pNavTitle = new CNavTitleBar(); CRect rect1; rect1.left = rect1.top = 0; @@ -225,10 +224,31 @@ BOOL CNSNavFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) this, NC_IDW_SELECTOR, pContext ); rect1.right = rect1.bottom = 1; - m_pNavMenu->Create(NULL, "", WS_CHILD | WS_VISIBLE, rect1, this, NC_IDW_NAVMENU, pContext); + m_pNavTitle->Create(NULL, "", WS_CHILD | WS_VISIBLE, rect1, this, NC_IDW_NAVMENU, pContext); m_nsContent->Create( NULL, "", WS_CHILD | WS_VISIBLE, rect1, - this, NC_IDW_MISCVIEW, pContext ); + this , NC_IDW_OUTLINER, pContext); +*/ + m_nsContent = CRDFContentView::DisplayRDFTreeFromResource(this, 0, 0, 100, 100, m_Node, pContext); + CRDFOutliner* pOutliner = (CRDFOutliner*)(m_nsContent->GetOutlinerParent()->GetOutliner()); + SetHTNode(HT_TopNode(pOutliner->GetHTView())); + + // Read in our float rect pref. + int16 left,right,top, bottom; + PREF_GetRectPref(gPrefFloatRect,&left, &top, &right, &bottom); + + // Create the window there. + m_rectFloat.SetRect(left, top, right, bottom); + m_rectDrag = m_rectFloat; + + // Determine the pixels we should consume if docked + int32 width; + PREF_GetIntPref(gPrefDockPercentage, &width); + m_DockSize = (int)width; + + // Read in our dockstyle + m_dwOverDockStyle = DOCKSTYLE_VERTLEFT; + PREF_GetIntPref(gPrefDockOrientation, &m_dwOverDockStyle); return TRUE; } @@ -260,7 +280,7 @@ void CNSNavFrame::OnSize( UINT nType, int cx, int cy ) { CRect tempRect; // We want to handle the redraw ourself to reduce the flickering. - m_pSelector->GetClientRect(&tempRect); + /* m_pSelector->GetClientRect(&tempRect); m_pSelector->MapWindowPoints( this, &tempRect); m_pSelector->SetWindowPos( NULL, 0, top, MIN_CATEGORY_WIDTH, cy - STARTY - top, SWP_NOREPOSITION | SWP_NOREDRAW); if ((tempRect.Height()) < cy - STARTY) @@ -272,9 +292,11 @@ void CNSNavFrame::OnSize( UINT nType, int cx, int cy ) m_pSelector->InvalidateRect( &tempRect, TRUE); } - m_pNavMenu->ShowWindow(SW_SHOW); - m_pNavMenu->SetWindowPos(NULL, MIN_CATEGORY_WIDTH+2, top, cx - MIN_CATEGORY_WIDTH, NAVBAR_HEIGHT, SWP_NOREPOSITION); + m_pNavTitle->ShowWindow(SW_SHOW); + m_pNavTitle->SetWindowPos(NULL, MIN_CATEGORY_WIDTH+2, top, cx - MIN_CATEGORY_WIDTH, NAVBAR_HEIGHT, SWP_NOREPOSITION); m_nsContent->SetWindowPos( NULL, MIN_CATEGORY_WIDTH+2, top+NAVBAR_HEIGHT, cx - MIN_CATEGORY_WIDTH - 2, cy - STARTY - top - NAVBAR_HEIGHT, 0); + */ + m_nsContent->SetWindowPos(NULL, 0, 0, cx, cy, 0); } else { //dock horiz. @@ -293,7 +315,7 @@ void CNSNavFrame::OnSize( UINT nType, int cx, int cy ) cx - STARTX, cy - MIN_CATEGORY_HEIGHT, SWP_NOREPOSITION | SWP_NOREDRAW); } ShowWindow(SW_SHOW); - if (m_DragWnd) + if (m_DragWnd && IsTreeVisible()) m_DragWnd->ShowWindow(SW_SHOW); } @@ -306,6 +328,25 @@ BOOL CNSNavFrame::PreCreateWindow(CREATESTRUCT & cs) return (CFrameWnd::PreCreateWindow(cs)); } +CNSNavFrame* CNSNavFrame::CreateFramedRDFViewFromResource(CWnd* pParent, int xPos, int yPos, + int width, int height, HT_Resource node) +{ + CNSNavFrame* pNavFrame = new CNSNavFrame(); + pNavFrame->SetDockStyle(DOCKSTYLE_FLOATING); + pNavFrame->SetHTNode(node); + pNavFrame->Create(NULL, HT_GetNodeName(node), WS_POPUP, + CRect(xPos, yPos, width, height), + pParent); + pNavFrame->SetWindowPos(&wndTopMost, xPos, yPos, width, height, 0); + pNavFrame->ShowWindow(SW_SHOW); + + CRDFOutliner* pOutliner = (CRDFOutliner*)(pNavFrame->GetContentView()->GetOutlinerParent()->GetOutliner()); + pOutliner->SetIsPopup(TRUE); + pOutliner->SetFocus(); + + return pNavFrame; +} + //------------------------------------------------------------------------------ // void CNSNavFrame::StartDrag(CPoint pt) // @@ -319,8 +360,11 @@ void CNSNavFrame::StartDrag(CPoint pt, BOOL mapDesktop) if (mapDesktop) MapWindowPoints(NULL, &cursorPt, 1); // Convert the point to screen coords. - if (XP_IsNavCenterDocked(GetHTPane())) + CRDFOutliner* pOutliner = (CRDFOutliner*)(GetContentView()->GetOutlinerParent()->GetOutliner()); + + if (XP_IsNavCenterDocked(GetHTPane()) || pOutliner->IsPopup()) { + pOutliner->SetIsPopup(FALSE); ForceFloat(FALSE); } else ShowWindow(SW_HIDE); @@ -332,13 +376,13 @@ void CNSNavFrame::StartDrag(CPoint pt, BOOL mapDesktop) CNSGenFrame* pFrame = NULL; CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser, FEU_FINDBROWSERANDEDITOR); - CFrameWnd *pBaseWnd = pGlue ? pGlue->GetFrameWnd() : NULL; + CFrameWnd *pBaseWnd = pGlue->GetFrameWnd(); if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) - { + { pFrame = (CNSGenFrame *)pBaseWnd; - CalcClientArea(&m_parentRect, pFrame); - pFrame->MapWindowPoints( NULL, &m_parentRect); } + CalcClientArea(&m_parentRect, pFrame); + pFrame->MapWindowPoints( NULL, &m_parentRect); // Cache the offset that we wish to preserve. m_nXOffset = cursorPt.x - m_dockingDragRect.left; @@ -408,7 +452,7 @@ BOOL nsModifyStyle(HWND hWnd, int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UIN { ASSERT(hWnd != NULL); DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset); - DWORD dwNewStyle; + DWORD dwNewStyle = dwStyle; if (dwRemove != NULL) dwNewStyle = dwStyle & ~dwRemove; if (dwAdd != NULL) @@ -481,7 +525,8 @@ void CNSNavFrame::ForceFloat(BOOL show) CFrameWnd *pLayout = GetParentFrame(); nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_CHILD, WS_OVERLAPPEDWINDOW); - + nsModifyStyle( GetSafeHwnd(), GWL_EXSTYLE, 0, WS_EX_CLIENTEDGE); + if (show) { MoveWindow( m_rectDrag); @@ -489,8 +534,12 @@ void CNSNavFrame::ForceFloat(BOOL show) else ShowWindow(SW_HIDE); SetParent(NULL); - m_DragWnd->DestroyWindow(); - m_DragWnd = NULL; + + if (m_DragWnd) + { + m_DragWnd->DestroyWindow(); + m_DragWnd = NULL; + } m_dwOverDockStyle = DOCKSTYLE_FLOATING; @@ -502,17 +551,20 @@ void CNSNavFrame::ForceFloat(BOOL show) XP_UndockNavCenter(GetHTPane()); // Tell ParentFrame that we are not docked anymore. - pLayout->RecalcLayout(); + if (pLayout) + pLayout->RecalcLayout(); // Select a new view if we were formerly collapsed. - if (m_pSelector->GetCurrentButton() == NULL) + if (m_pSelector && m_pSelector->GetCurrentButton() == NULL) m_pSelector->SelectNthView(0); +/* if (show) { m_nsContent->ShowWindow(SW_SHOW); m_nsContent->CalcChildSizes(); } +*/ } void CNSNavFrame::ComputeDockingSizes() @@ -525,8 +577,8 @@ void CNSNavFrame::ComputeDockingSizes() else { - m_DockWidth = MIN_CATEGORY_WIDTH + DRAGWIDTH; - m_DockHeight = MIN_CATEGORY_HEIGHT + DRAGWIDTH; + m_DockWidth = MIN_CATEGORY_WIDTH; + m_DockHeight = MIN_CATEGORY_HEIGHT; } } @@ -541,10 +593,13 @@ void CNSNavFrame::DockFrame(CNSGenFrame* pParent, short dockStyle) { CNSNavFrame* pFrame = pParent->GetDockedNavCenter(); if (pFrame) - { // if the parent frame has a docked frame, tell this frame to float. + { // if the parent frame has a docked frame, then destroy it. pFrame->DeleteNavCenter(); } - nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_OVERLAPPEDWINDOW , WS_CHILD); + nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_OVERLAPPEDWINDOW, WS_CHILD); + nsModifyStyle( GetSafeHwnd(), GWL_EXSTYLE, WS_EX_CLIENTEDGE, 0); + nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_POPUP, 0); + SetParent(pParent); // Tell XP layer that we are now docked. @@ -594,11 +649,6 @@ void CNSNavFrame::DockFrame(CNSGenFrame* pParent, short dockStyle) rect.right = m_parentRect.right; } - // Now move the window to the correct location. - ShowWindow(SW_HIDE); - SetWindowPos( &wndBottom, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top,0 ); - // Figure out the correct location to display the resize bar. CRect dragBarRect(rect); if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) { @@ -637,7 +687,11 @@ void CNSNavFrame::DockFrame(CNSGenFrame* pParent, short dockStyle) m_DragWnd->SetRect(dragBarRect); m_DragWnd->SetParent(GetParentFrame()); - m_DragWnd->ShowWindow(SW_SHOW); + // Now move the window to the correct location. + ShowWindow(SW_HIDE); + SetWindowPos( &wndBottom, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top,0 ); + ShowWindow(SW_SHOW); } @@ -665,39 +719,27 @@ void CNSNavFrame::EndDrag(CPoint pt) // drop { pFrame = (CNSGenFrame *)pBaseWnd; } - - // see if we're being re-docked. - if ( m_dockingState == undocked ) - { - // Indicate we need to be reborn docked. - m_dockingState = beingDocked; - - // Destroy the old windows. - DeleteNavCenter(); - } else { - DockFrame(pFrame, dwOverDockStyle); - m_nsContent->CalcChildSizes(); - - - ShowWindow(SW_SHOW); - } + DockFrame(pFrame, dwOverDockStyle); + // m_nsContent->CalcChildSizes(); } else { // Float this frame. MoveWindow( m_rectDrag); - - // See if we're being undocked. - if ( m_dockingState == docked ) { - // Indicate we need to be reborn undocked. - m_dockingState = beingUndocked; - - // Destroy the old windows. - DeleteNavCenter(); - } else { - ShowWindow(SW_SHOW); - } + + // If it had a button associated with it, now it doesn't. + if (m_pButton) + { + CRDFToolbarHolder* pHolder = (CRDFToolbarHolder*) + (m_pButton->GetParent()->GetParent()->GetParent()); + pHolder->SetCurrentButton(NULL); + m_pButton->SetDepressed(FALSE); + m_pButton->Invalidate(); + m_pButton = NULL; + } } + + ShowWindow(SW_SHOW); } @@ -799,12 +841,12 @@ short CNSNavFrame::CanDock(CPoint pt, BOOL mapDesktop) CNSGenFrame* pFrame = NULL; CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser, FEU_FINDBROWSERANDEDITOR); - CFrameWnd *pBaseWnd = pGlue ? pGlue->GetFrameWnd() : NULL; + CFrameWnd *pBaseWnd = pGlue->GetFrameWnd(); if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) { pFrame = (CNSGenFrame *)pBaseWnd; } - if (pFrame && mapDesktop) { + if (mapDesktop) { CWnd *pView = pFrame->GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE); if (XP_IsNavCenterDocked(GetHTPane())) { @@ -816,7 +858,7 @@ short CNSNavFrame::CanDock(CPoint pt, BOOL mapDesktop) } // If the top most activated frame is not a Navigator window, do not dock. - if (pFrame && pFrame->AllowDocking()) { + if (pFrame->AllowDocking()) { if (m_parentRect.PtInRect(pt)) { if ((pt.x < (m_parentRect.left +m_DockWidth)) && pt.x > m_parentRect.left) @@ -902,6 +944,8 @@ LRESULT CNSNavFrame::OnSizeParent(WPARAM, LPARAM lParam) // the top and bottom coordinates of the dragRect should already be included // in the toolbar. + if (!m_DragWnd) return 0; + CRect oldRect; GetWindowRect(&oldRect); CRect resizeRect(lpLayout->rect); @@ -909,54 +953,48 @@ LRESULT CNSNavFrame::OnSizeParent(WPARAM, LPARAM lParam) m_DragWnd->GetRect(oldDragRect); CRect dragRect(resizeRect); - + if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) { + //dragRect.top += 10; + //dragRect.bottom -= 10; + resizeRect.right = lpLayout->rect.left + oldRect.Width(); if (oldDragRect.left != resizeRect.right) // we move the drag bar. Need to resize here. resizeRect.right += oldDragRect.left - resizeRect.right; + + if (IsTreeVisible()) + { + + CWnd* pParent = GetParent(); + CRect parentRect; + pParent->GetClientRect(&parentRect); + + if (parentRect.Width() < resizeRect.Width() + DRAGWIDTH) + { + resizeRect.right = resizeRect.left + parentRect.Width() - DRAGWIDTH; + } + } + dragRect.left = resizeRect.right; - dragRect.right = dragRect.left + + DRAGWIDTH; - lpLayout->rect.left = resizeRect.right + DRAGWIDTH; + dragRect.right = dragRect.left + DRAGWIDTH; + + if (IsTreeVisible()) + lpLayout->rect.left = resizeRect.right + DRAGWIDTH; + else lpLayout->rect.left = resizeRect.right; + m_DragWnd->SetRect(dragRect); m_DockWidth = resizeRect.Width(); } - else if (m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) { - resizeRect.left = lpLayout->rect.right - oldRect.Width(); - if (oldDragRect.right != resizeRect.left) // we moved the drag bar. Need to resize here. - resizeRect.left -= resizeRect.left - oldDragRect.right; - dragRect.right = resizeRect.left; - dragRect.left = dragRect.right - DRAGWIDTH; - lpLayout->rect.right = resizeRect.left - DRAGWIDTH; - m_DragWnd->SetRect(dragRect); - m_DockWidth = resizeRect.Width(); - } - else if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP) { - resizeRect.bottom = lpLayout->rect.top + oldRect.Height(); - if (oldDragRect.top != resizeRect.bottom) // we moved the drag bar. Need to resize here. - resizeRect.bottom += oldDragRect.top - resizeRect.bottom; - dragRect.top = resizeRect.bottom; - dragRect.bottom = dragRect.top + DRAGWIDTH; - lpLayout->rect.top = resizeRect.bottom + DRAGWIDTH; - m_DragWnd->SetRect(dragRect); - m_DockHeight = resizeRect.Height(); - } - else if (m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) { - resizeRect.top = lpLayout->rect.bottom - oldRect.Height(); - if (oldDragRect.bottom != resizeRect.top) // we moved the drag bar. Need to resize here. - resizeRect.top -= resizeRect.top - oldDragRect.bottom; - dragRect.bottom = resizeRect.top; - dragRect.top = dragRect.bottom - DRAGWIDTH; - lpLayout->rect.bottom = resizeRect.top - DRAGWIDTH; - m_DragWnd->SetRect(dragRect); - m_DockHeight = resizeRect.Height(); - } + if (lpLayout->hDWP != NULL) { // reposition our frame window. SetWindowPos( &wndBottom, resizeRect.left, resizeRect.top, resizeRect.right - resizeRect.left, resizeRect.bottom - resizeRect.top, SWP_SHOWWINDOW ); m_dockingDragRect = resizeRect; - m_DragWnd->SetWindowPos( &wndBottom, dragRect.left, dragRect.top, dragRect.Width(), - dragRect.Height(), SWP_SHOWWINDOW ); + + if (IsTreeVisible()) + m_DragWnd->SetWindowPos( &wndBottom, dragRect.left, dragRect.top, dragRect.Width(), + dragRect.Height(), SWP_SHOWWINDOW ); } @@ -1047,7 +1085,7 @@ void CNSNavFrame::CollapseWindow() } else if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) { - dragBox.left -= (tempRect.Width() - MIN_CATEGORY_WIDTH - DRAGWIDTH); + dragBox.left -= (tempRect.Width() - MIN_CATEGORY_WIDTH); dragBox.right = dragBox.left + DRAGWIDTH; } else @@ -1063,6 +1101,7 @@ void CNSNavFrame::CollapseWindow() { m_DragWnd->SetRect(dragBox); m_DragWnd->MoveWindow(dragBox); + m_DragWnd->ShowWindow(SW_HIDE); GetParentFrame()->RecalcLayout(); } } @@ -1134,11 +1173,9 @@ void CNSNavFrame::Dump(CDumpContext& dc) const HT_Pane CNSNavFrame::GetHTPane() { - HT_Pane htRetval = NULL; - if(m_pSelector) { - htRetval = m_pSelector->GetHTPane(); - } - return(htRetval); + if(m_Node) + return HT_GetPane(HT_GetView(m_Node)); + return NULL; } void CNSNavFrame::OnNcLButtonDown( UINT nHitTest, CPoint point ) @@ -1178,37 +1215,3 @@ void CNSNavFrame::OnMouseMove( UINT nHitTest, CPoint point ) CWnd::OnNcMouseMove(nHitTest, point); } -void CNSNavFrame::PostNcDestroy() -{ - // Check to see if we need to recreate the NavCenter windows. - switch ( m_dockingState ) { - case beingDocked: - // Re-create within docked-to frame. - { - CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser, FEU_FINDBROWSERANDEDITOR); - CFrameWnd *pBaseWnd = pGlue ? pGlue->GetFrameWnd() : NULL; - if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) - { - CreateNewNavCenter( (CNSGenFrame*)pBaseWnd ); - } - else - { - CreateNewNavCenter(NULL); - } - } - break; - - case beingUndocked: - // Re-create with no parent. - CreateNewNavCenter(NULL); - break; - - case unknown: - case docked: - case undocked: - default: - // Pass on to base class (which will "delete this"). - CFrameWnd::PostNcDestroy(); - break; - } -} diff --git a/mozilla/cmd/winfe/navfram.h b/mozilla/cmd/winfe/navfram.h index 73be8f46aac..6317f48a97c 100644 --- a/mozilla/cmd/winfe/navfram.h +++ b/mozilla/cmd/winfe/navfram.h @@ -72,7 +72,9 @@ public: // create from serialization only // Implementation public: virtual ~CNSNavFrame(); - CContentView* GetContentView() {return m_nsContent;} + CRDFContentView* GetContentView() {return m_nsContent;} + void SetContentView(CRDFContentView* v) { m_nsContent = v; } + // Add new view to this frame. //void AddViewContext(const char* pUrl, const char* pTitle, CView* pView, CPaneCX* htmlPane = NULL); @@ -81,6 +83,10 @@ public: void CreateNewNavCenter(CNSGenFrame* pParentFrame = NULL, BOOL useViewType = FALSE, HT_ViewType viewType = HT_VIEW_BOOKMARK); void DeleteNavCenter(); + static CNSNavFrame* CreateFramedRDFViewFromResource(CWnd* pParent, int xPos, int yPos, + int width, int height, + HT_Resource node); + #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; @@ -95,17 +101,21 @@ public: short CanDock(CPoint pt, BOOL mapDesktop = FALSE); void ForceFloat(BOOL show = TRUE); int32 GetDockStyle() { return m_dwOverDockStyle;} + void SetDockStyle(int32 d) { m_dwOverDockStyle = d; } void ExpandWindow(); void CollapseWindow(); void ComputeDockingSizes(); void UpdateTitleBar(HT_View pView); - virtual void PostNcDestroy(); public: HT_Pane GetHTPane(); - CNavMenuBar* GetNavMenuBar() { return m_pNavMenu; } - BOOL IsTreeVisible() { return m_pSelector->IsTreeVisible(); } + CNavTitleBar* GetNavTitleBar() { return m_pNavTitle; } + BOOL IsTreeVisible() { return TRUE; } //m_pSelector->IsTreeVisible(); } + + void SetHTNode(HT_Resource node) { m_Node = node; } + void SetRDFButton(CRDFToolbarButton* pButton) { m_pButton = pButton; } + CRDFToolbarButton* GetRDFButton() { return m_pButton; } protected: // control bar embedded members friend class CSelector; @@ -118,7 +128,9 @@ protected: // control bar embedded members CPoint m_ptLast; // last mouse position during drag CDC* m_pDC; // where to draw during drag CDragBar* m_DragWnd; // the resize bar, when this frame is docked. - + HT_Resource m_Node; // the top node of the view. + CRDFToolbarButton* m_pButton; // A pointer to the button this view points to. + // NULL if window is floating. // All of these rects are in the Desktop window's coordinates. CRect m_rectDrag; // bounding rect when this frame is floating @@ -130,17 +142,8 @@ protected: // control bar embedded members int m_nXOffset, m_nYOffset; CSelector* m_pSelector; // the selector pane. - CContentView *m_nsContent; // the content pane. - CNavMenuBar* m_pNavMenu; // the embedded menu bar. - - // Indicator used when being docked/undocked. - enum { - unknown, - docked, - beingDocked, - undocked, - beingUndocked - } m_dockingState; + CRDFContentView *m_nsContent; // the content pane. + CNavTitleBar* m_pNavTitle; // the embedded title strip. // Generated message map functions protected: diff --git a/mozilla/cmd/winfe/outliner.cpp b/mozilla/cmd/winfe/outliner.cpp index 1e7d571218a..2dfc54971e1 100644 --- a/mozilla/cmd/winfe/outliner.cpp +++ b/mozilla/cmd/winfe/outliner.cpp @@ -232,6 +232,24 @@ COutliner::~COutliner ( ) delete m_pTip; } +void COutliner::DestroyColumns() +{ + if ( m_pColumn ) + { + while ( m_iNumColumns ) + { + if (m_pColumn[ m_iNumColumns - 1]->pHeader) + free((char*)m_pColumn[ m_iNumColumns - 1]->pHeader); + delete(m_pColumn[ m_iNumColumns - 1 ]); + m_iNumColumns--; + } + free(m_pColumn); + m_pColumn = NULL; + } + + m_iNumColumns = 0; +} + STDMETHODIMP COutliner::QueryInterface( REFIID refiid, LPVOID * ppv) @@ -3360,6 +3378,15 @@ void COutlinerParent::GetColumnRect( int iCol, RECT &rc ) } } +void COutlinerParent::EnableHeaders(BOOL bEnable) +{ + m_bDisableHeaders = !bEnable; + CRect rect; + GetClientRect(&rect); + Invalidate(); + OnSize(0, rect.Width(), rect.Height()); +} + void COutlinerParent::InvalidateColumn( int iCol ) { RECT rc; diff --git a/mozilla/cmd/winfe/outliner.h b/mozilla/cmd/winfe/outliner.h index b4959cbb467..76eda87ebbb 100644 --- a/mozilla/cmd/winfe/outliner.h +++ b/mozilla/cmd/winfe/outliner.h @@ -317,6 +317,8 @@ public: virtual void SetTotalLines( int ); virtual int GetTotalLines(); + virtual void DestroyColumns(); + protected: // @@ -459,7 +461,7 @@ public: ~COutlinerParent(); void EnableBorder ( BOOL bEnable = TRUE ) { m_bHasBorder = bEnable; } - void EnableHeaders ( BOOL bEnable = TRUE) { m_bDisableHeaders = !bEnable; Invalidate ( ); } + void EnableHeaders ( BOOL bEnable = TRUE); void EnableFocusFrame ( BOOL bEnable = TRUE) { m_bEnableFocusFrame = bEnable; } void SetOutliner ( COutliner * pOutliner ); diff --git a/mozilla/cmd/winfe/pain.cpp b/mozilla/cmd/winfe/pain.cpp index 0ad43d21b0e..89aba6eff9f 100644 --- a/mozilla/cmd/winfe/pain.cpp +++ b/mozilla/cmd/winfe/pain.cpp @@ -22,7 +22,7 @@ #include "pain.h" #include "navcntr.h" -CPaneCX *wfe_CreateNavCenterHTMLPain(HT_View htView, HWND hParent) +CPaneCX *wfe_CreateNavCenterHTMLPain(HWND hParent) { CPaneCX *pRetval = NULL; @@ -47,7 +47,6 @@ CPaneCX *wfe_CreateNavCenterHTMLPain(HT_View htView, HWND hParent) CWinCX *pWinCX = new CWinCX((CGenericDoc *)cccGrid.m_pCurrentDoc, NULL, pNewView, MWContextPane, Pane); if(pWinCX) { pWinCX->Initialize(pWinCX->CDCCX::IsOwnDC(), crClient); - XP_RegisterViewHTMLPane(htView, pWinCX->GetContext()); pRetval = VOID2CX(pWinCX, CPaneCX); } } diff --git a/mozilla/cmd/winfe/pain.h b/mozilla/cmd/winfe/pain.h index d4923fa67db..c99674a11a3 100644 --- a/mozilla/cmd/winfe/pain.h +++ b/mozilla/cmd/winfe/pain.h @@ -19,6 +19,6 @@ #ifndef __PAIN_H #define __PAIN_H -CPaneCX *wfe_CreateNavCenterHTMLPain(HT_View htView, HWND hParent); +CPaneCX *wfe_CreateNavCenterHTMLPain(HWND hParent); #endif // __PAIN_H diff --git a/mozilla/cmd/winfe/rdfacc.h b/mozilla/cmd/winfe/rdfacc.h index f2ae97dfee2..40ca4790065 100644 --- a/mozilla/cmd/winfe/rdfacc.h +++ b/mozilla/cmd/winfe/rdfacc.h @@ -21,6 +21,34 @@ #include "cxstubs.h" +class CIsomorphicCommandMap +{ +private: + CMapStringToString mapFromXPToFE; + CMapStringToString mapFromFEToXP; + +public: + static CIsomorphicCommandMap* InitializeCommandMap(const CString& initType); + // This function builds the command map and prepopulates it with the set of commands + // that can be responded to. + + void AddItem(CString xpItem, UINT feResource); + // Adds an isomorphic entry into the two maps. + + void RemoveXPItem(CString xpItem); + // Removes the isomorphic entry from the two maps (keyed on the XP item). + + void RemoveFEItem(UINT feResource); + // Removes the isomorphic entry from the two maps (keyed on the FE resource ID) + + UINT GetFEResource(CString xpItem); + // Given an XP name, retrieves the FE resource. + + CString GetXPResource(UINT resource); + // Given an FE resource, retrieves the XP name. +}; + + class CCustomImageObject; class CRDFImage; @@ -161,12 +189,19 @@ HICON DrawLocalFileIcon(HT_Resource r, int left, int top, HDC hdc); CRDFImage* DrawArbitraryURL(HT_Resource r, int left, int top, int imageWidth, int imageHeight, HDC hDC, COLORREF bkColor, CCustomImageObject* pObject, BOOL largeIcon); +CRDFImage* DrawRDFImage(CRDFImage* pImage, int left, int top, int imageWidth, int imageHeight, HDC hDC, + COLORREF bkColor); HICON FetchLocalFileIcon(HT_Resource r); CRDFImage* FetchCustomIcon(HT_Resource r, CCustomImageObject* pObject, BOOL largeIcon); IconType DetermineIconType(HT_Resource pNode, BOOL largeIcon); -void PaintBackground(HDC hdc, CRect rect, CRDFImage* pImage, int ySrcOffset = -1); - // This function tiles and paints the background image in the tree. +void PaintBackground(HDC hdc, CRect rect, CRDFImage* pImage, int xSrcOffset=-1, int ySrcOffset=-1); + // This function tiles and paints the background image in the tree. + +void Compute3DColors(COLORREF rgbColor, COLORREF &rgbLight, COLORREF &rgbDark); + // This function computes the appropriate highlight and shadow colors to + // use against a custom background. + void ResolveToPaletteColor(COLORREF& color, HPALETTE hPal); #endif // RDFACC_H \ No newline at end of file diff --git a/mozilla/cmd/winfe/rdfliner.cpp b/mozilla/cmd/winfe/rdfliner.cpp index 3eb928e2edf..26cb1f07ebb 100644 --- a/mozilla/cmd/winfe/rdfliner.cpp +++ b/mozilla/cmd/winfe/rdfliner.cpp @@ -21,9 +21,11 @@ #include "stdafx.h" #include "mainfrm.h" #include "hiddenfr.h" +#include "xp_ncent.h" #include "rdf.h" #include "htrdf.h" #include "rdfliner.h" +#include "pain.h" #include "shcut.h" #include "shcutdlg.h" #include "prefapi.h" @@ -56,7 +58,7 @@ extern int XP_BKMKS_HOURS_AGO; #define IDT_DRAGRECT 16414 #define EDIT_DELAY 500 -#define SPRINGLOAD_DELAY 300 +#define SPRINGLOAD_DELAY 500 #define RDF_DRAG_HEARTBEAT 125 // Faster than COutliner's DRAG_HEARTBEAT // Click location stuff @@ -198,14 +200,15 @@ BEGIN_MESSAGE_MAP(CRDFOutliner, COutliner) ON_WM_RBUTTONUP() ON_WM_CREATE() ON_WM_TIMER() + ON_WM_SIZE() //}}AFX_MSG_MAP END_MESSAGE_MAP() -CRDFOutliner::CRDFOutliner (HT_Pane thePane, HT_View theView, CRDFOutlinerParent* theParent) +CRDFOutliner::CRDFOutliner (CRDFOutlinerParent* theParent, HT_Pane thePane, HT_View theView) :COutliner(FALSE), m_pAncestor(NULL), m_Pane(thePane), m_View(theView), m_Parent(theParent), m_EditField(NULL), m_nSortType(HT_NO_SORT), m_nSortColumn(HT_NO_SORT), m_hEditTimer(0), m_hDragRectTimer(0), m_bNeedToClear(FALSE), m_nSelectedColumn(0), m_bDoubleClick(FALSE), m_Node(NULL), -m_bDataSourceInWindow(FALSE), m_NavMenuBar(NULL) +m_bDataSourceInWindow(FALSE), m_NavTitleBar(NULL), m_bInNavigationMode(FALSE), m_bIsPopup(FALSE) { ApiApiPtr(api); m_pUnkUserImage = api->CreateClassInstance(APICLASS_IMAGEMAP,NULL,(APISIGNATURE)IDB_BOOKMARKS); @@ -234,6 +237,13 @@ int CRDFOutliner::OnCreate(LPCREATESTRUCT lpCreateStruct) return iRetVal; } +void CRDFOutliner::OnSize( UINT nType, int cx, int cy ) +{ + SqueezeColumns( -1, 0, FALSE ); + m_iPaintLines = ( cy / m_itemHeight ) + 1; + EnableScrollBars ( ); +} + void CRDFOutliner::HandleEvent(HT_Notification ns, HT_Resource n, HT_Event whatHappened) { if (whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED) @@ -593,6 +603,12 @@ CRDFImage* DrawArbitraryURL(HT_Resource r, int left, int top, int imageWidth, in CCustomImageObject* pObject, BOOL largeIcon) { CRDFImage* pImage = FetchCustomIcon(r, pObject, largeIcon); + return DrawRDFImage(pImage, left, top, imageWidth, imageHeight, hDC, bkColor); +} + +CRDFImage* DrawRDFImage(CRDFImage* pImage, int left, int top, int imageWidth, int imageHeight, HDC hDC, + COLORREF bkColor) +{ if (pImage && pImage->FrameLoaded()) { // Now we draw this bad boy. @@ -793,7 +809,7 @@ IconType DetermineIconType(HT_Resource pNode, BOOL largeIcon) if (pNode != NULL) { char* pURL = largeIcon? HT_GetNodeLargeIconURL(pNode) : HT_GetNodeSmallIconURL(pNode); - TRACE("%s\n", pURL); + //TRACE("%s\n", pURL); if (strncmp("icon", pURL, 4) != 0) { // Time to load a custom image. @@ -893,7 +909,7 @@ void CRDFOutliner::SelectItem(int iSel,int mode,UINT flags) if (m_bNeedToClear) { HT_SetSelection(m_Node); - if (m_bNeedToEdit && !m_bDoubleClick) + if (m_bNeedToEdit && !m_bDoubleClick && !m_bUseSingleClick) { CRDFCommandMap& map = m_Parent->GetColumnCommandMap(); @@ -910,6 +926,8 @@ void CRDFOutliner::SelectItem(int iSel,int mode,UINT flags) m_bNeedToClear = FALSE; m_bNeedToEdit = FALSE; m_bDoubleClick = FALSE; + if (m_bUseSingleClick) + OnSelDblClk(iSel); break; case OUTLINER_LBUTTONDOWN: case OUTLINER_KEYDOWN: @@ -984,6 +1002,16 @@ BOOL CRDFOutliner::IsDocked() return theFrame->IsChild(this); } +void CRDFOutliner::SetNavigationMode(BOOL mode) +{ + m_bInNavigationMode = mode; + ((CRDFOutlinerParent*)GetParent())->EnableHeaders(!m_bInNavigationMode); + + // Need to invalidate the title strip. + CRDFContentView* pView = (CRDFContentView*)(GetParent()->GetParent()); + pView->GetTitleBar()->Invalidate(); +} + void CRDFOutliner::OnSelDblClk(int iLine) { if (m_Node) @@ -995,13 +1023,32 @@ void CRDFOutliner::OnSelDblClk(int iLine) else if (!HT_IsSeparator(m_Node))// && !IsDocked()) For now always do double-click behavior { DisplayURL(); + if (IsPopup()) + { + // Destroy the entire tree. + CFrameWnd* pFrameWnd = GetParentFrame(); + if (pFrameWnd->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) + ((CNSNavFrame*)pFrameWnd)->DeleteNavCenter(); + } } } } +void CRDFOutliner::SetHTView(HT_View v) +{ + m_Pane = HT_GetPane(v); + m_View = v; + m_iSelection = m_iFocus = -1; + int newCount = HT_GetItemListCount(m_View); + SetTotalLines(newCount); // Update the outliner's visible lines + m_iTopLine = 0; +} + void CRDFOutliner::DisplayURL() { char* url = HT_GetNodeURL(m_Node); + + // Hacking the window target (Added by Dave on 7/12/98) CAbstractCX * pCX = FEU_GetLastActiveFrameContext(); //Check for whether we need new browser window. @@ -1078,7 +1125,9 @@ void CRDFOutliner::DisplayURL() if (pLocalName) XP_FREE(pLocalName); } - else pCX->NormalGetUrl((LPTSTR) url); // Do a normal fetch. + else if (m_WindowTarget == "") + pCX->NormalGetUrl((LPTSTR) url, "rdftree"); // Do a normal fetch. + else pCX->NormalGetUrl((LPTSTR) url, "rdftree", (char*)(const char*)m_WindowTarget); } BOOL CRDFOutliner::TestRowCol(POINT point, int &iRow, int &iCol) @@ -1646,17 +1695,23 @@ void CRDFOutliner::OnKillFocus ( CWnd * pNewWnd ) void CRDFOutliner::FocusCheck(CWnd* pWnd, BOOL gotFocus) { - if (m_NavMenuBar) + if (m_NavTitleBar) { if (gotFocus) - m_NavMenuBar->NotifyFocus(TRUE); + m_NavTitleBar->NotifyFocus(TRUE); else { - CFrameWnd* pFrame = GetParentFrame(); - if (pFrame && !pFrame->IsChild(pWnd)) + CFrameWnd* pFrameWnd = GetParentFrame(); + if (pFrameWnd && !pFrameWnd->IsChild(pWnd)) { // Invalidate for a redraw - m_NavMenuBar->NotifyFocus(FALSE); + m_NavTitleBar->NotifyFocus(FALSE); + if (IsPopup()) + { + // Destroy the window. + if (pFrameWnd->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) + ((CNSNavFrame*)pFrameWnd)->DeleteNavCenter(); + } } } } @@ -1723,23 +1778,64 @@ void CRDFOutliner::OnPaint() GetClientRect(&rcClient); CPaintDC pdc ( this ); + if (m_View == NULL) + return; + // Read in all the properties HT_Resource top = HT_TopNode(m_View); void* data; PRBool foundData = FALSE; + if (m_bInNavigationMode) + { + // Options for navigation mode. + // Inherit colors from the toolbar if we point to a button. + CFrameWnd* pFrameWnd = GetParentFrame(); + if (pFrameWnd->IsKindOf(RUNTIME_CLASS(CNSNavFrame))) + { + // We have a parent navframe that could POTENTIALLY be attached to a button. + CNSNavFrame* pNav = (CNSNavFrame*)pFrameWnd; + if (pNav->GetRDFButton() != NULL) + { + // There's a button from which to inherit colors. + CRDFToolbar* pToolbar = (CRDFToolbar*)(pNav->GetRDFButton()->GetParent()); + m_ForegroundColor = m_SortForegroundColor = pToolbar->GetForegroundColor(); + m_BackgroundColor = m_SortBackgroundColor = pToolbar->GetBackgroundColor(); + } + } + else + { + // Use some defaults + m_ForegroundColor = m_SortForegroundColor = RGB(0,0,0); + m_BackgroundColor = m_SortBackgroundColor = RGB(240,240,240); + } + + m_bHasPipes = FALSE; + m_bDrawDividers = FALSE; + m_bUseSingleClick = TRUE; + } + else + { + // Options for management mode. + m_ForegroundColor = RGB(0,0,0); + m_BackgroundColor = RGB(240,240,240); + m_SortBackgroundColor = RGB(224,224,224); + m_SortForegroundColor = RGB(0,0,0); + m_bHasPipes = TRUE; + m_bDrawDividers = TRUE; + m_bUseSingleClick = FALSE; + } + // Foreground color - HT_GetNodeData(top, gNavCenter->treeFGColor, HT_COLUMN_STRING, &data); + HT_GetNodeData(top, gNavCenter->viewFGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_ForegroundColor); - else m_ForegroundColor = RGB(0,0,0); - + // background color - HT_GetNodeData(top, gNavCenter->treeBGColor, HT_COLUMN_STRING, &data); + HT_GetNodeData(top, gNavCenter->viewBGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_BackgroundColor); - else m_BackgroundColor = RGB(240,240,240); - + HT_GetNodeData(top, gNavCenter->showTreeConnections, HT_COLUMN_STRING, &data); if (data) { @@ -1747,19 +1843,20 @@ void CRDFOutliner::OnPaint() if (answer.GetLength() > 0 && (answer.GetAt(0) == 'n' || answer.GetAt(0) == 'N')) m_bHasPipes = FALSE; } - else m_bHasPipes = TRUE; - + // Sort foreground color HT_GetNodeData(top, gNavCenter->sortColumnFGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_SortForegroundColor); - else m_SortForegroundColor = RGB(0,0,0); - + // Sort background color HT_GetNodeData(top, gNavCenter->sortColumnBGColor, HT_COLUMN_STRING, &data); if (data) WFE_ParseColor((char*)data, &m_SortBackgroundColor); - else m_SortBackgroundColor = RGB(224,224,224); + + // Compute the shadow/highlight colors for sorting and for normal modes. + Compute3DColors(m_SortBackgroundColor, m_SortHighlightColor, m_SortShadowColor); + Compute3DColors(m_BackgroundColor, m_HighlightColor, m_ShadowColor); // Selection foreground color HT_GetNodeData(top, gNavCenter->selectionFGColor, HT_COLUMN_STRING, &data); @@ -1775,7 +1872,7 @@ void CRDFOutliner::OnPaint() // Background image URL m_BackgroundImageURL = ""; - HT_GetNodeData(top, gNavCenter->treeBGURL, HT_COLUMN_STRING, &data); + HT_GetNodeData(top, gNavCenter->viewBGURL, HT_COLUMN_STRING, &data); if (data) m_BackgroundImageURL = (char*)data; m_pBackgroundImage = NULL; // Clear out the BG image. @@ -1793,8 +1890,7 @@ void CRDFOutliner::OnPaint() if (answer.GetLength() > 0 && (answer.GetAt(0) == 'n' || answer.GetAt(0) == 'N')) m_bDrawDividers = FALSE; } - else m_bDrawDividers = TRUE; - + HPALETTE pOldPalette = NULL; if (sysInfo.m_iBitsPerPixel < 16 && (::GetDeviceCaps(pdc.m_hDC, RASTERCAPS) & RC_PALETTE)) { @@ -1848,7 +1944,7 @@ void CRDFOutliner::OnPaint() { int imageHeight = m_pBackgroundImage->bmpInfo->bmiHeader.biHeight; int ySrcOffset = (bgFillRect.top + m_iTopLine*m_itemHeight) % imageHeight; - PaintBackground(pdc, bgFillRect, m_pBackgroundImage, ySrcOffset); + PaintBackground(pdc, bgFillRect, m_pBackgroundImage, 0, ySrcOffset); } else { @@ -1918,7 +2014,161 @@ void DrawBGSubimage(CRDFImage* pImage, HDC hDC, int xSrcOffset, int ySrcOffset, } } -void PaintBackground(HDC hdc, CRect rect, CRDFImage* pImage, int ySrcOffset) +#define LIGHT_GRAY RGB(192, 192, 192) +#define DARK_GRAY RGB(128, 128, 128) +#define WHITE RGB(255, 255, 255) +#define BLACK RGB(0, 0, 0) + +void +GetSystem3DColors(COLORREF rgbBackground, COLORREF& rgbLightColor, COLORREF& rgbDarkColor) +{ +#ifdef XP_WIN32 + if (sysInfo.IsWin4_32()) { + // These are Windows 95 only + rgbLightColor = ::GetSysColor(COLOR_3DLIGHT); + rgbDarkColor = ::GetSysColor(COLOR_3DSHADOW); + } else { + rgbLightColor = LIGHT_GRAY; + rgbDarkColor = ::GetSysColor(COLOR_BTNSHADOW); + } +#else + rgbLightColor = LIGHT_GRAY; + rgbDarkColor = ::GetSysColor(COLOR_BTNSHADOW); +#endif + + // We need to make sure that both colors are visible against + // the background + if (rgbLightColor == rgbBackground) + rgbLightColor = rgbBackground == LIGHT_GRAY ? WHITE : LIGHT_GRAY; + + if (rgbDarkColor == rgbBackground) + rgbDarkColor = rgbBackground == DARK_GRAY ? BLACK : DARK_GRAY; +} + +// Constants for calculating Highlight (TS = "TopShadow") and +// shadow (BS = "BottomShadow") values relative to background +// Taken from UNIX version -- Eric Bina's Visual.c +// +// Bias brightness calculation by standard color-sensitivity values +// (Percents -- UNIX used floats, but we don't need to) +// +#define RED_LUMINOSITY 30 +#define GREEN_LUMINOSITY 59 +#define BLUE_LUMINOSITY 11 + +// Percent effect of intensity, light, and luminosity & on brightness, +#define INTENSITY_FACTOR 25 +#define LIGHT_FACTOR 0 +#define LUMINOSITY_FACTOR 75 + +// LITE color model percent to interpolate RGB towards black for BS, TS + +#define COLOR_LITE_BS_FACTOR 45 +#define COLOR_LITE_TS_FACTOR 70 + +// DARK color model - percent to interpolate RGB towards white for BS, TS + +#define COLOR_DARK_BS_FACTOR 30 +#define COLOR_DARK_TS_FACTOR 50 +#define MAX_COLOR 255 + +#define COLOR_DARK_THRESHOLD 51 +#define COLOR_LIGHT_THRESHOLD 204 + +void Compute3DColors(COLORREF rgbColor, COLORREF &rgbLight, COLORREF &rgbDark) +{ + unsigned uRed, uGreen, uBlue; + unsigned uRedBack = GetRValue(rgbColor); + unsigned uGreenBack = GetGValue(rgbColor); + unsigned uBlueBack = GetBValue(rgbColor); + unsigned intensity = (uRedBack + uGreenBack + uBlueBack) / 3; + unsigned luminosity = ((RED_LUMINOSITY * uRedBack)/ 100) + + ((GREEN_LUMINOSITY * uGreenBack)/ 100) + + ((BLUE_LUMINOSITY * uBlueBack)/ 100); + unsigned backgroundBrightness = ((intensity * INTENSITY_FACTOR) + + (luminosity * LUMINOSITY_FACTOR)) / 100; + unsigned f; + + if (backgroundBrightness < COLOR_DARK_THRESHOLD) { + // Dark Background - interpolate 30% toward black + uRed = uRedBack - (COLOR_DARK_BS_FACTOR * uRedBack / 100); + uGreen = uGreenBack - (COLOR_DARK_BS_FACTOR * uGreenBack / 100); + uBlue = uBlueBack - (COLOR_DARK_BS_FACTOR * uBlueBack / 100); + + rgbDark = RGB(uRed, uGreen, uBlue); + + // This interpolotes to 50% toward white + uRed = uRedBack + (COLOR_DARK_TS_FACTOR * + (MAX_COLOR - uRedBack) / 100); + uGreen = uGreenBack + (COLOR_DARK_TS_FACTOR * + (MAX_COLOR - uGreenBack) / 100); + + uBlue = uBlueBack + (COLOR_DARK_TS_FACTOR * + (MAX_COLOR - uBlueBack) / 100); + + } else if (backgroundBrightness > COLOR_LIGHT_THRESHOLD) { + // Interpolate 45% toward black + uRed = uRedBack - (COLOR_LITE_BS_FACTOR * uRedBack / 100); + uGreen = uGreenBack - (COLOR_LITE_BS_FACTOR * uGreenBack / 100); + uBlue = uBlueBack - (COLOR_LITE_BS_FACTOR * uBlueBack / 100); + rgbDark = RGB(uRed, uGreen, uBlue); + + // Original algorithm (from X source: visual.c) used: + // uRed = uRedBack - (COLOR_LITE_TS_FACTOR * uRedBack / 100), + // where FACTOR is 20%, but that makes no sense! + // I think the intention was large interpolation toward white, + // so use max of "medium" range (70%) for smooth continuity across threshhold + uRed = uRedBack + (COLOR_LITE_TS_FACTOR * (MAX_COLOR - uRedBack) / 100); + uGreen = uGreenBack + (COLOR_LITE_TS_FACTOR * (MAX_COLOR - uGreenBack) / 100); + uBlue = uBlueBack + (COLOR_LITE_TS_FACTOR * (MAX_COLOR - uBlueBack) / 100); + + } else { + // Medium Background + f = COLOR_DARK_BS_FACTOR + (backgroundBrightness + * ( COLOR_LITE_BS_FACTOR - COLOR_DARK_BS_FACTOR ) + / MAX_COLOR); + + uRed = uRedBack - (f * uRedBack / 100); + uGreen = uGreenBack - (f * uGreenBack / 100); + uBlue = uBlueBack - (f * uBlueBack / 100); + rgbDark = RGB(uRed, uGreen, uBlue); + + f = COLOR_DARK_TS_FACTOR + (backgroundBrightness + * ( COLOR_LITE_TS_FACTOR - COLOR_DARK_TS_FACTOR ) + / MAX_COLOR); + + uRed = uRedBack + (f * (MAX_COLOR - uRedBack) / 100); + uGreen = uGreenBack + (f * (MAX_COLOR - uGreenBack) / 100); + uBlue = uBlueBack + (f * (MAX_COLOR - uBlueBack) / 100); + } + + // Safety check for upper limit + uRed = min(MAX_COLOR, uRed); + uGreen = min(MAX_COLOR, uGreen); + uBlue = min(MAX_COLOR, uBlue); + + rgbLight = RGB(uRed, uGreen, uBlue); + + // Special case white backgrounds and black backgrounds + if (rgbLight == rgbColor && (uRedBack == MAX_COLOR && uGreenBack == MAX_COLOR && uBlueBack == MAX_COLOR)) + { + // For a white separator use medium gray colors. + rgbLight = RGB(192,192,192); + } + else if (rgbDark == rgbColor && rgbColor == 0) + { + // Use a dark gray color. + rgbDark = RGB(64,64,64); + } + + // If either of these colors is the same as the background color + // then use the system 3D element colors instead + if (rgbLight == rgbColor || rgbDark == rgbColor) { + GetSystem3DColors(rgbColor, rgbLight, rgbDark); + } +} + +void PaintBackground(HDC hdc, CRect rect, CRDFImage* pImage, int xSrcOffset, int ySrcOffset) { int totalWidth = rect.Width(); int totalHeight = rect.Height(); @@ -1933,10 +2183,12 @@ void PaintBackground(HDC hdc, CRect rect, CRDFImage* pImage, int ySrcOffset) int xDstOffset = rect.left; int yDstOffset = rect.top; - int xSrcOffset = 0; if (ySrcOffset == -1) // Assume we don't have a scrolled offset in the view we're drawing into. ySrcOffset = rect.top % imageHeight; + if (xSrcOffset == -1) // Assume we don't have a scrolled offset in the view we're drawing into. + xSrcOffset = rect.left % imageWidth; + int xRemainder = imageWidth - xSrcOffset; int yRemainder = imageHeight - ySrcOffset; @@ -2107,21 +2359,37 @@ void CRDFOutliner::PaintColumn(int iLineNo, int iColumn, LPRECT lpColumnRect, { BOOL hasFocus = FALSE; - if (theNode && HT_IsSeparator(theNode)) + CRect WinRect; + GetClientRect(&WinRect); + + if (theNode && HT_IsSeparator(theNode) && lpColumnRect->right != WinRect.right) { // Draw the horizontal line. - CPen separatorPen; - if (iColumn == GetSortColumn()) - separatorPen.CreatePen(PS_SOLID, 1, m_SortForegroundColor); - else separatorPen.CreatePen(PS_SOLID, 1, m_ForegroundColor); - - HPEN sepPen = (HPEN)separatorPen.GetSafeHandle(); - - HPEN usePen = IsSelected(iLineNo) ? hHighlightPen : sepPen; + CPen separatorHighlightPen; + CPen separatorShadowPen; - HPEN pOldPen = (HPEN)(::SelectObject(hdc, usePen)); + if (iColumn == GetSortColumn()) + { + separatorHighlightPen.CreatePen(PS_SOLID, 1, m_SortHighlightColor); + separatorShadowPen.CreatePen(PS_SOLID, 1, m_SortShadowColor); + } + else + { + separatorHighlightPen.CreatePen(PS_SOLID, 1, m_HighlightColor); + separatorShadowPen.CreatePen(PS_SOLID, 1, m_ShadowColor); + } + + //HPEN sepPen = (HPEN)separatorPen.GetSafeHandle(); + //HPEN usePen = IsSelected(iLineNo) ? hHighlightPen : sepPen; + + HPEN pOldPen = (HPEN)(::SelectObject(hdc, (HPEN)separatorShadowPen.GetSafeHandle())); ::MoveToEx(hdc, lpColumnRect->left, lpColumnRect->top+m_itemHeight/2, NULL); ::LineTo(hdc, lpColumnRect->right, lpColumnRect->top+m_itemHeight/2); + + ::SelectObject(hdc, (HPEN)separatorHighlightPen.GetSafeHandle()); + ::MoveToEx(hdc, lpColumnRect->left, lpColumnRect->top+m_itemHeight/2+1, NULL); + ::LineTo(hdc, lpColumnRect->right, lpColumnRect->top+m_itemHeight/2+1); + ::SelectObject(hdc, pOldPen); } @@ -2223,15 +2491,15 @@ void CRDFOutliner::DrawColumn(HDC hdc, LPRECT lpColumnRect, LPCTSTR lpszString, CRect newRect(bgRect); if (hasFocus) { - newRect.top +=2; - newRect.bottom-=2; - newRect.left+=2; - newRect.right-=2; + newRect.top +=1; + newRect.bottom-=1; + newRect.left+=1; + newRect.right-=1; } ::FillRect(hdc, &newRect, theBrush); } - else if (!hasFocus) - ::FrameRect( hdc, &bgRect, theBrush); + + ::FrameRect( hdc, &bgRect, theBrush); } // Adjust the text rectangle for the left and right margins @@ -2239,11 +2507,6 @@ void CRDFOutliner::DrawColumn(HDC hdc, LPRECT lpColumnRect, LPCTSTR lpszString, textRect.right -= COL_LEFT_MARGIN; WFE_DrawTextEx( m_iCSID, hdc, (LPTSTR) lpszString, iLength, &textRect, dwDTFormat, dwMoreFormat ); - - if (hasFocus) - { - DrawFocusRect ( hdc, &bgRect ); - } } int CRDFOutliner::DrawPipes ( int iLineNo, int iColNo, int offset, HDC hdc, void * pLineData ) @@ -2325,7 +2588,7 @@ int CRDFOutliner::DrawPipes ( int iLineNo, int iColNo, int offset, HDC hdc, void } HT_Resource r = (HT_Resource)pLineData; - if (r && HT_IsContainer(r)) + if (r && HT_IsContainer(r) && m_bHasPipes) { // Draw the trigger CBrush outerTrigger(RGB(128,128,128)); @@ -2386,6 +2649,12 @@ void CRDFOutliner::ColumnsSwapped() SetImageColumn(m_pColumn[0]->iCommand); } +void CRDFOutliner::DestroyColumns() +{ + m_Parent->DestroyColumns(); + COutliner::DestroyColumns(); +} + CRect CRDFOutliner::GetColumnRect(int iLine, int column) { CRect rectColumn; @@ -3249,7 +3518,7 @@ END_MESSAGE_MAP() CRDFOutlinerParent::CRDFOutlinerParent(HT_Pane thePane, HT_View theView) { - CRDFOutliner* theOutliner = new CRDFOutliner(thePane, theView, this); + CRDFOutliner* theOutliner = new CRDFOutliner(this, thePane, theView); m_pOutliner = theOutliner; } @@ -3284,6 +3553,9 @@ void CRDFOutlinerParent::OnPaint ( ) // Read in our values. CRDFOutliner* pRDFLiner = (CRDFOutliner*)m_pOutliner; HT_View view = pRDFLiner->GetHTView(); + if (view == NULL) + return; + HT_Resource top = HT_TopNode(view); // Foreground color @@ -3482,16 +3754,24 @@ void CRDFOutlinerParent::CreateColumns ( void ) void* token; uint32 tokenType; UINT index = 0; + while (HT_GetNextColumn(columnCursor, &columnName, &columnWidth, &token, &tokenType)) { // We have retrieved a new column. Contruct a front end column object CRDFColumn* newColumn = new CRDFColumn(columnName, columnWidth, token, tokenType); index = (UINT)columnMap.AddCommand(newColumn); - m_pOutliner->AddColumn(columnName, index, 5000, 10000, ColumnVariable, 3000); + m_pOutliner->AddColumn(columnName, index, 50, 10000, ColumnVariable, 100); } HT_DeleteColumnCursor(columnCursor); m_pOutliner->SetVisibleColumns(1); // For now... TODO: Get visible/invisible info! - m_pOutliner->SetImageColumn(0); + m_pOutliner->SetImageColumn(m_pOutliner->m_pColumn[0]->iCommand); + + // Make it so + RECT rcClient; + m_pOutliner->GetClientRect(&rcClient); + ((CRDFOutliner*)m_pOutliner)->OnSize(0, rcClient.right, rcClient.bottom); + + Invalidate(); } BOOL CRDFOutlinerParent::RenderData( int iColumn, CRect & rect, CDC &dc, LPCTSTR text ) @@ -3563,9 +3843,7 @@ BOOL CRDFOutlinerParent::ColumnCommand( int iColumn ) if (enSortType == HT_SORT_ASCENDING) sort = FALSE; - pOutliner->SetSelectedColumn(pOutliner->m_pColumn[ iColumn ]->iCommand); - - Invalidate(); + pOutliner->SetSelectedColumn(iColumn); HT_SetSortColumn(pOutliner->GetHTView(), enSortType == HT_NO_SORT ? NULL : theColumn->GetToken(), @@ -3644,106 +3922,154 @@ void CRDFEditWnd::OnKillFocus( CWnd* pNewWnd ) // ========================================================================= // RDF Content View -IMPLEMENT_DYNAMIC(CRDFContentView, CContentView) -BEGIN_MESSAGE_MAP(CRDFContentView, CContentView) +IMPLEMENT_DYNAMIC(CRDFContentView, CView) +BEGIN_MESSAGE_MAP(CRDFContentView, CView) //{{AFX_MSG_MAP(CMainFrame) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code ! - ON_MESSAGE(WM_NAVCENTER_QUERYPOSITION, OnNavCenterQueryPosition) ON_WM_CREATE() ON_WM_SIZE() ON_WM_SETFOCUS() //}}AFX_MSG_MAP END_MESSAGE_MAP() -LRESULT CRDFContentView::OnNavCenterQueryPosition(WPARAM wParam, LPARAM lParam) -{ - NAVCENTPOS *pPos = (NAVCENTPOS *)lParam; - - // We like being in the middle. - pPos->m_iYDisposition = 0; - - // We like being this many units in size. - pPos->m_iYVector = 200; - - // Handled. - return(NULL); -} - -BOOL CRDFContentView::PreCreateWindow(CREATESTRUCT& cs) -{ - cs.style |= WS_CLIPSIBLINGS | WS_CLIPCHILDREN; - - return CContentView::PreCreateWindow(cs); -} - -void CRDFContentView::OnDraw ( CDC * pDC ) -{ -} +CRDFContentView::CRDFContentView() +{ m_pOutlinerParent = NULL; m_pHTMLView = NULL; m_pNavBar = NULL; } int CRDFContentView::OnCreate ( LPCREATESTRUCT lpCreateStruct ) { - int iRetVal = CContentView::OnCreate ( lpCreateStruct ); + int iRetVal = CView::OnCreate ( lpCreateStruct ); LPCTSTR lpszClass = AfxRegisterWndClass( CS_VREDRAW, ::LoadCursor(NULL, IDC_ARROW)); + + m_pNavBar = new CNavTitleBar(); + + m_pOutlinerParent = new CRDFOutlinerParent(); m_pOutlinerParent->Create( lpszClass, _T("NSOutlinerParent"), WS_VISIBLE|WS_CHILD|WS_CLIPCHILDREN, CRect(0,0,100,100), this, 101 ); + + m_pHTMLView = NULL; //wfe_CreateNavCenterHTMLPain(m_hWnd); + + m_pNavBar->Create(NULL, "", WS_CHILD | WS_VISIBLE, CRect(0,0,100,100), this, NC_IDW_NAVMENU); + return iRetVal; } +CRDFContentView::~CRDFContentView() +{ + CRDFOutliner* pOutliner = (CRDFOutliner*)(GetOutlinerParent()->GetOutliner()); + HT_View v = pOutliner->GetHTView(); + HT_SetViewFEData(v, NULL); + + XP_UnregisterNavCenter(HT_GetPane(v)); + + HT_DeletePane(HT_GetPane(v)); + + delete m_pNavBar; + delete m_pOutlinerParent; + delete m_pHTMLView; +} + void CRDFContentView::OnSize ( UINT nType, int cx, int cy ) { CView::OnSize ( nType, cx, cy ); if (IsWindow(m_pOutlinerParent->m_hWnd)) { - m_pOutlinerParent->MoveWindow ( 0, 0, cx, cy ); + m_pNavBar->MoveWindow(0,0, cx, NAVBAR_HEIGHT); + m_pOutlinerParent->MoveWindow ( 0, NAVBAR_HEIGHT, cx, cy-NAVBAR_HEIGHT); } } -void CRDFContentView::InvalidateOutlinerParent() -{ -// COutliner* outliner = m_pOutlinerParent->GetOutliner(); -// outliner->SqueezeColumns(-1, 0, TRUE); -} - void CRDFContentView::OnSetFocus ( CWnd * pOldWnd ) { m_pOutlinerParent->SetFocus ( ); } +void CRDFContentView::SwitchHTViews(HT_View newView) +{ + m_pOutlinerParent->SetHTView(newView); + m_pOutlinerParent->GetOutliner()->DestroyColumns(); + CreateColumns(); +} + +void CRDFContentView::OnKillFocus(CWnd* pNewWnd) +{ +} + // Functionality for the RDF Tree Embedded in HTML (Added 3/10/98 by Dave Hyatt). // The event handler. Only cares about tree events, so we'll just pass everything to the // tree view. -void embeddedTreeNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) +void embeddedTreeNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened, + void *token, uint32 tokenType) { CRDFOutliner* theOutliner = (CRDFOutliner*)HT_GetViewFEData(HT_GetView(n)); if (theOutliner) theOutliner->HandleEvent(ns, n, whatHappened); } -void CRDFContentView::DisplayRDFTree(CWnd* pParent, int width, int height, RDF_Resource rdfResource) +CRDFContentView* CRDFContentView::DisplayRDFTreeFromPane(CWnd* pParent, int xPos, int yPos, + int width, int height, HT_Pane thePane, CCreateContext* pContext) { - HT_Notification ns = new HT_NotificationStruct; - ns->notifyProc = embeddedTreeNotifyProcedure; - ns->data = NULL; - - // Construct the pane and give it our notification struct - HT_Pane thePane = HT_PaneFromResource(rdfResource, ns, PR_FALSE); - - // Build our FE windows. - CRDFOutlinerParent* newParent = new CRDFOutlinerParent(thePane, HT_GetSelectedView(thePane)); - CRDFContentView* newView = new CRDFContentView(newParent); - // Create the windows - CRect rClient(0, 0, width, height); - newView->Create( NULL, "", WS_CHILD | WS_VISIBLE, rClient, pParent, NC_IDW_OUTLINER); + CRect rClient(xPos, yPos, width, height); + + CRDFContentView* newView = new CRDFContentView(); + + newView->Create(NULL, "", WS_CHILD | WS_VISIBLE, rClient, pParent, NC_IDW_OUTLINER, pContext); + + // Get the parent + COutlinerParent* newParent = newView->GetOutlinerParent(); + ((CRDFOutlinerParent*)newParent)->SetHTView(HT_GetSelectedView(thePane)); // Initialize the columns, etc. - newParent->Initialize(); + ((CRDFOutlinerParent*)newParent)->Initialize(); + + // Retrieve the RDF Outliner. + CRDFOutliner* pOutliner = (CRDFOutliner*)newParent->GetOutliner(); + + // Set to navigation mode. + pOutliner->SetNavigationMode(TRUE); // Set our FE data to be the outliner. - HT_SetViewFEData(HT_GetSelectedView(thePane), newParent->GetOutliner()); + HT_SetViewFEData(HT_GetSelectedView(thePane), pOutliner); + + // Explain who the title bar belongs to. + CNavTitleBar* pTitleBar = newView->GetTitleBar(); + pTitleBar->SetHTView(HT_GetSelectedView(thePane)); + pOutliner->SetTitleBar(pTitleBar); + + return newView; +} + +CRDFContentView* CRDFContentView::DisplayRDFTreeFromResource(CWnd* pParent, + int xPos, int yPos, int width, int height, HT_Resource node, CCreateContext* pContext) +{ + HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); + ns->notifyProc = embeddedTreeNotifyProcedure; + ns->data = NULL; + theApp.m_pRDFCX->TrackRDFWindow(pParent); + + HT_Pane thePane = HT_PaneFromResource(HT_GetRDFResource(node), ns, PR_FALSE, PR_TRUE, PR_TRUE); + + // Now call our helper function + return DisplayRDFTreeFromPane(pParent, xPos, yPos, width, height, thePane, pContext); +} + +CRDFContentView* CRDFContentView::DisplayRDFTreeFromSHACK(CWnd* pParent, int xPos, int yPos, int width, int height, char* url, int32 param_count, char** param_names, char** param_values) +{ + HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); + ns->notifyProc = embeddedTreeNotifyProcedure; + ns->data = NULL; + theApp.m_pRDFCX->TrackRDFWindow(pParent); + + // Construct the pane and give it our notification struct + HT_Pane thePane = HT_PaneFromURL(url, ns, 0, param_count, param_names, param_values); + + // Now call our helper function + return DisplayRDFTreeFromPane(pParent, xPos, yPos, width, height, thePane); } // Function to grab an RDF context diff --git a/mozilla/cmd/winfe/rdfliner.h b/mozilla/cmd/winfe/rdfliner.h index ab96e16293c..47bee089da1 100644 --- a/mozilla/cmd/winfe/rdfliner.h +++ b/mozilla/cmd/winfe/rdfliner.h @@ -11,9 +11,9 @@ * NPL. * * The Initial Developer of this code under the NPL is Netscape - * Communications Corporation. Portions created by Netscape are - * Copyright (C) 1998 Netscape Communications Corporation. All Rights - * Reserved. + * Commuyright (C) 1998 Netscape Communications Corporation. All Rights + * Resnications Corporation. Portions created by Netscape are + * Coperved. */ // RDF Tree View for Aurora. Created by Dave Hyatt. @@ -100,7 +100,7 @@ private: CRDFCommandMap m_MenuCommandMap; // The command mapping for menus - CNavMenuBar* m_NavMenuBar; // A pointer to the title nav menu. NULL if no menu button is present. + CNavTitleBar* m_NavTitleBar; // A pointer to the title strip. // Tree colors, fonts, and backgrounds COLORREF m_ForegroundColor; // The foreground color. Used for text, separators, etc. @@ -113,34 +113,71 @@ private: COLORREF m_SelectionForegroundColor; // Foreground color of the selection COLORREF m_SelectionBackgroundColor; // Background color of the selection + COLORREF m_ShadowColor; // Shadow color of the tree (used for drawing separators). + COLORREF m_HighlightColor; // Highlight color of the tree (used for drawing separators). + + COLORREF m_SortShadowColor; // Shadow color of the sorted tree (used for drawing separators). + COLORREF m_SortHighlightColor; // Highlight color of the sorted tree (used for drawing separators). + + COLORREF m_RolloverColor; // Rollover color of the tree. + COLORREF m_DividerColor; // Color of the dividers drawn between lines BOOL m_bDrawDividers; // Whether or not dividers should be drawn CString m_BackgroundImageURL; // The URL of the background image. CRDFImage* m_pBackgroundImage; // The image for the background. + BOOL m_bBarColor; // The color of the tree connections. + + BOOL m_bUseSingleClick; // Single click vs. double click + BOOL m_bUseHyperbolicScaling; // Whether or not to use hyperbolic scaling. + + CString m_WindowTarget; // The target window for this tree view. If "", then the + // last active window is assumed. + + BOOL m_bInNavigationMode; // The tree view has two different sets of defaults that + // it will assume if no value is defined for a specific + // property. These defaults are based on whether or not + // the user is browsing or managing data. + BOOL m_bIsPopup; // Whether or not we're a popup tree. + public: - CRDFOutliner (HT_Pane thePane, HT_View theView, CRDFOutlinerParent* theParent); + CRDFOutliner (CRDFOutlinerParent* theParent, HT_Pane thePane = NULL, HT_View theView = NULL); ~CRDFOutliner ( ); // Inspectors + COLORREF GetForegroundColor() { return m_ForegroundColor; } + COLORREF GetBackgroundColor() { return m_BackgroundColor; } + CString GetBackgroundImageURL() { return m_BackgroundImageURL; } + HT_View GetHTView() { return m_View; } // Return a handle to the hypertree view HT_Resource GetAcquiredNode() { return m_Node; } // Return handle to the acquired HT node CRDFOutlinerParent* GetRDFParent() { return m_Parent; } // RDFOutlinerParent handle UINT GetSelectedColumn() { return m_nSelectedColumn; } // Returns selected column int GetSortColumn() { return m_nSortColumn; } int GetSortType() { return m_nSortType; } - + BOOL IsPopup() { return m_bIsPopup; } + BOOL InNavigationMode() { return m_bInNavigationMode; } + // Setters + void SetNavigationMode(BOOL inMode); + void SetIsPopup(BOOL isPopup) { m_bIsPopup = isPopup; } + + void SetHTView(HT_View v); + void SetWindowTarget(char* target) { m_WindowTarget = target; } + void SetSortType(int sortType) { m_nSortType = sortType; } void SetSortColumn(int sortColumn) { m_nSortColumn = sortColumn; } void SetSelectedColumn(int nColumn) { m_nSelectedColumn = nColumn; } - void SetDockedMenuBar(CNavMenuBar* bar) { m_NavMenuBar = bar; } + void SetTitleBar(CNavTitleBar* bar) { m_NavTitleBar = bar; } // I am explicitly labeling as virtual any functions that have been // overridden. That is, unless I state otherwise, all virtual functions // are overridden versions of COutliner functions. + virtual void DestroyColumns(); + // Overridden to destroy the outliner's columns and clear our RDF column command map. + virtual void InitializeItemHeight(int iDesiredSize) { m_itemHeight = 19; } // Overridden to place a pixel of padding on either side of the line and to add a pixel for the // divider that is drawn between lines. @@ -318,6 +355,9 @@ public: afx_msg void OnPaint(); // Overridden to perform a drawing optimization (not performed by Outliner) + afx_msg void OnSize( UINT nType, int cx, int cy ); + // Overridden to ensure column repainting and resizing. + afx_msg void OnLButtonDown ( UINT nFlags, CPoint point ); afx_msg void OnLButtonUp (UINT nFlags, CPoint point ); afx_msg void OnMouseMove( UINT nFlags, CPoint point ); @@ -364,11 +404,13 @@ private: CString m_BackgroundImageURL; public: - CRDFOutlinerParent(HT_Pane thePane, HT_View theView); + CRDFOutlinerParent(HT_Pane thePane = NULL, HT_View theView = NULL); BOOL PreCreateWindow(CREATESTRUCT& cs); COutliner* GetOutliner(); void CreateColumns(); + void DestroyColumns() { columnMap.Clear(); } + BOOL RenderData( int iColumn, CRect & rect, CDC &dc, LPCTSTR text ); BOOL ColumnCommand( int iColumn ); void Initialize(); @@ -376,6 +418,8 @@ public: void LoadComplete(HT_Resource r) { Invalidate(); } + void SetHTView(HT_View newView) { ((CRDFOutliner*)GetOutliner())->SetHTView(newView); Invalidate(); GetOutliner()->Invalidate(); } + protected: afx_msg void OnDestroy(); afx_msg void OnPaint(); @@ -383,47 +427,56 @@ protected: }; -class CRDFContentView : public CContentView +class CRDFContentView : public CView { public: - COutlinerParent * m_pOutlinerParent; + CRDFOutlinerParent * m_pOutlinerParent; + CPaneCX* m_pHTMLView; + CNavTitleBar* m_pNavBar; // Construction public: - CRDFContentView(CRDFOutlinerParent* outlinerStuff) - { m_pOutlinerParent = outlinerStuff; }; + CRDFContentView(); + + ~CRDFContentView(); - ~CRDFContentView() - { - delete m_pOutlinerParent; - } + void OnDraw(CDC* pDC) {}; COutlinerParent* GetOutlinerParent() { return m_pOutlinerParent; } -// This functionality has been folded in from COutlinerView. I no longer derive from this class -// but instead come off of CContentView. +// This functionality has been folded in from COutlinerView. void CreateColumns ( ) { m_pOutlinerParent->CreateColumns ( ); } - void InvalidateOutlinerParent(); + void SwitchHTViews(HT_View htView); - static void DisplayRDFTree(CWnd* pParent, int width, int height, RDF_Resource rdfResource); - // This function can be called to create an embedded RDF tree view inside another window. - // Used to embed the tree in HTML. + CNavTitleBar* GetTitleBar() { return m_pNavBar; } + + static CRDFContentView* DisplayRDFTreeFromSHACK(CWnd* pParent, int xPos, int yPos, int width, + int height, char* url, int32 param_count, char** param_names, char** param_values); + // This function can be called to create an embedded RDF tree view using an + // external URL and specified targeting. + + static CRDFContentView* DisplayRDFTreeFromResource(CWnd* pParent, int xPos, int yPos, int width, + int height, HT_Resource node, CCreateContext* pContext = NULL); + // This function creates an embedded RDF tree view from an existing resource. + + static CRDFContentView* DisplayRDFTreeFromPane(CWnd* pParent, int xPos, int yPos, int width, + int height, HT_Pane pane, CCreateContext* pContext = NULL); + // This function creates an embedded RDF tree view once the pane has been constructed. protected: - virtual void OnDraw(CDC *pDC); - virtual BOOL PreCreateWindow(CREATESTRUCT& cs); DECLARE_DYNCREATE(CRDFContentView) - //{{AFX_MSG(CMainFrame) + //{{AFX_MSG(CRDFContentView) afx_msg LRESULT OnNavCenterQueryPosition(WPARAM wParam, LPARAM lParam); afx_msg int OnCreate ( LPCREATESTRUCT ); afx_msg void OnSize ( UINT, int, int ); afx_msg void OnSetFocus ( CWnd * pOldWnd ); + afx_msg void OnKillFocus (CWnd* pNewWnd); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; @@ -454,8 +507,4 @@ protected: DECLARE_MESSAGE_MAP() }; - -// Functions that will be used by the Personal Toolbar and Quickfile. Allow the -// display of arbitrary icons (or local file system icons) - #endif diff --git a/mozilla/cmd/winfe/res/mozilla.rc2 b/mozilla/cmd/winfe/res/mozilla.rc2 index a90f0145b23..877eb81d45d 100644 --- a/mozilla/cmd/winfe/res/mozilla.rc2 +++ b/mozilla/cmd/winfe/res/mozilla.rc2 @@ -379,7 +379,6 @@ BEGIN MENUITEM "Show &Navigation Toolbar", ID_VIEW_COMMANDTOOLBAR MENUITEM "Show &Location Toolbar", ID_VIEW_LOCATIONTOOLBAR MENUITEM "Show &Personal Toolbar", ID_VIEW_CUSTOMTOOLBAR - MENUITEM "Show Navi&gation Center", ID_VIEW_NAVCENTER MENUITEM SEPARATOR MENUITEM "In&crease Font\tCtrl+]", ID_VIEW_INCREASEFONT MENUITEM "&Decrease Font\tCtrl+[", ID_VIEW_DECREASEFONT @@ -783,7 +782,6 @@ BEGIN MENUITEM "Show &Navigation Toolbar", ID_VIEW_COMMANDTOOLBAR MENUITEM "Show &Location Toolbar", ID_VIEW_LOCATIONTOOLBAR MENUITEM "Show &Personal Toolbar", ID_VIEW_CUSTOMTOOLBAR - MENUITEM "Show Navi&gation Center", ID_VIEW_NAVCENTER MENUITEM SEPARATOR MENUITEM "In&crease Font\tCtrl+]" ID_VIEW_INCREASEFONT MENUITEM "&Decrease Font\tCtrl+[" ID_VIEW_DECREASEFONT diff --git a/mozilla/cmd/winfe/resource.h b/mozilla/cmd/winfe/resource.h index 7c969fc453f..ea1a19227a4 100755 --- a/mozilla/cmd/winfe/resource.h +++ b/mozilla/cmd/winfe/resource.h @@ -103,7 +103,6 @@ #define IDS_LDAP_SERVER_PROPERTY 125 #define IDI_MAIL 126 #define IDS_ADD_NEWS_SERVER 126 -#define IDC_URLTEXT 127 #define IDD_DIALOG1 127 #define IDR_MAINFRAME2 127 #define IDD_ADDRESS_USER 127 @@ -4073,9 +4072,6 @@ #define IDM_SAVEASTEMPLATE 65504 #define IDS_ADVSEARCH_TITLE 65505 #define IDS_BASICSEARCH_TITLE 65506 -#define ID_VIEW_NAVCENTER 65507 -#define IDS_SHOW_NAVCENTER 65508 -#define IDS_HIDE_NAVCENTER 65509 // Next default values for new objects // diff --git a/mozilla/cmd/winfe/statbar.cpp b/mozilla/cmd/winfe/statbar.cpp index 553f04cf2e6..fb92c227e83 100755 --- a/mozilla/cmd/winfe/statbar.cpp +++ b/mozilla/cmd/winfe/statbar.cpp @@ -1088,6 +1088,7 @@ CNetscapeStatusBar::CParentSubclass::CParentSubclass( CWnd *pParent, CNetscapeSt ASSERT( IsWindow( m_pParent->m_hWnd ) ); m_uTimerId = 0; + // // Subclass the parent window so we can process the WM_MENUSELECT msg i.e., so we // can switch modes from Simple/Panes without client intervention. diff --git a/mozilla/cmd/winfe/tlbutton.cpp b/mozilla/cmd/winfe/tlbutton.cpp index 4988d0bc15c..49bd0b08015 100644 --- a/mozilla/cmd/winfe/tlbutton.cpp +++ b/mozilla/cmd/winfe/tlbutton.cpp @@ -811,7 +811,7 @@ void CToolbarButton::OnLButtonDown(UINT nFlags, CPoint point) { m_hMenuTimer = SetTimer(IDT_MENU, MENU_DELAY_MS, NULL); } - + RedrawWindow(); } if(m_pToolTipText != NULL) @@ -822,7 +822,13 @@ void CToolbarButton::OnLButtonDown(UINT nFlags, CPoint point) // Do action immediately if this is set if( m_bDoOnButtonDown ) - OnAction(); + { + if (m_dwButtonStyle & TB_HAS_IMMEDIATE_MENU) + { + m_hMenuTimer = SetTimer(IDT_MENU, 0, NULL); + } + else OnAction(); + } else m_bButtonDown = TRUE; } @@ -890,28 +896,24 @@ void CToolbarButton::OnLButtonUp(UINT nFlags, CPoint point) { if(m_bEnabled) { - if (m_bHaveFocus) + // Do action only if not done on button down + if(!m_bDoOnButtonDown) + { + // Cursor is still over the button, so back to button up look + m_eState = eBUTTON_UP; + if(m_bButtonDown) + { + if (m_dwButtonStyle & TB_HAS_IMMEDIATE_MENU) + { + m_hMenuTimer = SetTimer(IDT_MENU, 0, NULL); + } + else OnAction(); + } + } + + if (m_dwButtonStyle & TB_HAS_IMMEDIATE_MENU) { - // Do action only if not done on button down - if(!m_bDoOnButtonDown) - { - // Cursor is still over the button, so back to button up look - m_eState = eBUTTON_UP; - if(m_bButtonDown) - { - if (m_dwButtonStyle & TB_HAS_IMMEDIATE_MENU) - { - m_hMenuTimer = SetTimer(IDT_MENU, 0, NULL); - } - else OnAction(); - } - } - } - else - { - // Restore borderless look - if(m_nChecked == 0) - m_eState = eNORMAL; + m_hMenuTimer = SetTimer(IDT_MENU, 0, NULL); } RedrawWindow(); @@ -1032,13 +1034,7 @@ void CToolbarButton::OnPaint() // Use the button face color as our background HBRUSH brFace = sysInfo.m_hbrBtnFace; - if (m_bDepressed) - { - // Use the button shadow color as our background instead. - brFace = ::CreateSolidBrush(sysInfo.m_clrBtnShadow); - ::SetBkColor(hMemDC, sysInfo.m_clrBtnShadow); - } - else if (hasCustomBGColor) + if (hasCustomBGColor) { // Use the button's custom background brFace = ::CreateSolidBrush(customBGColor); diff --git a/mozilla/cmd/winfe/tlbutton.h b/mozilla/cmd/winfe/tlbutton.h index ea2d0e29d5b..fb60e595185 100644 --- a/mozilla/cmd/winfe/tlbutton.h +++ b/mozilla/cmd/winfe/tlbutton.h @@ -215,6 +215,8 @@ public: const char *GetToolTipText(void) { return m_pToolTipText; } void SetToolTipText(LPCSTR pToolTipText); + void SetDepressed(BOOL b) { m_bDepressed = b; } + void SetStatusText(LPCSTR pStatusText); void SetBitmap(HBITMAP hBmpImg, BOOL bParentOwns); @@ -231,21 +233,25 @@ public: virtual CSize GetMaximalButtonSize(void); virtual CSize GetMinimalButtonSize(void); + CDropMenu* GetDropMenu() { return m_pDropMenu; } + BOOL AtMinimalSize(void); BOOL AtMaximalSize(void); virtual void CheckForMinimalSize(void); virtual void CheckForMaximalSize(void); + virtual void UpdateURLBar(char* url) {} + BOOL IsResourceID(void) { return m_bIsResourceID; } - UINT GetBitmapID(void) { return m_nBitmapID; } + virtual UINT GetBitmapID(void) { return m_nBitmapID; } UINT GetBitmapIndex(void) { return m_nBitmapIndex; } LPCTSTR GetBitmapFile(void) { return m_pBitmapFile; } CSize GetBitmapSize(void) { return m_bitmapSize; } int GetMaxTextCharacters(void) { return m_nMaxTextChars; } int GetMinTextCharacters(void) { return m_nMinTextChars; } - BOOL NeedsUpdate(void) { return m_bNeedsUpdate; } + virtual BOOL NeedsUpdate(void) { return m_bNeedsUpdate; } void Enable(BOOL bEnabled) { m_bEnabled = bEnabled; } BOOL IsEnabled(void) { return m_bEnabled; } diff --git a/mozilla/cmd/winfe/toolbar2.cpp b/mozilla/cmd/winfe/toolbar2.cpp index fc2e9395489..66787be7fdd 100644 --- a/mozilla/cmd/winfe/toolbar2.cpp +++ b/mozilla/cmd/winfe/toolbar2.cpp @@ -119,8 +119,12 @@ int CNSToolbar2::Create(CWnd *pParent) rect.SetRectEmpty(); CBrush brush; + DWORD shouldClipChildren = 0; + if (ShouldClipChildren()) + shouldClipChildren = WS_CLIPCHILDREN; + BOOL bResult = CWnd::Create( theApp.NSToolBarClass, NULL, - WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, + WS_CHILD | shouldClipChildren | WS_CLIPSIBLINGS, rect, pParent, 0, NULL); if(bResult) @@ -643,6 +647,14 @@ void CNSToolbar2::OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ) } } +void CNSToolbar2::UpdateURLBars(char* url) +{ + for(int i = 0; i < m_nNumButtons; i++) + { + m_pButtonArray[i]->UpdateURLBar(url); + } +} + BOOL CNSToolbar2::OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult ) { NMHDR *hdr = (NMHDR*)lParam; diff --git a/mozilla/cmd/winfe/toolbar2.h b/mozilla/cmd/winfe/toolbar2.h index 6fd4eae782f..00e4331ab31 100644 --- a/mozilla/cmd/winfe/toolbar2.h +++ b/mozilla/cmd/winfe/toolbar2.h @@ -98,6 +98,7 @@ public: CToolbarButton* RemoveButtonByCommand(UINT nCommand); void DecrementButtonCount() { m_nNumButtons--; } + virtual BOOL ShouldClipChildren() { return TRUE; } void HideButtonByCommand(UINT nCommand); void ShowButtonByCommand(UINT nCommand, int nPos); @@ -141,6 +142,7 @@ public: virtual BOOL OnNotify( WPARAM wParam, LPARAM lParam, LRESULT* pResult ); void OnUpdateCmdUI( CFrameWnd* pTarget, BOOL bDisableIfNoHndler ); + void UpdateURLBars(char* url); // Set a button to do its command on button down instead of button up BOOL SetDoOnButtonDownByCommand(UINT nCommand, BOOL bDoOnButtonDown); diff --git a/mozilla/cmd/winfe/tooltip.cpp b/mozilla/cmd/winfe/tooltip.cpp index 601af544195..585a7facdd0 100644 --- a/mozilla/cmd/winfe/tooltip.cpp +++ b/mozilla/cmd/winfe/tooltip.cpp @@ -27,6 +27,7 @@ CNSToolTip2::CNSToolTip2() { + hasCustomColors = FALSE; } @@ -68,6 +69,7 @@ LRESULT CNSToolTip2::WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) BEGIN_MESSAGE_MAP(CNSToolTip2, CToolTipCtrl) //{{AFX_MSG_MAP(CNSToolTip2) + ON_WM_CTLCOLOR_REFLECT() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -79,5 +81,15 @@ void CNSToolTip2::SetBounding(int *coord, int num, int x, int y) { } +HBRUSH CNSToolTip2::CtlColor ( CDC* pDC, UINT nCtlColor ) +{ + if (hasCustomColors) + { + pDC->SetTextColor( m_ForegroundColor ); // text + pDC->SetBkColor( m_BackgroundColor ); // text bkgnd + return m_BackgroundBrush; // ctl bkgnd + } + return NULL; +} #endif diff --git a/mozilla/cmd/winfe/tooltip.h b/mozilla/cmd/winfe/tooltip.h index 41d222ef296..3699c47b8d0 100644 --- a/mozilla/cmd/winfe/tooltip.h +++ b/mozilla/cmd/winfe/tooltip.h @@ -36,7 +36,12 @@ #else class CNSToolTip2 : public CToolTipCtrl { - +private: + COLORREF m_BackgroundColor; + COLORREF m_ForegroundColor; + CBrush m_BackgroundBrush; + BOOL hasCustomColors; + public: //Construction CNSToolTip2(); @@ -44,9 +49,14 @@ public: protected: virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam ); + void SetCustomColors(COLORREF fore, COLORREF back) + { m_BackgroundColor = back; m_ForegroundColor = fore; hasCustomColors = TRUE; + m_BackgroundBrush.CreateSolidBrush(m_BackgroundColor); + } // Generated message map functions //{{AFX_MSG(CNSToolTip2) + afx_msg HBRUSH CtlColor ( CDC* pDC, UINT nCtlColor ); //}}AFX_MSG DECLARE_MESSAGE_MAP() diff --git a/mozilla/cmd/winfe/urlbar.cpp b/mozilla/cmd/winfe/urlbar.cpp index 3c3cb5bcc70..da714b9daf3 100755 --- a/mozilla/cmd/winfe/urlbar.cpp +++ b/mozilla/cmd/winfe/urlbar.cpp @@ -48,6 +48,8 @@ static const int DRAG_ICON_HEIGHT = 15; static const int BOOKMARKS_TEXT_LEFT = 10; +static const int URLBAR_HEIGHT = 23; + BEGIN_MESSAGE_MAP(CURLBar, CURLBarBase) //{{AFX_MSG_MAP(CURLBar) ON_UPDATE_COMMAND_UI(ID_EDIT_COPY, OnUpdateEditCopy) @@ -121,72 +123,10 @@ void CURLBar::SetContext( LPUNKNOWN pUnk ) } } -LRESULT CURLBar::WindowProc( UINT message, WPARAM wParam, LPARAM lParam ) -{ - if ( ( message == WM_COMMAND ) && -#ifdef WIN32 - ( LOWORD( wParam ) == IDC_URL_EDIT ) ) - switch ( HIWORD ( wParam ) ) -#else - ( wParam == IDC_URL_EDIT ) ) - switch ( HIWORD ( lParam ) ) -#endif - { - case CBN_EDITCHANGE: - OnEditChange ( ); - break; - - case CBN_SELCHANGE: - OnSelChange ( ); - Invalidate(FALSE); - break; - - case CBN_CLOSEUP: - Invalidate(FALSE); - break; - - } - return CURLBarBase::WindowProc ( message, wParam, lParam ); -} - - -void CURLBar::OnLButtonDown(UINT nFlags, CPoint point) -{ - CDialogBar::OnLButtonDown(nFlags, point); - - int load = FALSE; - - if (!m_pIMWContext) - return; - - MapWindowPoints(GetParent(), &point, 1); - GetParent()->SendMessage(WM_LBUTTONDOWN, nFlags, MAKELPARAM(point.x, point.y)); - - -} - -HBRUSH CURLBar::OnCtlColor( CDC* pDC, CWnd* pWnd, UINT nCtlColor) -{ - return CURLBarBase::OnCtlColor(pDC, pWnd, nCtlColor); -} - void CURLBar::OnPaint() { - CURLBarBase::OnPaint ( ); - - CClientDC dc(this); - - CRect rcClient; - - GetClientRect(&rcClient); - - HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame()); - HPALETTE hOldPalette = ::SelectPalette(dc.m_hDC, hPalette, FALSE); - - // Use our background color - ::FillRect(dc.m_hDC, &rcClient, sysInfo.m_hbrBtnFace); - + CPaintDC dc(this); #ifdef _WIN32 if ( sysInfo.m_bWin4 ) m_pBox->SetFont( CFont::FromHandle ( (HFONT) GetStockObject (DEFAULT_GUI_FONT) ) ); @@ -199,54 +139,9 @@ void CURLBar::OnPaint() ASSERT(m_pFont != NULL); ::SendMessage(m_pBox->GetSafeHwnd(), WM_SETFONT, (WPARAM)m_pFont, FALSE); } - m_pBox->UpdateWindow ( ); - - if ( !sysInfo.m_bWin4 ) - { - // Draw 3D frame around URL box - - RECT rect; - m_pBox->GetWindowRect ( &rect ); - rect.right++; - rect.bottom++; - rect.left--; - rect.top--; - - ScreenToClient ( &rect ); - rect.right--; - rect.bottom--; - - RECT rcTmp = rect; - ::InflateRect( &rcTmp, -1, -1 ); - - WFE_DrawHighlight( dc.m_hDC, &rcTmp, - RGB(128, 128, 128), - RGB(0, 0, 0)); - WFE_DrawHighlight( dc.m_hDC, &rect, - RGB(192, 192, 192), - RGB(231, 231, 231) ); - } - - ::SelectPalette(dc.m_hDC, hOldPalette, TRUE); - + m_pBox->UpdateWindow(); } -void CURLBar::OnShowWindow( BOOL bShow, UINT nStatus ) -{ - m_bEraseBackground = bShow; -} - -BOOL CURLBar::OnEraseBkgnd( CDC* pDC ) -{ - if ( m_bEraseBackground ) { - m_bEraseBackground = FALSE; - return (BOOL) Default(); - } else { - return TRUE; - } -} - - #define TOTAL_SAVED_URLS 15 #define TOTAL_DISPLAYED_URLS 10 @@ -270,38 +165,13 @@ int CURLBar::OnCreate(LPCREATESTRUCT lpCreateStruct) m_pBox = new CEditWnd(this); m_pBox->Create( WS_CHILD|WS_VISIBLE|WS_TABSTOP, - rect, (CWnd *) m_pProxySurround, IDC_URL_EDIT); + rect, m_pProxySurround, IDC_URL_EDIT); } return(nRtn); } -void CURLBar::OnDestroy( ) -{ - CWnd::OnDestroy(); -} - - -void CURLBar::OnClose() -{ -} - -void CURLBar::OnPaletteChanged( CWnd* pFocusWnd ) -{ - if (pFocusWnd != this) { - HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame()); - if (WFE_IsGlobalPalette(hPalette)) { - HDC hDC = ::GetDC(m_hWnd); - HPALETTE hOldPalette = ::SelectPalette(hDC, hPalette, FALSE); - ::SelectPalette(hDC, hOldPalette, TRUE); - ::ReleaseDC(m_hWnd, hDC); - } - Invalidate(); - } -} - - CURLBar::~CURLBar() { @@ -321,31 +191,27 @@ CURLBar::~CURLBar() } -void CURLBar::DoDataExchange(CDataExchange* pDX) -{ - CURLBarBase::DoDataExchange(pDX); - //{{AFX_DATA_MAP(CURLBar) - //}}AFX_DATA_MAP -} ///////////////////////////////////////////////////////////////////////////// // CURLBar message handlers +void CURLBar::OnMouseMove(UINT nFlags, CPoint point) +{ + CURLBarBase::OnMouseMove(nFlags, point); + // Display previous status + wfe_Progress( m_pIMWContext->GetContext(), "" ); + + MapWindowPoints(GetParent(), &point, 1); + GetParent()->SendMessage(WM_MOUSEMOVE, nFlags, MAKELPARAM(point.x, point.y)); + +} + void CURLBar::OnSize(UINT nType, int cx, int cy) { - - int txtSpacing; - int boxSpacing; - CRect rcURLtext, rcIcon, bookmarkRect; - int x = BOOKMARKS_TEXT_LEFT; - - CWnd *pText = GetDlgItem( IDC_URLTEXT ); - - if (pText) { - pText->GetWindowRect(&rcURLtext); - // figure out how big we need to make the box - CDC * pDC = m_pBox->GetDC(); - + int boxSpacing; + if( m_pBox ) + { + CDC * pDC = m_pBox->GetDC(); TEXTMETRIC tm; // creates font for multibyte system running on WinNT and Win16 @@ -378,45 +244,22 @@ void CURLBar::OnSize(UINT nType, int cx, int cy) if(m_nBoxHeight > (cy - 2)) m_nBoxHeight = cy - 2; m_pBox->ReleaseDC(pDC); - } - - CURLBarBase::OnSize(nType, cx, cy); - - if( pText && m_pBox ) - { - // position the "Location" text - txtSpacing = (cy - rcURLtext.Height()) / 2 ; - - pText->MoveWindow(x, - txtSpacing, rcURLtext.Width(), rcURLtext.Height()); - - x += rcURLtext.Width() + 3; - - m_DragIconX = x; + + m_DragIconX = 1; // Position the proxy surround wnd + m_pProxySurround->MoveWindow(0, 0, cx, cy); - m_pProxySurround->MoveWindow(x-1, 1, ( cx - x - - ( GetSystemMetrics(SM_CXBORDER) * 2)),cy-2); - boxSpacing = (cy - m_nBoxHeight) / 2 ; - m_DragIconY = boxSpacing + (m_nBoxHeight - DRAG_ICON_HEIGHT)/2; + m_DragIconY = (cy - DRAG_ICON_HEIGHT)/2; - m_pPageProxy->MoveWindow(1, m_DragIconY-1, DRAG_ICON_WIDTH, DRAG_ICON_HEIGHT); + m_pPageProxy->MoveWindow(m_DragIconX, m_DragIconY, DRAG_ICON_WIDTH, DRAG_ICON_HEIGHT); - x += DRAG_ICON_WIDTH + 2; - // position the location edit box m_pBox->MoveWindow( DRAG_ICON_WIDTH+3, - (cy - m_nBoxHeight) / 2 -1, - ( cx - x - - ( GetSystemMetrics(SM_CXBORDER) * 2)) , - m_nBoxHeight); + boxSpacing, cx - DRAG_ICON_WIDTH - 5, m_nBoxHeight); + } - - m_DragIconY = boxSpacing + (m_nBoxHeight - DRAG_ICON_HEIGHT)/2 + 1; - - } ////////////////////////////////////////////////////////////////////////////// @@ -446,9 +289,6 @@ void CURLBar::ProcessEnterKey() id = 0; } -#ifdef MOZ_NGLAYOUT - XP_ASSERT(0); -#else if (HK_CallHook(HK_LOCATION, NULL, id, text, &new_text)) { // Nothing, new_text is already set. @@ -457,7 +297,6 @@ void CURLBar::ProcessEnterKey() { new_text = NULL; } -#endif /* MOZ_NGLAYOUT */ } if (new_text) @@ -481,14 +320,8 @@ void CURLBar::ProcessEnterKey() // need to because of the location / netsite history void CURLBar::UpdateFields( const char * msg ) { - CWnd *pText = GetDlgItem( IDC_URLTEXT ); - -#ifdef MOZ_NGLAYOUT - XP_ASSERT(0); -#else // strip random backend crap out of the url msg = LM_StripWysiwygURLPrefix(msg); -#endif /* MOZ_NGLAYOUT */ CString cs(msg); m_pBox->SetWindowText(cs); @@ -497,13 +330,13 @@ void CURLBar::UpdateFields( const char * msg ) m_pBox->Clear(); // If this was a netsite server change the string - History_entry* pEntry = SHIST_GetCurrent(&m_pIMWContext->GetContext()->hist); +/* History_entry* pEntry = SHIST_GetCurrent(&m_pIMWContext->GetContext()->hist); if (pEntry && pEntry->is_netsite) pText->SetWindowText(szLoadString(IDS_NETSITE)); else pText->SetWindowText(szLoadString(IDS_LOCATION)); - +*/ m_nTextStatus = TRUE; } @@ -578,38 +411,13 @@ void CURLBar::OnSelChange() // "Go to:" rather than "Location:" void CURLBar::OnEditChange() { - CWnd *pText = GetDlgItem( IDC_URLTEXT ); - +/* TODO: if( pText && m_nTextStatus ) { pText->SetWindowText(szLoadString(IDS_GOTO)); m_nTextStatus = FALSE; } -} - -void CURLBar::OnMouseMove(UINT nFlags, CPoint point) -{ - CURLBarBase::OnMouseMove(nFlags, point); - // Display previous status - wfe_Progress( m_pIMWContext->GetContext(), "" ); - - MapWindowPoints(GetParent(), &point, 1); - GetParent()->SendMessage(WM_MOUSEMOVE, nFlags, MAKELPARAM(point.x, point.y)); - -} - -void CURLBar::OnLButtonDblClk(UINT nFlags, CPoint point) -{ - CURLBarBase::OnLButtonDblClk(nFlags, point); - -} - - -void CURLBar::OnLButtonUp(UINT nFlags, CPoint point) -{ - MapWindowPoints(GetParent(), &point, 1); - GetParent()->SendMessage(WM_LBUTTONUP, nFlags, MAKELPARAM(point.x, point.y)); - +*/ } CEditWnd::~CEditWnd() @@ -618,13 +426,11 @@ CEditWnd::~CEditWnd() KillTimer(m_idTimer); if (m_pComplete) free(m_pComplete); - delete m_ToolTip; } BEGIN_MESSAGE_MAP(CEditWnd,CGenericEdit) ON_WM_TIMER() - ON_WM_MOUSEMOVE() END_MESSAGE_MAP() @@ -692,7 +498,6 @@ BOOL CEditWnd::PreTranslateMessage ( MSG * msg ) const char *c_url = (const char *)url; url_str = (char *)c_url; -#ifndef MOZ_NGLAYOUT if (HK_CallHook(HK_LOCATION, NULL, id, url_str, &new_url)) { // Nothing, new_url is already set. @@ -701,7 +506,6 @@ BOOL CEditWnd::PreTranslateMessage ( MSG * msg ) { new_url = NULL; } -#endif /* MOZ_NGLAYOUT */ } if (new_url) @@ -911,7 +715,6 @@ void CEditWnd::OnMouseMove(UINT nFlags, CPoint point) } } - // CProxySurroundWnd BEGIN_MESSAGE_MAP(CProxySurroundWnd, CWnd) @@ -1240,3 +1043,145 @@ void CPageProxyWindow::OnTimer( UINT nIDEvent ) } + +// ============================================== +// The URLBar Button class. +// ============================================== + +BEGIN_MESSAGE_MAP(CURLBarButton, CRDFToolbarButton) + //{{AFX_MSG_MAP(CURLBarButton) + ON_WM_SIZE() +//}}AFX_MSG_MAP +END_MESSAGE_MAP() + +// The Nav Center vocab element +extern "C" RDF_NCVocab gNavCenter; + +CSize CURLBarButton::GetButtonSizeFromChars(CString s, int c) +{ + // Get our width + void* data; + BOOL percent = FALSE; + int width = 100; + + if (m_Node == NULL) + return CSize(0,0); + + m_bIsSpring = FALSE; + HT_GetNodeData(m_Node, gNavCenter->urlBarWidth, HT_COLUMN_STRING, &data); + if (data) + { + CString strData((char*)data); + int length = strData.GetLength(); + if (strData[length-1] == '%') + { + percent = TRUE; + strData = strData.Left(length-1); + } + else if (strData[0] == '*') + { + m_bIsSpring = TRUE; + strData = "0"; + } + else + percent = FALSE; + + width = atoi(strData); + } + + if (foundOnRDFToolbar()) + { + CRDFToolbar* pToolbar = (CRDFToolbar*)GetParent(); + int rowWidth = pToolbar->GetRowWidth(); + if (percent) + return CSize((width/100.0) * rowWidth, URLBAR_HEIGHT); + else return CSize(width, URLBAR_HEIGHT); + } + + return CSize(0,0); // Must be on an RDF toolbar to make any sense at all. +} + +void CURLBarButton::DrawButtonBitmap(HDC hDC, CRect rcImg) +{ +} // Do nothing. + +void CURLBarButton::DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt) +{ + CRect rect; + GetClientRect(&rect); + CRect textRect(rect); + + ::DrawText(hDC, strTxt, -1, &textRect, DT_CENTER | DT_EXTERNALLEADING | DT_CALCRECT); + + rect.right = textRect.right; + rect.left += 6; + rect.right += 6; + + CRDFToolbarButton::DrawButtonText(hDC, rect, CSize(textRect.Width(), textRect.Height()), strTxt); + +} + +int CURLBarButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize, + LPCTSTR pButtonText, LPCTSTR pToolTipText, + LPCTSTR pStatusText, + CSize bitmapSize, int nMaxTextChars, int nMinTextChars, BOOKMARKITEM bookmark, + HT_Resource pNode, DWORD dwButtonStyle) +{ + + int result = CRDFToolbarButton::Create(pParent, nToolbarStyle, noviceButtonSize, advancedButtonSize, + pButtonText, pToolTipText, pStatusText, bitmapSize, nMaxTextChars, nMinTextChars, + bookmark, pNode, dwButtonStyle); + if (result) + { + // Button successfully created. Build the URL bar. + m_pURLBar=new CURLBar(); + m_pURLBar->Create( NULL, NULL, + WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE, + CRect(0,0,10,10), this, CURLBar::IDD); + + CWnd* pWnd = GetTopLevelFrame(); + if (pWnd->IsKindOf(RUNTIME_CLASS(CMainFrame))) + { + CMainFrame* pMain = (CMainFrame*)pWnd; + m_pURLBar->SetContext((LPUNKNOWN)pMain->GetMainContext()); + } + } + + return result; +} + +void CURLBarButton::OnSize(UINT nType, int x, int y) +{ + m_bitmapSize.cx = m_bitmapSize.cy = 0; + if (m_pURLBar) + { + CRect rect; + GetClientRect(&rect); + + CRect textRect(rect); + + CDC* pDC = GetDC(); + char* text = HT_GetNodeName(m_Node); + pDC->DrawText(text, -1, &textRect, DT_CENTER | DT_EXTERNALLEADING | DT_CALCRECT); + ReleaseDC(pDC); + + int startY = (rect.Height() - URLBAR_HEIGHT)/2; + m_pURLBar->MoveWindow(textRect.right, startY, rect.Width() - textRect.Width() - 3, + URLBAR_HEIGHT); + } +} + +void CURLBarButton::UpdateURLBar(char* url) +{ + if (m_pURLBar) + m_pURLBar->UpdateFields(url); +} + +CURLBarButton::CURLBarButton() +:m_pURLBar(NULL), m_bIsSpring(FALSE) +{} + +CURLBarButton::~CURLBarButton() +{ + delete m_pURLBar; +} diff --git a/mozilla/cmd/winfe/urlbar.h b/mozilla/cmd/winfe/urlbar.h index 2a213899578..7234b1c2e77 100755 --- a/mozilla/cmd/winfe/urlbar.h +++ b/mozilla/cmd/winfe/urlbar.h @@ -20,6 +20,7 @@ // CURLBar dialog #include "toolbar2.h" +#include "usertlbr.h" #include "dropmenu.h" #ifndef URLBAR_H @@ -32,19 +33,19 @@ protected: BOOL m_bRestart; char * m_pComplete; BOOL m_Scroll; - CWnd* m_pBar; - CNSToolTip2 *m_ToolTip; + CWnd* m_pBar; + CNSToolTip2 *m_ToolTip; public: - CEditWnd(CWnd* bar) { m_pBar = bar; m_ToolTip = 0; m_idTimer = 0; m_bRestart = TRUE; m_pComplete = NULL; m_Scroll = FALSE; } + CEditWnd(CWnd* bar) { m_pBar = bar; m_idTimer = 0; m_bRestart = TRUE; m_pComplete = NULL; m_Scroll = FALSE; } ~CEditWnd(); void UrlCompletion(void); void DrawCompletion(CString & cs, char * pszResult); - void SetToolTip(const char *inTipStr); + void SetToolTip(const char *inTipStr); virtual BOOL PreTranslateMessage ( MSG * msg ); virtual LRESULT DefWindowProc( UINT message, WPARAM wParam, LPARAM lParam ); - virtual afx_msg void OnTimer( UINT nIDEvent ); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); + virtual afx_msg void OnTimer( UINT nIDEvent ); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); DECLARE_MESSAGE_MAP(); }; @@ -100,7 +101,7 @@ public: DECLARE_MESSAGE_MAP() }; -#define CURLBarBase CDialogBar +#define CURLBarBase CWnd class CURLBar : public CURLBarBase { @@ -144,16 +145,12 @@ public: LPMWCONTEXT GetContext() const { return m_pIMWContext; } void UpdateFields( const char * msg); - void SetToolTip(const char * inTip); + void SetToolTip(const char * inTip); // Implementation protected: void ProcessEnterKey(); - // Overrides - virtual LRESULT WindowProc( UINT message, WPARAM wParam, LPARAM lParam ); - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - protected: // Generated message map functions //{{AFX_MSG(CURLBar) @@ -169,20 +166,43 @@ protected: afx_msg void OnUpdateEditUndo(CCmdUI* pCmdUI); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); - afx_msg void OnClose(); - afx_msg void OnDestroy( ); afx_msg void OnPaint(); - afx_msg void OnShowWindow( BOOL bShow, UINT nStatus ); - afx_msg BOOL OnEraseBkgnd( CDC* pDC ); afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); - afx_msg void OnLButtonUp(UINT nFlags, CPoint point); - afx_msg HBRUSH OnCtlColor( CDC*, CWnd*, UINT ); - afx_msg void OnPaletteChanged( CWnd* pFocusWnd ); - + //}}AFX_MSG DECLARE_MESSAGE_MAP() }; +class CURLBarButton : public CRDFToolbarButton +{ +protected: + CURLBar* m_pURLBar; // A pointer to the URL bar object. + BOOL m_bIsSpring; // Whether or not the url bar wants to expand to consume as much space as it can. +public: + CURLBarButton(); + ~CURLBarButton(); + + virtual CSize GetButtonSizeFromChars(CString s, int c); + // Overridden to handle special width/height requirements. + + virtual void DrawButtonBitmap(HDC hDC, CRect rcImg); + virtual void DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt); + + virtual void UpdateURLBar(char* url); + + virtual BOOL IsSpring() { return m_bIsSpring; } + + int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize, + LPCTSTR pButtonText, LPCTSTR pToolTipText, + LPCTSTR pStatusText, + CSize bitmapSize, int nMaxTextChars, int nMinTextChars, BOOKMARKITEM bookmark, + HT_Resource pNode, DWORD dwButtonStyle = 0); + + // Generated message map functions + //{{AFX_MSG(CToolbarButton) + afx_msg void OnSize(UINT nType, int x, int y); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; + #endif // URLBAR_H diff --git a/mozilla/cmd/winfe/usertlbr.cpp b/mozilla/cmd/winfe/usertlbr.cpp index 6cdde649275..e1656ae02ce 100644 --- a/mozilla/cmd/winfe/usertlbr.cpp +++ b/mozilla/cmd/winfe/usertlbr.cpp @@ -22,11 +22,23 @@ #include "dropmenu.h" #include "prefapi.h" #include "rdfliner.h" +#include "urlbar.h" extern "C" { #include "xpgetstr.h" }; +// The Nav Center vocab element +extern "C" RDF_NCVocab gNavCenter; + +#define TEXT_CHARACTERS_SHOWN 9 +#define BORDERSIZE 2 +#define TEXTVERTMARGIN 1 +#define TEXTONLYVERTMARGIN 2 +#define BITMAPVERTMARGIN 2 +#define TEXT_BITMAPVERTMARGIN 1 +#define HORIZMARGINSIZE 4 + #define LEFT_TOOLBAR_MARGIN 10 #define RIGHT_TOOLBAR_MARGIN 20 #define SPACE_BETWEEN_BUTTONS 2 @@ -87,6 +99,8 @@ CRDFToolbarButton::CRDFToolbarButton() m_uCurBMID = 0; currentRow = 0; + + m_pTreeView = NULL; } @@ -133,11 +147,8 @@ int CRDFToolbarButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButt CSize bitmapSize, int nMaxTextChars, int nMinTextChars, BOOKMARKITEM bookmark, HT_Resource pNode, DWORD dwButtonStyle ) { - m_bookmark = bookmark; - char *protocol = NULL; - BOOL bResult = CToolbarButton::Create(pParent, nToolbarStyle, noviceButtonSize, advancedButtonSize, pButtonText, pToolTipText, pStatusText, 0, 0, bitmapSize, TRUE, 0, nMaxTextChars, nMinTextChars, dwButtonStyle); @@ -145,20 +156,7 @@ int CRDFToolbarButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButt if(bResult) { SetNode(pNode); - m_nIconType = DetermineIconType(pNode, UseLargeIcons()); - - m_nBitmapID = GetBitmapID(); - m_nBitmapIndex = GetBitmapIndex(); - - HDC hDC = ::GetDC(m_hWnd); - - HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame()); - HBITMAP hBitmap = WFE_LookupLoadAndEnterBitmap(hDC, m_nBitmapID, TRUE, hPalette, - sysInfo.m_clrBtnFace, RGB(255, 0, 255)); - ::ReleaseDC(m_hWnd, hDC); - - SetBitmap(hBitmap, TRUE); - + UpdateIconInfo(); if (m_menu.m_hMenu == NULL || (m_menu.m_hMenu != NULL && !IsMenu(m_menu.m_hMenu))) m_menu.CreatePopupMenu(); } @@ -166,6 +164,27 @@ int CRDFToolbarButton::Create(CWnd *pParent, int nToolbarStyle, CSize noviceButt return bResult; } +void CRDFToolbarButton::UpdateIconInfo() +{ + m_nIconType = DetermineIconType(m_Node, UseLargeIcons()); + UINT oldBitmapID = m_nBitmapID; + m_nBitmapID = GetBitmapID(); + if (m_nBitmapID != oldBitmapID) + { + HDC hDC = ::GetDC(m_hWnd); + HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame()); + HBITMAP hBitmap = WFE_LookupLoadAndEnterBitmap(hDC, m_nBitmapID, TRUE, hPalette, + sysInfo.m_clrBtnFace, RGB(255, 0, 255)); + ::ReleaseDC(m_hWnd, hDC); + SetBitmap(hBitmap, TRUE); + if (m_nBitmapID == IDB_PICTURES) + SetBitmapSize(CSize(23,21)); // Command buttons + else SetBitmapSize(CSize(23,17)); // Personal toolbar buttons + } + + m_nBitmapIndex = GetBitmapIndex(); +} + CSize CRDFToolbarButton::GetMinimalButtonSize(void) { CString szText(HT_GetNodeName(m_Node)); @@ -180,8 +199,17 @@ CSize CRDFToolbarButton::GetMaximalButtonSize(void) void CRDFToolbarButton::OnAction(void) { - if(m_Node && !HT_IsContainer(m_Node)) + if(m_Node) { + char* url = HT_GetNodeURL(m_Node); + if (strncmp(url, "command:", 8) == 0) + { + // We're a command, baby. Look up our FE command and execute it. + UINT nCommand = theApp.m_pBrowserCommandMap->GetFEResource(url); + WFE_GetOwnerFrame(this)->PostMessage(WM_COMMAND, MAKEWPARAM(nCommand, nCommand), 0); + } + else if (!HT_IsContainer(m_Node)) + { CAbstractCX * pCX = FEU_GetLastActiveFrameContext(); ASSERT(pCX != NULL); if (pCX != NULL) @@ -189,6 +217,7 @@ void CRDFToolbarButton::OnAction(void) if (!HT_Launch(m_Node, pCX->GetContext())) pCX->NormalGetUrl((LPTSTR)HT_GetNodeURL(m_Node)); } + } } } @@ -199,6 +228,8 @@ void CRDFToolbarButton::FillInOleDataSource(COleDataSource *pDataSource) pDataSource->CacheGlobalData(cfHTNode, hString); // Need to "select" the button in the view. Hack. + HT_View theView = HT_GetView(m_Node); + HT_SetSelectedView(HT_GetPane(theView), theView); // Make sure this view is selected in the pane. HT_SetSelection(m_Node); // Now the view is sufficient @@ -266,40 +297,148 @@ void CRDFToolbarButton::EditTextChanged(char *pText) delete []pText; } RemoveTextEdit(); - - ((CRDFToolbar*)GetParent())->LayoutButtons(-1); + + if (foundOnRDFToolbar()) + ((CRDFToolbar*)GetParent())->LayoutButtons(-1); } void CRDFToolbarButton::DrawPicturesAndTextMode(HDC hDC, CRect rect) { - DrawBitmapOnSide(hDC, rect); + if (foundOnRDFToolbar()) + { + CRDFToolbar* theToolbar = (CRDFToolbar*)GetParent(); + void* data; + HT_GetNodeData(HT_TopNode(theToolbar->GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + { + DrawBitmapOnTop(hDC, rect); + return; + } + } + } + + DrawBitmapOnSide(hDC, rect); } void CRDFToolbarButton::DrawPicturesMode(HDC hDC, CRect rect) { + if (foundOnRDFToolbar()) + { + CRDFToolbar* theToolbar = (CRDFToolbar*)GetParent(); + void* data; + HT_GetNodeData(HT_TopNode(theToolbar->GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + { + DrawBitmapOnTop(hDC, rect); + return; + } + } + } + DrawBitmapOnSide(hDC, rect); } void CRDFToolbarButton::DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt) { + if (foundOnRDFToolbar()) + { + hasCustomTextColor = TRUE; + switch (m_eState) + { + case eDISABLED: + customTextColor = ((CRDFToolbar*)GetParent())->GetDisabledColor(); + if (customTextColor == -1) + { + hasCustomTextColor = FALSE; + } + break; + case eBUTTON_UP: + customTextColor = ((CRDFToolbar*)GetParent())->GetRolloverColor(); + break; + case eBUTTON_DOWN: + customTextColor = ((CRDFToolbar*)GetParent())->GetPressedColor(); + break; + case eNORMAL: + customTextColor = ((CRDFToolbar*)GetParent())->GetForegroundColor(); + break; + } + + if (m_bDepressed) + customTextColor = ((CRDFToolbar*)GetParent())->GetPressedColor(); + } + CToolbarButton::DrawButtonText(hDC, rcTxt, sizeTxt, strTxt); } CSize CRDFToolbarButton::GetButtonSizeFromChars(CString s, int c) { if(m_nToolbarStyle != TB_TEXT) + { + if (foundOnRDFToolbar()) + { + CRDFToolbar* theToolbar = (CRDFToolbar*)GetParent(); + void* data; + HT_GetNodeData(HT_TopNode(theToolbar->GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + { + return GetBitmapOnTopSize(s, c); + } + } + } return(GetBitmapOnSideSize(s, c)); + } else return(GetTextOnlySize(s, c)); } void CRDFToolbarButton::GetPicturesAndTextModeTextRect(CRect &rect) { + if (foundOnRDFToolbar()) + { + CRDFToolbar* theToolbar = (CRDFToolbar*)GetParent(); + void* data; + HT_GetNodeData(HT_TopNode(theToolbar->GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + { + GetBitmapOnTopTextRect(rect); + return; + } + } + } + GetBitmapOnSideTextRect(rect); } void CRDFToolbarButton::GetPicturesModeTextRect(CRect &rect) { + if (foundOnRDFToolbar()) + { + CRDFToolbar* theToolbar = (CRDFToolbar*)GetParent(); + void* data; + HT_GetNodeData(HT_TopNode(theToolbar->GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + { + GetBitmapOnTopTextRect(rect); + return; + } + } + } + GetBitmapOnSideTextRect(rect); } @@ -309,8 +448,10 @@ BOOL CRDFToolbarButton::CreateRightMouseMenu(void) if (m_bShouldShowRMMenu) { m_MenuCommandMap.Clear(); - HT_SetSelection(m_Node); // Make sure the node is the selection in the view. HT_View theView = HT_GetView(m_Node); + HT_SetSelectedView(HT_GetPane(theView), theView); // Make sure this view is selected in the pane. + HT_SetSelection(m_Node); // Make sure the node is the selection in the view. + HT_Cursor theCursor = HT_NewContextualMenuCursor(theView, PR_FALSE, PR_FALSE); if (theCursor != NULL) { @@ -413,10 +554,159 @@ BEGIN_MESSAGE_MAP(CRDFToolbarButton, CRDFToolbarButtonBase) ON_MESSAGE(DT_DRAGGINGOCCURRED, OnDropMenuDraggingOccurred) ON_MESSAGE(DM_MENUCLOSED, OnDropMenuClosed) ON_WM_SYSCOLORCHANGE() - //}}AFX_MSG_MAP + ON_WM_PAINT() + ON_WM_MOUSEACTIVATE() + //}}AFX_MSG_MAP END_MESSAGE_MAP() + +int CRDFToolbarButton::OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message ) +{ + m_bButtonDown = TRUE; + return MA_ACTIVATE; +} + + +void CRDFToolbarButton::OnPaint() +{ + CRect updateRect; + + GetUpdateRect(&updateRect); + + CPaintDC dcPaint(this); // device context for painting + CRect rcClient; + GetClientRect(&rcClient); + + HDC hSrcDC = dcPaint.m_hDC; + + HPALETTE hPalette; + HPALETTE hOldPalette; + CFrameWnd* pParent = WFE_GetOwnerFrame(this); + hPalette = WFE_GetUIPalette(pParent); + hOldPalette= ::SelectPalette(hSrcDC, hPalette, FALSE); + HDC hMemDC = ::CreateCompatibleDC(hSrcDC); + + if(hMemDC) + { + HPALETTE hOldMemPalette = ::SelectPalette(hMemDC, hPalette, FALSE); + + HBITMAP hbmMem = CreateCompatibleBitmap(hSrcDC, + rcClient.Width(), + rcClient.Height()); + + // + // Select the bitmap into the off-screen DC. + // + HBITMAP hbmOld = (HBITMAP)::SelectObject(hMemDC, hbmMem); + + // if we are not enabled then must make sure that button state is normal + if(!m_bEnabled) + { + m_eState = eNORMAL; + } + + CRect innerRect = rcClient; + + innerRect.InflateRect(-BORDERSIZE, -BORDERSIZE); + + int oldMode = ::SetBkMode(hMemDC, TRANSPARENT); + if (foundOnRDFToolbar()) + { + CRDFToolbar* pToolbar = (CRDFToolbar*)GetParent(); + if (pToolbar->GetBackgroundImage() == NULL || + (pToolbar->GetBackgroundImage() != NULL && + !pToolbar->GetBackgroundImage()->FrameSuccessfullyLoaded())) + { + // Fill with our background color. + HBRUSH hRegBrush = (HBRUSH) ::CreateSolidBrush(pToolbar->GetBackgroundColor()); + ::FillRect(hMemDC, rcClient, hRegBrush); + } + else + { + // There is a background. Let's do a tile on the rect corresponding to our position + // in the parent toolbar. + CWnd* pGrandParent = pToolbar->GetParent(); + CRect offsetRect(rcClient); + MapWindowPoints(pGrandParent, &offsetRect); + + // Now we want to fill the given rectangle. + PaintBackground(hMemDC, rcClient, pToolbar->GetBackgroundImage(), offsetRect.left, offsetRect.top); + } + } + else + { + ::FillRect(hMemDC, rcClient, sysInfo.m_hbrBtnFace); + } + + if(m_nToolbarStyle == TB_PICTURESANDTEXT) + { + DrawPicturesAndTextMode(hMemDC, innerRect); + } + else if(m_nToolbarStyle == TB_PICTURES) + { + DrawPicturesMode(hMemDC, innerRect); + } + else + { + DrawTextMode(hMemDC, innerRect); + } + + // Now, draw 3d visual button effects, depending on our state + switch (m_eState) + { + case eBUTTON_UP: + { + if( m_nChecked == 0 ) + DrawUpButton(hMemDC, rcClient); + else + DrawDownButton(hMemDC, rcClient); + } + break; + + case eBUTTON_CHECKED: + { + // A checked button but NOT mousing over - no black border + DrawCheckedButton(hMemDC, rcClient); + } + break; + + case eBUTTON_DOWN: + { + DrawDownButton(hMemDC, rcClient); + } + break; + + case eDISABLED: + { + if(m_nChecked == 2) + DrawCheckedButton(hMemDC, rcClient); + + } + break; + + case eNORMAL: + { + if (m_bDepressed) + DrawDownButton(hMemDC, rcClient); // Looks like it's locked down. + } + } + + ::SetBkMode(hMemDC, oldMode); + + ::BitBlt(hSrcDC, 0, 0, rcClient.Width(), rcClient.Height(), hMemDC, 0, 0, + SRCCOPY); + + ::SelectPalette(hMemDC, hOldMemPalette, FALSE); + ::SelectPalette(hSrcDC, hOldPalette, FALSE); + + ::SelectObject(hMemDC, hbmOld); + ::DeleteObject(hbmMem); + + ::DeleteDC(hMemDC); + } +} + LRESULT CRDFToolbarButton::OnDragMenuOpen(WPARAM wParam, LPARAM lParam) { // Set our drop menu's user data. @@ -453,7 +743,7 @@ LRESULT CRDFToolbarButton::OnFillInMenu(WPARAM wParam, LPARAM lParam) if (isOpen) FillInMenu(theNode); else HT_SetOpenState(theNode, (PRBool)TRUE); - + return 1; } @@ -585,6 +875,33 @@ void CRDFToolbarButton::OnSysColorChange( ) void CRDFToolbarButton::FillInMenu(HT_Resource theNode) { + // Determine our position +/* CWnd* frame = GetTopLevelFrame(); + CPoint point(0, GetRequiredButtonSize().cy); + MapWindowPoints(frame, &point, 1); +*/ + + if (!m_bDepressed) + { + CPoint point = RequestMenuPlacement(); + m_pTreeView = CNSNavFrame::CreateFramedRDFViewFromResource(NULL, point.x, point.y, 300, 500, m_Node); + SetDepressed(TRUE); + m_pTreeView->SetRDFButton(this); + CRDFToolbarHolder* pHolder = (CRDFToolbarHolder*)(GetParent()->GetParent()->GetParent()); + if (pHolder->GetCurrentButton() != NULL) + { + pHolder->GetCurrentButton()->GetTreeView()->DeleteNavCenter(); + pHolder->SetCurrentButton(this); + } + } + else + { + // Delete NavCenter. + m_pTreeView->DeleteNavCenter(); + m_pTreeView = NULL; + } + + /* m_pCachedDropMenu->CreateOverflowMenuItem(ID_HOTLIST_VIEW, CString(szLoadString(IDS_MORE_BOOKMARKS)), NULL, NULL ); HT_Cursor theCursor = HT_NewCursor(theNode); @@ -629,20 +946,36 @@ void CRDFToolbarButton::FillInMenu(HT_Resource theNode) HT_DeleteCursor(theCursor); m_pCachedDropMenu = NULL; + */ } UINT CRDFToolbarButton::GetBitmapID(void) { - if (m_nBitmapID != 0) - return m_nBitmapID; + if (m_Node) + { + if (strncmp(HT_GetNodeURL(m_Node), "command:", 8) == 0) + { + // We're an internal command. + return IDB_PICTURES; + } + else if (HT_IsContainer(m_Node)) + return IDB_BUTTON_FOLDER; + else return IDB_USERBTN; + } - if (m_Node && HT_IsContainer(m_Node)) - return IDB_BUTTON_FOLDER; - else return IDB_USERBTN; + return IDB_USERBTN; } UINT CRDFToolbarButton::GetBitmapIndex(void) { + if (m_Node) + { + if (strncmp(HT_GetNodeURL(m_Node), "command:", 8) == 0) + { + // We're an internal command. Access the command bitmap strip. + return theApp.m_pCommandToolbarIndices->GetFEResource(HT_GetNodeURL(m_Node)); + } + } return 0; } @@ -657,6 +990,18 @@ void CRDFToolbarButton::SetTextWithoutResize(CString text) XP_STRCPY(m_pButtonText, text); } +BOOL CRDFToolbarButton::NeedsUpdate() +{ + // Only internal commands need updating via the OnUpdateCmdUI handler. + // All other buttons are enabled/disabled using the appropriate HT calls. + if (m_Node && strncmp(HT_GetNodeURL(m_Node), "command:", 8) == 0) + { + m_nCommand = theApp.m_pBrowserCommandMap->GetFEResource(HT_GetNodeURL(m_Node)); + return TRUE; + } + return FALSE; +} + void CRDFToolbarButton::LoadComplete(HT_Resource r) { Invalidate(); @@ -664,10 +1009,42 @@ void CRDFToolbarButton::LoadComplete(HT_Resource r) void CRDFToolbarButton::DrawCustomIcon(HDC hDC, int x, int y) { - int size = UseLargeIcons() ? 23 : 16; - DrawArbitraryURL(m_Node, x, y, size, size, hDC, - m_bDepressed ? (::GetSysColor(COLOR_BTNSHADOW)) : (::GetSysColor(COLOR_BTNFACE)), + if (foundOnRDFToolbar()) + { + CRDFToolbar* pToolbar = (CRDFToolbar*)GetParent(); + + CRDFImage* pCustomImage = DrawArbitraryURL(m_Node, x, y, m_bitmapSize.cx, m_bitmapSize.cy, hDC, + pToolbar->GetBackgroundColor(), this, UseLargeIcons()); + + if (!pCustomImage->FrameSuccessfullyLoaded()) + return; + + // Adjust the toolbar button's width and height. + long width = pCustomImage->bmpInfo->bmiHeader.biWidth; + long height = pCustomImage->bmpInfo->bmiHeader.biHeight; + + if (width > m_bitmapSize.cx || height > m_bitmapSize.cy) + { + SetBitmapSize(CSize(width, height)); + + CSize buttonSize = GetMinimalButtonSize(); // Only care about height. + + // Grow the toolbar if necessary. + if (buttonSize.cy > pToolbar->GetRowHeight()) + { + pToolbar->SetRowHeight(buttonSize.cy); + pToolbar->LayoutButtons(-1); + GetParentFrame()->RecalcLayout(); + } + else + { + // We're too small. Need to adjust our bitmap height. + int diff = pToolbar->GetRowHeight() - buttonSize.cy; + SetBitmapSize(CSize(width, height + diff)); + } + } + } } @@ -677,6 +1054,154 @@ void CRDFToolbarButton::DrawLocalIcon(HDC hDC, int x, int y) DrawLocalFileIcon(m_Node, x, y, hDC); } +void CRDFToolbarButton::DrawButtonBitmap(HDC hDC, CRect rcImg) +{ + BTN_STATE eState = m_eState; + + if(m_eState == eBUTTON_CHECKED) + // A checked button has same bitmap as the normal state with no mouse-over + eState = eNORMAL; + else if(m_eState == eBUTTON_UP && m_nChecked == 2) + // if we are in the mouse over mode, but indeterminate we want our bitmap to have a disabled look + eState = eDISABLED; + + UpdateIconInfo(); + + // Create a scratch DC and select our bitmap into it. + HDC pBmpDC = ::CreateCompatibleDC(hDC); + HPALETTE hPalette = WFE_GetUIPalette(GetParentFrame()); + CBitmap BmpImg; + CPoint ptDst; + + HBITMAP hOldBmp; + HPALETTE hOldPal; + if (m_hBmpImg != NULL) + { + HINSTANCE hInst = AfxGetResourceHandle(); + HBITMAP hBmpImg; + hBmpImg = m_hBmpImg; + hOldBmp = (HBITMAP)::SelectObject(pBmpDC, hBmpImg); + hOldPal = ::SelectPalette(pBmpDC, WFE_GetUIPalette(NULL), TRUE); + ::RealizePalette(pBmpDC); + } + + // Get the image dimensions + + int realBitmapHeight; + if(m_nIconType == LOCAL_FILE) + { + realBitmapHeight = 16; + m_bitmapSize.cx = 16; + } + else if (m_nIconType == ARBITRARY_URL) + { + realBitmapHeight = m_bitmapSize.cy; + } + else + { + if (m_nBitmapID == IDB_PICTURES) + realBitmapHeight = 21; // Height of command buttons + else realBitmapHeight = 17; // Height of personal toolbar button bitmaps. + } + + // Center the image within the button + ptDst.x = (rcImg.Width() >= m_bitmapSize.cx) ? + rcImg.left + (((rcImg.Width() - m_bitmapSize.cx) + 1) / 2) : rcImg.left; + + ptDst.y = (rcImg.Height() >= realBitmapHeight) ? + rcImg.top + (((rcImg.Height() - realBitmapHeight) + 1) / 2) : rcImg.top; + + // If we're in the checked state, shift the image one pixel + if (m_eState == eBUTTON_CHECKED || (m_eState == eBUTTON_UP && m_nChecked == 1)) + { + ptDst.x += 1; + ptDst.y += 1; + } + + // Call the handy transparent blit function to paint the bitmap over + // whatever colors exist. + + CPoint bitmapStart; + + if(m_bIsResourceID) + bitmapStart = CPoint(m_nBitmapIndex * m_bitmapSize.cx, m_bEnabled ? realBitmapHeight * eState : realBitmapHeight); + + if(m_bIsResourceID) + { + + if(m_nIconType == LOCAL_FILE) + { + DrawLocalIcon(hDC, ptDst.x, ptDst.y); + } + else if (m_nIconType == ARBITRARY_URL) + { + DrawCustomIcon(hDC, ptDst.x, ptDst.y); + } + else + FEU_TransBlt( hDC, ptDst.x, ptDst.y, m_bitmapSize.cx, realBitmapHeight, + pBmpDC, bitmapStart.x, bitmapStart.y ,WFE_GetUIPalette(NULL), + GetSysColor(COLOR_BTNFACE)); + //::BitBlt(hDC, ptDst.x, ptDst.y, m_bitmapSize.cx, realBitmapHeight, + // pBmpDC, bitmapStart.x, bitmapStart.y, SRCCOPY); + } + + if (m_hBmpImg != NULL) + { + // Cleanup + ::SelectObject(pBmpDC, hOldBmp); + ::SelectPalette(pBmpDC, hOldPal, TRUE); + ::DeleteDC(pBmpDC); + } +} + +/////////////////////////////////////////////////////////////////////////// +// Class CRDFSeparatorButton +/////////////////////////////////////////////////////////////////////////// + +BEGIN_MESSAGE_MAP(CRDFSeparatorButton, CRDFToolbarButton) + //{{AFX_MSG_MAP(CRDFSeparatorButton) +//}}AFX_MSG_MAP + +END_MESSAGE_MAP() + +CSize CRDFSeparatorButton::GetButtonSizeFromChars(CString s, int c) +{ + return CSize(8, 8); +} + +void CRDFSeparatorButton::DrawButtonBitmap(HDC hDC, CRect rcImg) +{ + CDC* pDC = CDC::FromHandle(hDC); + + CRect clientRect; + GetClientRect(&clientRect); + + COLORREF shadowColor = ::GetSysColor(COLOR_3DSHADOW); + COLORREF highlightColor = ::GetSysColor(COLOR_3DLIGHT); + + if (foundOnRDFToolbar()) + { + CRDFToolbar* pToolbar = (CRDFToolbar*)GetParent(); + shadowColor = pToolbar->GetShadowColor(); + highlightColor = pToolbar->GetHighlightColor(); + } + + HPEN hShadowPen = (HPEN)::CreatePen(PS_SOLID, 1, shadowColor); + HPEN hHighlightPen = (HPEN)::CreatePen(PS_SOLID, 1, highlightColor); + + HPEN hOldPen = (HPEN)(pDC->SelectObject(hShadowPen)); + pDC->MoveTo(3, 3); + pDC->LineTo(3, clientRect.bottom - 2); + + (HPEN)(pDC->SelectObject(hHighlightPen)); + pDC->MoveTo(4, 3); + pDC->LineTo(4, clientRect.bottom - 2); + + pDC->SelectObject(hOldPen); + + VERIFY(::DeleteObject(hShadowPen)); + VERIFY(::DeleteObject(hHighlightPen)); +} /////////////////////////////////////////////////////////////////////////// // Class CRDFToolbarDropTarget @@ -723,7 +1248,7 @@ DROPEFFECT CRDFToolbarDropTarget::OnDragOver(CWnd * pWnd, COleDataObject * pData pButton = NULL; } - HT_Resource theNode = pButton ? pButton->GetNode() : HT_TopNode(HT_GetSelectedView(m_pToolbar->GetPane())); + HT_Resource theNode = pButton ? pButton->GetNode() : HT_TopNode(m_pToolbar->GetHTView()); m_pToolbar->SetDragButton(pButton); @@ -753,7 +1278,7 @@ DROPEFFECT CRDFToolbarDropTarget::OnDragOver(CWnd * pWnd, COleDataObject * pData BOOL CRDFToolbarDropTarget::OnDrop(CWnd * pWnd, COleDataObject * pDataObject, DROPEFFECT dropEffect, CPoint point) { - HT_Resource theNode = HT_TopNode(HT_GetSelectedView(m_pToolbar->GetPane())); + HT_Resource theNode = HT_TopNode(m_pToolbar->GetHTView()); if (m_pToolbar->GetDragButton()) theNode = m_pToolbar->GetDragButton()->GetNode(); @@ -768,15 +1293,70 @@ BOOL CRDFToolbarDropTarget::OnDrop(CWnd * pWnd, COleDataObject * pDataObject, // Class CRDFToolbar /////////////////////////////////////////////////////////////////////////// #define LINKTOOLBARHEIGHT 21 +#define COMMANDTOOLBARHEIGHT 42 #define SPACE_BETWEEN_ROWS 2 -// The Event Handler for HT notifications on the personal toolbar -static void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened) +// The Event Handler for HT notifications on the toolbars +static void toolbarNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened, + void *token, uint32 tokenType) { - CRDFToolbar* theToolbar = (CRDFToolbar*)ns->data; - if (n != NULL) - { + static int toolbarIDCounter = 0; + + CRDFToolbarHolder* theToolbarHolder = (CRDFToolbarHolder*)ns->data; + if (theToolbarHolder == NULL) + return; + HT_View theView = HT_GetView(n); + + // The pane has to handle some events. These will go here. + if (whatHappened == HT_EVENT_VIEW_SELECTED) + { + + } + + if (theView == NULL) + return; + + if (whatHappened == HT_EVENT_VIEW_ADDED) + { + CRDFToolbar* theNewToolbar = CRDFToolbar::CreateUserToolbar(theView, theToolbarHolder->GetCachedParentWindow()); + CButtonToolbarWindow *pWindow = new CButtonToolbarWindow(theNewToolbar, + theApp.m_pToolbarStyle, 43, 27, eSMALL_HTAB); + + theToolbarHolder->AddNewWindow(ID_PERSONAL_TOOLBAR+toolbarIDCounter, pWindow, toolbarIDCounter, 43, 27, 1, + HT_GetNodeName(HT_TopNode(theNewToolbar->GetHTView())),theApp.m_pToolbarStyle, TRUE, FALSE); + toolbarIDCounter++; + theToolbarHolder->GetCachedParentWindow()->RecalcLayout(); + } + else if (whatHappened == HT_EVENT_VIEW_DELETED) + { + CRDFToolbar* pToolbar = (CRDFToolbar*)HT_GetViewFEData(theView); + pToolbar->SetHTView(NULL); + delete pToolbar; + HT_SetViewFEData(theView, NULL); + } + else if (whatHappened == HT_EVENT_NODE_VPROP_CHANGED && HT_TopNode(theView) == n) + { + } + else if (whatHappened == HT_EVENT_NODE_EDIT && HT_TopNode(theView) == n) + { + // Edit being performed on a selector bar item. (STILL TO DO) + } + else if (whatHappened == HT_EVENT_VIEW_WORKSPACE_REFRESH) + { + } + // If the pane doesn't handle the event, then a view does. + else + { + CRDFToolbar* pToolbar = (CRDFToolbar*)HT_GetViewFEData(theView); + if (pToolbar != NULL) + pToolbar->HandleEvent(ns, n, whatHappened); + } +} + +void CRDFToolbar::HandleEvent(HT_Notification ns, HT_Resource n, HT_Event whatHappened) +{ + HT_View theView = m_ToolbarView; if (theView != NULL) { if (whatHappened == HT_EVENT_NODE_OPENCLOSE_CHANGED) @@ -788,7 +1368,7 @@ static void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatH if (n == HT_TopNode(theView)) { // Initial population of the toolbar. We should only receive this event once. - theToolbar->FillInToolbar(); + FillInToolbar(); } else { @@ -800,7 +1380,7 @@ static void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatH } else if (whatHappened == HT_EVENT_VIEW_REFRESH) { - theToolbar->LayoutButtons(-1); + LayoutButtons(-1); } else if (HT_TopNode(theView) == HT_GetParent(n)) { @@ -814,72 +1394,70 @@ static void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatH { // Destroy the toolbar button CRDFToolbarButton* pButton = (CRDFToolbarButton*)HT_GetNodeFEData(n); - if (theToolbar->m_hWnd) - theToolbar->RemoveButton(pButton); - else theToolbar->DecrementButtonCount(); + if (m_hWnd) + RemoveButton(pButton); + else DecrementButtonCount(); delete pButton; } } else if (whatHappened == HT_EVENT_NODE_ADDED) { - theToolbar->AddHTButton(n); - theToolbar->LayoutButtons(-1); + AddHTButton(n); + LayoutButtons(-1); + } + else if (whatHappened == HT_EVENT_NODE_EDIT) + { + CRDFToolbarButton* pButton = (CRDFToolbarButton*)HT_GetNodeFEData(n); + pButton->AddTextEdit(); } else if (whatHappened == HT_EVENT_NODE_VPROP_CHANGED) { CRDFToolbarButton* pButton = (CRDFToolbarButton*)HT_GetNodeFEData(n); - pButton->SetText(HT_GetNodeName(n)); // Update our name. - theToolbar->LayoutButtons(-1); + if (pButton->m_hWnd) + { + pButton->SetText(HT_GetNodeName(n)); // Update our name. + LayoutButtons(-1); + } } } } - } } -CRDFToolbar::CRDFToolbar(int nMaxButtons, int nToolbarStyle, int nPicturesAndTextHeight, int nPicturesHeight, - int nTextHeight) +CRDFToolbar::CRDFToolbar(HT_View htView, int nMaxButtons, int nToolbarStyle, int nPicturesAndTextHeight, + int nPicturesHeight, int nTextHeight) : CNSToolbar2(nMaxButtons, nToolbarStyle, nPicturesAndTextHeight, nPicturesHeight, nTextHeight) { + // Set our view and point HT at us. + m_pBackgroundImage = NULL; + m_ToolbarView = htView; + HT_SetViewFEData(htView, this); + m_nNumberOfRows = 1; - - // Construct the notification struct used by HT - HT_Notification ns = new HT_NotificationStruct; - ns->notifyProc = ptNotifyProcedure; - ns->data = this; - - // Construct the pane and give it our notification struct - m_PersonalToolbarPane = HT_NewPersonalToolbarPane(ns); - if (m_PersonalToolbarPane) - HT_SetPaneFEData(m_PersonalToolbarPane, this); + m_nRowHeight = LINKTOOLBARHEIGHT; + void* data; + HT_GetNodeData(HT_TopNode(GetHTView()), gNavCenter->toolbarBitmapPosition, HT_COLUMN_STRING, &data); + if (data) + { + CString position((char*)data); + if (position == "top") + m_nRowHeight = COMMANDTOOLBARHEIGHT; + } } -CRDFToolbar* CRDFToolbar::CreateUserToolbar(CWnd* pParent) +CRDFToolbar* CRDFToolbar::CreateUserToolbar(HT_View theView, CWnd* pParent) { - // read in the maximum size we're allowing for personal toolbar items - int32 nMaxToolbarButtonChars; - int32 nMinToolbarButtonChars; - - if(PREF_GetIntPref("browser.personal_toolbar_button.max_chars", &nMaxToolbarButtonChars) == - PREF_ERROR) - m_nMaxToolbarButtonChars = 30; - else - m_nMaxToolbarButtonChars = CASTINT(nMaxToolbarButtonChars); - - if(PREF_GetIntPref("browser.personal_toolbar_button.min_chars", &nMinToolbarButtonChars) == - PREF_ERROR) - m_nMinToolbarButtonChars = 15; - else - m_nMinToolbarButtonChars = CASTINT(nMinToolbarButtonChars); - - CRDFToolbar* pToolbar = new CRDFToolbar(MAX_TOOLBAR_BUTTONS,theApp.m_pToolbarStyle, 43, 27, 27); + CRDFToolbar* pToolbar = new CRDFToolbar(theView, MAX_TOOLBAR_BUTTONS, theApp.m_pToolbarStyle, 43, 27, 27); if (pToolbar->Create(pParent)) { - pToolbar->SetButtonsSameWidth(FALSE); - // Top node is already open. Fill it in. - pToolbar->FillInToolbar(); + PRBool openState; + HT_Resource topNode = HT_TopNode(theView); + HT_GetOpenState(topNode, &openState); + if (openState) + pToolbar->FillInToolbar(); + else HT_SetOpenState(topNode, PR_TRUE); // Let the callback kick in. } return pToolbar; @@ -887,12 +1465,7 @@ CRDFToolbar* CRDFToolbar::CreateUserToolbar(CWnd* pParent) CRDFToolbar::~CRDFToolbar() { - if (m_PersonalToolbarPane) - { - HT_Pane oldPane = m_PersonalToolbarPane; - m_PersonalToolbarPane = NULL; - HT_DeletePane(oldPane); - } + m_ToolbarView = NULL; } int CRDFToolbar::Create(CWnd *pParent) @@ -908,19 +1481,28 @@ int CRDFToolbar::Create(CWnd *pParent) DragAcceptFiles(FALSE); + HT_Resource topNode = HT_TopNode(GetHTView()); + BOOL fixedSize = FALSE; + + void* data; + HT_GetNodeData(topNode, gNavCenter->toolbarButtonsFixedSize, HT_COLUMN_STRING, &data); + if (data) + { + CString answer((char*)data); + if (answer.GetLength() > 0 && (answer.GetAt(0) == 'y' || answer.GetAt(0) == 'Y')) + fixedSize = TRUE; + } + SetButtonsSameWidth(fixedSize); + return result; } void CRDFToolbar::FillInToolbar() { - if (!m_PersonalToolbarPane) + if (!m_ToolbarView) return; - HT_View theView = HT_GetSelectedView(m_PersonalToolbarPane); - if (theView == NULL) - return; - - HT_Resource top = HT_TopNode(theView); + HT_Resource top = HT_TopNode(m_ToolbarView); HT_Cursor cursor = HT_NewCursor(top); if (cursor == NULL) return; @@ -936,22 +1518,37 @@ void CRDFToolbar::FillInToolbar() void CRDFToolbar::AddHTButton(HT_Resource item) { - if (HT_IsSeparator(item)) - return; - - CRDFToolbarButton* pButton = new CRDFToolbarButton; BOOKMARKITEM bookmark; - XP_STRCPY(bookmark.szText, HT_GetNodeName(item)); XP_STRCPY(bookmark.szAnchor, HT_GetNodeURL(item)); - CString csAmpersandString = FEU_EscapeAmpersand(CString(bookmark.szText)); + CString tooltipText(bookmark.szText); // Default is to use the name for the tooltip + CString statusBarText(bookmark.szAnchor); // and the URL for the status bar text. + + // Fetch the button's tooltip and status bar text. + void* data; + HT_GetNodeData(item, gNavCenter->buttonTooltipText, HT_COLUMN_STRING, &data); + if (data) + tooltipText = (char*)data; + HT_GetNodeData(item, gNavCenter->buttonStatusbarText, HT_COLUMN_STRING, &data); + if (data) + statusBarText = (char*)data; + + CRDFToolbarButton* pButton = NULL; + if (HT_IsURLBar(item)) + pButton = new CURLBarButton; + else if (HT_IsSeparator(item)) + { + pButton = new CRDFSeparatorButton; + tooltipText = "Separator"; + statusBarText = "Separator"; + } + else pButton = new CRDFToolbarButton; pButton->Create(this, theApp.m_pToolbarStyle, CSize(60,42), CSize(85, 25), csAmpersandString, - bookmark.szText, bookmark.szAnchor, CSize(23,17), + tooltipText, statusBarText, CSize(23,17), m_nMaxToolbarButtonChars, m_nMinToolbarButtonChars, bookmark, - item, - (HT_IsContainer(item) ? TB_HAS_DRAGABLE_MENU | TB_HAS_IMMEDIATE_MENU : 0)); + item, (HT_IsContainer(item) ? TB_HAS_DRAGABLE_MENU | TB_HAS_IMMEDIATE_MENU : 0)); if(HT_IsContainer(item)) { @@ -960,17 +1557,76 @@ void CRDFToolbar::AddHTButton(HT_Resource item) } HT_SetNodeFEData(item, pButton); + CSize buttonSize = pButton->GetMinimalButtonSize(); // Only care about height. + + if (buttonSize.cy > m_nRowHeight) + { + m_nRowHeight = buttonSize.cy; + GetParentFrame()->RecalcLayout(); + } + else if (buttonSize.cy < m_nRowHeight) + { + CSize size = pButton->GetBitmapSize(); + pButton->SetBitmapSize(CSize(size.cx, size.cy + (m_nRowHeight - buttonSize.cy))); + } - AddButtonAtIndex(pButton); // Have to put the button in the array, since the toolbar base class depends on it. + m_pButtonArray[m_nNumButtons] = pButton; + + m_nNumButtons++; + + if(CheckMaxButtonSizeChanged(pButton, TRUE) && !HT_IsURLBar(item) && !HT_IsSeparator(item)) + { + ChangeButtonSizes(); + } + else + { + CSize size = pButton->GetRequiredButtonSize(); + int nWidth = size.cx; + + if (m_bButtonsSameWidth && !HT_IsURLBar(item) && !HT_IsSeparator(item)) + nWidth = m_nMaxButtonWidth; + + //make sure it's the size of the largest button so far + pButton->SetButtonSize(CSize(nWidth, m_nMaxButtonHeight)); + } + + // Update the button if it's a command. + if (pButton->NeedsUpdate()) + { + pButton->OnUpdateCmdUI(GetTopLevelFrame(), FALSE); + } +} + +void CRDFToolbar::ChangeButtonSizes(void) +{ + int nWidth; + + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); + HT_Resource item; + while (item = HT_GetNextItem(cursor)) + { + CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); + if (!HT_IsSeparator(item) && !HT_IsURLBar(item) && pButton) + { + if(!m_bButtonsSameWidth) + { + CSize size = pButton->GetRequiredButtonSize(); + nWidth = size.cx; + } + else + nWidth = m_nMaxButtonWidth; + + pButton->SetButtonSize(CSize(nWidth, m_nMaxButtonHeight)); + } + } + HT_DeleteCursor(cursor); } int CRDFToolbar::GetHeight(void) { - return m_nNumberOfRows * (LINKTOOLBARHEIGHT + SPACE_BETWEEN_ROWS) + SPACE_BETWEEN_ROWS; + return m_nNumberOfRows * (m_nRowHeight + SPACE_BETWEEN_ROWS) + SPACE_BETWEEN_ROWS; } - - void CRDFToolbar::SetMinimumRows(int rowWidth) { int rowCount = 1; @@ -983,11 +1639,11 @@ void CRDFToolbar::SetMinimumRows(int rowWidth) return; } - HT_Cursor cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; HT_Resource item; - while (rowCount < MAX_TOOLBAR_ROWS && (item = HT_GetNextItem(cursor))) + while ((item = HT_GetNextItem(cursor))) { // Get the current button CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); @@ -1010,7 +1666,8 @@ void CRDFToolbar::SetMinimumRows(int rowWidth) SetRows(rowCount); } -void CRDFToolbar::ComputeLayoutInfo(CRDFToolbarButton* pButton, int numChars, int rowWidth, int& usedSpace) +void CRDFToolbar::ComputeLayoutInfo(CRDFToolbarButton* pButton, int numChars, int rowWidth, + int& usedSpace) { CString originalText = HT_GetNodeName(pButton->GetNode()); @@ -1025,7 +1682,9 @@ void CRDFToolbar::ComputeLayoutInfo(CRDFToolbarButton* pButton, int numChars, in } pButton->SetTextWithoutResize(strTxt); - pButton->SetButtonSize(pButton->GetButtonSizeFromChars(strTxt, numChars)); + + if (!m_bButtonsSameWidth || HT_IsURLBar(pButton->GetNode()) || HT_IsSeparator(pButton->GetNode())) + pButton->SetButtonSize(pButton->GetButtonSizeFromChars(strTxt, numChars)); // Determine how much additional padding we'll use to fill out a row if this button doesn't fit. int rowUsage = usedSpace % rowWidth; @@ -1048,7 +1707,6 @@ void CRDFToolbar::ComputeLayoutInfo(CRDFToolbarButton* pButton, int numChars, in currentRow--; pButton->SetRow(currentRow); - } void CRDFToolbar::LayoutButtons(int nIndex) @@ -1074,7 +1732,7 @@ void CRDFToolbar::LayoutButtons(int nIndex) if (rowWidth <= 0 && m_nWidth > 0) rowWidth = m_nWidth - RIGHT_TOOLBAR_MARGIN - LEFT_TOOLBAR_MARGIN; - SetMinimumRows(rowWidth); + SetMinimumRows(width); int newRows = GetRows(); @@ -1084,7 +1742,7 @@ void CRDFToolbar::LayoutButtons(int nIndex) int numChars = 0; // Start off trying to fit the whole thing on the toolbar. int minChars = 0; - HT_Cursor cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; HT_Resource item; @@ -1111,7 +1769,7 @@ void CRDFToolbar::LayoutButtons(int nIndex) usedSpace = 0; numChars--; // Let's see what we can fit. - HT_Cursor cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; HT_Resource item; @@ -1128,24 +1786,111 @@ void CRDFToolbar::LayoutButtons(int nIndex) HT_DeleteCursor(cursor); } - // That's it. lay them out with this number of characters. - - int nStartX = LEFT_TOOLBAR_MARGIN; + int nStartX = LEFT_TOOLBAR_MARGIN; int nStartY = SPACE_BETWEEN_ROWS; int row = 0; - CSize buttonSize; - CString strTxt; + // Now we have to handle springs + // Initialize our spring counter (we're using this to track the number of springs + // on each toolbar row). + int* springCounter = new int[newRows]; + int* rowPadding = new int[newRows]; + for (int init=0; init < newRows; init++) { springCounter[init] = 0; } + for (int init2=0; init2 < newRows; init2++) { rowPadding[init2] = 0; } - cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + // Count the springs on each row, as well as the padding on each row. + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; while ((item = HT_GetNextItem(cursor))) { // Get the current button CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); - if (!pButton) // Separator + if (!pButton) + continue; + + if (pButton->IsSpring()) + { + springCounter[row]++; + } + + CSize buttonSize = pButton->GetButtonSize(); // The size we must be + + int tempTotal = nStartX + buttonSize.cx; + if (tempTotal > (width - RIGHT_TOOLBAR_MARGIN)) + { + // Compute row padding + int rowPad = width - RIGHT_TOOLBAR_MARGIN - nStartX; + + // Store the row padding information + rowPadding[row] = rowPad; + + // Move to the next row. + nStartX = LEFT_TOOLBAR_MARGIN; + nStartY += m_nRowHeight + SPACE_BETWEEN_ROWS; + row++; + } + + nStartX += buttonSize.cx + SPACE_BETWEEN_BUTTONS; + } + rowPadding[row] = width - RIGHT_TOOLBAR_MARGIN - nStartX; + HT_DeleteCursor(cursor); + + // Now we know the number of springs on each row, and we know how much available padding + // we have on each row. Expand the springs' sizes so that all space on rows with springs + // is consumed. + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); + if (!cursor) + return; + while ((item = HT_GetNextItem(cursor))) + { + // Get the current button + CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); + if (!pButton) + continue; + + CSize buttonSize = pButton->GetButtonSize(); // The size we must be + int row = pButton->GetRow(); + + if (pButton->IsSpring()) + { + // Expand the spring + int numSprings = springCounter[row]; + int rowPad = rowPadding[row]; + int addPadding = rowPad; + if (numSprings > 1) + { + springCounter[row]--; + addPadding = rowPad / numSprings; + rowPadding[row] -= addPadding; + } + + pButton->SetButtonSize(CSize(buttonSize.cx + addPadding, buttonSize.cy)); + + } + } + HT_DeleteCursor(cursor); + + // Clean up. Delete our temporary arrays. + delete []springCounter; + delete []rowPadding; + + // That's it. lay them out with this number of characters. + nStartX = LEFT_TOOLBAR_MARGIN; + nStartY = SPACE_BETWEEN_ROWS; + row = 0; + CSize buttonSize; + CString strTxt; + + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); + if (!cursor) + return; + while ((item = HT_GetNextItem(cursor))) + { + // Get the current button + CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); + if (!pButton) continue; buttonSize = pButton->GetButtonSize(); // The size we must be @@ -1154,21 +1899,23 @@ void CRDFToolbar::LayoutButtons(int nIndex) if (tempTotal > (width - RIGHT_TOOLBAR_MARGIN)) { nStartX = LEFT_TOOLBAR_MARGIN; - nStartY += LINKTOOLBARHEIGHT + SPACE_BETWEEN_ROWS; + nStartY += m_nRowHeight + SPACE_BETWEEN_ROWS; } + if (buttonSize.cy < m_nRowHeight) + { + CSize size = pButton->GetBitmapSize(); + pButton->SetBitmapSize(CSize(size.cx, size.cy + (m_nRowHeight - buttonSize.cy))); + } + pButton->MoveWindow(nStartX, nStartY, - buttonSize.cx, buttonSize.cy); + buttonSize.cx, m_nRowHeight); nStartX += buttonSize.cx + SPACE_BETWEEN_BUTTONS; } HT_DeleteCursor(cursor); - //record the width of our toolbar - //if (nStartY == SPACE_BETWEEN_ROWS && nStartX < (width - RIGHT_TOOLBAR_MARGIN)) - // m_nWidth = nStartX; - //else - m_nWidth = width; + m_nWidth = width; if (oldRows != newRows) GetParentFrame()->RecalcLayout(); @@ -1193,7 +1940,7 @@ void CRDFToolbar::WidthChanged(int animWidth) if (rowWidth <= 0 && m_nWidth > 0) rowWidth = m_nWidth - RIGHT_TOOLBAR_MARGIN - LEFT_TOOLBAR_MARGIN; - SetMinimumRows(rowWidth); + SetMinimumRows(width); int newRows = GetRows(); @@ -1202,7 +1949,7 @@ void CRDFToolbar::WidthChanged(int animWidth) int numChars = 0; // Start off trying to fit the whole thing on the toolbar. int minChars = 0; - HT_Cursor cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; HT_Resource item; @@ -1229,7 +1976,7 @@ void CRDFToolbar::WidthChanged(int animWidth) usedSpace = 0; numChars--; // Let's see what we can fit. - HT_Cursor cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + HT_Cursor cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; HT_Resource item; @@ -1253,10 +2000,99 @@ void CRDFToolbar::WidthChanged(int animWidth) int row = 0; + // Now we have to handle springs + // Initialize our spring counter (we're using this to track the number of springs + // on each toolbar row). + int* springCounter = new int[newRows]; + int* rowPadding = new int[newRows]; + for (int init=0; init < newRows; init++) { springCounter[init] = 0; } + for (int init2=0; init2 < newRows; init2++) { rowPadding[init2] = 0; } + + // Count the springs on each row, as well as the padding on each row. + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); + if (!cursor) + return; + while ((item = HT_GetNextItem(cursor))) + { + // Get the current button + CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); + if (!pButton) + continue; + + if (pButton->IsSpring()) + { + springCounter[row]++; + } + + CSize buttonSize = pButton->GetButtonSize(); // The size we must be + + int tempTotal = nStartX + buttonSize.cx; + if (tempTotal > (width - RIGHT_TOOLBAR_MARGIN)) + { + // Compute row padding + int rowPad = width - RIGHT_TOOLBAR_MARGIN - nStartX; + + // Store the row padding information + rowPadding[row] = rowPad; + + // Move to the next row. + nStartX = LEFT_TOOLBAR_MARGIN; + nStartY += m_nRowHeight + SPACE_BETWEEN_ROWS; + row++; + } + + nStartX += buttonSize.cx + SPACE_BETWEEN_BUTTONS; + } + rowPadding[row] = width - RIGHT_TOOLBAR_MARGIN - nStartX; + HT_DeleteCursor(cursor); + + // Now we know the number of springs on each row, and we know how much available padding + // we have on each row. Expand the springs' sizes so that all space on rows with springs + // is consumed. + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); + if (!cursor) + return; + while ((item = HT_GetNextItem(cursor))) + { + // Get the current button + CRDFToolbarButton* pButton = (CRDFToolbarButton*)(HT_GetNodeFEData(item)); + if (!pButton) + continue; + + CSize buttonSize = pButton->GetButtonSize(); // The size we must be + int row = pButton->GetRow(); + + if (pButton->IsSpring()) + { + // Expand the spring + int numSprings = springCounter[row]; + int rowPad = rowPadding[row]; + int addPadding = rowPad; + if (numSprings > 1) + { + springCounter[row]--; + addPadding = rowPad / numSprings; + rowPadding[row] -= addPadding; + } + + pButton->SetButtonSize(CSize(buttonSize.cx + addPadding, buttonSize.cy)); + + } + } + HT_DeleteCursor(cursor); + + // Clean up. Delete our temporary arrays. + delete []springCounter; + delete []rowPadding; + + nStartX = LEFT_TOOLBAR_MARGIN; + nStartY = SPACE_BETWEEN_ROWS; + row = 0; + CSize buttonSize; CString strTxt; - cursor = HT_NewCursor(HT_TopNode(HT_GetSelectedView(m_PersonalToolbarPane))); + cursor = HT_NewCursor(HT_TopNode(m_ToolbarView)); if (!cursor) return; @@ -1273,11 +2109,17 @@ void CRDFToolbar::WidthChanged(int animWidth) if (tempTotal > (width - RIGHT_TOOLBAR_MARGIN)) { nStartX = LEFT_TOOLBAR_MARGIN; - nStartY += LINKTOOLBARHEIGHT + SPACE_BETWEEN_ROWS; + nStartY += m_nRowHeight + SPACE_BETWEEN_ROWS; } + if (buttonSize.cy < m_nRowHeight) + { + CSize size = pButton->GetBitmapSize(); + pButton->SetBitmapSize(CSize(size.cx, size.cy + (m_nRowHeight - buttonSize.cy))); + } + pButton->MoveWindow(nStartX, nStartY, - buttonSize.cx, buttonSize.cy); + buttonSize.cx, m_nRowHeight); nStartX += buttonSize.cx + SPACE_BETWEEN_BUTTONS; } @@ -1290,7 +2132,121 @@ void CRDFToolbar::WidthChanged(int animWidth) GetParentFrame()->RecalcLayout(); } +int CRDFToolbar::GetRowWidth() +{ + return m_nWidth - RIGHT_TOOLBAR_MARGIN - LEFT_TOOLBAR_MARGIN - SPACE_BETWEEN_BUTTONS; +} +void CRDFToolbar::OnPaint(void) +{ + CRect rcClient, updateRect, buttonRect, intersectRect; + + GetClientRect(&rcClient); + GetUpdateRect(&updateRect); + + CPaintDC dcPaint(this); + + // background color + HT_Resource top = HT_TopNode(GetHTView()); + void* data; + COLORREF backgroundColor = GetSysColor(COLOR_BTNFACE); + COLORREF shadowColor = backgroundColor; + COLORREF highlightColor = backgroundColor; + + HT_GetNodeData(top, gNavCenter->viewBGColor, HT_COLUMN_STRING, &data); + if (data) + { + WFE_ParseColor((char*)data, &backgroundColor); + } + Compute3DColors(backgroundColor, highlightColor, shadowColor); + + if (m_BackgroundColor != backgroundColor) + { + // Ensure proper filling in of parent space with the background color. + SetBackgroundColor(backgroundColor); + GetParent()->Invalidate(); + } + + SetShadowColor(shadowColor); + SetHighlightColor(highlightColor); + + // Foreground color + COLORREF foregroundColor = GetSysColor(COLOR_BTNTEXT); + HT_GetNodeData(top, gNavCenter->viewFGColor, HT_COLUMN_STRING, &data); + if (data) + { + WFE_ParseColor((char*)data, &foregroundColor); + } + SetForegroundColor(foregroundColor); + + // Rollover color + COLORREF rolloverColor = RGB(0, 0, 255); + HT_GetNodeData(top, gNavCenter->viewRolloverColor, HT_COLUMN_STRING, &data); + if (data) + { + WFE_ParseColor((char*)data, &rolloverColor); + } + SetRolloverColor(rolloverColor); + + // Pressed color + COLORREF pressedColor = RGB(0, 0, 128); + HT_GetNodeData(top, gNavCenter->viewPressedColor, HT_COLUMN_STRING, &data); + if (data) + { + WFE_ParseColor((char*)data, &pressedColor); + } + SetPressedColor(pressedColor); + + // Disabled color + COLORREF disabledColor = -1; + HT_GetNodeData(top, gNavCenter->viewDisabledColor, HT_COLUMN_STRING, &data); + if (data) + { + WFE_ParseColor((char*)data, &disabledColor); + } + SetDisabledColor(disabledColor); + + // Background image URL + CString backgroundImageURL = ""; + HT_GetNodeData(top, gNavCenter->viewBGURL, HT_COLUMN_STRING, &data); + if (data) + backgroundImageURL = (char*)data; + SetBackgroundImage(NULL); // Clear out the BG image. + + HBRUSH hRegBrush = (HBRUSH) ::CreateSolidBrush(backgroundColor); + if (backgroundImageURL != "") + { + // There's a background that needs to be drawn. + SetBackgroundImage(LookupImage(backgroundImageURL, NULL)); + } + + if (GetBackgroundImage() && + GetBackgroundImage()->FrameSuccessfullyLoaded()) + { + PaintBackground(dcPaint.m_hDC, &rcClient, GetBackgroundImage(), 0); + } + else + { + ::FillRect(dcPaint.m_hDC, &rcClient, hRegBrush); + } + + VERIFY(::DeleteObject(hRegBrush)); + + for (int i = 0; i < m_nNumButtons; i++) + { + m_pButtonArray[i]->GetClientRect(&buttonRect); + + m_pButtonArray[i]->MapWindowPoints(this, &buttonRect); + + if(intersectRect.IntersectRect(updateRect, buttonRect)) + { + MapWindowPoints(m_pButtonArray[i], &intersectRect); + m_pButtonArray[i]->RedrawWindow(&intersectRect); + } + + } + +} /////////////////////////////////////////////////////////////////////////////////// // CRDFToolbar Messages @@ -1299,15 +2255,18 @@ void CRDFToolbar::WidthChanged(int animWidth) BEGIN_MESSAGE_MAP(CRDFToolbar, CNSToolbar2) //{{AFX_MSG_MAP(CNSToolbar2) ON_WM_RBUTTONDOWN() - //}}AFX_MSG_MAP + ON_WM_PAINT() +//}}AFX_MSG_MAP END_MESSAGE_MAP() void CRDFToolbar::OnRButtonDown(UINT nFlags, CPoint point) { + HT_SetSelectedView(HT_GetPane(GetHTView()), GetHTView()); + HT_SetSelection(HT_TopNode(GetHTView())); + m_MenuCommandMap.Clear(); - HT_View theView = HT_GetSelectedView(m_PersonalToolbarPane); - HT_Cursor theCursor = HT_NewContextualMenuCursor(theView, PR_FALSE, PR_TRUE); + HT_Cursor theCursor = HT_NewContextualMenuCursor(m_ToolbarView, PR_FALSE, PR_TRUE); CMenu menu; ClientToScreen(&point); if (menu.CreatePopupMenu() != 0 && theCursor != NULL) @@ -1345,9 +2304,227 @@ BOOL CRDFToolbar::OnCommand( WPARAM wParam, LPARAM lParam ) if (theCommand) { HT_MenuCmd htCommand = theCommand->GetHTCommand(); - HT_DoMenuCmd(m_PersonalToolbarPane, htCommand); + HT_DoMenuCmd(HT_GetPane(m_ToolbarView), htCommand); } return TRUE; } return((BOOL)GetParentFrame()->SendMessage(WM_COMMAND, wParam, lParam)); } + +// ========================================================== +// CRDFDragToolbar +// Contains a single RDF toolbar. +// Handles drawing of backgrounds etc. etc. +// ========================================================== + +BEGIN_MESSAGE_MAP(CRDFDragToolbar, CDragToolbar) + //{{AFX_MSG_MAP(CRDFToolbarButton) + ON_WM_PAINT() + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +#define OPEN_BUTTON_WIDTH 9 +#define CLOSED_BUTTON_WIDTH 40 +#define CLOSED_BUTTON_HEIGHT 10 +#define DT_RIGHT_MARGIN 1 //Margin between end of toolbar and right border of Navigator +#define DRAGGING_BORDER_HEIGHT 2 +#define NOTOOL -1 + +#define HTAB_TOP_START 0 +#define HTAB_TOP_HEIGHT 7 +#define HTAB_MIDDLE_START 8 +#define HTAB_MIDDLE_HEIGHT 6 +#define HTAB_BOTTOM_START 15 +#define HTAB_BOTTOM_HEIGHT 3 + +extern HBITMAP m_hTabBitmap; + +void CRDFDragToolbar::OnPaint(void) +{ + CPaintDC dcPaint(this); // device context for painting + CRect rect; + + GetClientRect(&rect); + + // Use our toolbar background color (or background image TODO) + CRDFToolbar* pToolbar = (CRDFToolbar*)m_pToolbar->GetToolbar(); + + HBRUSH brFace = (HBRUSH) ::CreateSolidBrush(pToolbar->GetBackgroundColor()); + + ::FillRect(dcPaint.m_hDC, &rect, brFace); + + VERIFY(::DeleteObject(brFace)); + + CDC *pDC = &dcPaint; + HPALETTE hOldPal = ::SelectPalette(pDC->m_hDC, WFE_GetUIPalette(GetParentFrame()), FALSE); + + if(m_hTabBitmap != NULL) + { + + // Create a scratch DC and select our bitmap into it. + CDC * pBmpDC = new CDC; + pBmpDC->CreateCompatibleDC(pDC); + + + HBITMAP hOldBmp = (HBITMAP)::SelectObject(pBmpDC->m_hDC ,m_hTabBitmap); + HPALETTE hOldPalette = ::SelectPalette(pBmpDC->m_hDC, WFE_GetUIPalette(NULL), TRUE); + ::RealizePalette(pBmpDC->m_hDC); + CPoint bitmapStart(!m_bMouseInTab ? 0 : OPEN_BUTTON_WIDTH ,HTAB_TOP_START); + + //First do top of the tab + + ::BitBlt(pDC->m_hDC, 0, 0, OPEN_BUTTON_WIDTH, HTAB_TOP_HEIGHT, + pBmpDC->m_hDC, bitmapStart.x, bitmapStart.y, SRCCOPY); + + //Now do the middle portion of the tab + int y = HTAB_TOP_HEIGHT; + + bitmapStart.y = HTAB_MIDDLE_START; + + while(y < rect.bottom - HTAB_BOTTOM_HEIGHT) + { + ::BitBlt(pDC->m_hDC, 0, y, OPEN_BUTTON_WIDTH, HTAB_MIDDLE_HEIGHT, + pBmpDC->m_hDC, bitmapStart.x, bitmapStart.y, SRCCOPY); + + y += HTAB_MIDDLE_HEIGHT; + + } + + // Now do the bottom of the tab + y = rect.bottom - HTAB_BOTTOM_HEIGHT; + + bitmapStart.y = HTAB_BOTTOM_START; + + ::BitBlt(pDC->m_hDC, 0, y, OPEN_BUTTON_WIDTH, HTAB_BOTTOM_HEIGHT, + pBmpDC->m_hDC, bitmapStart.x, bitmapStart.y, SRCCOPY); + + + // Cleanup + ::SelectObject(pBmpDC->m_hDC, hOldBmp); + ::SelectPalette(pBmpDC->m_hDC, hOldPalette, TRUE); + ::SelectPalette(pDC->m_hDC, hOldPal, TRUE); + pBmpDC->DeleteDC(); + delete pBmpDC; + } + + if(m_bDragging) + { + CBrush brush(RGB(0, 0, 0)); + CBrush *pOldBrush = (CBrush*)dcPaint.SelectObject(&brush); + + //rect.left += OPEN_BUTTON_WIDTH; + + dcPaint.FrameRect(&rect, &brush); + + dcPaint.SelectObject(pOldBrush); + brush.DeleteObject(); + } +} + +// ========================================================== +// CRDFToolbarHolder +// The container of all the toolbars +// ========================================================== + +CRDFToolbarHolder::CRDFToolbarHolder(int maxToolbars, CFrameWnd* pParentWindow) +:CCustToolbar(maxToolbars) +{ + m_pCachedParentWindow = pParentWindow; + m_pCurrentButton = NULL; +} + +CRDFToolbarHolder::~CRDFToolbarHolder() +{ + if (m_ToolbarPane) + { + HT_Pane oldPane = m_ToolbarPane; + m_ToolbarPane = NULL; + HT_DeletePane(oldPane); + } +} + +void CRDFToolbarHolder::InitializeRDFData() +{ + HT_Notification ns = new HT_NotificationStruct; + XP_BZERO(ns, sizeof(HT_NotificationStruct)); + ns->notifyProc = toolbarNotifyProcedure; + ns->data = this; + + // Construct the pane and give it our notification struct + HT_Pane newPane = HT_NewToolbarPane(ns); + if (newPane) + { + SetHTPane(newPane); + HT_SetPaneFEData(newPane, this); + } +} + +CIsomorphicCommandMap* CIsomorphicCommandMap::InitializeCommandMap(const CString& initType) +{ + CIsomorphicCommandMap* result = new CIsomorphicCommandMap(); + + if (initType == "Browser Commands") + { + // Enter the builtin browser commands into the map. + result->AddItem("command:back", ID_NAVIGATE_BACK); + result->AddItem("command:forward", ID_NAVIGATE_FORWARD); + result->AddItem("command:reload", ID_NAVIGATE_RELOAD); + result->AddItem("command:home", ID_GO_HOME); + result->AddItem("command:print", ID_FILE_PRINT); + result->AddItem("command:stop", ID_NAVIGATE_INTERRUPT); + } + else if (initType == "Command Toolbar Bitmap Indices") + { + result->AddItem("command:back", 0); + result->AddItem("command:forward", 1); + result->AddItem("command:reload", 2); + result->AddItem("command:home", 3); + result->AddItem("command:print", 7); + result->AddItem("command:stop", 11); + } + return result; +} + +void CIsomorphicCommandMap::AddItem(CString xpItem, UINT feResource) +{ + char buffer[20]; + _itoa((int)feResource, buffer, 10); + mapFromXPToFE.SetAt(xpItem, CString(buffer)); + mapFromFEToXP.SetAt(CString(buffer), xpItem); +} + +void CIsomorphicCommandMap::RemoveXPItem(CString xpItem) +{ + CString result; + mapFromXPToFE.Lookup(xpItem, result); + mapFromXPToFE.RemoveKey(xpItem); + mapFromFEToXP.RemoveKey(result); +} + +void CIsomorphicCommandMap::RemoveFEItem(UINT feResource) +{ + char buffer[20]; + _itoa((int)feResource, buffer, 10); + CString resource(buffer); + CString result; + mapFromFEToXP.Lookup(resource, result); + mapFromXPToFE.RemoveKey(result); + mapFromFEToXP.RemoveKey(resource); +} + +UINT CIsomorphicCommandMap::GetFEResource(CString xpItem) +{ + CString result; + mapFromXPToFE.Lookup(xpItem, result); + return (atoi(result)); +} + +CString CIsomorphicCommandMap::GetXPResource(UINT feResource) +{ + char buffer[20]; + _itoa((int)feResource, buffer, 10); + CString resource(buffer); + CString result; + mapFromFEToXP.Lookup(resource, result); + return result; +} diff --git a/mozilla/cmd/winfe/usertlbr.h b/mozilla/cmd/winfe/usertlbr.h index 9b7c64ec98d..094b37179bc 100644 --- a/mozilla/cmd/winfe/usertlbr.h +++ b/mozilla/cmd/winfe/usertlbr.h @@ -52,8 +52,8 @@ class CRDFToolbarButtonDropTarget : public CRDFToolbarButtonDropTargetBase #define CRDFToolbarButtonBase CDragableToolbarButton -class CRDFToolbarButton: public CRDFToolbarButtonBase, public CCustomImageObject { - +class CRDFToolbarButton: public CRDFToolbarButtonBase, public CCustomImageObject +{ protected: HT_Resource m_Node; // The resource corresponding to the RDF node BOOKMARKITEM m_bookmark; @@ -62,15 +62,18 @@ protected: int currentRow; // The row of the personal toolbar this button resides on. CDropMenu* m_pCachedDropMenu; // A pointer to a drop menu that is tracked across // node opening (HT) callbacks + CNSNavFrame* m_pTreeView; // A pointer to a tree popup that is tracked. BOOL m_bShouldShowRMMenu; // Set to TRUE by default. Quickfile/Breadcrumbs set it to FALSE. CRDFCommandMap m_MenuCommandMap; // Command map for back-end generated right mouse menu commands. + + int m_nActualBitmapHeight; // The actual bitmap's height. public: CRDFToolbarButton(); ~CRDFToolbarButton(); - int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize, + virtual int Create(CWnd *pParent, int nToolbarStyle, CSize noviceButtonSize, CSize advancedButtonSize, LPCTSTR pButtonText, LPCTSTR pToolTipText, LPCTSTR pStatusText, CSize bitmapSize, int nMaxTextChars, int nMinTextChars, BOOKMARKITEM bookmark, @@ -79,13 +82,24 @@ public: int GetRow() { return currentRow; } void SetRow(int i) { currentRow = i; } + virtual BOOL foundOnRDFToolbar() { return TRUE; } // RDF Buttons must ALWAYS reside on RDF toolbars. (Derived + // classes could have different behavior, but base-class buttons + // make the assumption that they sit on an RDF toolbar. + + CNSNavFrame* GetTreeView() { return m_pTreeView; } + virtual void OnAction(void); virtual CSize GetButtonSizeFromChars(CString s, int c); virtual CSize GetMinimalButtonSize(); virtual CSize GetMaximalButtonSize(); + virtual BOOL IsSpring() { return FALSE; } // Whether or not the button will expand to consume + // all remaining space on a row. + virtual BOOL UseLargeIcons() { return FALSE; } - virtual void UpdateIconInfo() { DetermineIconType(m_Node, UseLargeIcons()); } + virtual void UpdateIconInfo(); + + virtual void DrawButtonBitmap(HDC hDC, CRect rcImg); virtual void FillInOleDataSource(COleDataSource *pDataSource); @@ -106,6 +120,8 @@ public: virtual HT_View GetHTView() { return HT_GetView(m_Node); } + virtual BOOL NeedsUpdate(); + protected: virtual void DrawPicturesMode(HDC hDC, CRect rect); virtual void DrawPicturesAndTextMode(HDC hDC, CRect rect); @@ -125,7 +141,9 @@ protected: afx_msg LRESULT OnDropMenuClosed(WPARAM, LPARAM); afx_msg LRESULT OnFillInMenu(WPARAM wParam, LPARAM lParam); afx_msg void OnSysColorChange( ); - + afx_msg void OnPaint(); + afx_msg int OnMouseActivate( CWnd* pDesktopWnd, UINT nHitTest, UINT message ); + //}}AFX_MSG DECLARE_MESSAGE_MAP() @@ -133,7 +151,30 @@ protected: }; -void ptNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened); +void toolbarNotifyProcedure (HT_Notification ns, HT_Resource n, HT_Event whatHappened); + +/**************************************************************************** +* +* Class: CRDFSeparatorButton +* +****************************************************************************/ + +class CRDFSeparatorButton : public CRDFToolbarButton +{ +protected: + +public: + virtual CSize GetButtonSizeFromChars(CString s, int c); + // Overridden to handle special width/height requirements. + + virtual void DrawButtonBitmap(HDC hDC, CRect rcImg); + virtual void DrawButtonText(HDC hDC, CRect rcTxt, CSize sizeTxt, CString strTxt) {}; + + // Generated message map functions + //{{AFX_MSG(CRDFSeparatorButton) + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; /**************************************************************************** * @@ -168,37 +209,51 @@ protected: }; -class CRDFToolbar : public CNSToolbar2 { +class CRDFToolbar : public CNSToolbar2, public CCustomImageObject { private: CRDFToolbarDropTarget m_DropTarget; - HT_Pane m_PersonalToolbarPane; + HT_View m_ToolbarView; CRDFCommandMap m_MenuCommandMap; // Command map for back-end generated right mouse menu commands. int m_nNumberOfRows; + int m_nRowHeight; CRDFToolbarButton* m_pDragButton; int m_iDragFraction; + COLORREF m_BackgroundColor; + COLORREF m_ForegroundColor; + COLORREF m_RolloverColor; + COLORREF m_PressedColor; + COLORREF m_DisabledColor; + COLORREF m_ShadowColor; + COLORREF m_HighlightColor; + + CRDFImage* m_pBackgroundImage; + static int m_nMinToolbarButtonChars; static int m_nMaxToolbarButtonChars; - + public: - CRDFToolbar(int nMaxButtons, int nToolbarStyle, int nPicturesAndTextHeight, int nPicturesHeight, + CRDFToolbar(HT_View theView, int nMaxButtons, int nToolbarStyle, int nPicturesAndTextHeight, int nPicturesHeight, int nTextHeight); ~CRDFToolbar(); // Used to create toolbars - static CRDFToolbar* CreateUserToolbar(CWnd* pParent); + static CRDFToolbar* CreateUserToolbar(HT_View theView, CWnd* pParent); int Create(CWnd *pParent); virtual int GetHeight(void); - + virtual int GetRowWidth(); + // Override layout scheme to dynamically resize buttons. void LayoutButtons(int nIndex); // Index will be ignored by this version of the function // since adding/deleting buttons may cause all buttons to resize - + // Toolbar's event handler. + void HandleEvent(HT_Notification ns, HT_Resource n, HT_Event whatHappened); + void AddHTButton(HT_Resource n); // Called to add a new button to the toolbar void SetMinimumRows(int rowWidth); // Called to determine and set the # of rows required by the toolbar. @@ -210,7 +265,8 @@ public: void FillInToolbar(); // Called to create and place the buttons on the toolbar - HT_Pane GetPane() { return m_PersonalToolbarPane; } // Returns the HT-Pane + HT_View GetHTView() { return m_ToolbarView; } // Returns the HT-View for this toolbar. + void SetHTView(HT_View v) { m_ToolbarView = v; } void SetDragFraction(int i) { m_iDragFraction = i; } int GetDragFraction() { return m_iDragFraction; } @@ -218,6 +274,34 @@ public: void SetDragButton(CRDFToolbarButton* pButton) { m_pDragButton = pButton; } CRDFToolbarButton* GetDragButton() { return m_pDragButton; } + void SetRowHeight(int i) { m_nRowHeight = i; } + int GetRowHeight() { return m_nRowHeight; } + + // Color/background customizability stuff + + COLORREF GetBackgroundColor() { return m_BackgroundColor; } + COLORREF GetForegroundColor() { return m_ForegroundColor; } + COLORREF GetRolloverColor() { return m_RolloverColor; } + COLORREF GetPressedColor() { return m_PressedColor; } + COLORREF GetDisabledColor() { return m_DisabledColor; } + COLORREF GetShadowColor() { return m_ShadowColor; } + COLORREF GetHighlightColor() { return m_HighlightColor; } + + CRDFImage* GetBackgroundImage() { return m_pBackgroundImage; } + void SetBackgroundColor(COLORREF c) { m_BackgroundColor = c; } + void SetForegroundColor(COLORREF c) { m_ForegroundColor = c; } + void SetRolloverColor(COLORREF c) { m_RolloverColor = c; } + void SetPressedColor(COLORREF c) { m_PressedColor = c; } + void SetDisabledColor(COLORREF c) { m_DisabledColor = c; } + void SetShadowColor(COLORREF c) { m_ShadowColor = c; } + void SetHighlightColor(COLORREF c) { m_HighlightColor = c; } + + void SetBackgroundImage(CRDFImage* p) { m_pBackgroundImage = p; } + + void LoadComplete(HT_Resource r) { Invalidate(); } + + void ChangeButtonSizes(void); // Overridden to prevent separators and url bars from changing size. + protected: // Helper function used in conjunction with LayoutButtons void ComputeLayoutInfo(CRDFToolbarButton* pButton, int numChars, int rowWidth, int& usedSpace); @@ -226,11 +310,48 @@ protected: //{{AFX_MSG(CRDFToolbar) afx_msg void OnRButtonDown(UINT nFlags, CPoint point); afx_msg BOOL OnCommand( WPARAM wParam, LPARAM lParam ); + afx_msg void OnPaint(void); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; +class CRDFDragToolbar : public CDragToolbar +{ +public: + + // Generated message map functions + //{{AFX_MSG(CDragToolbar) + afx_msg void OnPaint(void); + //}}AFX_MSG + + DECLARE_MESSAGE_MAP() +}; + +class CRDFToolbarHolder : public CCustToolbar +{ +protected: + HT_Pane m_ToolbarPane; + CFrameWnd* m_pCachedParentWindow; + CRDFToolbarButton* m_pCurrentButton; + +public: + CRDFToolbarHolder(int maxToolbars, CFrameWnd* pParent); + virtual ~CRDFToolbarHolder(); + + CRDFToolbarButton* GetCurrentButton() { return m_pCurrentButton; } + void SetCurrentButton(CRDFToolbarButton* button) { m_pCurrentButton = button; } + + HT_Pane GetHTPane() { return m_ToolbarPane; } + void SetHTPane(HT_Pane p) { m_ToolbarPane = p; } + CFrameWnd* GetCachedParentWindow() { return m_pCachedParentWindow; } + void InitializeRDFData(); + + virtual CDragToolbar* CreateDragBar() + { + return new CRDFDragToolbar(); + } +}; #endif