added style menu
git-svn-id: svn://10.0.0.236/trunk@18435 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
05710ba81b
commit
2f236a6ccc
@ -387,12 +387,18 @@ HandleLocationEvent(nsGUIEvent *aEvent)
|
||||
nsEventStatus
|
||||
nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
|
||||
{
|
||||
nsEventStatus result;
|
||||
#ifdef NS_DEBUG
|
||||
nsEventStatus result = DispatchDebugMenu(aID);
|
||||
result = DispatchDebugMenu(aID);
|
||||
if (nsEventStatus_eIgnore != result) {
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
result = DispatchStyleMenu(aID);
|
||||
if (nsEventStatus_eIgnore != result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (aID) {
|
||||
case VIEWER_EXIT:
|
||||
mApp->Exit();
|
||||
@ -2822,16 +2828,6 @@ nsBrowserWindow::DoToggleSelection()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserWindow::SetCompatibilityMode(PRBool aIsStandard)
|
||||
{
|
||||
if (nsnull != mPrefs) {
|
||||
int32 prefInt = (aIsStandard) ? eCompatibility_Standard : eCompatibility_NavQuirks;
|
||||
mPrefs->SetIntPref("nglayout.compatibility.mode", prefInt);
|
||||
mPrefs->SavePrefFile();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsBrowserWindow::DoDebugRobot()
|
||||
{
|
||||
@ -2928,17 +2924,121 @@ nsBrowserWindow::DispatchDebugMenu(PRInt32 aID)
|
||||
case VIEWER_TOP100:
|
||||
DoSiteWalker();
|
||||
break;
|
||||
|
||||
case VIEWER_NAV_QUIRKS_MODE:
|
||||
case VIEWER_STANDARD_MODE:
|
||||
SetCompatibilityMode(VIEWER_STANDARD_MODE == aID);
|
||||
break;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
#endif // NS_DEBUG
|
||||
|
||||
void
|
||||
nsBrowserWindow::SetCompatibilityMode(PRBool aIsStandard)
|
||||
{
|
||||
if (nsnull != mPrefs) {
|
||||
int32 prefInt = (aIsStandard) ? eCompatibility_Standard : eCompatibility_NavQuirks;
|
||||
mPrefs->SetIntPref("nglayout.compatibility.mode", prefInt);
|
||||
mPrefs->SavePrefFile();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsEventStatus
|
||||
nsBrowserWindow::DispatchStyleMenu(PRInt32 aID)
|
||||
{
|
||||
nsEventStatus result = nsEventStatus_eIgnore;
|
||||
|
||||
switch(aID) {
|
||||
case VIEWER_SELECT_STYLE_LIST:
|
||||
{
|
||||
nsIPresShell* shell = GetPresShell();
|
||||
if (nsnull != shell) {
|
||||
nsAutoString defaultStyle;
|
||||
nsIDocument* doc = shell->GetDocument();
|
||||
if (nsnull != doc) {
|
||||
nsIAtom* defStyleAtom = NS_NewAtom("DEFAULT-STYLE");
|
||||
doc->GetHeaderData(defStyleAtom, defaultStyle);
|
||||
NS_RELEASE(defStyleAtom);
|
||||
NS_RELEASE(doc);
|
||||
}
|
||||
|
||||
nsStringArray titles;
|
||||
shell->ListAlternateStyleSheets(titles);
|
||||
nsAutoString current;
|
||||
shell->GetActiveAlternateStyleSheet(current);
|
||||
|
||||
PRInt32 count = titles.Count();
|
||||
fprintf(stdout, "There %s %d alternate style sheet%s\n",
|
||||
((1 == count) ? "is" : "are"),
|
||||
count,
|
||||
((1 == count) ? "" : "s"));
|
||||
PRInt32 index;
|
||||
for (index = 0; index < count; index++) {
|
||||
fprintf(stdout, "%d: \"", index + 1);
|
||||
nsAutoString title;
|
||||
titles.StringAt(index, title);
|
||||
fputs(title, stdout);
|
||||
fprintf(stdout, "\" %s%s\n",
|
||||
((title.EqualsIgnoreCase(current)) ? "<< current " : ""),
|
||||
((title.EqualsIgnoreCase(defaultStyle)) ? "** default" : ""));
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
|
||||
case VIEWER_SELECT_STYLE_DEFAULT:
|
||||
{
|
||||
nsIPresShell* shell = GetPresShell();
|
||||
if (nsnull != shell) {
|
||||
nsIDocument* doc = shell->GetDocument();
|
||||
if (nsnull != doc) {
|
||||
nsAutoString defaultStyle;
|
||||
nsIAtom* defStyleAtom = NS_NewAtom("DEFAULT-STYLE");
|
||||
doc->GetHeaderData(defStyleAtom, defaultStyle);
|
||||
NS_RELEASE(defStyleAtom);
|
||||
NS_RELEASE(doc);
|
||||
fputs("Selecting default style sheet \"", stdout);
|
||||
fputs(defaultStyle, stdout);
|
||||
fputs("\"\n", stdout);
|
||||
shell->SelectAlternateStyleSheet(defaultStyle);
|
||||
}
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
|
||||
case VIEWER_SELECT_STYLE_ONE:
|
||||
case VIEWER_SELECT_STYLE_TWO:
|
||||
case VIEWER_SELECT_STYLE_THREE:
|
||||
case VIEWER_SELECT_STYLE_FOUR:
|
||||
{
|
||||
nsIPresShell* shell = GetPresShell();
|
||||
if (nsnull != shell) {
|
||||
nsStringArray titles;
|
||||
shell->ListAlternateStyleSheets(titles);
|
||||
nsAutoString title;
|
||||
titles.StringAt(aID - VIEWER_SELECT_STYLE_ONE, title);
|
||||
fputs("Selecting alternate style sheet \"", stdout);
|
||||
fputs(title, stdout);
|
||||
fputs("\"\n", stdout);
|
||||
shell->SelectAlternateStyleSheet(title);
|
||||
NS_RELEASE(shell);
|
||||
}
|
||||
}
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
|
||||
case VIEWER_NAV_QUIRKS_MODE:
|
||||
case VIEWER_STANDARD_MODE:
|
||||
SetCompatibilityMode(VIEWER_STANDARD_MODE == aID);
|
||||
result = nsEventStatus_eConsumeNoDefault;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
// Factory code for creating nsBrowserWindow's
|
||||
|
||||
@ -171,8 +171,9 @@ public:
|
||||
void DoDebugRobot();
|
||||
void DoSiteWalker();
|
||||
nsEventStatus DispatchDebugMenu(PRInt32 aID);
|
||||
void SetCompatibilityMode(PRBool aIsStandard);
|
||||
#endif
|
||||
nsEventStatus DispatchStyleMenu(PRInt32 aID);
|
||||
void SetCompatibilityMode(PRBool aIsStandard);
|
||||
|
||||
nsEventStatus ProcessDialogEvent(nsGUIEvent *aEvent);
|
||||
|
||||
|
||||
@ -60,6 +60,13 @@
|
||||
#define VIEWER_TABLE_INSPECTOR 40039
|
||||
#define VIEWER_IMAGE_INSPECTOR 40040
|
||||
|
||||
#define VIEWER_SELECT_STYLE_LIST 40500
|
||||
#define VIEWER_SELECT_STYLE_DEFAULT 40501
|
||||
#define VIEWER_SELECT_STYLE_ONE 40502
|
||||
#define VIEWER_SELECT_STYLE_TWO 40503
|
||||
#define VIEWER_SELECT_STYLE_THREE 40504
|
||||
#define VIEWER_SELECT_STYLE_FOUR 40505
|
||||
|
||||
// Note: must be in ascending sequential order
|
||||
#define VIEWER_ONE_COLUMN 40050
|
||||
#define VIEWER_TWO_COLUMN 40051
|
||||
|
||||
@ -89,14 +89,27 @@ VIEWER MENU DISCARDABLE
|
||||
MENUITEM "Debu&g Robot", VIEWER_DEBUGROBOT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Show Content Quality", VIEWER_SHOW_CONTENT_QUALITY
|
||||
MENUITEM SEPARATOR
|
||||
}
|
||||
#endif
|
||||
POPUP "&Style"
|
||||
{
|
||||
POPUP "Select &Style Sheet"
|
||||
{
|
||||
MENUITEM "List Availabe Sheets", VIEWER_SELECT_STYLE_LIST
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select Default", VIEWER_SELECT_STYLE_DEFAULT
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Select Alternate 1", VIEWER_SELECT_STYLE_ONE
|
||||
MENUITEM "Select Alternate 2", VIEWER_SELECT_STYLE_TWO
|
||||
MENUITEM "Select Alternate 3", VIEWER_SELECT_STYLE_THREE
|
||||
MENUITEM "Select Alternate 4", VIEWER_SELECT_STYLE_FOUR
|
||||
}
|
||||
POPUP "&Compatibility Mode Pref"
|
||||
{
|
||||
MENUITEM "Nav Quirks", VIEWER_NAV_QUIRKS_MODE
|
||||
MENUITEM "Standard", VIEWER_STANDARD_MODE
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
POPUP "&Tools"
|
||||
{
|
||||
MENUITEM "&JavaScript Console", JS_CONSOLE
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user