Component index
Section index

Component FRAMEWORK


Search

	/*
	    Here is a more complex example. Several FRAMEWORK inside one.
	    To make things simple, we are reusing the same FRAMEWORK 4 times.
	*/
	
	<mod>
	static void sample_framework3()
	{
	    <obj FRAMEWORK frame>("framework inside framework");
	        <f layout>
	            #if 1
	            layout_book();
	            layout_page("Page1");
	            layout_area1(false);
	            layout_end();
	            layout_page("Page2");
	            layout_area2(false);
	            layout_end();
	            #endif
	            #if 0
	                layout_page("Page3");
	                layout_area3(false);
	                layout_end();
	                layout_page("Page4");
	                layout_area4(false);
	                layout_end();
	            #endif
	            layout_end();
	        </f>
	        <f about>
	            xconf_notice (
	                "This is a sample program\n"
	                "showing frameworks inside a framework\n"
	                "Written by Jacques Gélinas\n"
	                "jack@solucorp.qc.ca");
	        </f>
	        <f helpindex>
	        </f>
	        <f menubar>
	            topmenu ("File");
	            menuentry (99,"Quit");
	            endmenu();
	            helpmenu();
	            endmenu();
	        </f>
	        <f menudo>
	            if (id == 99){
	                end();
	            }
	        </f>
	        <f document>
	            glocal int noarea = noarea;
	            if (0){
	                    DIALOG dia;
	                    SSTRING s;
	                    s.setfromf ("nbdoc %d area %d",info.nbdocument,noarea);
	                    dia.newf_str ("A string",s);
	                    int nof = 0;
	                    /*
	                        We tell our dialog it must wait for some messages
	                        to participate in the quit protocol.
	                        A dialog failing to do so will prevent the
	                        framework from exiting.
	                    */
	                    info.msgs.waitfor (dia);
	                    while (1){
	                        dia.edit ("","",help_nil,nof,0);
	                        if (must_end(info.msgs)){
	                            break;
	                        }
	                    }
	            }else{
	            <obj FRAMEWORK sub>(info);
	                <f layout>
	                    layout_area1(false);
	                    layout_area2(false);
	                    layout_newline();
	                    layout_area3(false);
	                    layout_area4(false);
	                </f>
	                <f document>
	                    DIALOG dia;
	                    SSTRING s;
	                    dia.newf_str ("A string",s);
	                    int nof = 0;
	                    info.msgs.waitfor (dia);
	                    while (1){
	                        dia.edit ("","",help_nil,nof,0);
	                        /*
	                            This is where we are testing the two messages
	                            sent by the framework. One asks if we accept
	                            to end. The other tells us this is it and we
	                            MUST end.
	                        */
	                        if (info.msgs.is_mayend()){
	                            SSTRING tmp;
	                            tmp.setfromf ("This is sub-document %d in page %d"
	                                ,noarea,glocal.noarea);
	                            if (framework_quitok ("Quit without save",tmp.get())){
	                                endok();
	                            }
	                        }else if (info.msgs.is_ending()){
	                            break;
	                        }
	                    }
	                </f>
	            </obj>
	            sub.loop();
	            }
	        </f>
	    </obj>
	    frame.loop();
	}
	</mod>