adding show/hide support for interior chrome and menubars

This commit is contained in:
danm%netscape.com 1999-06-10 01:27:47 +00:00
Родитель 44ba94ca11
Коммит ee69d9554d
3 изменённых файлов: 58 добавлений и 19 удалений

Просмотреть файл

@ -92,6 +92,31 @@ BarPropImpl::SetBrowserWindow(nsIBrowserWindow *aBrowser) {
mBrowser = aBrowser;
}
NS_IMETHODIMP
BarPropImpl::GetVisible(PRBool *aVisible, PRUint32 aChromeFlag) {
PRUint32 chromeFlags;
*aVisible = PR_FALSE;
if (mBrowser && NS_SUCCEEDED(mBrowser->GetChrome(chromeFlags))) {
if (chromeFlags & aChromeFlag)
*aVisible = PR_TRUE;
return NS_OK;
}
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
BarPropImpl::SetVisible(PRBool aVisible, PRUint32 aChromeFlag) {
PRUint32 chromeFlags;
if (mBrowser && NS_SUCCEEDED(mBrowser->GetChrome(chromeFlags))) {
if (aVisible)
chromeFlags |= aChromeFlag;
else
chromeFlags &= ~aChromeFlag;
return mBrowser->SetChrome(chromeFlags);
}
return NS_ERROR_FAILURE;
}
//
// MenubarProp class implementation
//
@ -104,16 +129,24 @@ MenubarPropImpl::~MenubarPropImpl() {
NS_IMETHODIMP
MenubarPropImpl::GetVisible(PRBool *aVisible) {
#if 1
return BarPropImpl::GetVisible(aVisible, NS_CHROME_MENU_BAR_ON);
#else
if (mBrowser)
return mBrowser->IsMenuBarVisible(aVisible);
return NS_ERROR_FAILURE;
#endif
}
NS_IMETHODIMP
MenubarPropImpl::SetVisible(PRBool aVisible) {
#if 1
return BarPropImpl::SetVisible(aVisible, NS_CHROME_MENU_BAR_ON);
#else
if (mBrowser)
return mBrowser->ShowMenuBar(aVisible);
return NS_ERROR_FAILURE;
#endif
}
//
@ -128,12 +161,12 @@ ToolbarPropImpl::~ToolbarPropImpl() {
NS_IMETHODIMP
ToolbarPropImpl::GetVisible(PRBool *aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::GetVisible(aVisible, NS_CHROME_TOOL_BAR_ON);
}
NS_IMETHODIMP
ToolbarPropImpl::SetVisible(PRBool aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::SetVisible(aVisible, NS_CHROME_TOOL_BAR_ON);
}
//
@ -148,12 +181,12 @@ LocationbarPropImpl::~LocationbarPropImpl() {
NS_IMETHODIMP
LocationbarPropImpl::GetVisible(PRBool *aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::GetVisible(aVisible, NS_CHROME_LOCATION_BAR_ON);
}
NS_IMETHODIMP
LocationbarPropImpl::SetVisible(PRBool aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::SetVisible(aVisible, NS_CHROME_LOCATION_BAR_ON);
}
//
@ -168,12 +201,12 @@ PersonalbarPropImpl::~PersonalbarPropImpl() {
NS_IMETHODIMP
PersonalbarPropImpl::GetVisible(PRBool *aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::GetVisible(aVisible, NS_CHROME_PERSONAL_TOOLBAR_ON);
}
NS_IMETHODIMP
PersonalbarPropImpl::SetVisible(PRBool aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::SetVisible(aVisible, NS_CHROME_PERSONAL_TOOLBAR_ON);
}
//
@ -188,12 +221,12 @@ StatusbarPropImpl::~StatusbarPropImpl() {
NS_IMETHODIMP
StatusbarPropImpl::GetVisible(PRBool *aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::GetVisible(aVisible, NS_CHROME_STATUS_BAR_ON);
}
NS_IMETHODIMP
StatusbarPropImpl::SetVisible(PRBool aVisible) {
return NS_ERROR_FAILURE;
return BarPropImpl::SetVisible(aVisible, NS_CHROME_STATUS_BAR_ON);
}
//

Просмотреть файл

@ -45,8 +45,8 @@ public:
NS_IMETHOD_(void) SetBrowserWindow(nsIBrowserWindow *aBrowser);
NS_IMETHOD GetVisible(PRBool *aVisible) = 0;
NS_IMETHOD SetVisible(PRBool aVisible) = 0;
NS_IMETHOD GetVisible(PRBool *aVisible, PRUint32 aChromeFlag);
NS_IMETHOD SetVisible(PRBool aVisible, PRUint32 aChromeFlag);
protected:
nsIBrowserWindow* mBrowser;

Просмотреть файл

@ -1969,6 +1969,9 @@ void nsWebShellWindow::ShowAppropriateChrome()
if (NS_FAILED(chromeDoc->GetDocumentElement(getter_AddRefs(rootElement))) || !rootElement)
return;
// special treatment for the menubar
ShowMenuBar(mChromeMask & NS_CHROME_MENU_BAR_ON ? PR_TRUE : PR_FALSE);
// get a list of this document's elements with the chromeclass attribute specified
xulRoot = do_QueryInterface(rootElement);
if (xulRoot) { // todo (maybe) the longer, straight DOM (not RDF) version?
@ -1989,25 +1992,24 @@ void nsWebShellWindow::ShowAppropriateChrome()
// show or hide the element according to its chromeclass and the chromemask
domElement->GetAttribute("chromeclass", chromeClass);
makeChange = PR_FALSE;
if (chromeClass == "menubar") {
if (!(mChromeMask & NS_CHROME_MENU_BAR_ON))
mWindow->ShowMenuBar(PR_FALSE);
if (chromeClass == "toolbar") {
makeChange = PR_TRUE;
flag = mChromeMask & NS_CHROME_TOOL_BAR_ON;
} else if (chromeClass == "location") {
makeChange = PR_TRUE;
flag = mChromeMask & NS_CHROME_LOCATION_BAR_ON;
} else if (chromeClass == "directories") {
makeChange = PR_TRUE;
flag = mChromeMask & NS_CHROME_PERSONAL_TOOLBAR_ON;
} else if (chromeClass == "status") {
makeChange = PR_TRUE;
flag = mChromeMask & NS_CHROME_STATUS_BAR_ON;
} else if (chromeClass == "toolbar") {
makeChange = PR_TRUE;
flag = mChromeMask & NS_CHROME_TOOL_BAR_ON;
}
if (makeChange) {
if (makeChange)
if (flag)
domElement->RemoveAttribute("chromehidden");
else
domElement->SetAttribute("chromehidden", "");
}
domElement->SetAttribute("chromehidden", "T");
}
}
}
@ -2423,6 +2425,10 @@ NS_IMETHODIMP nsWebShellWindow::SetProgress(PRInt32 aProgress, PRInt32 aProgress
NS_IMETHODIMP
nsWebShellWindow::ShowMenuBar(PRBool aShow)
{
if (aShow)
mChromeMask |= NS_CHROME_MENU_BAR_ON;
else
mChromeMask &= ~NS_CHROME_MENU_BAR_ON;
return mWindow->ShowMenuBar(aShow);
}