Register to post in forums, or Log in to your existing account
 

Related Links:
  Pre-defined Actions
Editor Demo [[EditorDemo]] 
This is an powerful text editor written using zApp. It supports full rich text editing, and includes import and export of HTML. The integrated as-you-type spellchecker flags unknown works with the familiar red squiggle and provides a right-click context menu for making corrections. Full HTML table support is also implemented with full border and color control. Finally, images of many different formats can be inserted into the document.

This application also handles editing multiple files at once, creating a tab for each file, which changes color as the file is edited.

This demonstration of zApp illustrates the power of many of it's visual components, from the text edit control, to the menu and toolbar controls. Very little code is needed to implement a very powerful application. It also demonstrates how to create new controls on-the-fly in your script, as new tabs and edit boxes are created dynamically for each file that is loaded.

Here is the zApp XML source code for this application:
Code:
<?xml version='1.0' encoding='ISO-8859-1' ?>
<!DOCTYPE zapp [
  <!ENTITY AppTitle "zApp Demo: Text Editor">
  <!ENTITY AppAuthor "Zugg Software">
  <!ENTITY AppVersion "1.0">
  <!ENTITY AppURL "http://www.zuggsoft.com/">
  <!ENTITY AppImage "ZAPP">
  <!ENTITY AboutBox SYSTEM "aboutbox.xml">
  ]>
<zapp>
  <splash color='#C4D2ED'>
    <image image='zapp' deltaleft='8' deltatop='8'/>
    <label align='Client' bevelouter='Lowered' autoleft='true' deltaleft='8' width='-8' height='-8' gradienttype='FullVertical' color='#C4D2ED' colorto='#7E98CB'><![CDATA[<b>&AppTitle;</b><br><br>
Version &AppVersion;<br><br>
by &AppAuthor;]]></label>
  </splash>
  <action name='MemoNew' action='_MemoNew'>
    MemoNew.Format = "Text"
    NewTab
    MemoNew.Target = CurrentMemo.Name
  </action>
  <action name='MemoOpen' action='_MemoOpen'>
    NewTab
    MemoOpen.Target = CurrentMemo.Name
  </action>
  <toolbar name='mainmenu' Fullsize='true'>
    <menu caption='&amp;File'>
      <item action='MemoNew'/>
      <item action='MemoOpen'/>
      <itemsep/>
      <item action='_MemoSave'/>
      <item action='_MemoSaveAs'/>
      <item action='_MemoExport'/>
      <itemsep/>
      <item action='_MemoPageSetup'/>
      <item action='_MemoPrintPreview'/>
      <item action='_MemoPrint'/>
      <itemsep/>
      <item action='_FileExit'/>
    </menu>
    <menu caption='&amp;Edit'>
      <item action='_MemoUndo'/>
      <item action='_MemoRedo'/>
      <itemsep/>
      <item action='_EditCut'/>
      <item action='_EditCopy'/>
      <item action='_EditPaste'/>
      <item action='_MemoPasteSpecial'/>
      <itemsep/>
      <item action='_MemoFind'/>
      <item action='_MemoFindNext'/>
      <item action='_MemoReplace'/>
      <itemsep/>
      <item action='_MemoCharCase'/>
      <item action='_MemoInsertPagebreak'/>
      <item action='_MemoRemovePagebreak'/>
      <itemsep/>
      <item action='_EditSpellCheck'/>
      <item action='_MemoThesaurus'/>
      <itemsep/>
      <item action='_EditSelectAll'/>
    </menu>
    <menu caption='&amp;Font'>
      <item action='_MemoFont'/>
      <itemsep/>
      <item action='_MemoBold'/>
      <item action='_MemoItalic'/>
      <item action='_MemoUnderline'/>
      <item action='_MemoStrikeOut'/>
      <itemsep/>
      <item action='_MemoFontColor'/>
      <item action='_MemoFontBackColor'/>
    </menu>
    <menu caption='&amp;Paragraph'>
      <item action='_MemoParagraph'/>
      <item action='_MemoBorder'/>
      <itemsep/>
      <item action='_MemoAlignLeft'/>
      <item action='_MemoAlignCenter'/>
      <item action='_MemoAlignRight'/>
      <item action='_MemoAlignJustify'/>
      <itemsep/>
      <item action='_MemoList'/>
      <item action='_MemoBulletList'/>
      <item action='_MemoNumberList'/>
      <itemsep/>
      <item action='_MemoWordwrap'/>
      <itemsep/>
      <item action='_MemoIndent'/>
      <item action='_MemoUnIndent'/>
      <itemsep/>
      <item action='_MemoSinglespace'/>
      <item action='_MemoDoublespace'/>
      <itemsep/>
      <item action='_MemoParagraphColor'/>
    </menu>
    <menu caption='&amp;View'>
      <item caption='Normal' script='core.themeindex = -1'/>
      <item caption='Standard' script='core.theme = "standard"'/>
      <item caption='Flat' script='core.theme = "flat"'/>
      <item caption='UltraFlat' script='core.theme = "ultraflat"'/>
      <item caption='Office11' script='core.theme = "office11"'/>
      <item caption='Aqua' script='core.theme = "aqua"'/>
      <item caption='Watercolor' script='core.theme = "watercolor"'/>
      <item caption='Plex' script='core.theme = "plex"'/>
      <item action='_ThemeSelect'/>
      <itemsep/>
      <item action='_MemoBackground'/>
      <item action='_MemoColor'/>
      <itemsep/>
      <item action='_MemoShowSpecial'/>
      <item action='_MemoShowTemplate'/>
      <itemsep/>
      <item action='_MemoFillColor'/>
      <item action='_MemoProperties'/>
    </menu>
    <menu caption='&amp;Insert'>
      <item action='_MemoInsertFile'/>
      <item action='_MemoInsertPicture'/>
      <item action='_MemoInsertHRule'/>
      <item action='_MemoInsertHyperlink'/>
      <item action='_MemoInsertSymbol'/>
      <item action='_MemoInsertTemplate'/>
    </menu>
    <menu caption='&amp;Table'>
      <item action='_MemoInsertTable'/>
      <itemsep/>
      <item action='_TableInsertLeft'/>
      <item action='_TableInsertRight'/>
      <item action='_TableInsertAbove'/>
      <item action='_TableInsertBelow'/>
      <itemsep/>
      <item action='_TableDeleteRow'/>
      <item action='_TableDeleteCol'/>
      <item action='_TableDelete'/>
      <itemsep/>
      <menu caption='Select'>
        <item action='_TableSelect'/>
        <item action='_TableSelectCol'/>
        <item action='_TableSelectRow'/>
        <item action='_TableSelectCell'/>
      </menu>
      <menu caption='Align'>
        <item action='_TableCellVAlignTop'/>
        <item action='_TableCellVAlignMiddle'/>
        <item action='_TableCellVAlignBottom'/>
        <item action='_TableCellVAlignDefault'/>
      </menu>
      <menu caption='Cell Borders'>
        <item action='_TableCellNoBorders'/>
        <item action='_TableCellAllBorders'/>
        <itemsep/>
        <item action='_TableCellLeftBorder'/>
        <item action='_TableCellRightBorder'/>
        <item action='_TableCellTopBorder'/>
        <item action='_TableCellBottomBorder'/>
      </menu>
      <itemsep/>
      <item action='_TableSplitCells'/>
      <item action='_TableMergeCells'/>
      <itemsep/>
      <item action='_TableGrid'/>
      <item action='_TableProperties'/>
    </menu>
    <menu caption='&amp;Help'>
      <item caption='&amp;About' script='core.execwindow( "About")'/>
    </menu>
  </toolbar>
  <toolbar name='maintoolbar'>
    <item action='MemoOpen'/>
    <item action='_MemoSave'/>
    <item action='_MemoQuickPrint'/>
    <itemsep/>
    <combo.fonts hint='Select font' caption='Font'/>
    <itemsep blank='true'/>
    <spinedit action='_FontSize' caption='Text Size'/>
    <itemsep/>
    <colorbtn action='_MemoFontColor'/>
    <colorbtn action='_MemoFontBackColor'/>
    <itemsep/>
    <item action='_MemoBold'/>
    <item action='_MemoItalic'/>
    <item action='_MemoUnderline'/>
    <item action='_MemoStrikeOut'/>
    <itemsep/>
    <item action='_MemoAlignLeft'/>
    <item action='_MemoAlignCenter'/>
    <item action='_MemoAlignRight'/>
    <itemsep/>
    <item action='_MemoBulletList'/>
    <item action='_MemoNumberList'/>
    <item action='_MemoInsertPicture'/>
    <item action='_EditAutoSpell'/>
  </toolbar>
  <window name='main' caption='Editor Demo' width="640" height="480" focus='Memo'>
    <toolbar name='mainmenu'/>
    <toolbar name='maintoolbar' row='1'/>
    <ruler align='top'/>
    <var name='OnChange'>
      EditPages.ActivePage.Color = "mistyrose"
    </var>
    <var name='OnFileChange'>
      if not(IsNull(zEvent.Sender.Tab)) then
        zEvent.Sender.Tab.Caption = str.ExtractFilename( zEvent.Filename)
        zEvent.Sender.Tab.Color = "Window"
      end if
    </var>
    <script>
      TabNum = 0
      sub NewTab
        TabNum = TabNum + 1
        Set CurrentTab = core.AddControl( "tab", "tab" &amp; TabNum, "EditPages")
        Set CurrentMemo = core.AddControl( "memo", "memo" &amp; TabNum, "tab" &amp; TabNum)
        CurrentMemo.Align = "client"
        CurrentMemo.Spellcheck = true
        CurrentMemo.ConfirmSave = true
        CurrentMemo.OnChange = OnChange.Value
        CurrentMemo.OnFileChange = OnFileChange.Value
        CurrentTab.Caption = "untitled" &amp; TabNum
        EditPages.ActivePageName = CurrentTab.Name
      end sub
    </script>
    <pages name='EditPages' align='client' showclosebutton='true' events='true'>
      <tab name='MainTab' caption='untitled'>
        <memo name='Memo' align='client' fontname='Arial' fontsize='12' spellcheck='true' confirmsave='true'
          onChange='=OnChange' onFileChange='=OnFileChange' datasource='DBSource'/>
      </tab>
    </pages>
    <script>
      Set CurrentMemo = core.FindControl("Memo")
      if (core.OptionCount > 0) then
        fName = core.OptionValue(1)
        CurrentMemo.LoadFromFile fName
        MainTab.caption = fName
      end if
    </script>
    <statusbar name='Status'/>
  </window>
  &AboutBox;
</zapp>

As you can see, most of the code consists of assigning pre-defined system actions to menu and toolbar buttons. The rest of the code deals with creating the new tab and edit control for each new file that is opened.
Viewer Comments [0 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net