#include "olbasewindow.h" #include "group.h" #include "olmenubutton.h" #include "olnotice.h" #include "edittext.h" #include "menu.h" #include "oltextfield.h" #include "label.h" extern object hn; void main() { olbasewindow win; olnotice file_popup,line_popup; olmenubutton m; group g,g2,g3; edittext t; oltextfield tf; label l; olbutton b; win = (olbasewindow)hn.newmember(/olbasewindow); win.framelabel = "Text Editor"; win.resizable = true; win.reshape(50,50,350,350); win.rename(/@topwin); g = (group)win.@current_layout.newmember(/group); g.setposition(10,null,10,10); g.setplacement(/left2right); g.minheight = 30; file_popup = (olnotice)newobject(/olnotice); file_popup.reshape(50,50,300,120); m = (olmenubutton)g.newmember(/olmenubutton); m.setscript(""," /MenuAction { pop exch pop dup 0 eq { w 2 div h 2 div /mapxy file_popup send } { 4 eq {[] /clearvalue /@text Send} if } ifelse } def "); m.addslave(file_popup); m[/file_popup] = file_popup; m.setlabel("File"); m.setmenu([ null, MCOMMAND, "Load File...", MACTIVE|MDEFAULT, null, "Save Current File", MINACTIVE, null, "Store as New File...", MINACTIVE, null, "Include File...", MINACTIVE, null, "Empty Document", MACTIVE, null ]); m.map(); g2 = (group)file_popup.@current_layout.newmember(/group); g2.setposition(10,10,10,10); g2.setjustification(/Centered); g2.rename(/@text_group); l = (label)g2.newmember(/label); l.setlabel("File Name"); l.fixedwidth = true; l.setposition(10,null,10,10); l.map(); tf = (oltextfield)g2.newmember(/oltextfield); tf.setvalue("hn/README"); tf.reshape(10,40,250,20); tf.rename(/@textfield); tf.map(); g3 = (group)g2.newmember(/group); g3.reshape(10,10,250,20); g3.setplacement(/left2right); g3.rename(/@topgroup); b = (olbutton)g3.newmember(/olbutton); b.setscript("","/Action {[] /unmap @window Send} def"); b.setlabel("Cancel"); b.setdefaultchoice(true); b.minwidth = b.preferredwidth(); b.fixedwidth = true; b.map(); b = (olbutton)g3.newmember(/olbutton); b.setscript("","/Action { [] /unmap @window Send [/@window /@current_layout /@text_group /@textfield] find_object /value get [ exch ] /setfile [/@topwin /@current_layout /@text] Send } def"); b.setlabel("Load File"); b.minwidth = b.preferredwidth(); b.fixedwidth = true; b.map(); g3.map(); g2.map(); line_popup = (olnotice)newobject(/olnotice); line_popup.reshape(50,50,300,120); m = (olmenubutton)g.newmember(/olmenubutton); m.setscript(""," /MenuAction { 3 1 roll pop pop { (Select Line at Number...) {w 2 div h 2 div /mapxy line_popup send} (Wrap at Word) {[/word] /set_line_wrap /@text Send } (Wrap at Character) {[/char] /set_line_wrap /@text Send } (Clip Lines) {[/none] /set_line_wrap /@text Send} } case } def "); m.addslave(line_popup); m[/line_popup] = line_popup; m.setlabel("View"); m.setmenu([ null, MCOMMAND, "Select Line at Number...", MACTIVE|MDEFAULT, null, "What Line Number?", MINACTIVE, null, "Show Caret at Top", MINACTIVE, null, "Change Line Wrap", MACTIVE, [ null, MCOMMAND, "Wrap at Word", MACTIVE, null, "Wrap at Character", MACTIVE, null, "Clip Lines", MACTIVE, null ] ]); m.map(); g2 = (group)line_popup.@current_layout.newmember(/group); g2.setposition(10,10,10,10); g2.setjustification(/Centered); g2.rename(/@line_group); l = (label)g2.newmember(/label); l.setlabel("Line Number"); l.fixedwidth = true; l.setposition(10,null,10,10); l.map(); tf = (oltextfield)g2.newmember(/oltextfield); tf.setvalue("5"); tf.reshape(10,40,250,20); tf.rename(/@line_no); tf.map(); g3 = (group)g2.newmember(/group); g3.reshape(10,10,250,20); g3.setplacement(/left2right); g3.rename(/@topgroup); b = (olbutton)g3.newmember(/olbutton); b.setscript("","/Action {[] /unmap @window Send} def"); b.setlabel("Cancel"); b.setdefaultchoice(true); b.minwidth = b.preferredwidth(); b.fixedwidth = true; b.map(); b = (olbutton)g3.newmember(/olbutton); b.setscript("","/Action { [] /unmap @window Send [/@window /@current_layout /@line_group /@line_no] find_object /value get [ exch cvi] /select_line_at [/@topwin /@current_layout /@text] Send } def"); b.setlabel("Select Line"); b.minwidth = b.preferredwidth(); b.fixedwidth = true; b.map(); g3.map(); g2.map(); m = (olmenubutton)g.newmember(/olmenubutton); m.setscript(""," /MenuAction { 3 1 roll pop pop { (Copy) {[] /copy_selection /@text Send } (Paste) {[] /paste_selection /@text Send } (Cut) {[] /cut_selection /@text Send } } case } def ");m.setlabel("Edit"); m.setmenu([ null, MCOMMAND|MPIN, "Again", MINACTIVE|MDEFAULT, null, "Undo", MACTIVE, [ null, MCOMMAND, "Undo Last Edit", MINACTIVE, null, "Undo All Edits", MINACTIVE, null ], "Copy", MACTIVE, null, "Paste", MACTIVE, null, "Cut", MACTIVE, null ]); m.map(); m = (olmenubutton)g.newmember(/olmenubutton); m.setlabel("Find"); m.setmenu([ null, MCOMMAND, "Find and Replace...", MACTIVE|MDEFAULT, null, "Find Selection", MACTIVE, [ null, MCOMMAND, "Forward", MINACTIVE, null, "Backward", MINACTIVE, null ], "Find Marked Text...", MACTIVE|MDEFAULT, null, "Replace |>Field<|", MACTIVE, [ null, MCOMMAND, "Expand", MINACTIVE, null, "Next", MINACTIVE, null, "Previous", MINACTIVE, null ] ]); m.map(); b = (olbutton)g.newmember(/olbutton); b.setscript("","/Action {systemdict /hn undef} def"); b.setlabel("Quit"); b.map(); g.map(); t = (edittext)win.@current_layout.newmember(/edittext); t.reshape(10,5,50,50); t.setposition(10,5,10,40); t.set_value(""); t.rename(/@text); t.set_font(/Courier, 12); t.map(); win.map(); }