<?xml version="1.0"?> 
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
<?xml-stylesheet href="chrome://navigator/skin/" type="text/css"?> 
<?xml-stylesheet href="chrome://editor/skin/" type="text/css"?> 

<!DOCTYPE window
[

<!-- These entity declarations will go into a separate, locale file at some point -->
<!-- Window title -->
<!ENTITY editorWindow.title "Editor">

<!-- Menu items:  the . means that the menu item isn't implemented yet -->

<!-- File menu items -->
<!ENTITY fileMenu.label "File">
<!ENTITY newCmd.label ".New Window">

]> 

<window id="main-window" xmlns:html="http://www.w3.org/TR/REC-html40"
			  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
			  onunload="EditorShutdown()" title="Editor">

  <html:script language="JavaScript" src="chrome://editor/content/EditorCommands.js">
  </html:script>

  <broadcaster id="args" value="chrome://editor/content/EditorInitPage.html"/>
  <broadcaster id="canPrint"/>
  
  <!-- Interim hack to transition from nsIXULWindowCallbacks/ShowWindowWithArgs -->
  <broadcaster id="dialog.start" ready="false"/>
  <observes element="dialog.start" attribute="ready" onchange="EditorStartup('html')"/>
    
  <menubar>
    <menu name="File">
      <menuitem name="New" onclick="EditorNew()"/>
      <menuitem name="Open..." onclick="EditorOpen()"/>
      <menuitem name=".Close" onclick="EditorClose()"/>
      <separator />
      <menuitem name="Save" onclick="EditorSave()"/>
      <menuitem name="Save As..." onclick="EditorSaveAs()"/>
      <separator />
      <menuitem name=".Print Setup..." onclick=""/>
      <menuitem name="Print Preview" onclick="EditorPrintPreview()"/>
      <menuitem name=".Print..." onclick="EditorPrint()"/>
      <separator />
      <menuitem name="Quit" onclick="EditorExit()"/>
    </menu>

    <menu name="Edit">
      <menuitem name="Undo" onclick="EditorUndo()"/>
      <menuitem name="Redo" onclick="EditorRedo()"/>
      <separator />
      <menuitem name="Cut" onclick="EditorCut()"/>
      <menuitem name="Copy" onclick="EditorCopy()"/>
      <menuitem name="Paste" onclick="EditorPaste()"/>
      <menuitem name="Paste as Quotation" onclick="EditorPasteAsQuotation()"/>
      <menuitem name=".Clear" onclick=""/>
      <separator />
      <menuitem name="Select All" onclick="EditorSelectAll()"/>
      <separator />
      <menuitem name="Find..." onclick="EditorFind()"/>
      <menuitem name="Find Again" onclick="EditorFindNext()"/>
    </menu>

    <menu name="View">
      <menuitem name=".Hide Composition Toolbar" onclick=""/>
      <menuitem name=".Hide Format Toolbar" onclick="" />
    </menu>
 
    <menu name="Insert">
      <menuitem name="Link..." onclick="EditorInsertLink()"/>
      <menuitem name=".Target..." onclick=""/>
      <menuitem name="Image..." onclick="EditorInsertImage()"/>
      <menuitem name="Horizontal Line" onclick="EditorInsertHLine()"/>
      <menuitem name=".Table" onclick=""/>
      <menuitem name=".HTML Tag..." onclick=""/>
      <separator />
      <menuitem name=".Line Break" onclick=""/>
      <menuitem name=".Break Below Image(s)" onclick=""/>
    </menu>
    <menu name="Format">
      <menu name="Font Face">
        <menuitem name="Default Variable Width" onclick="EditorSetFontFace('')"/>
        <menuitem name="Default Fixed Width" onclick="EditorSetFontFace('tt')"/>
        <separator/>
        <menuitem name="Arial, Helvetica" onclick="EditorSetFontFace('Arial, Helvetica, sans-serif')"/>
        <menuitem name="Times" onclick="EditorSetFontFace('Times New Roman, Times, serif')"/>
        <menuitem name="Courier" onclick="EditorSetFontFace('Courier New, Courier, mono')"/>
      </menu>
      <menu name="Size">
        <menuitem name="-4" onclick="EditorSetFontSize('-4')"/>
        <menuitem name="-3" onclick="EditorSetFontSize('-3')"/>
        <menuitem name="-2" onclick="EditorSetFontSize('-2')"/>
        <menuitem name="-1 (smaller)" onclick="EditorSetFontSize('-1')"/>
        <menuitem name="Normal" onclick="EditorSetFontSize('0')"/>
        <menuitem name="+1 (bigger)" onclick="EditorSetFontSize('+1')"/>
        <menuitem name="+2" onclick="EditorSetFontSize('+2')"/>
        <menuitem name="+3" onclick="EditorSetFontSize('+3')"/>
        <menuitem name="+4" onclick="EditorSetFontSize('+4')"/>
      </menu>
      <menu name="Style">
        <menuitem name="Bold" onclick="EditorApplyStyle('b')"/>
        <menuitem name="Italic" onclick="EditorApplyStyle('i')"/>
        <menuitem name="Underline" onclick="EditorApplyStyle('u')"/>
        <menuitem name="Strikethrough" onclick="EditorApplyStyle('strike')"/>
        <menuitem name="Superscript" onclick="EditorApplyStyle('sup')"/>
        <menuitem name="Subscript" onclick="EditorApplyStyle('sub')"/>
        <menuitem name="Blink" onclick="EditorApplyStyle('blink')"/>
        <menuitem name="Nonbreaking" onclick="EditorApplyStyle('nobr')"/>
      </menu>
      <menu name="Text Color">
        <menuitem name="Black" onclick="EditorSetFontColor('black')"/>
        <menuitem name="Gray" onclick="EditorSetFontColor('gray')"/>
        <menuitem name="Silver" onclick="EditorSetFontColor('silver')"/>
        <menuitem name="White" onclick="EditorSetFontColor('white')"/>
        <menuitem name="Red" onclick="EditorSetFontColor('red')"/>
        <menuitem name="Blue" onclick="EditorSetFontColor('blue')"/>
        <menuitem name="Green" onclick="EditorSetFontColor('green')"/>
        <menuitem name="Cyan" onclick="EditorSetFontColor('cyan')"/>
        <menuitem name="Yellow" onclick="EditorSetFontColor('yellow')"/>
        <menuitem name="Magenta" onclick="EditorSetFontColor('magenta')"/>
      </menu>
      <menu name="Background Color">
        <menuitem name="Black" onclick="EditorSetBackgroundColor('black')"/>
        <menuitem name="Gray" onclick="EditorSetBackgroundColor('gray')"/>
        <menuitem name="Silver" onclick="EditorSetBackgroundColor('silver')"/>
        <menuitem name="White" onclick="EditorSetBackgroundColor('white')"/>
        <menuitem name="Red" onclick="EditorSetBackgroundColor('red')"/>
        <menuitem name="Blue" onclick="EditorSetBackgroundColor('blue')"/>
        <menuitem name="Green" onclick="EditorSetBackgroundColor('green')"/>
        <menuitem name="Cyan" onclick="EditorSetBackgroundColor('cyan')"/>
        <menuitem name="Yellow" onclick="EditorSetBackgroundColor('yellow')"/>
        <menuitem name="Magenta" onclick="EditorSetBackgroundColor('magenta')"/>
      </menu>
      <menuitem name="Remove All Style(s)" onclick="EditorRemoveStyle('all')"/>
      <menuitem name="Remove Link(s)" onclick="EditorRemoveLinks()"/>
      <separator />
      <menu name="Heading">
        <menuitem name="Normal"    onclick="EditorSetParagraphFormat('normal')"/>
        <menuitem name="Heading 1" onclick="EditorSetParagraphFormat('h1')"/>
        <menuitem name="Heading 2" onclick="EditorSetParagraphFormat('h2')"/>
        <menuitem name="Heading 3" onclick="EditorSetParagraphFormat('h3')"/>
        <menuitem name="Heading 4" onclick="EditorSetParagraphFormat('h4')"/>
        <menuitem name="Heading 5" onclick="EditorSetParagraphFormat('h5')"/>
        <menuitem name="Heading 6" onclick="EditorSetParagraphFormat('h6')"/>
      </menu>
      <menu name="Paragraph">
        <menuitem name="Normal"                 onclick="EditorSetParagraphFormat('normal')"/>
        <menuitem name="Blockquote"             onclick="EditorSetParagraphFormat('blockquote')"/>
        <menuitem name="Address"                onclick="EditorSetParagraphFormat('address')"/>
        <menuitem name="Preformat"              onclick="EditorSetParagraphFormat('pre')"/>
        <menuitem name="List item"              onclick="EditorSetParagraphFormat('li')"/>
        <menuitem name="Definition term"        onclick="EditorSetParagraphFormat('dt')"/>
        <menuitem name="Definition description" onclick="EditorSetParagraphFormat('dd')"/>
      </menu>
    </menu>
    <menu name="Tools">
      <menuitem name="New Browser Window" onclick="EditorNewBrowser()"/>
      <menuitem name="New Plaintext Editor" onclick="EditorNewPlaintext()"/>
      <separator />
      <menuitem name="Spell Check" onclick="CheckSpelling()"/>
      <menuitem name="Set Focus" onclick="window.focus()"/>
    </menu>
    <menu name="Debug">
      <menuitem name="Output Text" onclick="EditorGetText()"/>
      <menuitem name="Output HTML" onclick="EditorGetHTML()"/>
      <separator />
      <menuitem name="Insert Text" onclick="EditorInsertText()"/>
      <separator />
      <menuitem name="Test Selection" onclick="EditorTestSelection()"/>
      <menuitem name="Test Document" onclick="EditorTestDocument()"/>
      <menuitem name="Run Unit Tests" onclick="EditorUnitTests()"/>
      <separator />
      <menuitem name="Start Log" onclick="EditorStartLog()"/>
      <menuitem name="Stop Log" onclick="EditorStopLog()"/>
      <menuitem name="Run Log" onclick="EditorRunLog()"/>
    </menu>
    <menu name="Help">
      <menuitem name=".About" onclick=""/>
    </menu>
  </menubar>
  
  <broadcaster id="Editor:Style:IsBold" bold="false"/>
  <broadcaster id="Editor:Style:IsItalic"/>
  <broadcaster id="Editor:Style:IsUnderline"/>

  <box id="outer-box" align="vertical">
    <toolbox>
      <toolbar>
		    <titledbutton id="ParagraphPopup" value="Paragraph" class="popup" align="left" popup="ParagraphMenu"/>
		    <titledbutton id="FontFacePopup" value="Font" class="popup" align="left" popup="FontFaceMenu"/>
		    <titledbutton id="FontSizePopup" value="Size" class="popup" align="left" popup="FontSizeMenu"/>
		    <titledbutton id="TextColorPopup" src="chrome://editor/skin/images/ED_TextColor.gif" class="popup" popup="TextColorMenu"/>
		    <titledbutton id="BackColorPopup" src="chrome://editor/skin/images/ED_BackColor.gif" class="popup" popup="BackColorMenu"/>
        <titledbutton id="BoldButton" src="chrome://editor/skin/images/ED_Bold.gif" align="bottom" onclick="EditorApplyStyle('b')">
		      <observes element="Editor:Style:IsBold" attribute="bold" onchange="onBoldChange()"/>
        </titledbutton>
	      <titledbutton src="chrome://editor/skin/images/ED_Italic.gif" align="bottom" onclick="EditorApplyStyle('i')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Underline.gif" align="bottom" onclick="EditorApplyStyle('u')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_ClearStyle.gif" align="bottom" onclick="EditorRemoveStyle('all')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Bullets.gif" align="bottom" onclick="EditorInsertList('ul')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Numbers.gif" align="bottom" onclick="EditorInsertList('ol')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Outdent.gif" align="bottom" onclick="EditorIndent('outdent')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Indent.gif" align="bottom" onclick="EditorIndent('indent')"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Align.gif" align="bottom" class="popup" popup="AlignmentMenu"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Link.gif" align="bottom" onclick="EditorInsertLink()"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Image.gif" align="bottom" onclick= "EditorInsertImage()"/>
	      <titledbutton src="chrome://editor/skin/images/ED_HLine.gif" align="bottom" onclick= "EditorInsertHLine()"/>
	      <titledbutton src="chrome://editor/skin/images/ED_Spell.gif" align="bottom" class="popup" onclick="CheckSpelling()"/>
      </toolbar>
    </toolbox>

    <html:iframe type="content" id="content-frame" src="about:blank" flex="100%"/>

    <!-- Ripped off from navigator.xul; this should be a XUL fragment! -->
    <box align="horizontal" id="status-bar">
      <titledbutton value="[Notification Component]" onclick="doTests()"/>
	    <box align="vertical" style="width:100px">
		    <spring flex="100%"/>
		    <progressmeter mode="normal" value="0">
		    </progressmeter>
		    <spring flex="100%"/>
  	  </box>
      <titledbutton id="statusText" align="right" flex="100%" value="Document: Done" style="font-family:sans-serif;font-size:2.5mm">
	    </titledbutton>
    </box>
  </box>

<!-- Popup Menus and Windows - Not displayed in primary chrome -->
<popup id="ParagraphMenu">
  <menu>
    <menuitem name="Normal"    onclick="EditorSetParagraphFormat('normal')"/>
    <menuitem name="Heading 1" onclick="EditorSetParagraphFormat('h1')"/>
    <menuitem name="Heading 2" onclick="EditorSetParagraphFormat('h2')"/>
    <menuitem name="Heading 3" onclick="EditorSetParagraphFormat('h3')"/>
    <menuitem name="Heading 4" onclick="EditorSetParagraphFormat('h4')"/>
    <menuitem name="Heading 5" onclick="EditorSetParagraphFormat('h5')"/>
    <menuitem name="Heading 6" onclick="EditorSetParagraphFormat('h6')"/>
    <menuitem name="Address"   onclick="EditorSetParagraphFormat('address')"/>
    <menuitem name="Preformat" onclick="EditorSetParagraphFormat('pre')"/>
    <menuitem name="List item" onclick="EditorSetParagraphFormat('li')"/>
    <menuitem name="Definition term" onclick="EditorSetParagraphFormat('dt')"/>
    <menuitem name="Definition description" onclick="EditorSetParagraphFormat('dd')"/>
  </menu>
</popup>

<popup id="FontFaceMenu">
  <menu>
    <menuitem name="Default Variable Width" onclick="EditorSetFontFace('')"/>
    <menuitem name="Default Fixed Width" onclick="EditorSetFontFace('tt')"/>
    <separator/>
    <menuitem name="Arial, Helvetica" onclick="EditorSetFontFace('Arial, Helvetica, sans-serif')"/>
    <menuitem name="Times" onclick="EditorSetFontFace('Times New Roman, Times, serif')"/>
    <menuitem name="Courier" onclick="EditorSetFontFace('Courier New, Courier, mono')"/>
  </menu>
</popup>

<popup id="FontSizeMenu">
  <menu>
    <menuitem name="-4" onclick="EditorSetFontSize('-4')"/>
    <menuitem name="-3" onclick="EditorSetFontSize('-3')"/>
    <menuitem name="-2" onclick="EditorSetFontSize('-2')"/>
    <menuitem name="-1 (smaller)" onclick="EditorSetFontSize('-1')"/>
    <menuitem name="Normal" onclick="EditorSetFontSize('0')"/>
    <menuitem name="+1 (bigger)" onclick="EditorSetFontSize('+1')"/>
    <menuitem name="+2" onclick="EditorSetFontSize('+2')"/>
    <menuitem name="+3" onclick="EditorSetFontSize('+3')"/>
    <menuitem name="+4" onclick="EditorSetFontSize('+4')"/>
  </menu>
</popup>

<popup id="BackColorMenu">
  <menu>
    <menuitem name="Black" onclick="EditorSetBackgroundColor('black')"/>
    <menuitem name="Gray" onclick="EditorSetBackgroundColor('gray')"/>
    <menuitem name="Silver" onclick="EditorSetBackgroundColor('silver')"/>
    <menuitem name="White" onclick="EditorSetBackgroundColor('white')"/>
    <menuitem name="Red" onclick="EditorSetBackgroundColor('red')"/>
    <menuitem name="Blue" onclick="EditorSetBackgroundColor('blue')"/>
    <menuitem name="Green" onclick="EditorSetBackgroundColor('green')"/>
    <menuitem name="Cyan" onclick="EditorSetBackgroundColor('cyan')"/>
    <menuitem name="Yellow" onclick="EditorSetBackgroundColor('yellow')"/>
    <menuitem name="Magenta" onclick="EditorSetBackgroundColor('magenta')"/>
  </menu>
</popup>

<popup id="TextColorMenu">
  <menu>
    <menuitem name="Black" onclick="EditorSetFontColor('black')"/>
    <menuitem name="Gray" onclick="EditorSetFontColor('gray')"/>
    <menuitem name="Silver" onclick="EditorSetFontColor('silver')"/>
    <menuitem name="White" onclick="EditorSetFontColor('white')"/>
    <menuitem name="Red" onclick="EditorSetFontColor('red')"/>
    <menuitem name="Blue" onclick="EditorSetFontColor('blue')"/>
    <menuitem name="Green" onclick="EditorSetFontColor('green')"/>
    <menuitem name="Cyan" onclick="EditorSetFontColor('cyan')"/>
    <menuitem name="Yellow" onclick="EditorSetFontColor('yellow')"/>
    <menuitem name="Magenta" onclick="EditorSetFontColor('magenta')"/>
  </menu>
</popup>

<popup id="AlignmentMenu">
  <menu>
    <menuitem name="Left" onclick="EditorAlign('left')"/>
    <menuitem name="Center" onclick="EditorAlign('center')"/>
    <menuitem name="Right" onclick="EditorAlign('right')"/>
    <menuitem name="Justified" onclick="EditorAlign('justify')"/>
  </menu>
</popup>


//-- Bug? If any other popups placed after this, they don't get used
<popup id="FontFaceWindow">
   <window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" width="40" height="40">
     <titledbutton value="Default Variable Width" onclick="opener.EditorSetFontFace(''); window.close();"/>
     <titledbutton value="Default Fixed Width"    onclick="opener.EditorSetFontFace('tt'); window.close();"/>
     <titledbutton value="Arial, Helvetica"       onclick="opener.EditorSetFontFace('Arial, Helvetica, sans-serif'); window.close();"/>
     <titledbutton value="Times"                  onclick="opener.EditorSetFontFace('Times New Roman, Times, serif'); window.close();"/>
     <titledbutton value="Courier"                onclick="opener.EditorSetFontFace('Courier New, Courier, mono'); window.close();"/>
   </window>
</popup>

</window>
