Author: gs Date: Wed Feb 9 13:26:39 2011 New Revision: 63381 URL: http://svn.opensuse.org/viewcvs/yast?rev=63381&view=rev Log: more examples added Added: trunk/ycp-ui-bindings/examples/MultiLineEdit4.ycp trunk/ycp-ui-bindings/examples/MultiSelectionBox4.ycp trunk/ycp-ui-bindings/examples/Tree-Checkbox2.ycp trunk/ycp-ui-bindings/examples/Tree-Checkbox3.ycp Added: trunk/ycp-ui-bindings/examples/MultiLineEdit4.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/examples/MultiLineEdit4.ycp?rev=63381&view=auto ============================================================================== --- trunk/ycp-ui-bindings/examples/MultiLineEdit4.ycp (added) +++ trunk/ycp-ui-bindings/examples/MultiLineEdit4.ycp Wed Feb 9 13:26:39 2011 @@ -0,0 +1,62 @@ +// Build dialog with MuliLineEdit widget, +// a character counter for the MuliLineEdit's contents as they are typed +// and an OK button. +{ + UI::OpenDialog( + `VBox( + `MultiLineEdit(`id(`problem), + `opt(`notify), // make UI::UserInput() return on every keystroke + "Problem &description:" ), + `HBox( + `Label("Number of characters entered:"), + `Label(`id(`char_count), "0 ") + ), + `PushButton(`id(`ok), "&OK") + ) + ); + + UI::ChangeWidget(`id(`problem), `Value, + "My first input is already\nhere" ); + + any ret = nil; + + do + { + // Wait for user input. + // + // Since the MultiLineEdit is in "notify" mode, it, too, will cause + // UI::UserInput() to return upon any single character entered. + ret = UI::UserInput(); + + if ( ret == `problem ) // User typed some text + { + // Set the `char_count label to the number of characters entered + // into the MultiLineEdit widget. + + UI::ChangeWidget(`id(`char_count), `Value, + sformat( "%1", size( (string) UI::QueryWidget(`id(`problem), `Value) ) ) ); + } + } while ( ret != `ok ); + + // Get the input from the MultiLineEdit. + // + // Notice: The return value of UI::UserInput() does NOT return this value! + // Rather, it returns the ID of the widget (normally the PushButton) + // that caused UI::UserInput() to return. + string input = (string) UI::QueryWidget(`id(`problem), `Value); + + // Close the dialog. + // Remember to read values from the dialog's widgets BEFORE closing it! + UI::CloseDialog(); + + // Pop up a new dialog to echo the input. + UI::OpenDialog( + `VBox( + `Label("You entered:"), + `Label(input), + `PushButton("&OK") + ) + ); + UI::UserInput(); + UI::CloseDialog(); +} Added: trunk/ycp-ui-bindings/examples/MultiSelectionBox4.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/examples/MultiSelectionBox4.ycp?rev=63381&view=auto ============================================================================== --- trunk/ycp-ui-bindings/examples/MultiSelectionBox4.ycp (added) +++ trunk/ycp-ui-bindings/examples/MultiSelectionBox4.ycp Wed Feb 9 13:26:39 2011 @@ -0,0 +1,40 @@ +{ + import "Label"; + + list items = [ + `item (`id ("a"), "a"), + `item (`id ("x"), "x"), + `item (`id ("y"), "y"), + `item (`id ("z"), "z") + ]; + + term contents = `HBox (`VSpacing (20), `VBox (`HSpacing(70), + `VSpacing (0.2), + `MultiSelectionBox (`id(`tree), `opt(`notify), "tree", items), + `HBox ( + `PushButton (`id (`ok), `opt (`default), Label::OKButton()), + `PushButton(`id (`cancel), `opt (`key_F9), Label::CancelButton()) + ), + `VSpacing (0.2) + )); + + UI::OpenDialog (`opt (`decorated), contents); + UI::ChangeWidget (`tree, `CurrentItem, nil); + while (true) + { + map event = UI::WaitForEvent (); + any ret = event["ID"]:nil; + if (ret == `tree) + { + string current = (string) UI::QueryWidget (`id(`tree),`CurrentItem); + y2internal ("current: %1", current); + } + + if (ret == `ok || ret == `cancel) + break; + } + string current = (string) UI::QueryWidget (`id(`tree),`CurrentItem); + y2internal ("current before leaving: %1", current ); + UI::CloseDialog (); +} + Added: trunk/ycp-ui-bindings/examples/Tree-Checkbox2.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/examples/Tree-Checkbox2.ycp?rev=63381&view=auto ============================================================================== --- trunk/ycp-ui-bindings/examples/Tree-Checkbox2.ycp (added) +++ trunk/ycp-ui-bindings/examples/Tree-Checkbox2.ycp Wed Feb 9 13:26:39 2011 @@ -0,0 +1,35 @@ +// Tree with icons +{ + UI::OpenDialog( + `VBox( + `Heading( "YaST2 Mini Control Center" ), + `Tree(`id(`mod), `opt(`notify, `multiSelection, `immediate ), + "Modules", + [ + `item(`id( "country" ), `icon( "yast-yast-language.png" ), "Localization", false, + [ + `item(`id( "keyboard" ), `icon( "yast-keyboard.png" ), "Keyboard" ), + `item(`id( "timezone" ), `icon( "yast-timezone.png" ), "Time zone" ) + ] + ), + `item(`id( "mouse" ), `icon( "yast-mouse.png" ), "Mouse" ), + `item(`id( "lan" ), `icon( "yast-lan.png" ), "Network" ), + `item(`id( `xmas ), `icon( "yast-software.png" ), "Merry X-Mas" ), + `item(`id( `newyear ), `icon( "yast-software.png" ), "Happy New Year" ) + ] ), + `HBox(`PushButton(`id(`ok), `opt(`default), "&OK"), + `PushButton(`id(`deselect), "&Log selected" ) + ) + ) + ); + + UI::ChangeWidget(`mod, `SelectedItems, ["keyboard", `xmas, `newyear ] ); + any id = nil; + + repeat + { + id = UI::UserInput(); + list selected_items = (list) UI::QueryWidget( `id(`mod), `SelectedItems ); + y2milestone( "Selected items: %1", selected_items ); + } until (id == `ok); +} Added: trunk/ycp-ui-bindings/examples/Tree-Checkbox3.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ycp-ui-bindings/examples/Tree-Checkbox3.ycp?rev=63381&view=auto ============================================================================== --- trunk/ycp-ui-bindings/examples/Tree-Checkbox3.ycp (added) +++ trunk/ycp-ui-bindings/examples/Tree-Checkbox3.ycp Wed Feb 9 13:26:39 2011 @@ -0,0 +1,44 @@ +{ + import "Label"; + + list items = [ + `item (`id ("a"), "a", false, []), + `item (`id ("x"), "x", true, [ + `item (`id ("y"), "y", false, []), + `item (`id ("z"), "z", false, []), + ]), + ]; + + term contents = `HBox (`VSpacing (20), `VBox (`HSpacing(70), + `VSpacing (0.2), + //`Tree (`id(`tree), `opt(`notify, `immediate, `multiSelection), "tree", items), + `Tree (`id(`tree), `opt(`notify, `multiSelection), "tree", items), + //`Tree (`id(`tree), `opt(`notify), "tree", items), + `HBox ( + `PushButton (`id (`ok), `opt (`default), Label::OKButton()), + `PushButton(`id (`cancel), `opt (`key_F9), Label::CancelButton()) + ), + `VSpacing (0.2) + )); + + UI::OpenDialog (`opt (`decorated), contents); + UI::ChangeWidget (`tree, `CurrentItem, nil); + while (true) + { + map event = UI::WaitForEvent (); + any ret = event["ID"]:nil; + if (ret == `tree) + { + string current = (string) UI::QueryWidget (`id(`tree),`CurrentItem); + y2internal ("current: %1", current); + } + + if (ret == `ok || ret == `cancel) + break; + } + string current = (string) UI::QueryWidget (`id(`tree),`CurrentItem); + y2internal ("current before leaving: %1", current); + + UI::CloseDialog (); +} + -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org