Search in sources :

Example 6 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class TerraCheckboxSkin method getBaseline.

@Override
public int getBaseline(int width, int height) {
    Checkbox checkbox = (Checkbox) getComponent();
    int baseline = -1;
    Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
    dataRenderer.render(checkbox.getButtonData(), checkbox, false);
    int clientWidth = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
    baseline = dataRenderer.getBaseline(clientWidth, height);
    return baseline;
}
Also used : Button(org.apache.pivot.wtk.Button) Checkbox(org.apache.pivot.wtk.Checkbox) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint)

Example 7 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class TerraCheckboxSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    Checkbox checkbox = (Checkbox) getComponent();
    Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
    int preferredHeight = CHECKBOX_SIZE;
    Object buttonData = checkbox.getButtonData();
    if (buttonData != null) {
        if (width != -1) {
            width = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
        }
        dataRenderer.render(checkbox.getButtonData(), checkbox, false);
        preferredHeight = Math.max(preferredHeight, dataRenderer.getPreferredHeight(width));
    }
    return preferredHeight;
}
Also used : Button(org.apache.pivot.wtk.Button) Checkbox(org.apache.pivot.wtk.Checkbox) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint)

Example 8 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class FileBrowserWithCharsetTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BoxPane windowContent = new BoxPane();
    windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
    windowContent.add(showHiddenCheckbox);
    PushButton button = new PushButton("Open File Browser");
    button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            final Window window = Window.getActiveWindow();
            final FileBrowserWithCharsetTest fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);
            fileBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
            fileBrowserSheet.open(window, new SheetCloseListener() {

                @Override
                public void sheetClosed(Sheet sheet) {
                    if (sheet.getResult()) {
                        Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
                        ListView listView = new ListView();
                        listView.setListData(new ArrayList<>(selectedFiles));
                        listView.setSelectMode(ListView.SelectMode.NONE);
                        listView.getStyles().put(Style.backgroundColor, null);
                        Alert.alert(MessageType.INFO, "You selected (charset " + fileBrowserSheet.getCharsetName() + "):", listView, window);
                    } else {
                        Alert.alert(MessageType.INFO, "You didn't select anything.", window);
                    }
                }
            });
        }
    });
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setMaximized(true);
    frame.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) ListView(org.apache.pivot.wtk.ListView) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) Checkbox(org.apache.pivot.wtk.Checkbox) PushButton(org.apache.pivot.wtk.PushButton) Sheet(org.apache.pivot.wtk.Sheet) FileBrowserSheet(org.apache.pivot.wtk.FileBrowserSheet) File(java.io.File)

Example 9 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class VFSBrowserTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    BoxPane windowContent = new BoxPane();
    windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
    windowContent.add(showHiddenCheckbox);
    PushButton button = new PushButton("Open File Browser");
    button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(final Button buttonArgument) {
            try {
                final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet(VFSBrowserSheet.Mode.OPEN);
                vfsBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
                vfsBrowserSheet.open(frame, new SheetCloseListener() {

                    @Override
                    public void sheetClosed(final Sheet sheet) {
                        if (sheet.getResult()) {
                            Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles();
                            ListView listView = new ListView();
                            listView.setListData(new ArrayList<>(selectedFiles));
                            listView.setSelectMode(ListView.SelectMode.NONE);
                            listView.getStyles().put(Style.backgroundColor, null);
                            Alert.alert(MessageType.INFO, "You selected:", listView, frame);
                        } else {
                            Alert.alert(MessageType.INFO, "You didn't select anything.", frame);
                        }
                    }
                });
            } catch (FileSystemException fse) {
                Alert.alert(MessageType.ERROR, String.format("File System Exception: %1$s", fse.getMessage()), frame);
            }
        }
    });
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setMaximized(true);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) FileSystemException(org.apache.commons.vfs2.FileSystemException) VFSBrowserSheet(org.apache.pivot.wtk.VFSBrowserSheet) ListView(org.apache.pivot.wtk.ListView) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Checkbox(org.apache.pivot.wtk.Checkbox) FileObject(org.apache.commons.vfs2.FileObject) PushButton(org.apache.pivot.wtk.PushButton) Sheet(org.apache.pivot.wtk.Sheet) VFSBrowserSheet(org.apache.pivot.wtk.VFSBrowserSheet)

Example 10 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class CheckboxSkin method mouseClick.

@Override
public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
    boolean consumed = super.mouseClick(component, button, x, y, count);
    Checkbox checkbox = (Checkbox) getComponent();
    checkbox.requestFocus();
    checkbox.press();
    return consumed;
}
Also used : Checkbox(org.apache.pivot.wtk.Checkbox)

Aggregations

Checkbox (org.apache.pivot.wtk.Checkbox)13 Button (org.apache.pivot.wtk.Button)9 GradientPaint (java.awt.GradientPaint)5 Paint (java.awt.Paint)5 ListButton (org.apache.pivot.wtk.ListButton)3 PushButton (org.apache.pivot.wtk.PushButton)3 BoxPane (org.apache.pivot.wtk.BoxPane)2 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)2 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)2 Frame (org.apache.pivot.wtk.Frame)2 ListView (org.apache.pivot.wtk.ListView)2 Sheet (org.apache.pivot.wtk.Sheet)2 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 File (java.io.File)1 URL (java.net.URL)1 FileObject (org.apache.commons.vfs2.FileObject)1