Theme:
v
Ribbon Example
Other pages of interest:

This page contains an example showing how to use Ribbon©.

It first displays the form which is created with some of its features and then it shows the APL+Win function that allows to create it.

The APL function allowing to create the above APL form is the following:

    ∇ ontop RibbonExample rarg;Z;C;D;minimized;qattop;vpos;tooltipNew;tooltipOpen;tooltipSave;tooltipClose;tooltipPrint;tooltipPaste;body;supertip;E;F;trans;galmenu;galicons;⎕io
[1]   ⎕io←1
[2]   :select rarg
[3]   :case''
[4]       ⍝ Create the main form
[5]       :if 0=⎕nc'ontop' ⋄ ontop←0 ⋄ :endif
[6]       ⎕wself←'ff'⎕wi'*Create' 'Form'('*style'(16×ontop))'*Hide'
[7]       DisplayTopRight 350 600
[8]
[9]       ⍝ Create the RibbonPad object
[10]      ⎕wself←'ff'⎕wi'*.rib.Create' 'LC.Objects.Ribbon.LoaderHookerAttribute'
[11]      ⎕wself←'ff'⎕wi'*.rib.Create' 'LC.Objects.Ribbon.Ribbon'
[12]      Z←⎕wi'imagesdll' 'LC.Objects.Ribbon.DemoImages.dll'
[13]      Z←⎕wi'*Set'('*scale'5)('*where'0 0 161,2⊃⎕wi'*:size')
[14]      Z←⎕wi'*:caption'('LC.Objects.Ribbon.dll v',(⎕wi'*xVersion'),' -- Example')
[15]      Z←⎕wi'*ribbonheight'161
[16]
[17]      Z←⎕wi'*:grid.Create' 'APL.Grid'('*scale'5)('*where'161 0,¯161 0+⎕wi'*:size')
[18]      Z←⎕wi'*:grid.Set'('xRows'100)('xCols'20)
[19]
[20]      tooltipNew←   'New (Ctrl+N)'   '' 'Create a new document.'     '' '' ''
[21]      tooltipOpen←  'Open (Ctrl+O)'  '' 'Open an existing document.' '' '' ''
[22]      tooltipSave←  'Save (Ctrl+S)'  '' 'Save the active document.'  '' '' ''
[23]      tooltipClose← 'Close'          '' 'Close the active document.' '' '' ''
[24]      tooltipPrint← 'Print (Ctrl+P)' '' 'Print the active document.' '' '' ''
[25]      tooltipPaste← 'Paste (Ctrl+V)' 'Press F1 for Help'('Paste the content of the clipboard')'' 'HelpBlue16np.png' ''
[26]
[27]      body←'Insert a SmartArt graphic to visually communicate information.'
[28]      body←body,⎕tclf,⎕tclf,'SmartArt graphics range from '
[29]      body←body,'graphical lists and process diagrams '
[30]      body←body,'to more complex graphics, such as Venn '
[31]      body←body,'and organisation charts.'
[32]      supertip←6⍴⊂''
[33]      supertip[1]←⊂'Insert SmartArt Graphic'
[34]      supertip[2]←⊂'Press F1 for more Help.'
[35]      supertip[3]←⊂body
[36]      supertip[4]←⊂'SmartArt.png'
[37]      supertip[5]←⊂'HelpBlue16np.png'
[38]      supertip[6]←⊂'Yellow'
[39]
[40]      ⎕wi'addthemebutton' '&Theme'
[41]
[42]      ⎕wi'*addmenutab'   '&File'
[43]
[44]      ⎕wi'addmenubutton' '&New'        'NewBlankDocument32np.png'  tooltipNew
[45]      ⎕wi'addmenubutton' '&Open...'    'OpenFileorFolder32np.png'  tooltipOpen
[46]      ⎕wi'addmenubutton' '&Save'       'SaveBlue32np.png'          tooltipSave
[47]      ⎕wi'addmenubutton' '&Save As...' 'SaveAs32np.png'            ''
[48]      ⎕wi'addmenubutton' '&Close'      'CloseFileorFolder32np.png' tooltipClose
[49]      ⎕wi'addmenubutton' '&Print...'   'Printer32np.png'           tooltipPrint
[50]      ⎕wi'addmenubutton' '&Help'       'HelpBlue32np.png'          ''
[51]
[52]      ⎕wi'mrus' 'c:\temp\file1.sf' 'c:\temp\file2.sf'
[53]      ⎕wi'mrutooltips' 'Data file' 'Documentation file'
[54]
[55]      ⎕wi'addtab' '&Home'
[56]      ⎕wi'addtab' '&Insert'
[57]      ⎕wi'addtab' '&Page Layout'
[58]      ⎕wi'addtab' '&References'
[59]      ⎕wi'addtab' '&View'
[60]      ⎕wi'addtab' '&Developer'
[61]
[62]      ⎕wi'ribbonbarminwidth'120
[63]      ⎕wi'addbar' '&Home'   '&Clipboard'     ''1
[64]      ⎕wi'addbar' '&Home'   '&Font'          'vertical'1
[65]      ⎕wi'addbar' '&Home'   '&Borders'       ''1
[66]      ⎕wi'addbar' '&Home'   '&Paragraph'     'vertical'0
[67]      ⎕wi'addbar' '&Home'   '&Search'        ''0
[68]      ⎕wi'addbar' '&Insert' '&Illustrations' ''1
[69]      ⎕wi'addbar' '&Insert' '&Classifications' ''1
[70]
[71]      ⎕wi'addsplitbutton' '&Home' '&Clipboard' ''   '&Paste' 'Paste32np.png' 'Top' tooltipPaste (('Paste'('Paste Option 1' 'Paste Option 2'))'Paste Special')
[72]      ⎕wi'addvcontainer'  '&Home' '&Clipboard' 'V1' '' 1
[73]      ⎕wi'addbutton'      '&Home' '&Clipboard' 'V1' '&Cut'   'Cut16np.png'   '' 'Cut'
[74]      ⎕wi'addbutton'      '&Home' '&Clipboard' 'V1' '&Copy'  'Copy16np.png'  '' 'Copy'
[75]
[76]      ⎕wi'addfontcombos'  '&Home' '&Font' 1 1 138
[77]      ⎕wi'addhcontainer'  '&Home' '&Font' 'H1' 'Top' 0
[78]      ⎕wi'addbutton'      '&Home' '&Font' 'H1' '&Bold'      'Bold.png'          '' 'Bold'
[79]      ⎕wi'addbutton'      '&Home' '&Font' 'H1' '&Italic'    'Italic.png'        '' 'Italic'
[80]      ⎕wi'addbutton'      '&Home' '&Font' 'H1' '&Underline' 'Underline.png'     '' 'Underline'
[81]      ⎕wi'addbutton'      '&Home' '&Font' 'H1' '&Strikeout' 'Strikeout.png'     '' 'StrikeOut'
[82]      ⎕wi'addFontColors'  '&Home' '&Font' 'H1'              'Font-With Color Bar.png'
[83]
[84]      galmenu←⊂'Custom' 'Search for Custom Border...' 'Search216np.png'  ⍝ ELE2feb12 added
[85]      galmenu←galmenu,⊂'Browse' 'Browse for Borders...' 'WorldWideWeb16np.png'  ⍝ ELE2feb12 added
[86]      galmenu←galmenu,⊂'Save' 'Save Current Border...' 'SaveBlue16np.png'  ⍝ ELE2feb12 added
[87]      galicons←'All' 'Bottom' 'DiagonalLeft' 'DiagonalRight' 'DoubleBottom' 'DoubleRight' 'DoubleLeft' 'DoubleOutside' 'DoubleRight' 'DoubleTop'  ⍝ ELE2feb12 added
[88]      galicons←galicons,'Inside' 'InsideHorizontal' 'InsideVertical' 'None' 'Outside' 'Right' 'ThickBottom' 'ThickLeft' 'ThickOutside' 'ThickRight' 'ThickTop'  ⍝ ELE2feb12 added
[89]      galicons←(⊂'Border'),¨galicons,¨⊂'.png'       ⍝ ELE2feb12 added
[90]      ⎕wi'addgallery'     '&Home' '&Borders' '&Borders' galmenu galicons  ⍝ ELE2feb12 added
[91]
[92]      ⎕wi'addsplitbutton' '&Insert' '&Illustrations'  ''     '&Shapes'     'ShapesColored32np.png' '' '' ''
[93]      ⎕wi'addbutton'      '&Insert' '&Illustrations' ''     '&SmartArt'   'Clip Art.png' '' supertip
[94]      ⎕wi'addcalculator'  '&Insert' '&Illustrations' '&Calculator'
[95]
[96]      ⎕wi'addbutton' '&Insert' '&Classifications' '' 'CAH' 'Paste32np.png' '' ''  ⍝ ELE7feb12 added
[97]      ⎕wi'aligninribbonbar' '&Insert' '&Classifications' 'center' ''  ⍝ ELE7feb12 added
[98]
[99]      ⎕wi'addqatbutton'   '&Save' 'SaveBlue16np.png' 'Save'
[100]     ⎕wi'addqatbutton'   '&Undo' 'Undo16np.png'     'Undo'
[101]     ⎕wi'addqatbutton'   '&Redo' 'Redo16np.png'     'Redo'
[102]     ⎕wi'addqatmenubutton' '&About the Ribbon DLL...' 1
[103]
[104]     ⎕wi'xtheme' 'Office2010Silver'
[105]     ⎕wi'xtheme' 0 0 64
[106]
[107] ⍝ Lines below show how you would localize the Ribbon to the French culture!
[108] ⍝   trans←0 2⍴⊂''
[109] ⍝   trans←trans⍪'Exit'                       "&Quitter"
[110] ⍝   trans←trans⍪'MaximizeRibbon'             "&Maximiser le Ruban"
[111] ⍝   trans←trans⍪'MinimizeRibbon'             "Mi&nimiser le Ruban"
[112] ⍝   trans←trans⍪'Options'                    "Opt&ions"
[113] ⍝   trans←trans⍪'QatAddItem'                 "&Ajouter à la Barre d'Accès Rapide"
[114] ⍝   trans←trans⍪'QatCustomizeMenuLabel'      "Personnaliser la Barre d'Accès Rapide"
[115] ⍝   trans←trans⍪'QatCustomizeMenuTooltip'    "Menu: Personnaliser la Barre d'Accès Rapide"
[116] ⍝   trans←trans⍪'QatCustomizeText'           "&Personnaliser la Barre d'Accès Rapide..."
[117] ⍝   trans←trans⍪'QatDialogAddButton'         "&Ajouter >>"
[118] ⍝   trans←trans⍪'QatDialogCancelButton'      "Annuler"
[119] ⍝   trans←trans⍪'QatDialogCaption'           "Personnaliser la Barre d'Accès Rapide"
[120] ⍝   trans←trans⍪'QatDialogCategoriesLabel'   "&Choisissez parmi:"
[121] ⍝   trans←trans⍪'QatDialogOkButton'          "OK"
[122] ⍝   trans←trans⍪'QatDialogPlacementCheckbox' "&Placer la Barre d'Accès Rapide sous le Ruban"
[123] ⍝   trans←trans⍪'QatDialogRemoveButton'      "&Supprimer"
[124] ⍝   trans←trans⍪'QatPlaceAboveRibbon'        "&Placer la Barre d'Accès Rapide au dessus du Ruban"
[125] ⍝   trans←trans⍪'QatPlaceBelowRibbon'        "&Placer la Barre d'Accès Rapide sous le Ruban"
[126] ⍝   trans←trans⍪'QatRemoveItem'              "&Supprimer de la Barre d'Accès Rapide"
[127] ⍝   trans←trans⍪'RecentDocuments'            "Documents Récents"
[128] ⍝   ⎕wi'translations'trans
[129]
[130]     ⎕wi'selectfirsttab'
[131]     ⎕wi'minimizeondoubleclick'0
[132]
[133]     ⍝ Form Events
[134]     Z←⎕wi'*:onFocus' 'RibbonExample"onFocus"'
[135]     Z←⎕wi'*:onResize' 'RibbonExample"onResize"'
[136]     Z←⎕wi'*:onUnfocus' 'RibbonExample"onUnfocus"'
[137]
[138]     ⍝ RibbonExample Events
[139]     Z←⎕wi'*onXRibbonButtonClicked' 'RibbonExample"rib_onXRibbonButtonClicked"'
[140]     Z←⎕wi'*onXRibbonHeightChanged' 'RibbonExample"onResize"'
[141]     Z←⎕wi'*onXFontNameChanged' 'RibbonExample"rib_onXFontNameChanged"'
[142]     Z←⎕wi'*onXFontSizeChanged' 'RibbonExample"rib_onXFontSizeChanged"'
[143]     Z←⎕wi'*onXSelectedColorChanged' 'RibbonExample"rib_onXSelectedColorChanged"'
[144]     Z←⎕wi'*onXCalculatorResultChanged' 'RibbonExample"rib_onXCalculatorResultChanged"'
[145]
[146]     Z←⎕wi'*:Show'
[147]     :if ontop ⋄ SessionFocus ⋄ :endif
[148]
[149] ⍝ Event Handlers
[150] :case'onFocus'
[151]     Z←⎕wcall'SystemParametersInfo' 'SPI_SETDRAGFULLWINDOWS'0(4⍴⎕tcnul)0
[152] :case'onResize'
[153]     (C D)←⎕wi'*:size'
[154]     (E F)←⎕wi'*:rib.size'
[155]     Z←⎕wi'*:rib.size'E D
[156]     Z←⎕wi'*:grid.where'E 0,0⌈(C-E)D
[157] :case'onUnfocus'
[158]     Z←⎕wcall'SystemParametersInfo' 'SPI_SETDRAGFULLWINDOWS'1(4⍴⎕tcnul)0
[159] :case'rib_onXFontNameChanged'
[160]     ⎕←⎕warg
[161] :case'rib_onXFontSizeChanged'
[162]     ⎕←⎕warg
[163] :case'rib_onXRibbonButtonClicked'
[164]     :select ⎕←↑⎕warg
[165]     :case'HomeClipboardPaste'
[166]         ⍝ Handle a click on the Paste button in Home/Clipboard here
[167]     :case'HomeClipboardCut'
[168]         ⍝ Handle a click on the Cut button in Home/Clipboard here
[169]     :case'HomeClipboardCopy'
[170]         ⍝ Handle a click on the Copy button in Home/Clipboard here
[171]     :case'QATMenuAbouttheRibbonDLL'
[172]         Z←⎕wi'*XAbout'
[173]     :endselect
[174] :case'rib_onXSelectedColorChanged'
[175]     ⎕←⎕warg
[176] :case'rib_onXCalculatorResultChanged'
[177]     ⎕←⎕warg
[178] :endselect
    ∇