!******************************************************** !* Creating Object Window (COW) system. !* MACRO MODULE m_button(); !* This macro module creates an rektangel in the active !* module and generate a cre_button part call in a MBS-file. !* It demonstrates the use of parameters, constants and !* variables as well as macros and 'add_mbs' calls. !* !* The module was originally created interactively but !* comments and small changes have been added later !* through the MBS-editor. !* !* This program is done for both english and swedish users with !* Linux or WIN95 VARKON system. !* This version of (COW) is a demo with no connection of !* objects to the created windows. !* !* (C) AB Daterra 1997 !* Thomas Hellner !* !******************************************************** INT main_id, bidx,bid1,bid2,bid3,bid4,bid5,bid6,bid7,bid8,bid9,bid10, edit1,edit2,edit3,edit4,edit5,edit6,edit7,edit8,edit9,edit10, icon1,icon2,icon3,icon4; CONSTANT VECTOR main_pos = vec(125,10); CONSTANT FLOAT main_dx= 260,main_dy= 430; CONSTANT STRING BIG_FONT = "-adobe-courier-bold-r-normal--24-240-75-75-m-150-iso8859-1"; CONSTANT STRING MED_FONT = "-adobe-courier-bold-r-normal--18-180-75-75-m-110-iso8859-1"; string errm*32; ref id; STRING bidn*32, ! bidd number pos*132, ! windowcorner uper left b*32, ! windowwidth in pixels h*32, ! windowheight in pixels r*32, ! framethicknes in pixels s1*132, ! text "on" s2*132, ! text "off" font*132, ! textfont fpen*32, ! subwindow color tpen*32; ! text color int status; string pm1*132, pm2*132, par*132, doc*132, lang*132, path*132; BEGINMODULE !* !****Declare and get some environment parameters. !* par:="vec(0,0)"; lang:=get_environment("VARKON_INI"); doc:=get_environment("VARKON_PRD"); path:=get_environment("VARKON_PRD"); !* !****Create the main window. !* main_id:=cre_win(main_pos,main_dx,main_dy,"**** COW ****"); !* !****Create the company loggo in the main window. !* if finds(act_ostype(),"WIN")=0 then icon1:=cre_icon(main_id,vec(10,3),3, path+"/Cow/ico/loggo.xbm",7,1); icon1:=cre_icon(main_id,vec(90, 3),3, path+"/Cow/ico/button.xbm",7,1); else icon1:=cre_icon(main_id,vec(10,3),3, path+"\Cow\ico\loggo.bmp",7,1); icon1:=cre_icon(main_id,vec(90, 3),3, path+"\Cow\ico\button.bmp",7,1); endif; !* !****Create the company name in the main window. !* bid5:=cre_button(main_id,vec(60,77),200,15,0, " ** AB DATERRA ** "," ",""); !* !****Create edit areas for input values in the main window. !* edit1:=cre_edit(main_id,vec(85,100),160,20,2," ",45); edit2:=cre_edit(main_id,vec(85,130),40,20,2,"1",45); edit3:=cre_edit(main_id,vec(85,160),40,20,2,"90",45); edit4:=cre_edit(main_id,vec(85,190),40,20,2,"20",45); edit5:=cre_edit(main_id,vec(85,220),40,20,2,"2",45); edit6:=cre_edit(main_id,vec(85,250),110,20,2,"ON",45); edit7:=cre_edit(main_id,vec(85,280),110,20,2,"OFF",45); edit8:=cre_edit(main_id,vec(85,310),110,20,2," ",45); edit9:=cre_edit(main_id,vec(85,340),40,20,2,"7",45); edit10:=cre_edit(main_id,vec(85,370),40,20,2,"1",45); !* !****Create text for the edit areas off input values in the main window. !* if finds(lang,"english")=0 then bid6:=cre_button(main_id,vec(10,100),70,20,2,"Position"," P1 ",""); bid4:=cre_button(main_id,vec(10,130),70,20,0,"Id hid"," ",""); bid4:=cre_button(main_id,vec(10,160),70,20,0,"Bredd b"," ",""); bid4:=cre_button(main_id,vec(10,190),70,20,0,"Höjd h"," ",""); bid4:=cre_button(main_id,vec(10,220),70,20,0,"Ram r"," ",""); bid4:=cre_button(main_id,vec(10,250),70,20,0,"Text1 s1"," ",""); bid4:=cre_button(main_id,vec(10,280),70,20,0,"Text2 s2"," ",""); bid4:=cre_button(main_id,vec(10,310),70,20,0,"Font font"," ",""); bid4:=cre_button(main_id,vec(10,340),70,20,0,"Pen fpen"," ",""); bid4:=cre_button(main_id,vec(10,370),70,20,0,"Text tpen"," ",""); !* !****Create the Ok/Reject/Help buttons in the main window. !* bid1:=cre_button(main_id,vec(5,400),55,22,3,"Ok","Ok",""); bid2:=cre_button(main_id,vec(70,400),55,22,3,"Avbryt","Avbryt",""); bid3:=cre_button(main_id,vec(135,400),55,22,3,"Hjälp","Hjälp",""); else bid6:=cre_button(main_id,vec(10,100),70,20,2,"Position"," P1 ",""); bid4:=cre_button(main_id,vec(10,130),70,20,0,"Id hid"," ",""); bid4:=cre_button(main_id,vec(10,160),70,20,0,"Width b"," ",""); bid4:=cre_button(main_id,vec(10,190),70,20,0,"Heigth h"," ",""); bid4:=cre_button(main_id,vec(10,220),70,20,0,"Frame r"," ",""); bid4:=cre_button(main_id,vec(10,250),70,20,0,"Text1 s1"," ",""); bid4:=cre_button(main_id,vec(10,280),70,20,0,"Text2 s2"," ",""); bid4:=cre_button(main_id,vec(10,310),70,20,0,"Font font"," ",""); bid4:=cre_button(main_id,vec(10,340),70,20,0,"Pen fpen"," ",""); bid4:=cre_button(main_id,vec(10,370),70,20,0,"Text tpen"," ",""); !* !****Create the Ok/Reject/Help buttons in the main window. !* bid1:=cre_button(main_id,vec(5,400),55,22,3,"Ok","Ok",""); bid2:=cre_button(main_id,vec(70,400),55,22,3,"Reject","Reject",""); bid3:=cre_button(main_id,vec(135,400),55,22,3,"Help","Help",""); endif; !* !****Show the main window on screen. !* show_win(main_id); loop: !* !****Wait for input. !* bidx:=wait_win(main_id); if bidx = bid1 then !* !****The Ok button is chosen. !* pos:=get_edit(main_id,edit1); bidn:=get_edit(main_id,edit2); b:=get_edit(main_id,edit3); h:=get_edit(main_id,edit4); r:=get_edit(main_id,edit5); s1:=get_edit(main_id,edit6); s2:=get_edit(main_id,edit7); font:=get_edit(main_id,edit8); fpen:=get_edit(main_id,edit9); tpen:=get_edit(main_id,edit10); !* !****Check indata. !* part(#10,m_error(lang,pos,b,h,r,"1","1",errm)); if finds(errm,"0")=0 then goto loop;endif; if finds(font,"FONT")=0 then font:="""""";endif; id:=add_mbs("part","men_button", bidn,pos,b,h,r,chr(34)+s1+chr(34), chr(34)+s2+chr(34),chr(34)+font+chr(34), fpen,tpen); del_win(main_id); exit(); elif bidx = bid2 then !* !****The Reject button is chosen. !* del_win(main_id); exit(); elif bidx = bid3 then !* !****The Help button is chosen. !* if finds(act_ostype(),"WIN")=0 then part(#20,m_help(doc+"/Cow/doc/cre_butt.doc")); else part(#30,m_help(doc+"\Cow\doc\cre_butt.doc")); endif; goto loop; elif bidx = bid6 then !* !****Position. !* part(#40,ma_posw(par,"Button","Select position",status)); if status = 0 then del_win(main_id,edit1); edit1:=cre_edit(main_id,vec(85,100),160,20,2,par,132); pos:=get_edit(main_id,edit1); show_win(main_id); endif; goto loop; else goto loop; endif; ENDMODULE