Component index
Section index

Component FRAMEWORK


Search

	/*
	    This presents a typical usage of the FRAMEWORK component. It is
	    a multi-document text editor. Each text is presented in a notebook page.
	    (the text editor is dummy).
	
	    This sample shows how to use the FRAMEWORK and how to deal with
	    the quit-without-save issue where the FRAMEWORK asks all document
	    if they are ready to quit or not
	*/
	<mod>
	static void sample_framework()
	{
	    <obj FRAMEWORK frame>("sample");
	        <f about>
	            xconf_notice (
	                "This is a sample program\n"
	                "showing the framework TLMP component\n"
	                "Written by Jacques Gélinas\n"
	                "jack@solucorp.qc.ca");
	        </f>
	        <f helpindex>
	        </f>
	        <f menubar>
	            topmenu ("File");
	            menuentry (1,"Load");
	            menuentry (2,"Save");
	            menuentry (3,"Save as");
	            menuentry (99,"Quit");
	            endmenu();
	            topmenu ("Options");
	            menuentry (901,"Preferences");
	            endmenu();
	            helpmenu();
	            endmenu();
	        </f>
	        <f menudo>
	            if (id == 99){
	                end();
	            }else if (id == 1){
	                newdocument ();
	            }
	        </f>
	        <f taskbar>
	            newbutton (1,"icon1","button1","long text button1");
	            newbutton (2,"icon2","button2","long text button2");
	        </f>
	        <f taskdo>
	            xconf_notice ("You selected the button %d",id);
	        </f>
	        <f document>
	            DIALOG dia;
	            info.msgs.waitfor (dia);
	            SSTRING tmp;
	            tmp.setfrom ("This is a document");
	            dia.newf_textarea (NULL,tmp,60,20);
	            int nof = 0;
	            while (1){
	                MENU_STATUS code = dia.edit ("Some text","",help_nil,nof,0);
	                if (code == MENU_MESSAGE){
	                    if (info.msgs.is_ending()){
	                        break;
	                    }else if (info.msgs.is_mayend()){
	                        dia.save();
	                        if (xconf_yesno ("Forget changes", "Quit without saving",help_nil)==MENU_YES){
	                            endok();
	                        }
	                    }
	                }
	            }
	        </f>
	    </obj>
	    frame.newdocument();
	    frame.loop();
	}
	</mod>