[yast-commit] r50386 - /trunk/ycp-ui-bindings/examples/ButtonBox2.ycp
Author: sh-sh-sh Date: Tue Aug 26 17:58:55 2008 New Revision: 50386 URL: http://svn.opensuse.org/viewcvs/yast?rev=50386&view=rev Log: new example Added: trunk/ycp-ui-bindings/examples/ButtonBox2.ycp Added: trunk/ycp-ui-bindings/examples/ButtonBox2.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/examples/ButtonBox2.ycp?rev=50386&view=auto ============================================================================== --- trunk/ycp-ui-bindings/examples/ButtonBox2.ycp (added) +++ trunk/ycp-ui-bindings/examples/ButtonBox2.ycp Tue Aug 26 17:58:55 2008 @@ -0,0 +1,124 @@ +// Demo for common ButtonBox-based dialogs +{ + void showDialog( term buttonBox ) + { + UI::OpenDialog( + `VBox( + `Label( "Hello, World!" ), + buttonBox + ) + ); + UI::UserInput(); + UI::CloseDialog(); + + } + + + void okCancelDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`ok ), "&OK" ), + `PushButton(`id(`cancel), "&Cancel" ) + ) + ); + } + + + void yesNoDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`yes ), "&Yes" ), + `PushButton(`id(`no ), "&No" ) + ) + ); + } + + + void continueCancelDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`continue ), "&Cancel" ), + `PushButton(`id(`cancel ), "C&ancel" ) + ) + ); + } + + + void okApplyCancelDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`ok ), "&OK" ), + `PushButton(`id(`apply ), "&Apply" ), + `PushButton(`id(`cancel), "&Cancel" ) + ) + ); + } + + + void okApplyCancelHelpDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`ok ), "&OK" ), + `PushButton(`id(`apply ), "&Apply" ), + `PushButton(`id(`cancel), "&Cancel" ), + `PushButton(`id(`help ), "&Help" ) + ) + ); + } + + + void okApplyCancelCustomHelpDialog() + { + showDialog( `ButtonBox( + `PushButton(`id(`ok ), "&OK" ), + `PushButton(`id(`apply ), "&Apply" ), + `PushButton(`id(`cancel ), "&Cancel" ), + `PushButton(`id(`custom1 ), "&Do Something" ), + `PushButton(`id(`custom2 ), "Do &More" ), + `PushButton(`id(`help ), "&Help" ) + ) + ); + } + + + + term buttons = + `VBox( + `PushButton(`id(`okCancel ), `opt(`hstretch), "&OK / Cancel" ), + `PushButton(`id(`yesNo ), `opt(`hstretch), "&Yes / No" ), + `PushButton(`id(`continueCancel ), `opt(`hstretch), "C&ontinue / Cancel" ), + `PushButton(`id(`okApply ), `opt(`hstretch), "OK / &Apply / Cancel" ), + `PushButton(`id(`okEtcHelp ), `opt(`hstretch), "OK / Apply / Cancel / &Help" ), + `PushButton(`id(`okCustom ), `opt(`hstretch), "OK / Apply / Cancel / C&ustom / Help" ) + ); + + UI::OpenDialog( + `MarginBox( 1.0, 0.5, + `VBox( + `Heading( "ButtonBox Examples" ), + `VSpacing( 0.5 ), + `HVCenter( `HSquash( buttons ) ), + `VSpacing( 0.5 ), + `Right(`PushButton(`id(`close), "&Close" ) ) + ) + ) + ); + + symbol button = nil; + + repeat + { + button = (symbol) UI::UserInput(); + + if ( button == `okCancel ) okCancelDialog(); + if ( button == `yesNo ) yesNoDialog(); + if ( button == `continueCancel ) continueCancelDialog(); + if ( button == `okApply ) okApplyCancelDialog(); + if ( button == `okEtcHelp ) okApplyCancelHelpDialog(); + if ( button == `okCustom ) okApplyCancelCustomHelpDialog(); + + } until ( button == `close || // [Close] button + button == `cancel ); // WM_CLOSE + + UI::CloseDialog(); +} -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
sh-sh-sh@svn.opensuse.org