├── .gitignore ├── LICENSE.txt ├── Main.hx ├── README.md ├── bin ├── 2.jpg ├── AsWing.swf ├── icon.png └── princess.jpg ├── compile.hxml └── org └── aswing ├── ASColor.hx ├── ASFont.hx ├── ASFontAdvProperties.hx ├── AWKeyboard.hx ├── AWSprite.hx ├── AWTextField.hx ├── AbstractButton.hx ├── AbstractCellEditor.hx ├── AbstractListCell.hx ├── AbstractListModel.hx ├── AbstractTabbedPane.hx ├── AsWingConstants.hx ├── AsWingManager.hx ├── AsWingUtils.hx ├── AssetBackground.hx ├── AssetIcon.hx ├── AssetPane.hx ├── Border.hx ├── BorderLayout.hx ├── BoundedRangeModel.hx ├── Box.hx ├── BoxLayout.hx ├── ButtonGroup.hx ├── ButtonModel.hx ├── Cell.hx ├── CellEditor.hx ├── CellPane.hx ├── CenterLayout.hx ├── ComboBoxEditor.hx ├── Component.hx ├── Container.hx ├── ContainerOrderFocusTraversalPolicy.hx ├── Cursor.hx ├── CursorManager.hx ├── Decorator.hx ├── DefaultBoundedRangeModel.hx ├── DefaultButtonModel.hx ├── DefaultCheckBoxCellEditor.hx ├── DefaultComboBoxCellEditor.hx ├── DefaultComboBoxEditor.hx ├── DefaultComboBoxListCell.hx ├── DefaultComboBoxListCellFactory.hx ├── DefaultListCell.hx ├── DefaultListCellFactory.hx ├── DefaultListSelectionModel.hx ├── DefaultListTextCellFactory.hx ├── DefaultNumberTextFieldCellEditor.hx ├── DefaultSingleSelectionModel.hx ├── DefaultTextFieldCellEditor.hx ├── EditableComponent.hx ├── EmptyFont.hx ├── EmptyIcon.hx ├── EmptyLayout.hx ├── FlowLayout.hx ├── FlowWrapLayout.hx ├── FocusManager.hx ├── FocusTraversalPolicy.hx ├── FrameTitleBar.hx ├── FrameTitleBarLayout.hx ├── GeneralListCellFactory.hx ├── GradientBackground.hx ├── GridLayout.hx ├── GroundDecorator.hx ├── Icon.hx ├── Insets.hx ├── JAccordion.hx ├── JAdjuster.hx ├── JButton.hx ├── JCheckBox.hx ├── JCheckBoxMenuItem.hx ├── JClosableTabbedPane.hx ├── JColorChooser.hx ├── JComboBox.hx ├── JFrame.hx ├── JFrameTitleBar.hx ├── JLabel.hx ├── JLabelButton.hx ├── JLayeredPane.hx ├── JList.hx ├── JLoadPane.hx ├── JMenu.hx ├── JMenuBar.hx ├── JMenuItem.hx ├── JOptionPane.hx ├── JPanel.hx ├── JPopup.hx ├── JPopupMenu.hx ├── JProgressBar.hx ├── JRadioButton.hx ├── JRadioButtonMenuItem.hx ├── JRootPane.hx ├── JScrollBar.hx ├── JScrollPane.hx ├── JSeparator.hx ├── JSharedToolTip.hx ├── JSlider.hx ├── JSpacer.hx ├── JSplitPane.hx ├── JStepper.hx ├── JTabbedPane.hx ├── JTable.hx ├── JTextArea.hx ├── JTextComponent.hx ├── JTextField.hx ├── JToggleButton.hx ├── JToolBar.hx ├── JToolTip.hx ├── JTree.hx ├── JViewport.hx ├── JWindow.hx ├── KeyMap.hx ├── KeySequence.hx ├── KeyStroke.hx ├── KeyType.hx ├── KeyboardManager.hx ├── LayoutManager.hx ├── ListCell.hx ├── ListCellFactory.hx ├── ListModel.hx ├── ListSelectionModel.hx ├── LoadIcon.hx ├── LookAndFeel.hx ├── MenuElement.hx ├── MenuSelectionManager.hx ├── MultipleAssetIcon.hx ├── MutableListModel.hx ├── Orientable.hx ├── RepaintManager.hx ├── ScrollPaneLayout.hx ├── SimpleButton.hx ├── SimpleButtonIcon.hx ├── SimpleButtonIconToggle.hx ├── SingleSelectionModel.hx ├── SoftBox.hx ├── SoftBoxLayout.hx ├── SolidBackground.hx ├── StyleResult.hx ├── StyleTune.hx ├── ToggleButtonModel.hx ├── UIDefaults.hx ├── UIManager.hx ├── VectorListModel.hx ├── ViewportLayout.hx ├── Viewportable.hx ├── WeightBoxLayout.hx ├── WindowLayout.hx ├── WindowOrderFocusTraversalPolicy.hx ├── border ├── BevelBorder.hx ├── CaveBorder.hx ├── DecorateBorder.hx ├── EmptyBorder.hx ├── LineBorder.hx ├── SideLineBorder.hx ├── SimpleTitledBorder.hx └── TitledBorder.hx ├── colorchooser ├── AbstractColorChooserPanel.hx ├── ColorRectIcon.hx ├── ColorSelectionModel.hx ├── DefaultColorSelectionModel.hx ├── JColorMixer.hx ├── JColorSwatches.hx ├── NoColorIcon.hx ├── PreviewColorIcon.hx └── VerticalLayout.hx ├── dnd ├── DefaultDragImage.hx ├── DirectlyRemoveMotion.hx ├── DragListener.hx ├── DragManager.hx ├── DraggingImage.hx ├── DropMotion.hx ├── RejectedMotion.hx └── SourceData.hx ├── error ├── AsWingManagerNotInited.hx ├── Error.hx ├── ImpMissError.hx └── UnsupportedError.hx ├── event ├── AWEvent.hx ├── AttachEvent.hx ├── CellEditorListener.hx ├── ClickCountEvent.hx ├── ColorChooserEvent.hx ├── ContainerEvent.hx ├── DragAndDropEvent.hx ├── ExpandVetoException.hx ├── FocusKeyEvent.hx ├── FrameEvent.hx ├── InteractiveEvent.hx ├── ListDataEvent.hx ├── ListDataListener.hx ├── ListItemEvent.hx ├── ModelEvent.hx ├── MovedEvent.hx ├── PopupEvent.hx ├── PropertyChangeEvent.hx ├── ReleaseEvent.hx ├── ResizedEvent.hx ├── ScrollPaneEvent.hx ├── SelectionEvent.hx ├── TabCloseEvent.hx ├── TableCellEditEvent.hx ├── TableModelEvent.hx ├── TableModelListener.hx ├── ToolTipEvent.hx ├── TreeCellEditEvent.hx ├── TreeEvent.hx ├── TreeModelEvent.hx ├── TreeModelListener.hx ├── TreeSelectionEvent.hx └── WindowEvent.hx ├── ext ├── DateChooser.hx ├── DateGridLayout.hx ├── DateLabel.hx ├── DateRange.hx ├── DefaultGridCell.hx ├── Folder.hx ├── Form.hx ├── FormRow.hx ├── GeneralGridListCellFactory.hx ├── GridCellHolder.hx ├── GridList.hx ├── GridListCell.hx ├── GridListCellFactory.hx ├── GridListItemEvent.hx ├── GridListLayout.hx └── MultilineLabel.hx ├── geom ├── IntDimension.hx ├── IntPoint.hx └── IntRectangle.hx ├── graphics ├── BitmapBrush.hx ├── GradientBrush.hx ├── GradientPen.hx ├── Graphics2D.hx ├── IBrush.hx ├── IPen.hx ├── Pen.hx └── SolidBrush.hx ├── plaf ├── ASColorUIResource.hx ├── ASFontUIResource.hx ├── AdjusterUI.hx ├── ArrayUIResource.hx ├── BaseComponentUI.hx ├── ColorSwatchesUI.hx ├── ComboBoxUI.hx ├── ComponentUI.hx ├── DefaultEmptyDecoraterResource.hx ├── DefaultsDecorator.hx ├── DefaultsDecoratorBase.hx ├── EmptyLayoutUIResourse.hx ├── EmptyUIResources.hx ├── FrameUI.hx ├── InsetsUIResource.hx ├── MenuElementUI.hx ├── SliderUI.hx ├── SplitPaneUI.hx ├── TableUI.hx ├── TreeUI.hx ├── UIResource.hx ├── UIStyleTune.hx └── basic │ ├── BasicAccordionUI.hx │ ├── BasicAdjusterUI.hx │ ├── BasicButtonUI.hx │ ├── BasicCheckBoxMenuItemUI.hx │ ├── BasicCheckBoxUI.hx │ ├── BasicClosableTabbedPaneUI.hx │ ├── BasicColorChooserUI.hx │ ├── BasicColorMixerUI.hx │ ├── BasicColorSwatchesUI.hx │ ├── BasicComboBoxUI.hx │ ├── BasicFrameTitleBarUI.hx │ ├── BasicFrameUI.hx │ ├── BasicGraphicsUtils.hx │ ├── BasicLabelButtonUI.hx │ ├── BasicLabelUI.hx │ ├── BasicListUI.hx │ ├── BasicLookAndFeel.hx │ ├── BasicMenuBarUI.hx │ ├── BasicMenuItemUI.hx │ ├── BasicMenuUI.hx │ ├── BasicPanelUI.hx │ ├── BasicPopupMenuUI.hx │ ├── BasicProgressBarUI.hx │ ├── BasicRadioButtonMenuItemUI.hx │ ├── BasicRadioButtonUI.hx │ ├── BasicScrollBarUI.hx │ ├── BasicScrollPaneUI.hx │ ├── BasicSeparatorUI.hx │ ├── BasicSliderUI.hx │ ├── BasicSpacerUI.hx │ ├── BasicSplitPaneUI.hx │ ├── BasicStepperUI.hx │ ├── BasicTabbedPaneUI.hx │ ├── BasicTableHeaderUI.hx │ ├── BasicTableUI.hx │ ├── BasicTextAreaUI.hx │ ├── BasicTextComponentUI.hx │ ├── BasicTextFieldUI.hx │ ├── BasicToggleButtonUI.hx │ ├── BasicToolBarUI.hx │ ├── BasicToolTipUI.hx │ ├── BasicTreeUI.hx │ ├── BasicViewportUI.hx │ ├── DefaultMenuLayout.hx │ ├── accordion │ └── BasicAccordionHeader.hx │ ├── adjuster │ ├── PopupSliderThumbIcon.hx │ └── PopupSliderUI.hx │ ├── background │ ├── ButtonBackground.hx │ ├── ComboBoxBackground.hx │ ├── FrameBackground.hx │ ├── InputBackground.hx │ ├── ListBackground.hx │ ├── PanelBackground.hx │ ├── ProgressBarBackground.hx │ ├── ProgressBarIcon.hx │ ├── ScrollBarBackground.hx │ ├── ScrollBarThumb.hx │ ├── TableBackground.hx │ ├── TableHeaderBackground.hx │ ├── TextComponentBackBround.hx │ ├── ToggleButtonBackground.hx │ └── ToolTipBackground.hx │ ├── border │ ├── ColorChooserBorder.hx │ ├── ComboBoxBorder.hx │ ├── ComboBoxPopupBorder.hx │ ├── EmptyBorderResource.hx │ ├── FrameBorder.hx │ ├── PopupMenuBorder.hx │ ├── ProgressBarBorder.hx │ ├── TableHeaderCellBorder.hx │ ├── TextAreaBorder.hx │ ├── TextComponentBorder.hx │ ├── TextFieldBorder.hx │ └── ToolTipBorder.hx │ ├── cursor │ ├── HV_ResizeCursor.hx │ ├── H_ResizeCursor.hx │ └── V_ResizeCursor.hx │ ├── frame │ └── BasicFrameTitleBarBG.hx │ ├── icon │ ├── ArrowIcon.hx │ ├── CheckBoxIcon.hx │ ├── CheckBoxMenuItemCheckIcon.hx │ ├── FrameCloseIcon.hx │ ├── FrameIcon.hx │ ├── FrameIconifiedIcon.hx │ ├── FrameMaximizeIcon.hx │ ├── FrameNormalIcon.hx │ ├── MenuArrowIcon.hx │ ├── MenuCheckIcon.hx │ ├── MenuItemArrowIcon.hx │ ├── MenuItemCheckIcon.hx │ ├── RadioButtonIcon.hx │ ├── RadioButtonMenuItemCheckIcon.hx │ ├── ScrollBarArrowIcon.hx │ ├── SliderThumbIcon.hx │ ├── SolidArrowIcon.hx │ └── TitleIcon.hx │ ├── splitpane │ ├── Divider.hx │ └── DividerIcon.hx │ ├── tabbedpane │ ├── BasicClosableTabbedPaneTab.hx │ ├── BasicTabbedPaneTab.hx │ ├── ClosableTab.hx │ ├── CloseIcon.hx │ ├── Tab.hx │ └── TabBackground.hx │ └── tree │ ├── BasicExpandControl.hx │ └── ExpandControl.hx ├── resizer ├── DefaultResizeBarHandler.hx ├── DefaultResizer.hx ├── ResizeStrategy.hx ├── ResizeStrategyImp.hx ├── Resizer.hx └── ResizerController.hx ├── table ├── AbstractTableCell.hx ├── AbstractTableModel.hx ├── DefaultTableColumnModel.hx ├── DefaultTableModel.hx ├── DefaultTextCell.hx ├── DefaultTextHeaderCell.hx ├── GeneralTableCellFactory.hx ├── GeneralTableCellFactoryUIResource.hx ├── JTableHeader.hx ├── PoorTextCell.hx ├── PropertyTableModel.hx ├── PropertyTranslator.hx ├── Resizable2.hx ├── Resizable2Imp1.hx ├── Resizable3.hx ├── Resizable3Imp1.hx ├── Resizable3Imp2.hx ├── SelectablePoorTextCell.hx ├── TableCell.hx ├── TableCellEditor.hx ├── TableCellFactory.hx ├── TableColumn.hx ├── TableColumnModel.hx ├── TableColumnModelEvent.hx ├── TableColumnModelListener.hx ├── TableModel.hx └── sorter │ ├── Arrow.hx │ ├── Directive.hx │ ├── Row.hx │ ├── SortableHeaderRenderer.hx │ ├── SortableTextHeaderCell.hx │ └── TableSorter.hx ├── tree ├── AbstractLayoutCache.hx ├── DefaultMutableTreeNode.hx ├── DefaultTreeCell.hx ├── DefaultTreeModel.hx ├── DefaultTreeSelectionModel.hx ├── EmptySelectionModel.hx ├── EnumerationInfo.hx ├── FHTreeStateNode.hx ├── FixedHeightLayoutCache.hx ├── GeneralTreeCellFactory.hx ├── GeneralTreeCellFactoryUIResource.hx ├── MutableTreeNode.hx ├── NodeDimensions.hx ├── PathPlaceHolder.hx ├── RowMapper.hx ├── SearchInfo.hx ├── TreeCell.hx ├── TreeCellEditor.hx ├── TreeCellFactory.hx ├── TreeFolderIcon.hx ├── TreeLeafIcon.hx ├── TreeModel.hx ├── TreeNode.hx ├── TreePath.hx ├── TreePathMap.hx └── TreeSelectionModel.hx └── util ├── AbstractImpulser.hx ├── ArrayList.hx ├── ArrayUtils.hx ├── DateAs.hx ├── DepthManager.hx ├── HashMap.hx ├── HashSet.hx ├── Impulser.hx ├── LinkedList.hx ├── List.hx ├── ListNode.hx ├── ObjectUtils.hx ├── Reflection.hx ├── Stack.hx ├── StringUtils.hx ├── Timer.hx ├── WeakMap.hx └── WeakReference.hx /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | 9 | # Compiled Static libraries 10 | *.lai 11 | *.la 12 | *.a 13 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2005-2012(c) AsWing.org. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are 5 | permitted provided that the following conditions are met: 6 | 7 | 1) Redistributions of source code must retain the above copyright notice, this list of 8 | conditions and the following disclaimer. 9 | 10 | 2) Redistributions in binary form must reproduce the above copyright notice, this list of 11 | conditions and the following disclaimer in the documentation and/or other materials 12 | provided with the distribution. 13 | 14 | 3) Neither the name AsWing.org nor the names of its contributors may be used to endorse 15 | or promote products derived from this software without specific prior written permission. 16 | 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 21 | THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 23 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 25 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | HaxeAsWing 2 | ========== 3 | 4 | HaxeAsWing is an Open Source Haxe GUI framework and library that allows programmers to App. Its usage is similar to Java Swing. It provides a set of GUI components -------------------------------------------------------------------------------- /bin/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsWing/aswing-openfl/a861b4f8031356a9131f405f89d3dffd5eb2473c/bin/2.jpg -------------------------------------------------------------------------------- /bin/AsWing.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsWing/aswing-openfl/a861b4f8031356a9131f405f89d3dffd5eb2473c/bin/AsWing.swf -------------------------------------------------------------------------------- /bin/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsWing/aswing-openfl/a861b4f8031356a9131f405f89d3dffd5eb2473c/bin/icon.png -------------------------------------------------------------------------------- /bin/princess.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AsWing/aswing-openfl/a861b4f8031356a9131f405f89d3dffd5eb2473c/bin/princess.jpg -------------------------------------------------------------------------------- /compile.hxml: -------------------------------------------------------------------------------- 1 | -main Main 2 | -swf-version 9 3 | -swf test.swf -------------------------------------------------------------------------------- /org/aswing/AbstractListCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.error.ImpMissError; 9 | 10 | /** 11 | * Abstract list cell. 12 | * @author paling 13 | */ 14 | class AbstractListCell implements ListCell { 15 | 16 | private var value:Dynamic; 17 | private static var AWML_INDEX:Int = 0; 18 | 19 | private var awmlIndex:Int; 20 | 21 | public function new() { 22 | AWML_INDEX++; 23 | awmlIndex = AWML_INDEX; 24 | 25 | } 26 | 27 | public function getAwmlIndex():Int { 28 | return awmlIndex; 29 | } 30 | 31 | public function setListCellStatus(list:JList, isSelected:Bool, index:Int):Void { 32 | var com:Component = getCellComponent(); 33 | if (isSelected) { 34 | com.setBackground(list.getSelectionBackground()); 35 | com.setForeground(list.getSelectionForeground()); 36 | } else { 37 | com.setBackground(list.getBackground()); 38 | com.setForeground(list.getForeground()); 39 | } 40 | com.setFont(list.getFont()); 41 | } 42 | 43 | public function setCellValue(value:Dynamic):Void { 44 | this.value = value; 45 | 46 | } 47 | 48 | public function getCellValue():Dynamic { 49 | return value; 50 | } 51 | 52 | /** 53 | * Subclass should override this method 54 | */ 55 | 56 | public function getCellComponent():Component { 57 | throw new ImpMissError(); 58 | return null; 59 | } 60 | 61 | public function dispose():Void { 62 | 63 | } 64 | } -------------------------------------------------------------------------------- /org/aswing/AbstractListModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.event.ListDataListener; 9 | import org.aswing.event.ListDataEvent; 10 | import org.aswing.util.ArrayUtils; 11 | /** 12 | * Abstract list model that provide the list model events base. 13 | * @author paling 14 | */ 15 | class AbstractListModel { 16 | 17 | private var listeners:Array; 18 | 19 | public function new() { 20 | listeners = new Array(); 21 | } 22 | 23 | public function addListDataListener(l:ListDataListener):Void { 24 | listeners.push(l); 25 | } 26 | 27 | public function removeListDataListener(l:ListDataListener):Void { 28 | ArrayUtils.removeFromArray(listeners, l); 29 | } 30 | 31 | private function fireContentsChanged(target:Dynamic, index0:Int, index1:Int, removedItems:Array):Void { 32 | var e:ListDataEvent = new ListDataEvent(target, index0, index1, removedItems); 33 | 34 | for (i in 0...listeners.length) { 35 | var lis:ListDataListener = cast(listeners[i], ListDataListener); 36 | lis.contentsChanged(e); 37 | } 38 | } 39 | 40 | private function fireIntervalAdded(target:Dynamic, index0:Int, index1:Int):Void { 41 | var e:ListDataEvent = new ListDataEvent(target, index0, index1, []); 42 | 43 | for (i in 0...listeners.length) { 44 | var lis:ListDataListener = cast(listeners[i], ListDataListener); 45 | lis.intervalAdded(e); 46 | } 47 | } 48 | 49 | private function fireIntervalRemoved(target:Dynamic, index0:Int, index1:Int, removedItems:Array):Void { 50 | var e:ListDataEvent = new ListDataEvent(target, index0, index1, removedItems); 51 | 52 | for (i in 0...listeners.length) { 53 | var lis:ListDataListener = cast(listeners[i], ListDataListener); 54 | lis.intervalRemoved(e); 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /org/aswing/AssetBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.geom.IntRectangle; 10 | import flash.display.DisplayObject; 11 | 12 | /** 13 | * A background with specified asset display object. 14 | *

15 | * The display object will be added to component to be the backgound, and will 16 | * be set width and height property to fit the size 17 | * of the component. 18 | *

19 | * @author paling 20 | */ 21 | class AssetBackground implements GroundDecorator { 22 | 23 | private var asset:DisplayObject; 24 | 25 | public function new(asset:DisplayObject) { 26 | this.asset = asset; 27 | } 28 | 29 | public function updateDecorator(com:Component, g:Graphics2D, bounds:IntRectangle):Void { 30 | asset.x = bounds.x; 31 | asset.y = bounds.y; 32 | asset.width = bounds.width; 33 | asset.height = bounds.height; 34 | } 35 | 36 | public function getDisplay(c:Component):DisplayObject { 37 | return asset; 38 | } 39 | } -------------------------------------------------------------------------------- /org/aswing/Border.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.geom.IntRectangle; 9 | import org.aswing.graphics.Graphics2D; 10 | /** 11 | * Interface describing an object capable of rendering a border around the edges of a component. 12 | *

13 | * You can either return a display object to be the border or just return null and paint the border 14 | * in updateBorder method use the component g(Graphics). 15 | *

16 | */ 17 | interface Border extends Decorator { 18 | 19 | /** 20 | * Updates the border. 21 | * @param c the component which owns the border. 22 | * @param g the graphics of the component, you can paint picture onto it. 23 | * @param b the bounds of the border should be. 24 | */ 25 | function updateBorder(c:Component, g:Graphics2D, b:IntRectangle):Void; 26 | 27 | /** 28 | * Returns the insets of the border. 29 | * @param c the component which owns the border. 30 | * @param b the bounds of the border should be. 31 | */ 32 | function getBorderInsets(c:Component, b:IntRectangle):Insets; 33 | } -------------------------------------------------------------------------------- /org/aswing/Cell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * Complex component cell base class, like JList, JTable's cell. 10 | * @author paling 11 | */ 12 | interface Cell { 13 | /** 14 | * Sets the value of this cell. 15 | * @param value which should represent on the component of this cell. 16 | */ 17 | function setCellValue(value:Dynamic):Void; 18 | 19 | /** 20 | * Returns the value of the cell. 21 | * @return the value of the cell. 22 | */ 23 | function getCellValue():Dynamic; 24 | 25 | /** 26 | * Return the represent component of this cell. 27 | * @return the cell component. 28 | */ 29 | function getCellComponent():Component; 30 | 31 | function dispose():Void; 32 | } -------------------------------------------------------------------------------- /org/aswing/CellPane.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * Cell Pane is just a container, it do not layout children, 10 | * do not invalidate parent. 11 | * @author paling 12 | */ 13 | class CellPane extends Container { 14 | 15 | public function new() { 16 | super(); 17 | } 18 | 19 | override public function revalidate():Void { 20 | valid = true; 21 | } 22 | 23 | override public function invalidate():Void { 24 | valid = true; 25 | } 26 | 27 | override private function invalidateTree():Void { 28 | valid = true; 29 | } 30 | 31 | override public function validate():Void { 32 | valid = true; 33 | } 34 | } -------------------------------------------------------------------------------- /org/aswing/CenterLayout.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing; 5 | 6 | import org.aswing.Component; 7 | import org.aswing.Container; 8 | import org.aswing.EmptyLayout; 9 | import org.aswing.geom.IntDimension; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.Insets; 12 | 13 | /** 14 | * Simple LayoutManager aligned the single contained component by the container's center. 15 | * 16 | * @author paling 17 | * @author Igor Sadovskiy 18 | */ 19 | class CenterLayout extends EmptyLayout { 20 | public function new() { 21 | super(); 22 | } 23 | 24 | /** 25 | * Calculates preferred layout size for the given container. 26 | */ 27 | 28 | override public function preferredLayoutSize(target:Container):IntDimension { 29 | return ( (target.getComponentCount() > 0) ? 30 | target.getInsets().getOutsideSize(target.getComponent(0).getPreferredSize()) : 31 | target.getInsets().getOutsideSize()); 32 | } 33 | 34 | /** 35 | * Layouts component by center inside the given container. 36 | * 37 | * @param target the container to lay out 38 | */ 39 | 40 | override public function layoutContainer(target:Container):Void { 41 | if (target.getComponentCount() > 0) { 42 | var size:IntDimension = target.getSize(); 43 | var insets:Insets = target.getInsets(); 44 | var rd:IntRectangle = insets.getInsideBounds(size.getBounds()); 45 | var c:Component = target.getComponent(0); 46 | 47 | var cd:IntRectangle = rd.clone(); 48 | var preferSize:IntDimension = c.getPreferredSize(); 49 | cd.setSize(preferSize); 50 | 51 | if (rd.width > preferSize.width) { 52 | cd.x += Std.int((rd.width - preferSize.width) / 2); 53 | } 54 | if (rd.height > preferSize.height) { 55 | cd.y += Std.int((rd.height - preferSize.height) / 2); 56 | } 57 | cd.x = Math.round(cd.x); 58 | cd.y = Math.round(cd.y); 59 | c.setBounds(cd); 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /org/aswing/ComboBoxEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * The editor component used for JComboBox components. 10 | * @author paling 11 | */ 12 | interface ComboBoxEditor { 13 | 14 | /** 15 | * Return the component that performance the editing asset. 16 | * @return the editor component 17 | */ 18 | function getEditorComponent():Component; 19 | 20 | /** 21 | * Sets whether the editor is editable now. 22 | */ 23 | function setEditable(b:Bool):Void; 24 | 25 | /** 26 | * Returns whether the editor is editable now. 27 | */ 28 | function isEditable():Bool; 29 | 30 | /** 31 | * Adds a listener to listen the editor event when the edited item changes. 32 | * @param listener the listener 33 | * @param priority the priority 34 | * @param useWeakReference Determines whether the reference to the listener is strong or weak. 35 | * @see org.aswing.event.AWEvent#ACT 36 | */ 37 | function addActionListener(listener:Dynamic -> Void, priority:Int = 0, useWeakReference:Bool = false):Void; 38 | 39 | /** 40 | * Removes a action listener. 41 | * @param listener the listener to be removed. 42 | * @see org.aswing.event.AWEvent#ACT 43 | */ 44 | function removeActionListener(listener:Dynamic -> Void):Void; 45 | 46 | /** 47 | * Set the item that should be edited. Cancel any editing if necessary. 48 | */ 49 | function setValue(value:Dynamic):Void; 50 | 51 | /** 52 | * Return the edited item. 53 | */ 54 | function getValue():Dynamic; 55 | 56 | /** 57 | * Ask the editor to start editing and to select everything in the editor. 58 | */ 59 | function selectAll():Void; 60 | 61 | function dispose():Void; 62 | } -------------------------------------------------------------------------------- /org/aswing/Cursor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import flash.display.DisplayObject; 9 | import flash.display.Bitmap; 10 | import flash.display.Sprite; 11 | /** 12 | * The Cursor definited from Look and Feels. 13 | * @author paling 14 | */ 15 | class Cursor { 16 | 17 | /** 18 | * Horizontal resize cursor key. 19 | */ 20 | inline public static var H_RESIZE_CURSOR:String = "System.hResizeCursor"; 21 | 22 | /** 23 | * Vertical resize cursor key. 24 | */ 25 | inline public static var V_RESIZE_CURSOR:String = "System.vResizeCursor"; 26 | 27 | /** 28 | * Horizontal move cursor key. 29 | */ 30 | inline public static var H_MOVE_CURSOR:String = "System.hMoveCursor"; 31 | 32 | /** 33 | * Vertical move cursor key. 34 | */ 35 | inline public static var V_MOVE_CURSOR:String = "System.vMoveCursor"; 36 | 37 | /** 38 | * All direction resize cursor key. 39 | */ 40 | inline public static var HV_RESIZE_CURSOR:String = "System.hvResizeCursor"; 41 | 42 | /** 43 | * All direction move cursor key. 44 | */ 45 | inline public static var HV_MOVE_CURSOR:String = "System.hvMoveCursor"; 46 | 47 | /** 48 | * Create a cursor from the look and feel defined system cursor. 49 | * @param the type of the cursor 50 | * @return a cursor, or null if there is not such cursor of this type. 51 | */ 52 | 53 | public static function createCursor(type:String):DisplayObject { 54 | var cursor:DisplayObject = cast( UIManager.getInstance(type), DisplayObject); 55 | if (cursor == null) { 56 | return null; 57 | } else if (Std.is(cursor, Bitmap)) { 58 | var sp:Sprite = AsWingUtils.createSprite(null, "bmCursorAdap"); 59 | sp.addChild(cursor); 60 | cursor.x = -cursor.width / 2; 61 | cursor.y = -cursor.height / 2; 62 | return sp; 63 | } else { 64 | return cursor; 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /org/aswing/Decorator.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import flash.display.DisplayObject; 9 | 10 | /** 11 | * Decorator for components, it return a display object to be the UI decorator. 12 | */ 13 | interface Decorator { 14 | /** 15 | * Returns the display object which is used as the component decorator. 16 | *

17 | * For same component, this method must return same display object. 18 | *

19 | * @param c the component which will use this decorator. 20 | * @return the display object 21 | */ 22 | function getDisplay(c:Component):DisplayObject; 23 | 24 | } -------------------------------------------------------------------------------- /org/aswing/DefaultCheckBoxCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.AbstractCellEditor; 9 | import org.aswing.Component; 10 | import org.aswing.JCheckBox; 11 | 12 | /** 13 | * @author paling 14 | */ 15 | class DefaultCheckBoxCellEditor extends AbstractCellEditor { 16 | 17 | private var checkBox:JCheckBox; 18 | 19 | public function new() { 20 | super(); 21 | setClickCountToStart(1); 22 | } 23 | 24 | public function getCheckBox():JCheckBox { 25 | if (checkBox == null) { 26 | checkBox = new JCheckBox(); 27 | } 28 | return checkBox; 29 | } 30 | 31 | override public function getEditorComponent():Component { 32 | return getCheckBox(); 33 | } 34 | 35 | override public function getCellEditorValue():Dynamic { 36 | return getCheckBox().isSelected(); 37 | } 38 | 39 | /** 40 | * Sets the value of this cell. 41 | * @param value the new value of this cell 42 | */ 43 | 44 | override private function setCellEditorValue(value:Dynamic):Void { 45 | var selected:Bool = false; 46 | if (value == true) { 47 | selected = true; 48 | } 49 | if (Std.is(value, String)) { 50 | var va:String = cast(value, String); 51 | if (va.toLowerCase() == "true") { 52 | selected = true; 53 | } 54 | } 55 | getCheckBox().setSelected(selected); 56 | } 57 | 58 | public function toString():String { 59 | return "DefaultCheckBoxCellEditor[]"; 60 | } 61 | } -------------------------------------------------------------------------------- /org/aswing/DefaultComboBoxCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.AbstractCellEditor; 9 | import org.aswing.Component; 10 | import org.aswing.JComboBox; 11 | 12 | /** 13 | * The default editor for table and tree cells, use a combobox. 14 | *

15 | * @author paling 16 | */ 17 | class DefaultComboBoxCellEditor extends AbstractCellEditor { 18 | 19 | private var comboBox:JComboBox; 20 | 21 | public function new() { 22 | super(); 23 | setClickCountToStart(1); 24 | } 25 | 26 | public function getComboBox():JComboBox { 27 | if (comboBox == null) { 28 | comboBox = new JComboBox(); 29 | } 30 | return comboBox; 31 | } 32 | 33 | override public function getEditorComponent():Component { 34 | return getComboBox(); 35 | } 36 | 37 | override public function getCellEditorValue():Dynamic { 38 | return getComboBox().getSelectedItem(); 39 | } 40 | 41 | /** 42 | * Sets the value of this cell. 43 | * @param value the new value of this cell 44 | */ 45 | 46 | override private function setCellEditorValue(value:Dynamic):Void { 47 | getComboBox().setSelectedItem(value); 48 | } 49 | 50 | public function toString():String { 51 | return "DefaultComboBoxCellEditor[]"; 52 | } 53 | } -------------------------------------------------------------------------------- /org/aswing/DefaultComboBoxListCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import flash.events.MouseEvent; 9 | 10 | /** 11 | * The list cell for combobox drop down list. 12 | * @author paling 13 | */ 14 | class DefaultComboBoxListCell extends DefaultListCell { 15 | 16 | private var rolloverBackground:ASColor; 17 | private var rolloverForeground:ASColor; 18 | private var realBackground:ASColor; 19 | private var realForeground:ASColor; 20 | 21 | public function new() { 22 | super(); 23 | } 24 | 25 | override private function initJLabel(jlabel:JLabel):Void { 26 | super.initJLabel(jlabel); 27 | jlabel.addEventListener(MouseEvent.ROLL_OVER, __labelRollover, false, 0, false); 28 | jlabel.addEventListener(MouseEvent.ROLL_OUT, __labelRollout, false, 0, false); 29 | } 30 | 31 | override public function setListCellStatus(list:JList, isSelected:Bool, index:Int):Void { 32 | var com:Component = getCellComponent(); 33 | if (isSelected) { 34 | com.setBackground((realBackground = list.getSelectionBackground())); 35 | com.setForeground((realForeground = list.getSelectionForeground())); 36 | } else { 37 | com.setBackground((realBackground = list.getBackground())); 38 | com.setForeground((realForeground = list.getForeground())); 39 | } 40 | com.setFont(list.getFont()); 41 | rolloverBackground = list.getSelectionBackground().changeAlpha(0.8); 42 | rolloverForeground = list.getSelectionForeground(); 43 | } 44 | 45 | private function __labelRollover(e:MouseEvent):Void { 46 | if (rolloverBackground != null) { 47 | getJLabel().setBackground(rolloverBackground); 48 | getJLabel().setForeground(rolloverForeground); 49 | } 50 | } 51 | 52 | private function __labelRollout(e:MouseEvent):Void { 53 | if (realBackground != null) { 54 | getJLabel().setBackground(realBackground); 55 | getJLabel().setForeground(realForeground); 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /org/aswing/DefaultComboBoxListCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * The default list cell factory for JComboBox drop down list. 10 | * @see org.aswing.JComboBox 11 | * @author paling 12 | */ 13 | class DefaultComboBoxListCellFactory extends DefaultListTextCellFactory { 14 | 15 | public function new(shareCelles:Bool = true, sameHeight:Bool = true) { 16 | super(DefaultComboBoxListCell, shareCelles, sameHeight); 17 | } 18 | } -------------------------------------------------------------------------------- /org/aswing/DefaultListCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.event.ResizedEvent; 9 | import org.aswing.geom.IntPoint; 10 | 11 | /** 12 | * Default list cell, render item value.toString() text. 13 | * @author paling 14 | */ 15 | class DefaultListCell extends AbstractListCell { 16 | 17 | private var jlabel:JLabel; 18 | 19 | private static var sharedToolTip:JSharedToolTip; 20 | 21 | public function new() { 22 | super(); 23 | if (sharedToolTip == null) { 24 | sharedToolTip = JSharedToolTip.getSharedInstance(); 25 | sharedToolTip.setOffsetsRelatedToMouse(false); 26 | sharedToolTip.setOffsets(new IntPoint(0, 0)); 27 | } 28 | } 29 | 30 | override public function setCellValue(value:Dynamic):Void { 31 | super.setCellValue(value); 32 | getJLabel().setText(getStringValue(value)); 33 | __resized(null); 34 | } 35 | 36 | /** 37 | * Override this if you need other value->string translator 38 | */ 39 | 40 | private function getStringValue(value:Dynamic):String { 41 | return value + ""; 42 | } 43 | 44 | override public function getCellComponent():Component { 45 | return getJLabel(); 46 | } 47 | 48 | private function getJLabel():JLabel { 49 | if (jlabel == null) { 50 | jlabel = new JLabel(); 51 | initJLabel(jlabel); 52 | } 53 | return jlabel; 54 | } 55 | 56 | private function initJLabel(jlabel:JLabel):Void { 57 | jlabel.setHorizontalAlignment(JLabel.LEFT); 58 | jlabel.setOpaque(true); 59 | jlabel.setFocusable(false); 60 | jlabel.addEventListener(ResizedEvent.RESIZED, __resized); 61 | 62 | } 63 | 64 | private function __resized(e:ResizedEvent):Void { 65 | if (getJLabel().getWidth() < getJLabel().getPreferredWidth()) { 66 | getJLabel().setToolTipText(value.toString()); 67 | 68 | sharedToolTip.registerComponent(getJLabel()); 69 | } else { 70 | getJLabel().setToolTipText(null); 71 | sharedToolTip.unregisterComponent(getJLabel()); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /org/aswing/DefaultListCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * The default list cell factory for JList. 10 | * @see org.aswing.JList 11 | * @author paling 12 | */ 13 | class DefaultListCellFactory extends DefaultListTextCellFactory { 14 | 15 | public function new(shareCelles:Bool = true, sameHeight:Bool = true) { 16 | super(DefaultListCell, shareCelles, sameHeight); 17 | } 18 | } -------------------------------------------------------------------------------- /org/aswing/DefaultNumberTextFieldCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.DefaultTextFieldCellEditor; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | class DefaultNumberTextFieldCellEditor extends DefaultTextFieldCellEditor { 14 | 15 | public function new() { 16 | super(); 17 | } 18 | 19 | /** 20 | * Subclass override this method to implement specified input restrict 21 | */ 22 | 23 | override private function getRestrict():String { 24 | return "-0123456789.E"; 25 | } 26 | 27 | /** 28 | * Subclass override this method to implement specified value transform 29 | */ 30 | 31 | override private function transforValueFromText(text:String):Dynamic { 32 | return Std.parseFloat(text); 33 | } 34 | } -------------------------------------------------------------------------------- /org/aswing/DefaultSingleSelectionModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | import flash.events.EventDispatcher; 8 | 9 | import org.aswing.event.InteractiveEvent; 10 | /** 11 | * A generic implementation of SingleSelectionModel. 12 | * @author paling 13 | */ 14 | class DefaultSingleSelectionModel extends EventDispatcher implements SingleSelectionModel { 15 | 16 | private var index:Int; 17 | 18 | public function new() { 19 | index = -1; 20 | super(); 21 | } 22 | 23 | public function getSelectedIndex():Int { 24 | return index; 25 | } 26 | 27 | public function setSelectedIndex(index:Int, programmatic:Bool = true):Void { 28 | if (this.index != index) { 29 | this.index = index; 30 | fireChangeEvent(programmatic); 31 | } 32 | } 33 | 34 | public function clearSelection(programmatic:Bool = true):Void { 35 | setSelectedIndex(-1, programmatic); 36 | } 37 | 38 | public function isSelected():Bool { 39 | return getSelectedIndex() != -1; 40 | } 41 | 42 | public function addStateListener(listener:Dynamic -> Void, priority:Int = 0, useWeakReference:Bool = false):Void { 43 | addEventListener(InteractiveEvent.STATE_CHANGED, listener, false, priority, useWeakReference); 44 | } 45 | 46 | public function removeStateListener(listener:Dynamic -> Void):Void { 47 | removeEventListener(InteractiveEvent.STATE_CHANGED, listener); 48 | } 49 | 50 | private function fireChangeEvent(programmatic:Bool):Void { 51 | dispatchEvent(new InteractiveEvent(InteractiveEvent.STATE_CHANGED, programmatic)); 52 | } 53 | } -------------------------------------------------------------------------------- /org/aswing/DefaultTextFieldCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.AbstractCellEditor; 9 | import org.aswing.Component; 10 | import org.aswing.JTextField; 11 | 12 | /** 13 | * The default editor for table and tree cells, use a textfield. 14 | *

15 | * @author paling 16 | */ 17 | class DefaultTextFieldCellEditor extends AbstractCellEditor { 18 | 19 | private var textField:JTextField; 20 | 21 | public function new() { 22 | super(); 23 | setClickCountToStart(2); 24 | } 25 | 26 | public function getTextField():JTextField { 27 | if (textField == null) { 28 | textField = new JTextField(); 29 | //textField.setBorder(null); 30 | #if (flash9) 31 | textField.setRestrict(getRestrict()); 32 | #end 33 | } 34 | return textField; 35 | } 36 | 37 | /** 38 | * Subclass override this method to implement specified input restrict 39 | */ 40 | 41 | private function getRestrict():String { 42 | return null; 43 | } 44 | 45 | /** 46 | * Subclass override this method to implement specified value transform 47 | */ 48 | 49 | private function transforValueFromText(text:String):Dynamic { 50 | return text; 51 | } 52 | 53 | override public function getEditorComponent():Component { 54 | return getTextField(); 55 | } 56 | 57 | override public function getCellEditorValue():Dynamic { 58 | return transforValueFromText(getTextField().getText()); 59 | } 60 | 61 | /** 62 | * Sets the value of this cell. 63 | * @param value the new value of this cell 64 | */ 65 | 66 | override private function setCellEditorValue(value:Dynamic):Void { 67 | getTextField().setText(value + ""); 68 | #if (flash9) 69 | getTextField().selectAll(); 70 | #end 71 | } 72 | 73 | public function toString():String { 74 | return "DefaultTextFieldCellEditor[]"; 75 | } 76 | } -------------------------------------------------------------------------------- /org/aswing/EditableComponent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * Interface for editable components. 10 | * @author paling 11 | */ 12 | interface EditableComponent { 13 | 14 | /** 15 | * Returns true if the component is editable, false not editable. 16 | * @return true if the component is editable, false not editable. 17 | */ 18 | function isEditable():Bool; 19 | 20 | /** 21 | * Sets the whether or not the component is editable. 22 | * @param b true to set to editable, false not editable. 23 | */ 24 | function setEditable(b:Bool):Void; 25 | } -------------------------------------------------------------------------------- /org/aswing/EmptyFont.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import flash.text.TextField; 9 | import flash.text.TextFormat; 10 | /** 11 | * EmptyFont is a font that will not change text field's format. 12 | */ 13 | class EmptyFont extends ASFont { 14 | 15 | public function new() { 16 | super(); 17 | } 18 | 19 | /** 20 | * Do nothing here. 21 | * @param textField the text filed to be applied font. 22 | * @param beginIndex The zero-based index position specifying the first character of the desired range of text. 23 | * @param endIndex The zero-based index position specifying the last character of the desired range of text. 24 | */ 25 | 26 | override public function apply(textField:TextField, beginIndex:Int = -1, endIndex:Int = -1):Void { 27 | } 28 | 29 | /** 30 | * Returns new TextFormat(). 31 | * @return new TextFormat(). 32 | */ 33 | 34 | override public function getTextFormat():TextFormat { 35 | return new TextFormat(); 36 | } 37 | } -------------------------------------------------------------------------------- /org/aswing/EmptyIcon.hx: -------------------------------------------------------------------------------- 1 | package org.aswing; 2 | 3 | 4 | import flash.display.DisplayObject; 5 | import org.aswing.graphics.Graphics2D; 6 | 7 | /** 8 | * EmptyIcon is just for sit a place. 9 | * @author paling 10 | */ 11 | class EmptyIcon implements Icon { 12 | 13 | private var width:Int; 14 | private var height:Int; 15 | 16 | public function new(width:Int, height:Int) { 17 | this.width = width; 18 | this.height = height; 19 | } 20 | 21 | public function getDisplay(c:Component):DisplayObject { 22 | return null; 23 | } 24 | 25 | public function getIconWidth(c:Component):Int { 26 | return width; 27 | } 28 | 29 | public function getIconHeight(c:Component):Int { 30 | return height; 31 | } 32 | 33 | public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 34 | } 35 | } -------------------------------------------------------------------------------- /org/aswing/EmptyLayout.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing; 5 | 6 | import org.aswing.geom.IntDimension; 7 | import org.aswing.Container; 8 | import org.aswing.Component; 9 | 10 | /** 11 | * LayoutManager's empty implementation. 12 | * @author paling 13 | */ 14 | class EmptyLayout implements LayoutManager { 15 | public function new() { 16 | } 17 | 18 | /** 19 | * Do nothing 20 | * @inheritDoc 21 | */ 22 | 23 | public function addLayoutComponent(comp:Component, constraints:Dynamic):Void { 24 | } 25 | 26 | /** 27 | * Do nothing 28 | * @inheritDoc 29 | */ 30 | 31 | public function removeLayoutComponent(comp:Component):Void { 32 | } 33 | 34 | /** 35 | * Simply return target.getSize(); 36 | */ 37 | 38 | public function preferredLayoutSize(target:Container):IntDimension { 39 | return target.getSize(); 40 | } 41 | 42 | /** 43 | * new IntDimension(0, 0); 44 | */ 45 | 46 | public function minimumLayoutSize(target:Container):IntDimension { 47 | return new IntDimension(0, 0); 48 | } 49 | 50 | /** 51 | * return IntDimension.createBigDimension(); 52 | */ 53 | 54 | public function maximumLayoutSize(target:Container):IntDimension { 55 | return IntDimension.createBigDimension(); 56 | } 57 | 58 | /** 59 | * do nothing 60 | */ 61 | 62 | public function layoutContainer(target:Container):Void { 63 | } 64 | 65 | /** 66 | * return 0 67 | */ 68 | 69 | public function getLayoutAlignmentX(target:Container):Float { 70 | return 0; 71 | } 72 | 73 | /** 74 | * return 0 75 | */ 76 | 77 | public function getLayoutAlignmentY(target:Container):Float { 78 | return 0; 79 | } 80 | 81 | /** 82 | * do nothing 83 | */ 84 | 85 | public function invalidateLayout(target:Container):Void { 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /org/aswing/FocusTraversalPolicy.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * A FocusTraversalPolicy defines the order in which Components with a 10 | * particular focus cycle root are traversed in a Container. 11 | *

12 | * The core responsibility of a FocusTraversalPolicy is to provide algorithms 13 | * determining the next and previous Components to focus when traversing 14 | * forward or backward in a UI. Each FocusTraversalPolicy must also provide 15 | * algorithms for determining the default Components in a 16 | * traversal cycle. The default Component is the first 17 | * to receive focus when traversing down into a new focus traversal cycle. 18 | * if the next/previous searched null to be returned, it means can't found a 19 | * component to be focused. 20 | *

21 | * 22 | */ 23 | interface FocusTraversalPolicy { 24 | 25 | /** 26 | * Returns the Component that should receive the focus after c. 27 | * 28 | * @param c the focus position used to count next 29 | * @return the Component that should receive the focus after c, or 30 | * null if no Component can be found in this policy 31 | */ 32 | function getComponentAfter(c:Component):Component; 33 | 34 | /** 35 | * Returns the Component that should receive the focus before c. 36 | * 37 | * @param c the focus position used to count previous 38 | * @return the Component that should receive the focus before c, or 39 | * null if no Component can be found in this policy 40 | */ 41 | function getComponentBefore(c:Component):Component; 42 | 43 | /** 44 | * Returns the default Component to focus in the specifield container. 45 | * This Component will be the first to receive focus when traversing down into 46 | * this container. 47 | * @param container the cirle root container 48 | * @return the default Component in the container, 49 | * or null if no Component can be found 50 | */ 51 | function getDefaultComponent(container:Container):Component; 52 | } -------------------------------------------------------------------------------- /org/aswing/FrameTitleBarLayout.hx: -------------------------------------------------------------------------------- 1 | package org.aswing; 2 | 3 | 4 | import org.aswing.BorderLayout; 5 | import org.aswing.Container; 6 | import org.aswing.FrameTitleBar; 7 | import org.aswing.JLabel; 8 | import org.aswing.geom.IntDimension; 9 | 10 | class FrameTitleBarLayout extends BorderLayout { 11 | 12 | private var minSize:IntDimension; 13 | 14 | public function new(minWidth:Int = 50, height:Int = 20) { 15 | super(); 16 | minSize = new IntDimension(minWidth, height); 17 | } 18 | 19 | private function countMinSize(target:Container):Void { 20 | var bar:FrameTitleBar = cast( target, FrameTitleBar ); 21 | minSize.height = bar.getMinimizeHeight(); 22 | } 23 | 24 | override public function minimumLayoutSize(target:Container):IntDimension { 25 | countMinSize(target); 26 | return preferredLayoutSize(target); 27 | } 28 | 29 | /** 30 | * 31 | */ 32 | 33 | override public function preferredLayoutSize(target:Container):IntDimension { 34 | countMinSize(target); 35 | var size:IntDimension = super.preferredLayoutSize(target); 36 | var bar:FrameTitleBar = cast( target, FrameTitleBar ); 37 | var label:JLabel = bar.getLabel(); 38 | if (label != null && label.isVisible()) { 39 | size.width -= Std.int(Math.max(0, label.getPreferredWidth() - 60)); 40 | } 41 | size.width = Std.int(Math.max(minSize.width, size.width)); 42 | size.height = Std.int(Math.max(minSize.height, size.height)); 43 | return size; 44 | } 45 | } -------------------------------------------------------------------------------- /org/aswing/GradientBackground.hx: -------------------------------------------------------------------------------- 1 | package org.aswing; 2 | 3 | 4 | import flash.display.GradientType; 5 | import flash.display.SpreadMethod; 6 | import org.aswing.graphics.GradientBrush; 7 | import org.aswing.graphics.Graphics2D; 8 | import org.aswing.geom.IntRectangle; 9 | import flash.display.DisplayObject; 10 | import flash.geom.Matrix; 11 | import flash.display.Shape; 12 | import flash.display.InterpolationMethod; 13 | import flash.display.SpreadMethod; 14 | 15 | /** 16 | * A background decorator that paint a gradient color. 17 | * @author 18 | */ 19 | class GradientBackground implements GroundDecorator { 20 | 21 | private var brush:GradientBrush; 22 | private var direction:Float; 23 | private var shape:Shape; 24 | 25 | public function new(fillType:GradientType, colors:Array, alphas:Array, ratios:Array, direction:Float = 0, 26 | ?spreadMethod:SpreadMethod, ?interpolationMethod:InterpolationMethod, ?focalPointRatio:Float = 0) { 27 | this.brush = new GradientBrush(fillType, colors, alphas, ratios, new Matrix(), 28 | spreadMethod, interpolationMethod, focalPointRatio); 29 | this.direction = direction; 30 | shape = new Shape(); 31 | } 32 | 33 | public function updateDecorator(com:Component, g:Graphics2D, bounds:IntRectangle):Void { 34 | shape.graphics.clear(); 35 | g = new Graphics2D(shape.graphics); 36 | var matrix:Matrix = new Matrix(); 37 | matrix.createGradientBox(bounds.width, bounds.height, direction, bounds.x, bounds.y); 38 | brush.setMatrix(matrix); 39 | g.fillRectangle(brush, bounds.x, bounds.y, bounds.width, bounds.height); 40 | } 41 | 42 | public function getDisplay(c:Component):DisplayObject { 43 | return shape; 44 | } 45 | 46 | } -------------------------------------------------------------------------------- /org/aswing/GroundDecorator.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.geom.IntRectangle; 10 | import org.aswing.graphics.Graphics2D; 11 | /** 12 | * Decorator for background or foreground of a components. 13 | *

14 | * You can either return a display object to be the decorator or just return null and paint 15 | * in updateDecorator method use the component g(Graphics). 16 | *

17 | * (Maybe it is not good to paint on the component graphics for foreground decorator since component graphics 18 | * is not on top of component children) 19 | */ 20 | interface GroundDecorator extends Decorator { 21 | 22 | /** 23 | * Updates the decorator. 24 | * @param c the component which owns the ground decorator. 25 | * @param g the graphics of the component, you can paint picture onto it. 26 | * @param b the bounds of the component can be decorated. 27 | */ 28 | function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void; 29 | 30 | } -------------------------------------------------------------------------------- /org/aswing/Icon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.graphics.Graphics2D; 10 | /** 11 | * A small fixed size picture, typically used to decorate components. 12 | *

13 | * You can either return a display object to be the icon or just return null and paint the picture 14 | * in updateIcon method use the component g(Graphics). 15 | *

16 | * But, you'd better to return a display object here, because if you just paint graphics 17 | * to the target component graphics, there's a situation that your painted graphics maybe 18 | * not eyeable, that is when the component has a background decorator with a display object, 19 | * it will cover this graphics. If you return a display object here, it will be no problem of this case. 20 | */ 21 | interface Icon extends Decorator { 22 | 23 | /** 24 | * Returuns the icon width. 25 | *

26 | * For same component param, this method must return same value. 27 | *

28 | * @param c the component which owns the icon. 29 | * @return the width of the icon. 30 | */ 31 | function getIconWidth(c:Component):Int; 32 | 33 | /** 34 | * Returns the icon height. 35 | *

36 | * For same component param, this method must return same value. 37 | *

38 | * @param c the component which owns the icon. 39 | * @return the height of the icon. 40 | */ 41 | function getIconHeight(c:Component):Int; 42 | 43 | /** 44 | * Updates the icon. 45 | * @param c the component which owns the icon. 46 | * @param g the graphics of the component, you can paint picture onto it. 47 | * @param x the x coordinates of the icon should be. 48 | * @param y the y coordinates of the icon should be. 49 | */ 50 | function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void; 51 | 52 | } -------------------------------------------------------------------------------- /org/aswing/JAccordion.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.error.Error; 9 | import org.aswing.plaf.ComponentUI; 10 | import org.aswing.plaf.basic.BasicAccordionUI; 11 | 12 | /** 13 | * Accordion Container. 14 | * @author paling 15 | */ 16 | class JAccordion extends AbstractTabbedPane { 17 | 18 | /** 19 | * Create an accordion. 20 | */ 21 | public function new() { 22 | super(); 23 | setName("JAccordion"); 24 | 25 | updateUI(); 26 | } 27 | 28 | override public function updateUI():Void { 29 | setUI(UIManager.getUI(this)); 30 | } 31 | 32 | override public function getDefaultBasicUIClass():Class { 33 | return org.aswing.plaf.basic.BasicAccordionUI; 34 | } 35 | 36 | override public function getUIClassID():String { 37 | return "AccordionUI"; 38 | } 39 | 40 | /** 41 | * Generally you should not set layout to JAccordion. 42 | * @param layout layoutManager for JAccordion 43 | * @throws ArgumentError when you set a non-AccordionUI layout to JAccordion. 44 | */ 45 | 46 | override public function setLayout(layout:LayoutManager):Void { 47 | if (Std.is(layout, ComponentUI)) { 48 | super.setLayout(layout); 49 | } else { 50 | throw new Error("Cannot set non-AccordionUI layout to JAccordion!"); 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /org/aswing/JButton.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.plaf.basic.BasicButtonUI; 9 | 10 | /** 11 | * An implementation of a "push" button. 12 | * @author paling 13 | */ 14 | class JButton extends AbstractButton { 15 | public function new(text:String = "", icon:Icon = null) { 16 | super(text, icon); 17 | setName("JButton" + text); 18 | 19 | setModel(new DefaultButtonModel()); 20 | } 21 | 22 | /** 23 | * Returns whether this button is the default button of its root pane or not. 24 | * @return true if this button is the default button of its root pane, false otherwise. 25 | */ 26 | 27 | public function isDefaultButton():Bool { 28 | var rootPane:JRootPane = getRootPaneAncestor(); 29 | if (rootPane != null) { 30 | return rootPane.getDefaultButton() == this; 31 | } 32 | return false; 33 | } 34 | 35 | /** 36 | * Wrap a SimpleButton to be this button's representation. 37 | * @param btn the SimpleButton to be wrap. 38 | * @return the button self 39 | */ 40 | 41 | override public function wrapSimpleButton(btn:SimpleButton):AbstractButton { 42 | mouseChildren = true; 43 | drawTransparentTrigger = false; 44 | setShiftOffset(0); 45 | setIcon(new SimpleButtonIcon(btn)); 46 | setBorder(null); 47 | setMargin(new Insets()); 48 | setBackgroundDecorator(null); 49 | setOpaque(false); 50 | setHorizontalTextPosition(AsWingConstants.CENTER); 51 | setVerticalTextPosition(AsWingConstants.CENTER); 52 | return this; 53 | } 54 | 55 | override public function updateUI():Void { 56 | setUI(UIManager.getUI(this)); 57 | } 58 | 59 | override public function getDefaultBasicUIClass():Class { 60 | return org.aswing.plaf.basic.BasicButtonUI; 61 | } 62 | 63 | override public function getUIClassID():String { 64 | return "ButtonUI"; 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /org/aswing/JCheckBox.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | import org.aswing.plaf.basic.BasicCheckBoxUI; 8 | 9 | 10 | /** 11 | * An implementation of a check box -- an item that can be selected or 12 | * deselected, and which displays its state to the user. 13 | * By convention, any number of check boxes in a group can be selected. 14 | * @author paling 15 | */ 16 | class JCheckBox extends JToggleButton { 17 | 18 | public function new(text:String = "", icon:Icon = null) { 19 | super(text, icon); 20 | setName("JCheckBox"); 21 | setIconTextGap(1); 22 | } 23 | 24 | override public function getUIClassID():String { 25 | return "CheckBoxUI"; 26 | } 27 | 28 | override public function getDefaultBasicUIClass():Class { 29 | return org.aswing.plaf.basic.BasicCheckBoxUI; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /org/aswing/JCheckBoxMenuItem.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.plaf.basic.BasicCheckBoxMenuItemUI; 9 | 10 | /** 11 | * A menu item that can be selected or deselected. If selected, the menu 12 | * item typically appears with a checkmark next to it. If unselected or 13 | * deselected, the menu item appears without a checkmark. Like a regular 14 | * menu item, a check box menu item can have either text or a graphic 15 | * icon associated with it, or both. 16 | * @author paling 17 | */ 18 | class JCheckBoxMenuItem extends JMenuItem { 19 | 20 | public function new(text:String = "", icon:Icon = null) { 21 | super(text, icon); 22 | setName("JCheckBoxMenuItem"); 23 | setModel(new ToggleButtonModel()); 24 | } 25 | 26 | override public function getUIClassID():String { 27 | return "CheckBoxMenuItemUI"; 28 | } 29 | 30 | override public function getDefaultBasicUIClass():Class { 31 | return org.aswing.plaf.basic.BasicCheckBoxMenuItemUI; 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /org/aswing/JPanel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.plaf.basic.BasicPanelUI; 9 | 10 | /** 11 | * The general container - panel. 12 | * @author paling 13 | */ 14 | class JPanel extends Container { 15 | 16 | public function new(?layout:LayoutManager = null) { 17 | super(); 18 | setName("JPanel"); 19 | if (layout == null) layout = new FlowLayout(); 20 | this.layout = layout; 21 | updateUI(); 22 | } 23 | 24 | override public function updateUI():Void { 25 | setUI(UIManager.getUI(this)); 26 | } 27 | 28 | override public function getDefaultBasicUIClass():Class { 29 | return org.aswing.plaf.basic.BasicPanelUI; 30 | } 31 | 32 | override public function getUIClassID():String { 33 | return "PanelUI"; 34 | } 35 | } -------------------------------------------------------------------------------- /org/aswing/JRadioButton.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | import org.aswing.plaf.basic.BasicRadioButtonUI; 8 | 9 | 10 | /** 11 | * An implementation of a radio button -- an item that can be selected or 12 | * deselected, and which displays its state to the user. 13 | * Used with a {@link ButtonGroup} object to create a group of buttons 14 | * in which only one button at a time can be selected. (Create a ButtonGroup 15 | * object and use its append method to include the JRadioButton objects 16 | * in the group.) 17 | *
18 | * Note: 19 | * The ButtonGroup object is a logical grouping -- not a physical grouping. 20 | * Tocreate a button panel, you should still create a {@link JPanel} or similar 21 | * container-object and add a {@link org.aswing.border.Border} to it to set it off from surrounding 22 | * components. 23 | *
24 | * @author paling 25 | */ 26 | class JRadioButton extends JToggleButton { 27 | 28 | public function new(text:String = "", icon:Icon = null) { 29 | super(text, icon); 30 | setName("JRadioButton"); 31 | } 32 | 33 | override public function getDefaultBasicUIClass():Class { 34 | return org.aswing.plaf.basic.BasicRadioButtonUI; 35 | } 36 | 37 | override public function getUIClassID():String { 38 | return "RadioButtonUI"; 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /org/aswing/JRadioButtonMenuItem.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.plaf.basic.BasicRadioButtonMenuItemUI; 9 | 10 | /** 11 | * An implementation of a radio button menu item. 12 | * A JRadioButtonMenuItem is 13 | * a menu item that is part of a group of menu items in which only one 14 | * item in the group can be selected. The selected item displays its 15 | * selected state. Selecting it causes any other selected item to 16 | * switch to the unselected state. 17 | * To control the selected state of a group of radio button menu items, 18 | * use a ButtonGroup object. 19 | * @author paling 20 | */ 21 | class JRadioButtonMenuItem extends JMenuItem { 22 | 23 | public function new(text:String = "", icon:Icon = null) { 24 | super(text, icon); 25 | setName("JRadioButtonMenuItem"); 26 | setModel(new ToggleButtonModel()); 27 | } 28 | 29 | override public function getUIClassID():String { 30 | return "RadioButtonMenuItemUI"; 31 | } 32 | 33 | override public function getDefaultBasicUIClass():Class { 34 | return org.aswing.plaf.basic.BasicRadioButtonMenuItemUI; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /org/aswing/JSeparator.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.plaf.basic.BasicSeparatorUI; 9 | 10 | /** 11 | * JSeparator provides a general purpose component for 12 | * implementing divider lines - most commonly used as a divider 13 | * between menu items that breaks them up into logical groupings. 14 | * Instead of using JSeparator directly, 15 | * you can use the JMenu or JPopupMenu 16 | * addSeparator method to create and add a separator. 17 | * JSeparators may also be used elsewhere in a GUI 18 | * wherever a visual divider is useful. 19 | * 20 | * @author paling 21 | */ 22 | class JSeparator extends Component implements Orientable { 23 | 24 | /** 25 | * Horizontal orientation. 26 | */ 27 | inline public static var HORIZONTAL:Int = AsWingConstants.HORIZONTAL; 28 | /** 29 | * Vertical orientation. 30 | */ 31 | inline public static var VERTICAL:Int = AsWingConstants.VERTICAL; 32 | 33 | private var orientation:Int; 34 | 35 | /** 36 | * JSeparator(orientation:Number)
37 | * JSeparator() default orientation to HORIZONTAL; 38 | *

39 | * @param orientation (optional) the orientation. 40 | */ 41 | 42 | public function new(orientation:Int = AsWingConstants.HORIZONTAL) { 43 | super(); 44 | setName("JSeparator"); 45 | this.orientation = orientation; 46 | setFocusable(false); 47 | updateUI(); 48 | } 49 | 50 | override public function updateUI():Void { 51 | setUI(UIManager.getUI(this)); 52 | } 53 | 54 | override public function getUIClassID():String { 55 | return "SeparatorUI"; 56 | } 57 | 58 | override public function getDefaultBasicUIClass():Class { 59 | return org.aswing.plaf.basic.BasicSeparatorUI; 60 | } 61 | 62 | public function getOrientation():Int { 63 | return orientation; 64 | } 65 | 66 | public function setOrientation(orientation:Int):Void { 67 | if (this.orientation != orientation) { 68 | this.orientation = orientation; 69 | revalidate(); 70 | repaint(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /org/aswing/JToggleButton.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | import org.aswing.plaf.basic.BasicToggleButtonUI; 8 | 9 | 10 | /** 11 | * An implementation of a two-state button. 12 | * The JRadioButton and JCheckBox classes 13 | * are subclasses of this class. 14 | * @author paling 15 | */ 16 | class JToggleButton extends AbstractButton { 17 | public function new(text:String = "", icon:Icon = null) { 18 | super(text, icon); 19 | setName("JToggleButton"); 20 | setModel(new ToggleButtonModel()); 21 | 22 | //updateUI(); 23 | } 24 | 25 | override public function updateUI():Void { 26 | setUI(UIManager.getUI(this)); 27 | } 28 | 29 | override public function getDefaultBasicUIClass():Class { 30 | return org.aswing.plaf.basic.BasicToggleButtonUI; 31 | } 32 | 33 | override public function getUIClassID():String { 34 | return "ToggleButtonUI"; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /org/aswing/KeySequence.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | import org.aswing.error.Error; 7 | 8 | 9 | /** 10 | * Key Sequence, defines a key sequence. 11 | *

12 | * Thanks Romain for his Fever{@link http://fever.riaforge.org} accelerator framworks implementation, 13 | * this is a simpler implementation study from his. 14 | * @author paling 15 | */ 16 | class KeySequence implements KeyType { 17 | 18 | /** Constant definition for concatenation character. */ 19 | inline public static var LIMITER:String = "+"; 20 | 21 | private var codeString:String; 22 | private var codeSequence:Array; 23 | 24 | /** 25 | * KeySequence(key1:KeyStroke, key2:KeyStroke, ...)
26 | * KeySequence(description:String, codeSequence:Array)
27 | * Create a key definition with keys. 28 | * @throws ArgumentError when arguments is not illegular. 29 | */ 30 | 31 | public function new(arguments:Array) { 32 | if (Std.is(arguments[0], KeyStroke)) { 33 | var key:KeyStroke = cast(arguments[0], KeyStroke); 34 | codeSequence = [key.getCode()]; 35 | codeString = key.getDescription(); 36 | for (i in 1...arguments.length) { 37 | key = cast(arguments[i], KeyStroke); 38 | codeString += (LIMITER + key.getDescription()); 39 | codeSequence.push(key.getCode()); 40 | } 41 | } else { 42 | if (Std.is(arguments[1], Array)) { 43 | codeString = arguments[0].toString(); 44 | codeSequence = arguments[1].concat(); 45 | } else { 46 | throw new Error("KeySequence constructing error!!"); 47 | } 48 | } 49 | } 50 | 51 | public function getDescription():String { 52 | return codeString; 53 | } 54 | 55 | public function getCodeSequence():Array { 56 | return codeSequence.copy(); 57 | } 58 | 59 | public function toString():String { 60 | return "KeySequence[" + getDescription + "]"; 61 | } 62 | } -------------------------------------------------------------------------------- /org/aswing/KeyType.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * KeyType defined with description representing the key sequence with a string, 10 | * codeSequence contains the key codes sequence. 11 | * Same codeSequence will be considered as same key definition. 12 | *

13 | * For example "C" and [67] mean the C key on the key board. 14 | * "Ctrl+C" and [17, 67] mean the first Ctrl and then C keys. 15 | *

16 | * Thanks Romain for his Fever{@link http://fever.riaforge.org} accelerator framworks implementation, 17 | * this is a simpler implementation study from his. 18 | * 19 | * @see org.aswing.Keyboard 20 | * @see org.aswing.KeySequence 21 | * @author paling 22 | */ 23 | interface KeyType { 24 | 25 | /** 26 | * Returns the key code sequence. Same code sequence be track as same key definition. 27 | * @return an array(uint[]) that contains the key codes sequence 28 | */ 29 | function getCodeSequence():Array; 30 | 31 | /** 32 | * Returns the string that represent the key sequence. 33 | * @return string that represent the key sequence. 34 | */ 35 | function getDescription():String; 36 | } -------------------------------------------------------------------------------- /org/aswing/ListCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * Cell for JList. 10 | * @see JList 11 | * @author paling 12 | */ 13 | interface ListCell extends Cell { 14 | /** 15 | * Sets the table cell status, include the owner-JList, isSelected, the cell index. 16 | * @param the cell's owner, a JList 17 | * @param isSelected true to set the cell selected, false to set not selected. 18 | * @param index the index of the list item 19 | */ 20 | function setListCellStatus(list:JList, isSelected:Bool, index:Int):Void; 21 | 22 | function getAwmlIndex():Int; 23 | } -------------------------------------------------------------------------------- /org/aswing/ListModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.event.ListDataListener; 9 | 10 | /** 11 | * ListMode is a MVC pattern's mode for List UI, different List UI can connected to 12 | * a same mode to view the mode's data. When the mode's data changed the mode should 13 | * fire a event to all its ListDataListeners. 14 | * @author paling 15 | */ 16 | interface ListModel { 17 | /** 18 | * Adds a listener to the list that's notified each time a change to the data model occurs. 19 | */ 20 | function addListDataListener(l:ListDataListener):Void; 21 | /** 22 | * Returns the value at the specified index. 23 | */ 24 | function getElementAt(index:Int):Dynamic; 25 | 26 | /** 27 | * Returns the length of the list. 28 | */ 29 | function getSize():Int; 30 | 31 | /** 32 | * Removes a listener from the list that's notified each time a change to the data model occurs. 33 | */ 34 | function removeListDataListener(l:ListDataListener):Void; 35 | } -------------------------------------------------------------------------------- /org/aswing/MenuElement.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * Any component that can be placed into a menu should implement this interface. 10 | * This interface is used by MenuSelectionManager 11 | * to handle selection and navigation in menu hierarchies. 12 | * 13 | * @author paling 14 | */ 15 | interface MenuElement { 16 | 17 | /** 18 | * Call by the MenuSelectionManager when the 19 | * MenuElement is added or remove from 20 | * the menu selection. 21 | */ 22 | function menuSelectionChanged(isIncluded:Bool):Void; 23 | 24 | /** 25 | * This method should return an array containing the sub-elements for the receiving menu element 26 | * 27 | * @return an array of MenuElements 28 | */ 29 | function getSubElements():Array; //MenuElement[] 30 | 31 | /** 32 | * Precess the selection when key typed. 33 | */ 34 | function processKeyEvent(code:Int):Void; 35 | 36 | /** 37 | * Sets whether the menu element is in use. 38 | */ 39 | function setInUse(b:Bool):Void; 40 | 41 | /** 42 | * Returns whether the menu element is in use or not. 43 | */ 44 | function isInUse():Bool; 45 | 46 | /** 47 | * This method should return the Component used to paint the receiving element. 48 | * The returned component will be used to convert events and detect if an event is inside 49 | * a MenuElement's component. 50 | * 51 | * @return the Component value 52 | */ 53 | function getMenuComponent():Component; 54 | } -------------------------------------------------------------------------------- /org/aswing/MutableListModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * MutableListMode is a MVC pattern's mode for List UI, different List UI can connected to 10 | * a same mode to view the mode's data. When the mode's data changed the mode should 11 | * fire a event to all its ListDataListeners. 12 | * @author bill 13 | */ 14 | interface MutableListModel extends ListModel { 15 | 16 | /** 17 | * Inserts a element at specified position. 18 | */ 19 | function insertElementAt(item:Dynamic, index:Int):Void; 20 | 21 | /** 22 | * Removes a element from a specified position. 23 | */ 24 | function removeElementAt (index:Int):Void; 25 | } -------------------------------------------------------------------------------- /org/aswing/Orientable.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * An component or any thing has HORIZONTAL or VERTICAL form. 10 | * @author paling 11 | */ 12 | interface Orientable { 13 | 14 | /** 15 | * Sets the orientation, or how the splitter is divided. The options 16 | * are: 17 | *

    18 | *
  • AsWingConstants.HORIZONTAL
  • 19 | *
  • AsWingConstants.VERTICAL
  • 20 | *
21 | * 22 | * @param orientation an integer specifying the orientation 23 | */ 24 | function setOrientation(ori:Int):Void; 25 | 26 | /** 27 | * Returns the orientation. 28 | * 29 | * @return an integer giving the orientation 30 | * @see #setOrientation() 31 | */ 32 | function getOrientation():Int; 33 | } -------------------------------------------------------------------------------- /org/aswing/SimpleButtonIcon.hx: -------------------------------------------------------------------------------- 1 | package org.aswing; 2 | 3 | 4 | import flash.display.DisplayObject; 5 | import flash.filters.BitmapFilter; 6 | import org.aswing.graphics.Graphics2D; 7 | 8 | class SimpleButtonIcon implements Icon { 9 | 10 | private var asset:SimpleButton; 11 | private var width:Int; 12 | private var height:Int; 13 | 14 | private static var disabledFilters:Array; 15 | private static var eabledFilters:Array= []; 16 | 17 | public function new(asset:SimpleButton) { 18 | this.asset = asset; 19 | width = Math.ceil(asset.width); 20 | height = Math.ceil(asset.height); 21 | 22 | if (disabledFilters == null) { 23 | var cmatrix:Array = [0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0.3, 0.59, 0.11, 0, 0, 0, 0, 0, 1, 0]; 24 | #if(flash9) 25 | disabledFilters = [cast(new flash.filters.ColorMatrixFilter(cmatrix),BitmapFilter)]; 26 | #end 27 | } 28 | 29 | } 30 | 31 | public function getDisplay(c:Component):DisplayObject { 32 | return asset; 33 | } 34 | 35 | public function getIconWidth(c:Component):Int { 36 | return width; 37 | } 38 | 39 | public function getIconHeight(c:Component):Int { 40 | return height; 41 | } 42 | 43 | public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 44 | asset.x = x; 45 | asset.y = y; 46 | #if (flash9) 47 | asset.mouseEnabled = c.isEnabled(); 48 | #end 49 | asset.filters = c.isEnabled() ? eabledFilters : disabledFilters; 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /org/aswing/SingleSelectionModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * A model that supports at most one indexed selection. 10 | * @author paling 11 | */ 12 | interface SingleSelectionModel { 13 | 14 | /** 15 | * Returns the model's selection. 16 | * 17 | * @return the model's selection, or -1 if there is no selection 18 | * @see #setSelectedIndex() 19 | */ 20 | function getSelectedIndex():Int; 21 | 22 | /** 23 | * Sets the model's selected index to index. 24 | * 25 | * Notifies any listeners if the model changes. 26 | * 27 | * @param index an int specifying the model selection. 28 | * @param programmatic indicate if this is a programmatic change. 29 | * @see #getSelectedIndex() 30 | * @see #addChangeListener() 31 | */ 32 | function setSelectedIndex(index:Int, programmatic:Bool = true):Void; 33 | 34 | /** 35 | * Clears the selection (to -1). 36 | * @param programmatic indicate if this is a programmatic change. 37 | */ 38 | function clearSelection(programmatic:Bool = true):Void; 39 | 40 | /** 41 | * Returns true if the selection model currently has a selected value. 42 | * @return true if a value is currently selected 43 | */ 44 | function isSelected():Bool; 45 | 46 | /** 47 | * Adds a listener to listen the Model's state change event. 48 | * @param listener the listener 49 | * @param priority the priority 50 | * @param useWeakReference Determines whether the reference to the listener is strong or weak. 51 | * @see org.aswing.event.InteractiveEvent#STATE_CHANGED 52 | */ 53 | function addStateListener(listener:Dynamic -> Void, priority:Int = 0, useWeakReference:Bool = false):Void; 54 | /** 55 | * Removes a state listener. 56 | * @param listener the listener to be removed. 57 | * @see org.aswing.event.InteractiveEvent#STATE_CHANGED 58 | */ 59 | function removeStateListener(listener:Dynamic -> Void):Void; 60 | } -------------------------------------------------------------------------------- /org/aswing/SolidBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.geom.IntRectangle; 10 | import flash.display.DisplayObject; 11 | import org.aswing.graphics.SolidBrush; 12 | import flash.display.Shape; 13 | 14 | /** 15 | * A background decorator that paint a solid color. 16 | * @author 17 | */ 18 | class SolidBackground implements GroundDecorator { 19 | 20 | private var color:ASColor; 21 | private var shape:Shape; 22 | 23 | public function new(color:ASColor) { 24 | this.color = color; 25 | shape = new Shape(); 26 | } 27 | 28 | public function updateDecorator(c:Component, g:Graphics2D, bounds:IntRectangle):Void { 29 | shape.graphics.clear(); 30 | g = new Graphics2D(shape.graphics); 31 | g.fillRectangle(new SolidBrush(color), bounds.x, bounds.y, bounds.width, bounds.height); 32 | } 33 | 34 | public function getDisplay(c:Component):DisplayObject { 35 | return shape; 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /org/aswing/StyleResult.hx: -------------------------------------------------------------------------------- 1 | package org.aswing; 2 | 3 | 4 | /** 5 | * The class for a result of a main color adjusted by a adjuster. 6 | */ 7 | class StyleResult { 8 | 9 | /** 10 | * Content light color 11 | */ 12 | public var clight:ASColor; 13 | /** 14 | * Content dark color 15 | */ 16 | public var cdark:ASColor; 17 | /** 18 | * Border light color 19 | */ 20 | public var blight:ASColor; 21 | /** 22 | * Border dark color 23 | */ 24 | public var bdark:ASColor; 25 | /** 26 | * Shadow color alpha 27 | */ 28 | public var shadow:Float; 29 | /** 30 | * The round rect radius 31 | */ 32 | public var round:Float; 33 | 34 | public function new(mainColor:ASColor, tune:StyleTune) { 35 | clight = tune.getCLight(mainColor); 36 | cdark = tune.getCDark(mainColor); 37 | blight = tune.getBLight(mainColor); 38 | bdark = tune.getBDark(mainColor); 39 | shadow = tune.getShadowAlpha(); 40 | round = tune.round; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /org/aswing/ToggleButtonModel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * The ToggleButton model 10 | * @author paling 11 | */ 12 | class ToggleButtonModel extends DefaultButtonModel { 13 | 14 | public function new() { 15 | super(); 16 | } 17 | 18 | /** 19 | * Sets the selected state of the button. 20 | * @param b true selects the toggle button, 21 | * false deselects the toggle button. 22 | */ 23 | 24 | override public function setSelected(b:Bool):Void { 25 | 26 | var group:ButtonGroup = getGroup(); 27 | if (group != null) { 28 | // use the group model instead 29 | group.setSelected(this, b); 30 | b = group.isSelected(this); 31 | } 32 | super.setSelected(b); 33 | } 34 | 35 | /** 36 | * Sets the button to released or unreleased. 37 | */ 38 | 39 | override public function setPressed(b:Bool):Void { 40 | 41 | if (isPressed() == b || !isEnabled()) { 42 | return; 43 | } 44 | 45 | if (b == false && isArmed()) { 46 | setSelected(!isSelected()); 47 | } 48 | 49 | pressed = b; 50 | 51 | fireStateChanged(); 52 | if (!isPressed() && isArmed()) { 53 | fireActionEvent(); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /org/aswing/WindowOrderFocusTraversalPolicy.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing; 6 | 7 | 8 | /** 9 | * The focus traversal policy for windows, the only different from 10 | * ContainerOrderFocusTraversalPolicy is that it choose the first 11 | * content pane component to be the default component. 12 | */ 13 | class WindowOrderFocusTraversalPolicy extends ContainerOrderFocusTraversalPolicy { 14 | 15 | public function new() { 16 | super(); 17 | } 18 | 19 | /** 20 | * This will return the first focusable component in the container. 21 | * @return the default component to be focused. 22 | */ 23 | 24 | override public function getDefaultComponent(container:Container):Component { 25 | if (Std.is(container, JWindow)) { 26 | var window:JWindow = cast(container, JWindow) ; 27 | var content:Container = window.getContentPane(); 28 | if (content.isShowing() && content.isVisible() && content.isFocusable()) { 29 | return content; 30 | } 31 | var dc:Component = getFirstComponent(content); 32 | if (dc == null) { 33 | return super.getDefaultComponent(container); 34 | } else { 35 | return dc; 36 | } 37 | } else { 38 | return super.getDefaultComponent(container); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /org/aswing/border/EmptyBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.border; 6 | 7 | 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.Border; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.Component; 12 | import org.aswing.Insets; 13 | 14 | /** 15 | * EmptyBorder not draw any graphics, only use to hold a blank space around component. 16 | * @author paling 17 | */ 18 | class EmptyBorder extends DecorateBorder { 19 | 20 | private var margin:Insets; 21 | 22 | public function new(interior:Border = null, margin:Insets = null) { 23 | super(interior); 24 | if (margin == null) { 25 | this.margin = new Insets(); 26 | } else { 27 | this.margin = margin.clone(); 28 | } 29 | } 30 | 31 | public function setTop(v:Int):Void { 32 | margin.top = v; 33 | } 34 | 35 | public function setLeft(v:Int):Void { 36 | margin.left = v; 37 | } 38 | 39 | public function setBottom(v:Int):Void { 40 | margin.bottom = v; 41 | } 42 | 43 | public function setRight(v:Int):Void { 44 | margin.right = v; 45 | } 46 | 47 | public function getTop():Int { 48 | return margin.top; 49 | } 50 | 51 | public function getLeft():Int { 52 | return margin.left; 53 | } 54 | 55 | public function getBottom():Int { 56 | return margin.bottom; 57 | } 58 | 59 | public function getRight():Int { 60 | return margin.right; 61 | } 62 | 63 | public static function createIndent(indent:Int):EmptyBorder { 64 | return new EmptyBorder(null, new Insets(indent, indent, indent, indent)); 65 | } 66 | 67 | override public function updateBorderImp(com:Component, g:Graphics2D, bounds:IntRectangle):Void { 68 | } 69 | 70 | override public function getBorderInsetsImp(c:Component, bounds:IntRectangle):Insets { 71 | return margin.clone(); 72 | } 73 | 74 | } -------------------------------------------------------------------------------- /org/aswing/colorchooser/ColorRectIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.colorchooser; 6 | 7 | import org.aswing.ASColor; 8 | import org.aswing.Component; 9 | import org.aswing.Icon; 10 | import org.aswing.graphics.Graphics2D; 11 | import org.aswing.graphics.SolidBrush; 12 | import org.aswing.graphics.Pen; 13 | import flash.display.DisplayObject; 14 | 15 | /** 16 | * @author paling 17 | */ 18 | class ColorRectIcon implements Icon { 19 | private var width:Float; 20 | private var height:Float; 21 | private var color:ASColor; 22 | 23 | public function new(width:Int, height:Int, color:ASColor) { 24 | this.width = width; 25 | this.height = height; 26 | this.color = color; 27 | } 28 | 29 | public function setColor(color:ASColor):Void { 30 | this.color = color; 31 | } 32 | 33 | public function getColor():ASColor { 34 | return color; 35 | } 36 | 37 | /** 38 | * Return the icon's width. 39 | */ 40 | 41 | public function getIconWidth(c:Component):Int { 42 | return Std.int(width); 43 | } 44 | 45 | /** 46 | * Return the icon's height. 47 | */ 48 | 49 | public function getIconHeight(c:Component):Int { 50 | return Std.int(height); 51 | } 52 | 53 | public function updateIcon(com:Component, g:Graphics2D, x:Int, y:Int):Void { 54 | var w:Int = Std.int(width); 55 | var h:Int = Std.int(height); 56 | g.fillRectangle(new SolidBrush(ASColor.WHITE), x, y, w, h); 57 | //why 58 | 59 | if (color != null) { 60 | var t:Float = 5; 61 | for (c in 0...w) { 62 | g.drawLine(new Pen(ASColor.GRAY, 1), x + c, y, x + c, y + h); 63 | } 64 | for (r in 0...h) { 65 | g.drawLine(new Pen(ASColor.GRAY, 1), x, y + r, x + w, y + r); 66 | } 67 | g.fillRectangle(new SolidBrush(color), x, y, width, height); 68 | } else { 69 | g.drawLine(new Pen(ASColor.RED, 2), x + 1, y + h - 1, x + w - 1, y + 1); 70 | } 71 | 72 | } 73 | 74 | public function getDisplay(c:Component):DisplayObject { 75 | return null; 76 | } 77 | } -------------------------------------------------------------------------------- /org/aswing/colorchooser/JColorMixer.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.colorchooser; 6 | 7 | import org.aswing.colorchooser.AbstractColorChooserPanel; 8 | import org.aswing.UIManager; 9 | import org.aswing.plaf.basic.BasicColorMixerUI; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | class JColorMixer extends AbstractColorChooserPanel { 15 | 16 | public function new() { 17 | super(); 18 | updateUI(); 19 | } 20 | 21 | override public function updateUI():Void { 22 | setUI(UIManager.getUI(this)); 23 | } 24 | 25 | override public function getUIClassID():String { 26 | return "ColorMixerUI"; 27 | } 28 | 29 | override public function getDefaultBasicUIClass():Class { 30 | return org.aswing.plaf.basic.BasicColorMixerUI; 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /org/aswing/colorchooser/JColorSwatches.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.colorchooser; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.plaf.ColorSwatchesUI; 10 | import org.aswing.plaf.basic.BasicColorSwatchesUI; 11 | 12 | /** 13 | * @author paling 14 | */ 15 | class JColorSwatches extends AbstractColorChooserPanel { 16 | 17 | public function new() { 18 | super(); 19 | updateUI(); 20 | } 21 | 22 | override public function updateUI():Void { 23 | setUI(UIManager.getUI(this)); 24 | } 25 | 26 | override public function getDefaultBasicUIClass():Class { 27 | return org.aswing.plaf.basic.BasicColorSwatchesUI; 28 | } 29 | 30 | override public function getUIClassID():String { 31 | return "ColorSwatchesUI"; 32 | } 33 | 34 | /** 35 | * Adds a component to this panel's sections bar 36 | * @param com the component to be added 37 | */ 38 | 39 | public function addComponentColorSectionBar(com:Component):Void { 40 | cast(getUI(), ColorSwatchesUI).addComponentColorSectionBar(com); 41 | } 42 | } -------------------------------------------------------------------------------- /org/aswing/colorchooser/NoColorIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing.colorchooser; 5 | 6 | import flash.display.DisplayObject; 7 | import flash.display.Shape; 8 | 9 | import org.aswing.ASColor; 10 | import org.aswing.Component; 11 | import org.aswing.Icon; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.graphics.Pen; 14 | import org.aswing.graphics.SolidBrush; 15 | /** 16 | * @author paling 17 | */ 18 | class NoColorIcon implements Icon { 19 | 20 | private var shape:Shape; 21 | private var width:Float; 22 | private var height:Float; 23 | 24 | public function new(width:Int, height:Int) { 25 | this.width = width; 26 | this.height = height; 27 | shape = new Shape(); 28 | } 29 | 30 | /** 31 | * Return the icon's width. 32 | */ 33 | 34 | public function getIconWidth(c:Component):Int { 35 | return Std.int(width); 36 | } 37 | 38 | /** 39 | * Return the icon's height. 40 | */ 41 | 42 | public function getIconHeight(c:Component):Int { 43 | return Std.int(height); 44 | } 45 | 46 | /** 47 | * Draw the icon at the specified location. 48 | */ 49 | 50 | public function updateIcon(com:Component, g:Graphics2D, x:Int, y:Int):Void { 51 | shape.graphics.clear(); 52 | g = new Graphics2D(shape.graphics); 53 | //why 54 | 55 | g.beginDraw(new Pen(ASColor.BLACK, 1)); 56 | g.beginFill(new SolidBrush(ASColor.WHITE)); 57 | var w:Float = width / 2 + 1; 58 | var h:Float = height / 2 + 1; 59 | x = Std.int(x + w / 2 - 1); 60 | y = Std.int(y + h / 2 - 1); 61 | g.rectangle(x, y, w, h); 62 | g.endFill(); 63 | g.endDraw(); 64 | g.drawLine(new Pen(ASColor.RED, 2), x + 1, y + h - 1, x + w - 1, y + 1); 65 | 66 | } 67 | 68 | public function getDisplay(c:Component):DisplayObject { 69 | return shape; 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /org/aswing/dnd/DefaultDragImage.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | import flash.display.Shape; 9 | import flash.display.DisplayObject; 10 | import org.aswing.Component; 11 | import org.aswing.graphics.Graphics2D; 12 | import org.aswing.graphics.Pen; 13 | /** 14 | * The default drag image. 15 | * @author paling 16 | */ 17 | class DefaultDragImage implements DraggingImage { 18 | 19 | private var image:Shape; 20 | private var width:Int; 21 | private var height:Int; 22 | 23 | public function new(dragInitiator:Component) { 24 | width = Std.int(dragInitiator.width); 25 | height = Std.int(dragInitiator.height); 26 | 27 | image = new Shape(); 28 | } 29 | 30 | public function getDisplay():DisplayObject { 31 | return image; 32 | } 33 | 34 | public function switchToRejectImage():Void { 35 | image.graphics.clear(); 36 | var r:Float = Math.min(width, height) - 2; 37 | var x:Float = 0; 38 | var y:Float = 0; 39 | var w:Float = width; 40 | var h:Float = height; 41 | var g:Graphics2D = new Graphics2D(image.graphics); 42 | //why 43 | 44 | g.drawLine(new Pen(ASColor.RED, 2), x + 1, y + 1, x + 1 + r, y + 1 + r); 45 | g.drawLine(new Pen(ASColor.RED, 2), x + 1 + r, y + 1, x + 1, y + 1 + r); 46 | g.drawRectangle(new Pen(ASColor.GRAY), x, y, w, h); 47 | 48 | } 49 | 50 | public function switchToAcceptImage():Void { 51 | image.graphics.clear(); 52 | var g:Graphics2D = new Graphics2D(image.graphics); 53 | g.drawRectangle(new Pen(ASColor.GRAY), 0, 0, width, height); 54 | } 55 | 56 | } -------------------------------------------------------------------------------- /org/aswing/dnd/DirectlyRemoveMotion.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | import org.aswing.Component; 9 | import flash.display.Sprite; 10 | 11 | /** 12 | * Remove the dragging movieclip directly. 13 | * @author paling 14 | */ 15 | class DirectlyRemoveMotion implements DropMotion { 16 | 17 | public function new():Void { 18 | 19 | } 20 | 21 | public function startMotionAndLaterRemove(dragInitiator:Component, dragObject:Sprite):Void { 22 | if (dragObject.parent != null) { 23 | dragObject.parent.removeChild(dragObject); 24 | } 25 | } 26 | 27 | public function forceStop():Void { 28 | } 29 | } -------------------------------------------------------------------------------- /org/aswing/dnd/DragListener.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | import org.aswing.event.DragAndDropEvent; 9 | 10 | /** 11 | * Drag and Drop listener. 12 | * 13 | * @author paling 14 | */ 15 | interface DragListener { 16 | 17 | /** 18 | * When a drag action started. 19 | * @param e the event. 20 | * @see Component#isDragEnabled() 21 | */ 22 | function onDragStart(e:DragAndDropEvent):Void; 23 | 24 | /** 25 | * Called while a drag operation is ongoing, when the mouse pointer enters a 26 | * drop trigger component area. 27 | * @param e the event. 28 | * @see Component#isDropTrigger() 29 | */ 30 | function onDragEnter(e:DragAndDropEvent):Void; 31 | 32 | /** 33 | * Called when a drag operation is ongoing(mouse is moving), while the mouse 34 | * pointer is still over the entered component area. 35 | * @param e the event. 36 | * @see Component#isDropTrigger() 37 | */ 38 | function onDragOverring(e:DragAndDropEvent):Void; 39 | 40 | /** 41 | * Called while a drag operation is ongoing, when the mouse pointer has exited 42 | * the entered a drop trigger component. 43 | * @param e the event. 44 | * @see Component#isDropTrigger() 45 | */ 46 | function onDragExit(e:DragAndDropEvent):Void; 47 | 48 | /** 49 | * Called when drag operation finished. 50 | *

51 | * Generally if you want to do a custom motion of the dragging movie clip when 52 | * dropped, you may call the DragManager.setDropMotion() method to achieve. 53 | *

54 | * @param e the event. 55 | * @see Component#isDropTrigger() 56 | * @see org.aswing.dnd.DragManager#setDropMotion() 57 | */ 58 | function onDragDrop(e:DragAndDropEvent):Void; 59 | 60 | } -------------------------------------------------------------------------------- /org/aswing/dnd/DraggingImage.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | import flash.display.DisplayObject; 9 | 10 | /** 11 | * The Image for dragging representing. 12 | * 13 | * @author paling 14 | */ 15 | interface DraggingImage { 16 | 17 | /** 18 | * Returns the display object for the representation of dragging. 19 | */ 20 | function getDisplay():DisplayObject ; 21 | 22 | /** 23 | * Paints the image for accept state of dragging.(means drop allowed) 24 | */ 25 | function switchToAcceptImage():Void; 26 | 27 | /** 28 | * Paints the image for reject state of dragging.(means drop not allowed) 29 | */ 30 | function switchToRejectImage():Void; 31 | } -------------------------------------------------------------------------------- /org/aswing/dnd/DropMotion.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | import org.aswing.Component; 9 | import flash.display.Sprite; 10 | 11 | /** 12 | * The motion when a drag action dropped. 13 | * The motion must remove the drag movie clip when motion is completed. 14 | * @author paling 15 | */ 16 | interface DropMotion { 17 | 18 | /** 19 | * Starts the drop motion and remove the dragObject from its parent when motion is completed. 20 | * @param dragInitiator the drag initiator 21 | * @param dragObject the display object to do motion 22 | */ 23 | function startMotionAndLaterRemove(dragInitiator:Component, dragObject:Sprite):Void; 24 | 25 | /** 26 | * A new drag is started, so the last motion should be stopped if it is still running. 27 | */ 28 | function forceStop():Void; 29 | 30 | } -------------------------------------------------------------------------------- /org/aswing/dnd/SourceData.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.dnd; 6 | 7 | 8 | /** 9 | * The drag source data. 10 | * @author paling 11 | */ 12 | class SourceData { 13 | 14 | private var name:String; 15 | private var data:Dynamic; 16 | 17 | public function new(name:String, data:Dynamic) { 18 | this.name = name; 19 | this.data = data; 20 | } 21 | 22 | public function getName():String { 23 | return name; 24 | } 25 | 26 | public function getData():Dynamic { 27 | return data; 28 | } 29 | } -------------------------------------------------------------------------------- /org/aswing/error/AsWingManagerNotInited.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.error; 6 | 7 | import org.aswing.error.Error; 8 | /** 9 | * The error indicated that the operation you are doing shuold be after 10 | * AsWingManager.setRoot(a root). 11 | * 12 | * @see org.aswing.AsWingManager 13 | * @author paling 14 | */ 15 | class AsWingManagerNotInited extends Error { 16 | 17 | public function new() { 18 | super("You have not call AsWingManager.setRoot() yet!"); 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /org/aswing/error/Error.hx: -------------------------------------------------------------------------------- 1 | /** 2 | * ... 3 | * @author palp 4 | */ 5 | 6 | package org.aswing.error; 7 | 8 | class Error { 9 | var errorID:Int; 10 | var message:Dynamic; 11 | var name:Dynamic; 12 | 13 | public function new(?inMessage:Dynamic, id:Dynamic = 0) { 14 | message = inMessage; 15 | errorID = id; 16 | } 17 | 18 | public function toString():String { return message; } 19 | 20 | function getStackTrace():String { return ""; } 21 | } 22 | -------------------------------------------------------------------------------- /org/aswing/error/ImpMissError.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.error; 6 | import org.aswing.error.Error; 7 | /** 8 | * This error indicates that an abstract class's abstract method missing overriden error. 9 | */ 10 | class ImpMissError extends Error { 11 | public function new() { 12 | super("Subclass should override this method to do implementation!!"); 13 | } 14 | } -------------------------------------------------------------------------------- /org/aswing/error/UnsupportedError.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.error; 6 | 7 | import org.aswing.error.Error; 8 | 9 | /** 10 | * This error indicates that a function/operation is not supported. 11 | */ 12 | class UnsupportedError extends Error { 13 | 14 | public function new(type:String) { 15 | super("This function/operation is not supported!!"); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /org/aswing/event/AttachEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | import flash.events.Event; 8 | 9 | /** 10 | * The event for JAttachPane. 11 | * @see org.aswing.JAttachPane 12 | * @author paling 13 | */ 14 | class AttachEvent extends AWEvent { 15 | /** 16 | * The AttachEvent.ATTACHED constant defines the value of the 17 | * type property of the event object for a attached event. 18 | * 19 | *

The properties of the event object have the following values:

20 | * 21 | * 22 | * 23 | * 24 | * 28 | * 32 | *
PropertyValue
bubblesfalse
cancelablefalse
currentTargetThe Object that defines the 25 | * event listener that handles the event. For example, if you use 26 | * comp.addEventListener() to register an event listener, 27 | * comp is the value of the currentTarget.
targetThe Object that dispatched the event; 29 | * it is not always the Object listening for the event. 30 | * Use the currentTarget property to always access the 31 | * Object listening for the event.
33 | * 34 | * @eventType attached 35 | */ 36 | inline public static var ATTACHED:String = "attached"; 37 | 38 | public function new(type:String) { 39 | super(type, false, false); 40 | } 41 | 42 | override public function clone():Event { 43 | return new AttachEvent(type); 44 | } 45 | } -------------------------------------------------------------------------------- /org/aswing/event/CellEditorListener.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | import org.aswing.CellEditor; 9 | 10 | /** 11 | * CellEditorListener defines the interface for an object that listens 12 | * to changes in a CellEditor 13 | * 14 | * @author paling 15 | */ 16 | interface CellEditorListener { 17 | 18 | /** This tells the listeners the editor has ended editing */ 19 | function editingStopped(source:CellEditor):Void; 20 | 21 | /** This tells the listeners the editor has canceled editing */ 22 | function editingCanceled(source:CellEditor):Void; 23 | } -------------------------------------------------------------------------------- /org/aswing/event/ClickCountEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | import flash.events.Event; 9 | 10 | /** 11 | * For continusely clicks. 12 | */ 13 | class ClickCountEvent extends AWEvent { 14 | 15 | /** 16 | * The ClickCountEvent.CLICK_COUNT constant defines the value of the 17 | * type property of the event object for a clickCount event. 18 | * 19 | *

The properties of the event object have the following values:

20 | * 21 | * 22 | * 23 | * 24 | * 25 | * 29 | * 33 | *
PropertyValue
bubblesfalse
cancelablefalse
getCount()the continuesly clicked count
currentTargetThe Object that defines the 26 | * event listener that handles the event. For example, if you use 27 | * comp.addEventListener() to register an event listener, 28 | * comp is the value of the currentTarget.
targetThe Object that dispatched the event; 30 | * it is not always the Object listening for the event. 31 | * Use the currentTarget property to always access the 32 | * Object listening for the event.
34 | * 35 | * @eventType clickCount 36 | */ 37 | inline public static var CLICK_COUNT:String = "clickCount"; 38 | 39 | private var count:Int; 40 | 41 | public function new(type:String, count:Int) { 42 | super(type, false, false); 43 | this.count = count; 44 | } 45 | 46 | public function getCount():Int { 47 | return count; 48 | } 49 | 50 | override public function clone():Event { 51 | return new ClickCountEvent(type, count); 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /org/aswing/event/ColorChooserEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | import flash.events.Event; 8 | 9 | import org.aswing.ASColor; 10 | class ColorChooserEvent extends AWEvent { 11 | /** 12 | * The ColorChooserEvent.COLOR_ADJUSTING When user adjusting to a new color. 13 | *

The properties of the event object have the following values:

14 | * 15 | * 16 | * 17 | * 18 | * 19 | * 20 | * 24 | * 28 | *
PropertyValue
bubblesfalse
cancelablefalse
getContainer()the container who just be added a child.
getChild()the added child.
currentTargetThe Object that defines the 21 | * event listener that handles the event. For example, if you use 22 | * comp.addEventListener() to register an event listener, 23 | * comp is the value of the currentTarget.
targetThe Object that dispatched the event; 25 | * it is not always the Object listening for the event. 26 | * Use the currentTarget property to always access the 27 | * Object listening for the event.
29 | * 30 | * @eventType colorAdjusting 31 | */ 32 | inline public static var COLOR_ADJUSTING:String = "colorAdjusting"; 33 | private var color:ASColor; 34 | 35 | public function new(type:String, color:ASColor) { 36 | this.color = color; 37 | super(type, false, false); 38 | } 39 | 40 | public function getColor():ASColor { 41 | return color; 42 | } 43 | 44 | override public function clone():Event { 45 | return new ColorChooserEvent(type, color); 46 | } 47 | } -------------------------------------------------------------------------------- /org/aswing/event/ExpandVetoException.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | import org.aswing.error.Error; 7 | 8 | 9 | /** 10 | * Exception used to stop and expand/collapse from happening. 11 | * @author paling 12 | */ 13 | class ExpandVetoException extends Error { 14 | 15 | public function new(message:String) { 16 | super(message); 17 | 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /org/aswing/event/ListDataEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | /** 9 | * The event for list model. 10 | * @see org.aswing.JList 11 | * @see org.aswing.ListModel 12 | * @see org.aswing.event.ListDataListener 13 | * @author paling 14 | */ 15 | class ListDataEvent extends ModelEvent { 16 | 17 | private var index0:Int; 18 | private var index1:Int; 19 | private var removedItems:Array; 20 | 21 | /** 22 | * Returns the lower index of the range. For a single 23 | * element, this value is the same as that returned by {@link #getIndex1}. 24 | * @return an int representing the lower index value 25 | */ 26 | 27 | public function getIndex0():Int { return index0; } 28 | 29 | /** 30 | * Returns the upper index of the range. For a single 31 | * element, this value is the same as that returned by {@link #getIndex0}. 32 | * @return an int representing the upper index value 33 | */ 34 | 35 | public function getIndex1():Int { return index1; } 36 | 37 | /** 38 | * Returns the removed items, it is null or empty array when this is not a removed event. 39 | * @return a array that contains the removed items 40 | */ 41 | 42 | public function getRemovedItems():Array { return removedItems.copy(); } 43 | 44 | /** 45 | * Constructs a ListDataEvent object. 46 | * 47 | * @param source the source Object (typically this) 48 | * @param index0 an int specifying the bottom of a range 49 | * @param index1 an int specifying the top of a range 50 | * @param removedItems (optional) the items has been removed. 51 | */ 52 | 53 | public function new(source:Dynamic, index0:Int, index1:Int, removedItems:Array) { 54 | super(source); 55 | this.index0 = index0; 56 | this.index1 = index1; 57 | this.removedItems = removedItems.copy(); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /org/aswing/event/ListDataListener.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | interface ListDataListener { 9 | /** 10 | * Sent after the indices in the index0,index1 11 | * interval have been inserted in the data model. 12 | * The new interval includes both index0 and index1. 13 | * 14 | * @param e a ListDataEvent encapsulating the 15 | * event information 16 | */ 17 | function intervalAdded(e:ListDataEvent):Void; 18 | 19 | 20 | /** 21 | * Sent after the indices in the index0,index1 interval 22 | * have been removed from the data model. The interval 23 | * includes both index0 and index1. 24 | * 25 | * @param e a ListDataEvent encapsulating the 26 | * event information 27 | */ 28 | function intervalRemoved(e:ListDataEvent):Void; 29 | 30 | 31 | /** 32 | * Sent when the contents of the list has changed in a way 33 | * that's too complex to characterize with the previous 34 | * methods. For example, this is sent when an item has been 35 | * replaced. Index0 and index1 bracket the change. 36 | * 37 | * @param e a ListDataEvent encapsulating the 38 | * event information 39 | */ 40 | function contentsChanged(e:ListDataEvent):Void; 41 | } -------------------------------------------------------------------------------- /org/aswing/event/ModelEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | /** 9 | * The base class for model events. 10 | * @author paling 11 | */ 12 | class ModelEvent { 13 | 14 | private var source:Dynamic; 15 | 16 | public function new(source:Dynamic) { 17 | this.source = source; 18 | } 19 | 20 | public function getSource():Dynamic { 21 | return source; 22 | } 23 | } -------------------------------------------------------------------------------- /org/aswing/event/TabCloseEvent.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.event; 2 | 3 | import flash.events.Event; 4 | 5 | 6 | /** 7 | * The event for JClosableTabbedPane tab close button clicked. 8 | * @author paling 9 | */ 10 | class TabCloseEvent extends AWEvent { 11 | 12 | /** 13 | * The TabCloseEvent.TAB_CLOSING constant defines the value of the 14 | * type property of the event object for a tabClosing event. 15 | * 16 | *

The properties of the event object have the following values:

17 | * 18 | * 19 | * 20 | * 21 | * 22 | * 26 | * 30 | *
PropertyValue
bubblesfalse
cancelablefalse
getIndex()the tab index
currentTargetThe Object that defines the 23 | * event listener that handles the event. For example, if you use 24 | * comp.addEventListener() to register an event listener, 25 | * comp is the value of the currentTarget.
targetThe Object that dispatched the event; 27 | * it is not always the Object listening for the event. 28 | * Use the currentTarget property to always access the 29 | * Object listening for the event.
31 | * 32 | * @eventType tabClosing 33 | */ 34 | inline public static var TAB_CLOSING:String = "tabClosing"; 35 | 36 | private var index:Int; 37 | 38 | public function new(index:Int) { 39 | super(TAB_CLOSING, false, false); 40 | this.index = index; 41 | } 42 | 43 | /** 44 | * Return the index of tab that close button clicked. 45 | */ 46 | 47 | public function getIndex():Int { 48 | return index; 49 | } 50 | 51 | override public function clone():Event { 52 | return new TabCloseEvent(index); 53 | } 54 | } -------------------------------------------------------------------------------- /org/aswing/event/TableModelListener.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.event; 6 | 7 | 8 | /** 9 | * TableModelListener defines the interface for an object that listens 10 | * to changes in a TableModel. 11 | * @author paling 12 | */ 13 | interface TableModelListener { 14 | /** 15 | * This fine grain notification tells listeners the exact range 16 | * of cells, rows, or columns that changed. 17 | */ 18 | function tableChanged(e:TableModelEvent):Void; 19 | } -------------------------------------------------------------------------------- /org/aswing/ext/DefaultGridCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | import org.aswing.ASColor; 9 | import org.aswing.Component; 10 | import org.aswing.JLabel; 11 | 12 | /** 13 | * The default grid list cell render value.toString() as texts. 14 | * 15 | */ 16 | class DefaultGridCell extends JLabel implements GridListCell { 17 | 18 | private var value:Dynamic; 19 | 20 | public function new() { 21 | super(); 22 | setOpaque(true); 23 | setBackground(ASColor.WHITE); 24 | } 25 | 26 | public function setCellValue(value:Dynamic):Void { 27 | this.value = value; 28 | setText(value + ""); 29 | } 30 | 31 | public function getCellValue():Dynamic { 32 | return value; 33 | } 34 | 35 | public function getCellComponent():Component { 36 | return this; 37 | } 38 | 39 | public function setGridListCellStatus(gridList:GridList, selected:Bool, index:Int):Void { 40 | var c:ASColor = index % 2 == 0 ? ASColor.WHITE : ASColor.GRAY; 41 | if (selected) { 42 | c = ASColor.BLUE; 43 | } 44 | setBackground(c); 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /org/aswing/ext/GeneralGridListCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | /** 9 | * General factory to generate instance by a class 10 | */ 11 | class GeneralGridListCellFactory implements GridListCellFactory { 12 | 13 | private var cellClass:Class; 14 | 15 | public function new(cellClass:Class) { 16 | this.cellClass = cellClass; 17 | } 18 | 19 | public function createNewGridListCell():GridListCell { 20 | return cast(Type.createInstance(cellClass, []), GridListCell); 21 | } 22 | 23 | } -------------------------------------------------------------------------------- /org/aswing/ext/GridCellHolder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | import org.aswing.Container; 9 | 10 | class GridCellHolder extends Container { 11 | 12 | private var list:GridList; 13 | 14 | public function new(list:GridList) { 15 | super(); 16 | this.list = list; 17 | } 18 | 19 | public function getList():GridList { 20 | return list; 21 | } 22 | } -------------------------------------------------------------------------------- /org/aswing/ext/GridListCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | import org.aswing.Cell; 9 | 10 | interface GridListCell extends Cell { 11 | 12 | /** 13 | * Sets the table cell status 14 | * @param gridList the cell's owner, a GridList 15 | * @param selected true to set the cell selected, false to set not selected. 16 | * @param index the index of this cell 17 | */ 18 | function setGridListCellStatus(gridList:GridList, selected:Bool, index:Int):Void; 19 | 20 | function getAwmlIndex():Int; 21 | } -------------------------------------------------------------------------------- /org/aswing/ext/GridListCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | /** 9 | * The factory to generate grid list cell instances. 10 | */ 11 | interface GridListCellFactory { 12 | 13 | /** 14 | * Creates a new list cell. 15 | */ 16 | function createNewGridListCell():GridListCell; 17 | 18 | } -------------------------------------------------------------------------------- /org/aswing/ext/MultilineLabel.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.ext; 6 | 7 | 8 | import org.aswing.JTextArea; 9 | 10 | /** 11 | * MutilineLabel performances just like a label that wordwrap and multiline. 12 | * It is simulated by a JTextArea with no border no backgorund decorator and background not opaque. 13 | * By default it is wrodwrap and selectable. 14 | * @author paling 15 | */ 16 | class MultilineLabel extends JTextArea { 17 | 18 | public function new(text:String = "", rows:Int = 0, columns:Int = 0) { 19 | super(text, rows, columns); 20 | setWordWrap(true); 21 | setBorder(null); 22 | setBackgroundDecorator(null); 23 | setOpaque(false); 24 | setEditable(false); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /org/aswing/graphics/BitmapBrush.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing.graphics; 5 | 6 | import flash.display.Graphics; 7 | import flash.display.BitmapData; 8 | import flash.geom.Matrix; 9 | 10 | 11 | /** 12 | * Encapsulate the fill parameter for flash.display.Graphics.beginBitmapFill() 13 | * @see http://livedocs.macromedia.com/flex/2/langref/flash/display/Graphics.html#beginBitmapFill() 14 | * @author n0rthwood 15 | */ 16 | class BitmapBrush implements IBrush { 17 | 18 | private var _bitmapData:BitmapData; 19 | private var _matrix:Matrix; 20 | private var _repeat:Bool; 21 | private var _smooth:Bool; 22 | 23 | public function new(bitmap:BitmapData, ?matrix:Matrix = null, ?repeat:Bool = true, ?smooth:Bool = false) { 24 | this._bitmapData = bitmap; 25 | this._matrix = matrix; 26 | this._repeat = repeat; 27 | this._smooth = smooth; 28 | } 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | 34 | public function beginFill(target:Graphics):Void { 35 | target.beginBitmapFill(_bitmapData, _matrix, _repeat, _smooth); 36 | } 37 | 38 | /** 39 | * @inheritDoc 40 | */ 41 | 42 | public function endFill(target:Graphics):Void { 43 | target.endFill(); 44 | } 45 | 46 | public function getBitmapData():BitmapData { 47 | return _bitmapData; 48 | } 49 | 50 | /** 51 | * 52 | */ 53 | 54 | public function setBitmapData(bitmapData:BitmapData):Void { 55 | this._bitmapData = bitmapData; 56 | } 57 | 58 | public function getMatrix():Matrix { 59 | return _matrix; 60 | } 61 | 62 | /** 63 | * 64 | */ 65 | 66 | public function setMatrix(matrix:Matrix):Void { 67 | this._matrix = matrix; 68 | } 69 | 70 | public function isRepeat():Bool { 71 | return _repeat; 72 | } 73 | 74 | /** 75 | * 76 | */ 77 | 78 | public function setRepeat(repeat:Bool):Void { 79 | this._repeat = repeat; 80 | } 81 | 82 | public function isSmooth():Bool { 83 | return _smooth; 84 | } 85 | 86 | /** 87 | * 88 | */ 89 | 90 | public function setSmooth(smooth:Bool):Void { 91 | this._smooth = smooth; 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /org/aswing/graphics/IBrush.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.graphics; 6 | 7 | 8 | import flash.display.Graphics; 9 | 10 | /** 11 | * Brush to fill a closed area.
12 | * Use it with a org.aswing.graphics.Graphics2D instance 13 | * @author paling 14 | */ 15 | interface IBrush { 16 | 17 | /** 18 | * 19 | * This method will be called by Graphics2D autumaticlly.
20 | * It applys the fill paramters to the instance of flash.display.Graphics 21 | * 22 | * @param target the instance of a flash.display.Graphics 23 | */ 24 | function beginFill(target:Graphics):Void; 25 | 26 | /** 27 | * 28 | * This method will be called by Graphics2D autumaticlly.
29 | * It marks the end of filling 30 | * 31 | * @param target the instance of a flash.display.Graphics 32 | */ 33 | function endFill(target:Graphics):Void; 34 | } -------------------------------------------------------------------------------- /org/aswing/graphics/IPen.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing.graphics; 5 | 6 | 7 | import flash.display.Graphics; 8 | 9 | /** 10 | * Pen to draw lines.
11 | * Use it with a org.aswing.graphics.Graphics2D instance 12 | * @author n0rthwood 13 | */ 14 | interface IPen { 15 | 16 | /** 17 | * 18 | * This method will be called by Graphics2D autumaticlly.
19 | * It will set the lineStyle to the instance of flash.display.Graphics 20 | * @param target the instance of graphics from a display object 21 | */ 22 | function setTo(target:Graphics):Void; 23 | } -------------------------------------------------------------------------------- /org/aswing/graphics/SolidBrush.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.graphics; 6 | 7 | 8 | import flash.display.Graphics; 9 | import org.aswing.ASColor; 10 | import org.aswing.graphics.IBrush; 11 | 12 | /** 13 | * SolidBrush encapsulate fill parameters for flash.display.Graphics.beginFill() 14 | * @see http://livedocs.macromedia.com/flex/2/langref/flash/display/Graphics.html#beginFill() 15 | * @author paling 16 | */ 17 | class SolidBrush implements IBrush { 18 | 19 | private var color:ASColor; 20 | 21 | public function new(color:ASColor) { 22 | this.color = color; 23 | } 24 | 25 | public function getColor():ASColor { 26 | return color; 27 | } 28 | 29 | /** 30 | * Sets the color 31 | */ 32 | 33 | public function setColor(color:ASColor):Void { 34 | this.color = color; 35 | } 36 | 37 | /** 38 | * Begins fill 39 | */ 40 | 41 | public function beginFill(target:Graphics):Void { 42 | target.beginFill(color.getRGB(), color.getAlpha()); 43 | } 44 | 45 | /** 46 | * Ends fill 47 | */ 48 | 49 | public function endFill(target:Graphics):Void { 50 | target.endFill(); 51 | } 52 | } -------------------------------------------------------------------------------- /org/aswing/plaf/ASColorUIResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.ASColor; 9 | 10 | /** 11 | * Color UI Resource. 12 | * @author paling 13 | */ 14 | class ASColorUIResource extends ASColor implements UIResource { 15 | public function new(color:Int = 0x000000, alpha:Float = 1) { 16 | super(color, alpha); 17 | } 18 | 19 | /** 20 | * Create a color ui resource with a color. 21 | */ 22 | 23 | public static function createResourceColor(color:ASColor):ASColorUIResource { 24 | return new ASColorUIResource(color.getRGB(), color.getAlpha()); 25 | } 26 | } -------------------------------------------------------------------------------- /org/aswing/plaf/ASFontUIResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | import org.aswing.ASFont; 8 | 9 | /** 10 | * Font UI Resource. 11 | * @author paling 12 | */ 13 | class ASFontUIResource extends ASFont implements UIResource { 14 | public function new(name:String = "Tahoma", size:Float = 11, bold:Bool = false, italic:Bool = false, underline:Bool = false, embedFontsOrAdvancedPros:Dynamic = null) { 15 | super(name, size, bold, italic, underline, embedFontsOrAdvancedPros); 16 | } 17 | 18 | /** 19 | * Create a font ui resource with a font. 20 | */ 21 | 22 | public static function createResourceFont(font:ASFont):ASFontUIResource { 23 | return new ASFontUIResource(font.getName(), font.getSize(), font.isBold(), font.isItalic(), font.isUnderline(), font.getAdvancedProperties()); 24 | } 25 | } -------------------------------------------------------------------------------- /org/aswing/plaf/AdjusterUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.JTextField; 9 | import org.aswing.JSlider; 10 | import org.aswing.plaf.ComponentUI; 11 | 12 | /** 13 | * Pluginable ui for JAdjuster. 14 | * @see org.aswing.JAdjuster 15 | * @author paling 16 | */ 17 | interface AdjusterUI extends ComponentUI { 18 | 19 | function getInputText():JTextField; 20 | 21 | function getPopupSlider():JSlider; 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/ArrayUIResource.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | //class UArray extends Array{ 3 | class ArrayUIResource { 4 | 5 | 6 | } 7 | 8 | -------------------------------------------------------------------------------- /org/aswing/plaf/ColorSwatchesUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.Component; 9 | 10 | /** 11 | * Pluggable look and feel interface for JColorSwatchs. 12 | * 13 | * @author paling 14 | */ 15 | interface ColorSwatchesUI extends ComponentUI { 16 | 17 | /** 18 | * Adds a component to this panel's sections bar. 19 | * @param com the component to be added 20 | */ 21 | function addComponentColorSectionBar(com:Component):Void; 22 | 23 | } -------------------------------------------------------------------------------- /org/aswing/plaf/ComboBoxUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.JComboBox; 9 | 10 | /** 11 | * Pluginable ui for JComboBox. 12 | * @see org.aswing.JComboBox 13 | * @author paling 14 | */ 15 | interface ComboBoxUI extends ComponentUI { 16 | 17 | /** 18 | * Set the visiblity of the popup 19 | */ 20 | function setPopupVisible(c:JComboBox, v:Bool):Void; 21 | 22 | /** 23 | * Determine the visibility of the popup 24 | */ 25 | function isPopupVisible(c:JComboBox):Bool; 26 | } -------------------------------------------------------------------------------- /org/aswing/plaf/DefaultsDecorator.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | 4 | /** 5 | * The decorator that will use defaults properties. 6 | */ 7 | interface DefaultsDecorator { 8 | 9 | /** 10 | * Sets the defaults properties owner. 11 | * Which the owner.getDefault() will be called. 12 | */ 13 | function setDefaultsOwner(owner:ComponentUI):Void; 14 | 15 | } -------------------------------------------------------------------------------- /org/aswing/plaf/DefaultsDecoratorBase.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | 4 | import org.aswing.Component; 5 | 6 | class DefaultsDecoratorBase implements DefaultsDecorator { 7 | 8 | private var defaultsOwner:ComponentUI; 9 | 10 | public function new() { 11 | 12 | } 13 | 14 | public function setDefaultsOwner(owner:ComponentUI):Void { 15 | defaultsOwner = owner; 16 | } 17 | 18 | public function getDefaultsOwner(c:Component):ComponentUI { 19 | if (defaultsOwner != null) { 20 | return defaultsOwner; 21 | } else { 22 | return c.getUI(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /org/aswing/plaf/EmptyLayoutUIResourse.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | 4 | import org.aswing.EmptyLayout; 5 | 6 | /** 7 | * A UIResource layout manager. 8 | * @author 9 | */ 10 | class EmptyLayoutUIResourse extends EmptyLayout implements UIResource { 11 | } -------------------------------------------------------------------------------- /org/aswing/plaf/EmptyUIResources.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.Border; 9 | import org.aswing.GroundDecorator; 10 | import org.aswing.Icon; 11 | 12 | /** 13 | * The default empty values for ui resources. 14 | * A value defined in LAF with null or missing definition, it will be treat as these 15 | * default values here. 16 | *

17 | * For example, if you define button.border = null in the LAF class, then in fact the 18 | * UIDefaults will return EmptyUIResources.BORDER to you. 19 | *

20 | * @author paling 21 | */ 22 | class EmptyUIResources { 23 | /** 24 | * The default empty value for border. 25 | */ 26 | public static var BORDER:Border = DefaultEmptyDecoraterResource.INSTANCE; 27 | 28 | /** 29 | * The default empty value for icon. 30 | */ 31 | public static var ICON:Icon = DefaultEmptyDecoraterResource.INSTANCE; 32 | 33 | /** 34 | * The default empty value for ground decorator. 35 | */ 36 | public static var DECORATOR:GroundDecorator = DefaultEmptyDecoraterResource.INSTANCE; 37 | 38 | /** 39 | * The default empty value for insets. 40 | */ 41 | public static var INSETS:InsetsUIResource = new InsetsUIResource(); 42 | 43 | /** 44 | * The default empty value for font. 45 | */ 46 | public static var FONT:ASFontUIResource = new ASFontUIResource(); 47 | 48 | /** 49 | * The default empty value for color. 50 | */ 51 | public static var COLOR:ASColorUIResource = new ASColorUIResource(); 52 | 53 | /** 54 | * The default empty value for style tune. 55 | */ 56 | public static var STYLE_TUNE:UIStyleTune = new UIStyleTune(); 57 | } -------------------------------------------------------------------------------- /org/aswing/plaf/FrameUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | /** 9 | * Pluginable ui for JFrame. 10 | * @see org.aswing.JFrame 11 | * @author paling 12 | */ 13 | interface FrameUI extends ComponentUI { 14 | /** 15 | * Flash the modal frame. (User clicked other where is not in the modal frame, 16 | * flash the frame to make notice this frame is modal.) 17 | */ 18 | function flashModalFrame():Void; 19 | 20 | /** 21 | * For flashModalFrame to judge whether paint actived color or inactived color. 22 | */ 23 | function isPaintActivedFrame():Bool; 24 | } -------------------------------------------------------------------------------- /org/aswing/plaf/InsetsUIResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.Insets; 9 | 10 | /** 11 | * Insets UI Resource. 12 | * @author paling 13 | */ 14 | class InsetsUIResource extends Insets implements UIResource { 15 | public function new(top:Int = 0, left:Int = 0, bottom:Int = 0, right:Int = 0) { 16 | super(top, left, bottom, right); 17 | } 18 | 19 | /** 20 | * Create a insets ui resource with a insets. 21 | */ 22 | 23 | public function createInsetsResource(insets:Insets):InsetsUIResource { 24 | return new InsetsUIResource(insets.top, insets.left, insets.bottom, insets.right); 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /org/aswing/plaf/MenuElementUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | /** 9 | * Pluginable ui for MenuItem. 10 | * @see org.aswing.JMenuItem 11 | * @author paling 12 | */ 13 | interface MenuElementUI extends ComponentUI { 14 | 15 | /** 16 | * Subclass override this to process key event. 17 | */ 18 | function processKeyEvent(code:Int):Void; 19 | } -------------------------------------------------------------------------------- /org/aswing/plaf/SliderUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.Insets; 9 | 10 | /** 11 | * Pluginable ui for Slider. 12 | * @see org.aswing.JSlider 13 | * @author paling 14 | */ 15 | interface SliderUI extends ComponentUI { 16 | 17 | function getTrackMargin():Insets; 18 | 19 | } -------------------------------------------------------------------------------- /org/aswing/plaf/SplitPaneUI.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | import org.aswing.JSplitPane; 4 | /** 5 | * Pluggable look and feel interface for JSplitPane. 6 | * @author paling 7 | */ 8 | class SplitPaneUI extends BaseComponentUI { 9 | public function new() { 10 | super(); 11 | } 12 | 13 | /** 14 | * Messaged to relayout the JSplitPane based on the preferred size 15 | * of the children components. 16 | */ 17 | 18 | public function resetToPreferredSizes(jc:JSplitPane):Void { 19 | trace("Subclass need to override this method!"); 20 | } 21 | 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/TableUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf; 6 | 7 | 8 | import org.aswing.JTable; 9 | import org.aswing.geom.IntDimension; 10 | 11 | /** 12 | * Pluginable ui for JTable. 13 | * @see org.aswing.JTable 14 | * @author paling 15 | */ 16 | interface TableUI extends ComponentUI { 17 | 18 | /** 19 | * Returns the view size. 20 | */ 21 | function getViewSize(table:JTable):IntDimension; 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/UIResource.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | 4 | /** 5 | * This interface is used to mark objects created by ComponentUI delegates. 6 | * The ComponentUI.installUI() and 7 | * ComponentUI.uninstallUI() methods can use this interface 8 | * to decide if a properties value has been overridden. For example, the 9 | * JPanel border property is initialized by BasicPanelUI.installUI(), 10 | * only if it's initial value is an UIResource instance: 11 | *
12 |  * if (panel.getBorder() is UIResource) {
13 |  *     panel.setBorder(UIManager.getBorder("Panel.border"));
14 |  * }
15 |  * 
16 | * At uninstallUI() time we will not reset the property, because it will 17 | * be replaced by next UI installing. 18 | * 19 | * Some other type value like Numbers, Booleans, there will be method in the Component 20 | * indicated that if is it set by user or LAFs, for example: 21 | *
22 |  * if (!panel.isOpaqueSet()) {
23 |  *     panel.setOpaque(UIManager.getBoolean("Panel.opaque"));
24 |  *     panel.setOpaqueSet(false);
25 |  * }
26 |  * 
27 | * @see EmptyUIResources 28 | * @see ComponentUI 29 | * @author paling 30 | */ 31 | interface UIResource { 32 | 33 | } -------------------------------------------------------------------------------- /org/aswing/plaf/UIStyleTune.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf; 2 | 3 | 4 | import org.aswing.StyleTune; 5 | 6 | /** 7 | * StyleTune UIResource 8 | */ 9 | class UIStyleTune extends StyleTune implements UIResource { 10 | 11 | /** 12 | * Create a StyleTune with specified params 13 | * @param cg gradient brightness range of content color 14 | * @param bo birightness offset for border color 15 | * @param bg gradient brightness range of border color 16 | * @param sa shadow alpha 17 | * @param ma the adjuster for mideground color, null means use this(StyleTune) 18 | */ 19 | public function new(cg:Float = 0.2, bo:Float = 0.15, bg:Float = 0.35, sa:Float = 0.2, r:Float = 0, ma:UIStyleTune = null) { 20 | super(cg, bo, bg, sa, r, ma); 21 | } 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicCheckBoxMenuItemUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class BasicCheckBoxMenuItemUI extends BasicMenuItemUI { 12 | 13 | override private function getPropertyPrefix():String { 14 | return "CheckBoxMenuItem."; 15 | } 16 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicCheckBoxUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | /** 9 | * Basic CheckBox implementation. 10 | * @author paling 11 | * @private 12 | */ 13 | class BasicCheckBoxUI extends BasicRadioButtonUI { 14 | 15 | public function new() { 16 | super(); 17 | } 18 | 19 | override private function getPropertyPrefix():String { 20 | return "CheckBox."; 21 | } 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicPanelUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.JPanel; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.graphics.Graphics2D; 12 | import org.aswing.plaf.BaseComponentUI; 13 | 14 | /** 15 | * @private 16 | * @author paling 17 | */ 18 | class BasicPanelUI extends BaseComponentUI { 19 | public function new() { 20 | super(); 21 | } 22 | 23 | override public function installUI(c:Component):Void { 24 | var p:JPanel = cast(c, JPanel); 25 | installDefaults(p); 26 | } 27 | 28 | override public function uninstallUI(c:Component):Void { 29 | var p:JPanel = cast(c, JPanel); 30 | uninstallDefaults(p); 31 | } 32 | 33 | private function installDefaults(p:JPanel):Void { 34 | var pp:String = "Panel."; 35 | LookAndFeel.installColorsAndFont(p, pp); 36 | LookAndFeel.installBorderAndBFDecorators(p, pp); 37 | LookAndFeel.installBasicProperties(p, pp); 38 | } 39 | 40 | private function uninstallDefaults(p:JPanel):Void { 41 | LookAndFeel.uninstallBorderAndBFDecorators(p); 42 | } 43 | 44 | override private function paintBackGround(c:Component, g:Graphics2D, b:IntRectangle):Void { 45 | //do nothing, bg decorator will do this job 46 | } 47 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicRadioButtonMenuItemUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class BasicRadioButtonMenuItemUI extends BasicMenuItemUI { 12 | 13 | override private function getPropertyPrefix():String { 14 | return "RadioButtonMenuItem."; 15 | } 16 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicRadioButtonUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | import org.aswing.Icon; 9 | import org.aswing.AbstractButton; 10 | import org.aswing.Component; 11 | import org.aswing.geom.IntRectangle; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.graphics.SolidBrush; 14 | /** 15 | * Basic RadioButton implementation. 16 | * @author paling 17 | * @private 18 | */ 19 | class BasicRadioButtonUI extends BasicToggleButtonUI { 20 | 21 | private var defaultIcon:Icon; 22 | 23 | public function new() { 24 | super(); 25 | } 26 | 27 | override private function installDefaults(b:AbstractButton):Void { 28 | super.installDefaults(b); 29 | defaultIcon = getIcon(getPropertyPrefix() + "icon"); 30 | } 31 | 32 | override private function uninstallDefaults(b:AbstractButton):Void { 33 | super.uninstallDefaults(b); 34 | if (defaultIcon.getDisplay(b) != null) { 35 | if (button.contains(defaultIcon.getDisplay(b))) { 36 | button.removeChild(defaultIcon.getDisplay(b)); 37 | } 38 | } 39 | } 40 | 41 | override private function getPropertyPrefix():String { 42 | return "RadioButton."; 43 | } 44 | 45 | public function getDefaultIcon():Icon { 46 | return defaultIcon; 47 | } 48 | 49 | override private function getIconToLayout():Icon { 50 | if (button.getIcon() == null) { 51 | if (defaultIcon.getDisplay(button) != null) { 52 | if (!button.contains(defaultIcon.getDisplay(button))) { 53 | button.addChild(defaultIcon.getDisplay(button)); 54 | } 55 | } 56 | return defaultIcon; 57 | } else { 58 | return button.getIcon(); 59 | } 60 | } 61 | 62 | override private function paintBackGround(c:Component, g:Graphics2D, b:IntRectangle):Void { 63 | if (c.isOpaque()) { 64 | g.fillRectangle(new SolidBrush(c.getBackground()), b.x, b.y, b.width, b.height); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicSpacerUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | import org.aswing.Component; 8 | import org.aswing.JSpacer; 9 | import org.aswing.plaf.BaseComponentUI; 10 | import org.aswing.geom.IntDimension; 11 | 12 | /** 13 | * @private 14 | */ 15 | class BasicSpacerUI extends BaseComponentUI { 16 | public function new() { 17 | super(); 18 | } 19 | 20 | private function getPropertyPrefix():String { 21 | return "Spacer."; 22 | } 23 | 24 | override public function installUI(c:Component):Void { 25 | installDefaults(cast(c, JSpacer)); 26 | } 27 | 28 | override public function uninstallUI(c:Component):Void { 29 | uninstallDefaults(cast(c, JSpacer)); 30 | } 31 | 32 | private function installDefaults(s:JSpacer):Void { 33 | var pp:String = getPropertyPrefix(); 34 | LookAndFeel.installColors(s, pp); 35 | LookAndFeel.installBasicProperties(s, pp); 36 | LookAndFeel.installBorderAndBFDecorators(s, pp); 37 | } 38 | 39 | private function uninstallDefaults(s:JSpacer):Void { 40 | LookAndFeel.uninstallBorderAndBFDecorators(s); 41 | } 42 | 43 | override public function getPreferredSize(c:Component):IntDimension { 44 | return c.getInsets().getOutsideSize(new IntDimension(0, 0)); 45 | } 46 | 47 | override public function getMaximumSize(c:Component):IntDimension { 48 | return IntDimension.createBigDimension(); 49 | } 50 | /** 51 | * Returns null 52 | */ 53 | 54 | override public function getMinimumSize(c:Component):IntDimension { 55 | return new IntDimension(0, 0); 56 | } 57 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicTextAreaUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class BasicTextAreaUI extends BasicTextComponentUI { 12 | 13 | public function new() { 14 | super(); 15 | } 16 | 17 | //override this to the sub component's prefix 18 | 19 | override private function getPropertyPrefix():String { 20 | return "TextArea."; 21 | } 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/BasicTextFieldUI.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class BasicTextFieldUI extends BasicTextComponentUI { 12 | 13 | public function new() { 14 | super(); 15 | } 16 | 17 | //override this to the sub component's prefix 18 | 19 | override private function getPropertyPrefix():String { 20 | return "TextField."; 21 | } 22 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/DefaultMenuLayout.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic; 6 | 7 | 8 | import org.aswing.SoftBoxLayout; 9 | import org.aswing.plaf.UIResource; 10 | import org.aswing.AsWingConstants; 11 | 12 | /** 13 | * @private 14 | */ 15 | class DefaultMenuLayout extends SoftBoxLayout implements UIResource { 16 | /** 17 | * Specifies that components should be laid out left to right. 18 | */ 19 | inline public static var X_AXIS:Int = 0; 20 | 21 | /** 22 | * Specifies that components should be laid out top to bottom. 23 | */ 24 | inline public static var Y_AXIS:Int = 1; 25 | 26 | public function new(axis:Int, gap:Int = 0, align:Int = AsWingConstants.LEFT) { 27 | super(axis, gap, align); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/adjuster/PopupSliderThumbIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.adjuster; 6 | 7 | 8 | import org.aswing.plaf.basic.icon.SliderThumbIcon; 9 | import org.aswing.Component; 10 | 11 | /** 12 | * @private 13 | */ 14 | class PopupSliderThumbIcon extends SliderThumbIcon { 15 | 16 | public function new() { 17 | super(); 18 | } 19 | 20 | override private function getPropertyPrefix():String { 21 | return "Adjuster."; 22 | } 23 | 24 | override public function getIconHeight(c:Component):Int { 25 | return 12; 26 | } 27 | 28 | override public function getIconWidth(c:Component):Int { 29 | return 12; 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/ComboBoxBackground.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.background; 2 | 3 | 4 | /** 5 | * @private 6 | */ 7 | class ComboBoxBackground extends TextComponentBackBround { 8 | 9 | public function new() { 10 | super(); 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/InputBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.background; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class InputBackground extends TextComponentBackBround { 12 | 13 | public function new() { 14 | super(); 15 | } 16 | 17 | override private function getChangeSharpen(enabled:Bool, editable:Bool):Float { 18 | if (enabled != true) { 19 | return 0.2; 20 | } else if (editable != true) { 21 | return 1; 22 | } else { 23 | return 1; 24 | } 25 | } 26 | 27 | override private function getChangeAlpha(enabled:Bool, editable:Bool):Float { 28 | if (enabled != true) { 29 | return 0.2; 30 | } else if (editable != true) { 31 | return 0.5; 32 | } else { 33 | return 1; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/ListBackground.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.background; 2 | 3 | 4 | import flash.display.DisplayObject; 5 | 6 | import org.aswing.ASColor; 7 | import org.aswing.StyleResult; 8 | import org.aswing.StyleTune; 9 | import org.aswing.Component; 10 | import org.aswing.GroundDecorator; 11 | import org.aswing.geom.IntRectangle; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.plaf.UIResource; 14 | import org.aswing.plaf.basic.BasicGraphicsUtils; 15 | 16 | class ListBackground implements GroundDecorator implements UIResource { 17 | 18 | public function new() { 19 | } 20 | 21 | public function getDisplay(c:Component):DisplayObject { 22 | return null; 23 | } 24 | 25 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 26 | if (c.isOpaque()) { 27 | var cl:ASColor = c.getMideground(); 28 | var style:StyleResult; 29 | var adjuster:StyleTune = c.getStyleTune(); 30 | if (!c.isEnabled()) { 31 | adjuster = adjuster.sharpen(0.5); 32 | cl = cl.changeAlpha(0.6); 33 | } 34 | style = new StyleResult(cl, adjuster); 35 | BasicGraphicsUtils.fillGradientRoundRect(g, b, style, -Math.PI / 2); 36 | } 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/PanelBackground.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.background; 2 | 3 | 4 | import flash.display.DisplayObject; 5 | 6 | import org.aswing.Component; 7 | import org.aswing.GroundDecorator; 8 | import org.aswing.geom.IntRectangle; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.SolidBrush; 11 | import org.aswing.plaf.UIResource; 12 | 13 | class PanelBackground implements GroundDecorator implements UIResource { 14 | 15 | public function new() { 16 | } 17 | 18 | public function getDisplay(c:Component):DisplayObject { 19 | return null; 20 | } 21 | 22 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 23 | if (c.isOpaque()) { 24 | g.fillRectangle(new SolidBrush(c.getBackground()), b.x, b.y, b.width, b.height); 25 | } 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/ProgressBarBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.background; 6 | import flash.filters.GlowFilter; 7 | import flash.display.DisplayObject; 8 | import flash.display.Shape; 9 | import flash.filters.BitmapFilter; 10 | import org.aswing.AsWingConstants; 11 | import org.aswing.Component; 12 | import org.aswing.GroundDecorator; 13 | import org.aswing.Orientable; 14 | import org.aswing.StyleTune; 15 | import org.aswing.geom.IntRectangle; 16 | import org.aswing.graphics.Graphics2D; 17 | import org.aswing.graphics.SolidBrush; 18 | import org.aswing.plaf.UIResource; 19 | 20 | /** 21 | * @private 22 | */ 23 | class ProgressBarBackground implements GroundDecorator implements UIResource { 24 | 25 | private var shape:Shape; 26 | 27 | public function new() { 28 | shape = new Shape(); 29 | } 30 | 31 | public function getDisplay(c:Component):DisplayObject { 32 | return shape; 33 | } 34 | 35 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 36 | if (Std.is(c, Orientable) && c.isOpaque()) { 37 | var bar:Orientable = cast(c, Orientable) ; 38 | var verticle:Bool = (bar.getOrientation() == AsWingConstants.VERTICAL); 39 | shape.graphics.clear(); 40 | var style:StyleTune = c.getStyleTune(); 41 | g = new Graphics2D(shape.graphics); 42 | b = b.clone(); 43 | var radius:Float = 0; 44 | if (verticle) { 45 | radius = Math.floor(b.width / 2); 46 | } else { 47 | radius = Math.floor(b.height / 2); 48 | } 49 | if (radius > style.round) { 50 | radius = style.round; 51 | } 52 | 53 | g.fillRoundRect(new SolidBrush(c.getBackground().changeAlpha(1)), b.x, b.y, b.width, b.height, radius); 54 | var f:Array= new Array(); 55 | f.push(new GlowFilter(0x0, style.shadowAlpha, 5, 5, 1, 1, true)); 56 | shape.filters = f; 57 | 58 | shape.alpha = c.getBackground().getAlpha(); 59 | } 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/ScrollBarBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.background; 6 | import flash.filters.GlowFilter; 7 | import flash.display.DisplayObject; 8 | import flash.display.Shape; 9 | import flash.filters.BitmapFilter; 10 | import org.aswing.AsWingConstants; 11 | import org.aswing.Component; 12 | import org.aswing.GroundDecorator; 13 | import org.aswing.Orientable; 14 | import org.aswing.StyleTune; 15 | import org.aswing.geom.IntRectangle; 16 | import org.aswing.graphics.Graphics2D; 17 | import org.aswing.graphics.SolidBrush; 18 | import org.aswing.plaf.UIResource; 19 | 20 | /** 21 | * @private 22 | */ 23 | class ScrollBarBackground implements GroundDecorator implements UIResource { 24 | 25 | private var shape:Shape; 26 | 27 | public function new() { 28 | shape = new Shape(); 29 | } 30 | 31 | public function getDisplay(c:Component):DisplayObject { 32 | return shape; 33 | } 34 | 35 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 36 | if (Std.is(c, Orientable) && c.isOpaque()) { 37 | var bar:Orientable = cast(c, Orientable) ; 38 | var verticle:Bool = (bar.getOrientation() == AsWingConstants.VERTICAL); 39 | shape.graphics.clear(); 40 | var style:StyleTune = c.getStyleTune(); 41 | g = new Graphics2D(shape.graphics); 42 | b = b.clone(); 43 | 44 | 45 | g.fillRoundRect(new SolidBrush(c.getBackground().changeAlpha(1)), b.x, b.y, b.width, b.height, style.round); 46 | var f:Array= new Array(); 47 | f.push(new GlowFilter(0x0, style.shadowAlpha, 5, 5, 1, 1, true)); 48 | shape.filters = f; 49 | 50 | shape.alpha = c.getBackground().getAlpha(); 51 | } 52 | } 53 | 54 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/TableBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.background; 6 | 7 | 8 | import flash.display.DisplayObject; 9 | import flash.display.Shape; 10 | import flash.filters.GlowFilter; 11 | import flash.filters.BitmapFilter; 12 | import org.aswing.ASColor; 13 | import org.aswing.Component; 14 | import org.aswing.GroundDecorator; 15 | import org.aswing.StyleResult; 16 | import org.aswing.StyleTune; 17 | import org.aswing.geom.IntRectangle; 18 | import org.aswing.graphics.Graphics2D; 19 | import org.aswing.plaf.UIResource; 20 | import org.aswing.plaf.basic.BasicGraphicsUtils; 21 | 22 | /** 23 | * @private 24 | */ 25 | class TableBackground implements GroundDecorator implements UIResource { 26 | 27 | private var shape:Shape; 28 | 29 | public function new() { 30 | shape = new Shape(); 31 | } 32 | 33 | public function getDisplay(c:Component):DisplayObject { 34 | return shape; 35 | } 36 | 37 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 38 | shape.graphics.clear(); 39 | if (c.isOpaque()) { 40 | g = new Graphics2D(shape.graphics); 41 | var tune:StyleTune = c.getStyleTune().mide; 42 | var cl:ASColor = c.getMideground(); 43 | var style:StyleResult = new StyleResult(cl, tune); 44 | b = b.clone(); 45 | style.cdark = style.cdark.changeAlpha(1); 46 | style.clight = style.clight.changeAlpha(1); 47 | BasicGraphicsUtils.fillGradientRoundRect(g, b, style, -Math.PI / 2); 48 | var bd:ASColor = style.bdark; 49 | var f:Array = new Array(); 50 | f.push(new GlowFilter(0xFFFFFF, 0.5, 2, 2, 20, 1, true)); 51 | f.push(new GlowFilter(bd.getRGB(), 1, 2, 2, 20, 1)); 52 | shape.filters = f; 53 | 54 | //new flash.filters.BevelFilter(1, 45, 0xFFFFFF, 0.4, 0x0, 0.4, 1, 1, 1, 1, BitmapFilterType.INNER), 55 | 56 | 57 | shape.alpha = cl.getAlpha(); 58 | } 59 | shape.visible = c.isOpaque(); 60 | } 61 | 62 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/background/ToolTipBackground.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.background; 6 | 7 | 8 | import flash.display.DisplayObject; 9 | import flash.display.Shape; 10 | 11 | import org.aswing.ASColor; 12 | import org.aswing.Component; 13 | import org.aswing.GroundDecorator; 14 | import org.aswing.StyleTune; 15 | import org.aswing.geom.IntRectangle; 16 | import org.aswing.graphics.Graphics2D; 17 | import org.aswing.graphics.SolidBrush; 18 | import org.aswing.plaf.UIResource; 19 | import org.aswing.plaf.basic.BasicGraphicsUtils; 20 | 21 | /** 22 | * @private 23 | */ 24 | class ToolTipBackground implements GroundDecorator implements UIResource { 25 | 26 | private var shape:Shape; 27 | 28 | public function new() { 29 | shape = new Shape(); 30 | } 31 | 32 | public function getDisplay(c:Component):DisplayObject { 33 | return shape; 34 | } 35 | 36 | public function updateDecorator(c:Component, g:Graphics2D, b:IntRectangle):Void { 37 | shape.visible = c.isOpaque(); 38 | if (c.isOpaque()) { 39 | shape.graphics.clear(); 40 | g = new Graphics2D(shape.graphics); 41 | var cc:ASColor = c.getBackground(); 42 | var bc:ASColor = c.getMideground(); 43 | var tune:StyleTune = c.getStyleTune(); 44 | g.beginFill(new SolidBrush(bc)); 45 | var r:Float = tune.round; 46 | b = new IntRectangle(0, 0, c.getWidth(), c.getHeight()); 47 | if (r < 1) { 48 | g.rectangle(b.x, b.y, b.width, b.height); 49 | } else { 50 | BasicGraphicsUtils.drawRoundRect(g, b.x, b.y, b.width, b.height, r); 51 | } 52 | g.endFill(); 53 | g.beginFill(new SolidBrush(cc)); 54 | r -= 0.5; 55 | b.grow(-1, -1); 56 | if (r < 1) { 57 | g.rectangle(b.x, b.y, b.width, b.height); 58 | } else { 59 | BasicGraphicsUtils.drawRoundRect(g, b.x, b.y, b.width, b.height, r); 60 | } 61 | g.endFill(); 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/ColorChooserBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | import org.aswing.Insets; 8 | import org.aswing.border.EmptyBorder; 9 | import org.aswing.plaf.UIResource; 10 | 11 | /** 12 | * @private 13 | */ 14 | class ColorChooserBorder extends EmptyBorder implements UIResource { 15 | 16 | public function new() { 17 | super(null, new Insets(6, 6, 6, 6)); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/ComboBoxBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | import org.aswing.ASColor; 9 | import org.aswing.border.BevelBorder; 10 | import org.aswing.plaf.UIResource; 11 | import org.aswing.Component; 12 | import org.aswing.EditableComponent; 13 | import org.aswing.graphics.Graphics2D; 14 | import org.aswing.geom.IntRectangle; 15 | 16 | /** 17 | * Discard in aswing 2.0(Background raped his job) 18 | * @private 19 | */ 20 | class ComboBoxBorder extends BevelBorder implements UIResource { 21 | 22 | private var colorInited:Bool; 23 | 24 | public function new() { 25 | super(null, BevelBorder.LOWERED); 26 | colorInited = false; 27 | } 28 | 29 | override public function updateBorderImp(c:Component, g:Graphics2D, b:IntRectangle):Void { 30 | if (colorInited != true) { 31 | setHighlightOuterColor(c.getUI().getColor("ComboBox.light")); 32 | setHighlightInnerColor(c.getUI().getColor("ComboBox.highlight")); 33 | setShadowOuterColor(c.getUI().getColor("ComboBox.darkShadow")); 34 | setShadowInnerColor(c.getUI().getColor("ComboBox.shadow")); 35 | } 36 | 37 | var box:EditableComponent = cast(c, EditableComponent) ; 38 | if (box != null) { 39 | if (box.isEditable()) { 40 | setBevelType(BevelBorder.LOWERED); 41 | } else { 42 | setBevelType(BevelBorder.RAISED); 43 | } 44 | } 45 | super.updateBorderImp(c, g, b); 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/EmptyBorderResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | import org.aswing.Insets; 9 | import org.aswing.Border; 10 | import org.aswing.plaf.UIResource; 11 | import org.aswing.border.EmptyBorder; 12 | 13 | class EmptyBorderResource extends EmptyBorder implements UIResource { 14 | 15 | public function new(interior:Border = null, margin:Insets = null) { 16 | super(interior, margin); 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/PopupMenuBorder.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.border; 2 | 3 | 4 | import flash.display.Shape; 5 | import flash.display.DisplayObject; 6 | 7 | import flash.filters.BitmapFilter; 8 | import flash.filters.DropShadowFilter; 9 | import org.aswing.Border; 10 | import org.aswing.Component; 11 | import org.aswing.StyleTune; 12 | import org.aswing.ASColor; 13 | import org.aswing.StyleResult; 14 | import org.aswing.Insets; 15 | import org.aswing.geom.IntRectangle; 16 | import org.aswing.graphics.Graphics2D; 17 | import org.aswing.plaf.UIResource; 18 | import org.aswing.plaf.basic.BasicGraphicsUtils; 19 | 20 | /** 21 | * @private 22 | */ 23 | class PopupMenuBorder implements Border implements UIResource { 24 | 25 | private var shape:Shape; 26 | 27 | public function new() { 28 | shape = new Shape(); 29 | } 30 | 31 | public function updateBorder(c:Component, g:Graphics2D, b:IntRectangle):Void { 32 | shape.graphics.clear(); 33 | if (c.isOpaque()) { 34 | b = b.clone(); 35 | b.height -= 4; 36 | b.width -= 4; 37 | g = new Graphics2D(shape.graphics); 38 | var tune:StyleTune = c.getStyleTune(); 39 | var cl:ASColor = c.getBackground(); 40 | var style:StyleResult = new StyleResult(cl.changeAlpha(1), tune); 41 | 42 | BasicGraphicsUtils.fillGradientRoundRect(g, b, style, Math.PI / 2); 43 | BasicGraphicsUtils.drawGradientRoundRectLine(g, b, 1, style, Math.PI / 2); 44 | var f:Array = new Array(); 45 | f.push(new DropShadowFilter(1, 45, 0x0, style.shadow, 4, 4, 1, 1)); 46 | shape.filters = f; 47 | 48 | //new flash.filters.BevelFilter(1, 90, style.blight.offsetHLS(0, 0, 0.2).getRGB(), 0.9, 0x0, 0.0, 1, 1, 1, 1, BitmapFilterType.INNER), 49 | 50 | 51 | shape.alpha = cl.getAlpha(); 52 | } 53 | shape.visible = c.isOpaque(); 54 | } 55 | 56 | public function getBorderInsets(com:Component, bounds:IntRectangle):Insets { 57 | return new Insets(2, 2, 6, 6); 58 | } 59 | 60 | public function getDisplay(c:Component):DisplayObject { 61 | return shape; 62 | } 63 | 64 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/ProgressBarBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | import org.aswing.ASColor; 9 | import org.aswing.Component; 10 | import org.aswing.border.LineBorder; 11 | import org.aswing.geom.IntRectangle; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.plaf.UIResource; 14 | /** 15 | * Discard in aswing 2.0(Background raped his job) 16 | * @private 17 | */ 18 | class ProgressBarBorder extends LineBorder implements UIResource { 19 | 20 | public function new() { 21 | color = null; 22 | super(); 23 | } 24 | 25 | override public function updateBorderImp(c:Component, g:Graphics2D, b:IntRectangle):Void { 26 | if (color == null) { 27 | color = c.getUI().getColor("ProgressBar.foreground"); 28 | setColor(color); 29 | } 30 | super.updateBorderImp(c, g, b); 31 | } 32 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/TextAreaBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | /** 9 | * Discard in aswing 2.0(Background raped his job) 10 | * @private 11 | */ 12 | class TextAreaBorder extends TextComponentBorder { 13 | 14 | public function new() { 15 | super(); 16 | } 17 | 18 | //override this to the sub component's prefix 19 | 20 | override private function getPropertyPrefix():String { 21 | return "TextArea."; 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/TextComponentBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.graphics.Pen; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.Border; 12 | import org.aswing.ASColor; 13 | import org.aswing.Component; 14 | import org.aswing.EditableComponent; 15 | import org.aswing.Insets; 16 | import flash.display.DisplayObject; 17 | import org.aswing.plaf.UIResource; 18 | import org.aswing.plaf.ComponentUI; 19 | import org.aswing.error.ImpMissError; 20 | 21 | /** 22 | * Discard in aswing 2.0(Background raped his job) 23 | * @private 24 | */ 25 | class TextComponentBorder implements Border implements UIResource { 26 | 27 | private var light:ASColor; 28 | private var shadow:ASColor; 29 | 30 | public function new() { 31 | 32 | } 33 | 34 | private function getPropertyPrefix():String { 35 | throw new ImpMissError(); 36 | return ""; 37 | } 38 | 39 | private function reloadColors(ui:ComponentUI):Void { 40 | light = ui.getColor(getPropertyPrefix() + "light"); 41 | shadow = ui.getColor(getPropertyPrefix() + "shadow"); 42 | } 43 | 44 | public function updateBorder(c:Component, g:Graphics2D, r:IntRectangle):Void { 45 | 46 | 47 | if (light == null) { 48 | reloadColors(c.getUI()); 49 | } 50 | var x1:Float = r.x; 51 | var y1:Float = r.y; 52 | var w:Float = r.width; 53 | var h:Float = r.height; 54 | var textCom:EditableComponent = cast(c, EditableComponent); 55 | //why 56 | 57 | if (textCom.isEditable() && c.isEnabled()) { 58 | g.drawRectangle(new Pen(shadow, 1), x1 + 0.5, y1 + 0.5, w - 1, h - 1); 59 | } 60 | g.drawRectangle(new Pen(light, 1), x1 + 1.5, y1 + 1.5, w - 3, h - 3); 61 | 62 | } 63 | 64 | public function getBorderInsets(com:Component, bounds:IntRectangle):Insets { 65 | return new Insets(2, 2, 2, 2); 66 | } 67 | 68 | public function getDisplay(c:Component):DisplayObject { 69 | return null; 70 | } 71 | 72 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/TextFieldBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | /** 9 | * Discard in aswing 2.0(Background raped his job) 10 | * @private 11 | */ 12 | class TextFieldBorder extends TextComponentBorder { 13 | 14 | public function new() { 15 | super(); 16 | } 17 | 18 | //override this to the sub component's prefix 19 | 20 | override private function getPropertyPrefix():String { 21 | return "TextField."; 22 | } 23 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/border/ToolTipBorder.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.border; 6 | 7 | 8 | import org.aswing.ASColor; 9 | import org.aswing.border.LineBorder; 10 | import org.aswing.plaf.UIResource; 11 | import org.aswing.Component; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.geom.IntRectangle; 14 | 15 | /** 16 | * @private 17 | */ 18 | class ToolTipBorder extends LineBorder implements UIResource { 19 | 20 | 21 | public function new() { 22 | super(); 23 | } 24 | 25 | override public function updateBorderImp(c:Component, g:Graphics2D, b:IntRectangle):Void { 26 | if (color == null) { 27 | color = c.getUI().getColor("ToolTip.borderColor"); 28 | setColor(color); 29 | } 30 | super.updateBorderImp(c, g, b); 31 | } 32 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/cursor/HV_ResizeCursor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.cursor; 6 | 7 | 8 | import flash.display.Shape; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.Pen; 11 | import org.aswing.graphics.SolidBrush; 12 | import org.aswing.UIManager; 13 | import org.aswing.ASColor; 14 | 15 | /** 16 | * @private 17 | * @author valley 18 | */ 19 | class HV_ResizeCursor extends Shape { 20 | 21 | private var resizeArrowColor:ASColor; 22 | private var resizeArrowLightColor:ASColor; 23 | private var resizeArrowDarkColor:ASColor; 24 | 25 | public function new() { 26 | super(); 27 | 28 | resizeArrowColor = UIManager.getColor("Frame.resizeArrow"); 29 | resizeArrowLightColor = UIManager.getColor("Frame.resizeArrowLight"); 30 | resizeArrowDarkColor = UIManager.getColor("Frame.resizeArrowDark"); 31 | 32 | var w:Float = 1; //arrowAxisHalfWidth 33 | var r:Float = 4; 34 | var arrowPoints:Array; 35 | 36 | arrowPoints = [{y:-r * 2, x:0}, {y:-r, x:-r}, {y:-r, x:-w}, 37 | {y:-w, x:-w}, {y:-w, x:-r}, {y:-r, x:-r}, {y:0, x:-2 * r}, 38 | {y:r, x:-r }, {y:w, x:-r}, {y:w, x:-w }, 39 | {y:r, x:-w}, {y:r, x:-r}, {y:r * 2, x:0}, 40 | {y:r, x:r}, {y:r, x:w}, 41 | {y:w, x:w}, {y:w, x:r}, {y:r, x:r}, {y:0, x:2 * r}, 42 | {y:-r, x:r}, {y:-w, x:r}, {y:-w, x:w}, 43 | {y:-r, x:w}, {y:-r, x:r}]; 44 | 45 | var gdi:Graphics2D = new Graphics2D(graphics); 46 | //why 47 | 48 | gdi.drawPolygon(new Pen(resizeArrowColor.changeAlpha(0.4), 4), arrowPoints); 49 | gdi.fillPolygon(new SolidBrush(resizeArrowLightColor), arrowPoints); 50 | gdi.drawPolygon(new Pen(resizeArrowDarkColor, 1), arrowPoints); 51 | } 52 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/cursor/H_ResizeCursor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.cursor; 6 | 7 | 8 | import flash.display.Shape; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.Pen; 11 | import org.aswing.graphics.SolidBrush; 12 | import org.aswing.UIManager; 13 | import org.aswing.ASColor; 14 | 15 | /** 16 | * @private 17 | */ 18 | class H_ResizeCursor extends Shape { 19 | 20 | private var resizeArrowColor:ASColor; 21 | private var resizeArrowLightColor:ASColor; 22 | private var resizeArrowDarkColor:ASColor; 23 | 24 | public function new() { 25 | super(); 26 | 27 | resizeArrowColor = UIManager.getColor("Frame.resizeArrow"); 28 | resizeArrowLightColor = UIManager.getColor("Frame.resizeArrowLight"); 29 | resizeArrowDarkColor = UIManager.getColor("Frame.resizeArrowDark"); 30 | 31 | var w:Float = 1; //arrowAxisHalfWidth 32 | var r:Float = 4; 33 | var arrowPoints:Array; 34 | 35 | arrowPoints = [{x:-r * 2, y:0}, {x:-r, y:-r}, {x:-r, y:-w}, 36 | {x:r, y:-w}, {x:r, y:-r}, {x:r * 2, y:0}, 37 | {x:r, y:r}, {x:r, y:w}, {x:-r, y:w}, 38 | {x:-r, y:r}]; 39 | var gdi:Graphics2D = new Graphics2D(graphics); 40 | 41 | //why 42 | 43 | gdi.drawPolygon(new Pen(resizeArrowColor.changeAlpha(0.4), 4), arrowPoints); 44 | gdi.fillPolygon(new SolidBrush(resizeArrowLightColor), arrowPoints); 45 | gdi.drawPolygon(new Pen(resizeArrowDarkColor, 1), arrowPoints); 46 | } 47 | 48 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/cursor/V_ResizeCursor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.cursor; 6 | 7 | 8 | import flash.display.Shape; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.Pen; 11 | import org.aswing.graphics.SolidBrush; 12 | import org.aswing.UIManager; 13 | import org.aswing.ASColor; 14 | 15 | /** 16 | * @private 17 | */ 18 | class V_ResizeCursor extends Shape { 19 | 20 | private var resizeArrowColor:ASColor; 21 | private var resizeArrowLightColor:ASColor; 22 | private var resizeArrowDarkColor:ASColor; 23 | 24 | public function new() { 25 | super(); 26 | 27 | resizeArrowColor = UIManager.getColor("Frame.resizeArrow"); 28 | resizeArrowLightColor = UIManager.getColor("Frame.resizeArrowLight"); 29 | resizeArrowDarkColor = UIManager.getColor("Frame.resizeArrowDark"); 30 | 31 | var w:Float = 1; //arrowAxisHalfWidth 32 | var r:Float = 4; 33 | var arrowPoints:Array; 34 | 35 | arrowPoints = [{y:-r * 2, x:0}, {y:-r, x:-r}, {y:-r, x:-w}, 36 | {y:r, x:-w}, {y:r, x:-r}, {y:r * 2, x:0}, 37 | {y:r, x:r}, {y:r, x:w}, {y:-r, x:w}, 38 | {y:-r, x:r}]; 39 | var gdi:Graphics2D = new Graphics2D(graphics); 40 | //why 41 | 42 | gdi.drawPolygon(new Pen(resizeArrowColor.changeAlpha(0.4), 4), arrowPoints); 43 | gdi.fillPolygon(new SolidBrush(resizeArrowLightColor), arrowPoints); 44 | gdi.drawPolygon(new Pen(resizeArrowDarkColor, 1), arrowPoints); 45 | } 46 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/CheckBoxMenuItemCheckIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import flash.display.Shape; 9 | import flash.display.DisplayObject; 10 | import flash.filters.BitmapFilterType; 11 | import org.aswing.Component; 12 | import org.aswing.AbstractButton; 13 | import org.aswing.graphics.Graphics2D; 14 | import org.aswing.graphics.Pen; 15 | /** 16 | * @private 17 | */ 18 | class CheckBoxMenuItemCheckIcon extends MenuCheckIcon { 19 | 20 | private var shape:Shape; 21 | 22 | public function new() { 23 | shape = new Shape(); 24 | super(); 25 | } 26 | 27 | override public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 28 | shape.graphics.clear(); 29 | g = new Graphics2D(shape.graphics); 30 | var menu:AbstractButton = cast(c, AbstractButton); 31 | //why 32 | 33 | if (menu.isSelected()) { 34 | g.beginDraw(new Pen(c.getMideground(), 2)); 35 | g.moveTo(x, y + 4); 36 | g.lineTo(x + 3, y + 7); 37 | g.lineTo(x + 8, y + 2); 38 | g.endDraw(); 39 | } 40 | 41 | #if(flash9) 42 | shape.filters = 43 | [new flash.filters.BevelFilter(1, 90, 0x0, 0, 0xFFFFFF, 1, 1, 1, 1, 1, BitmapFilterType.OUTER)]; 44 | #end 45 | } 46 | 47 | override public function getDisplay(c:Component):DisplayObject { 48 | return shape; 49 | } 50 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/FrameCloseIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | 6 | package org.aswing.plaf.basic.icon; 7 | 8 | 9 | import flash.display.CapsStyle; 10 | import flash.display.LineScaleMode; 11 | 12 | import org.aswing.StyleResult; 13 | import org.aswing.ASColor; 14 | import org.aswing.graphics.Graphics2D; 15 | import org.aswing.graphics.Pen; 16 | /** 17 | * The icon for frame close. 18 | * @author paling 19 | * @private 20 | */ 21 | class FrameCloseIcon extends FrameIcon { 22 | 23 | public function new() { 24 | super(); 25 | } 26 | 27 | override public function updateIconImp(c:StyleResult, g:Graphics2D, x:Int, y:Int):Void { 28 | var gap:Int = 5; 29 | var w:Int = width - 1 - gap * 2; 30 | var h:Int = height - 1 - gap * 2; 31 | var x1:Int = x + gap; 32 | var y1:Int = y + gap; 33 | var cl:ASColor = c.bdark; 34 | //why 35 | 36 | var lightPane:Pen = new Pen(cl, 2, true, LineScaleMode.NORMAL, CapsStyle.ROUND); 37 | g.drawLine(lightPane, x1, y1, x1 + w, y1 + h); 38 | g.drawLine(lightPane, x1 + w, y1, x1, y1 + h); 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/FrameIconifiedIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import org.aswing.StyleResult; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.SolidBrush; 11 | /** 12 | * The icon for frame iconified. 13 | * @author paling 14 | * @private 15 | */ 16 | class FrameIconifiedIcon extends FrameIcon { 17 | 18 | public function new() { 19 | super(); 20 | } 21 | 22 | override public function updateIconImp(c:StyleResult, g:Graphics2D, x:Int, y:Int):Void { 23 | var w:Float = width - 8 - 1; 24 | var h:Float = 2; 25 | y = Math.round(y + Math.floor((height - 2) * 3 / 4 - 2)); 26 | x = x + 4; 27 | g.fillRectangle(new SolidBrush(c.bdark), x, y, w, h); 28 | } 29 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/FrameMaximizeIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import org.aswing.StyleResult; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.SolidBrush; 11 | /** 12 | * The icon for frame maximize. 13 | * @author paling 14 | * @private 15 | */ 16 | class FrameMaximizeIcon extends FrameIcon { 17 | 18 | public function new() { 19 | super(); 20 | } 21 | 22 | override public function updateIconImp(c:StyleResult, g:Graphics2D, x:Int, y:Int):Void { 23 | var gap:Int = 4; 24 | x = x + gap; 25 | y = y + gap; 26 | var w:Int = width - 1 - gap * 2; 27 | var h:Int = height - 1 - gap * 2 - 2; 28 | g.fillRectangle(new SolidBrush(c.bdark), x, y, w, 1); 29 | var darkBrush:SolidBrush = new SolidBrush(c.bdark); 30 | g.fillRectangle(darkBrush, x, y + 1, w, 1); 31 | g.fillRectangleRingWithThickness(darkBrush, x, y + 2, w, h, 1); 32 | } 33 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/FrameNormalIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import org.aswing.StyleResult; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.graphics.SolidBrush; 11 | /** 12 | * The icon for frame normal. 13 | * @author paling 14 | * @private 15 | */ 16 | class FrameNormalIcon extends FrameIcon { 17 | 18 | public function new() { 19 | super(); 20 | } 21 | 22 | override public function updateIconImp(c:StyleResult, g:Graphics2D, x:Int, y:Int):Void { 23 | var gap:Int = 4; 24 | var w:Int = 5; 25 | var h:Int = 4; 26 | var x1:Int = x + gap; 27 | var y2:Int = y + gap; 28 | var x2:Int = x1 + 3; 29 | var y1:Int = y2 + 3; 30 | var lightBrush:SolidBrush = new SolidBrush(c.bdark); 31 | var darkBrush:SolidBrush = new SolidBrush(c.bdark); 32 | g.fillRectangle(lightBrush, x2, y2, w, 1); 33 | g.fillRectangle(darkBrush, x2, y2 + 1, w, 1); 34 | g.fillRectangle(darkBrush, x2 + w - 1, y2 + 2, 1, h - 1); 35 | g.fillRectangle(darkBrush, x2 + w - 2, y2 + h, 1, 1); 36 | 37 | g.fillRectangle(lightBrush, x1, y1, w, 1); 38 | g.fillRectangleRingWithThickness(darkBrush, x1, y1 + 1, w, h, 1); 39 | } 40 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/MenuArrowIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import org.aswing.ASColor; 9 | import org.aswing.Component; 10 | import org.aswing.graphics.Graphics2D; 11 | import org.aswing.plaf.UIResource; 12 | 13 | /** 14 | * @private 15 | */ 16 | class MenuArrowIcon extends SolidArrowIcon implements UIResource { 17 | 18 | public function new() { 19 | super(0, 8, ASColor.BLACK); 20 | } 21 | 22 | override public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 23 | super.updateIcon(c, g, x, y); 24 | paintIconWithColor(c.getMideground()); 25 | } 26 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/MenuCheckIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.Icon; 10 | import org.aswing.Component; 11 | import flash.display.DisplayObject; 12 | import org.aswing.plaf.UIResource; 13 | 14 | /** 15 | * @private 16 | */ 17 | class MenuCheckIcon implements Icon implements UIResource { 18 | 19 | public function new() { 20 | } 21 | 22 | public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 23 | } 24 | 25 | public function getIconHeight(c:Component):Int { 26 | return 8; 27 | } 28 | 29 | public function getIconWidth(c:Component):Int { 30 | return 8; 31 | } 32 | 33 | public function getDisplay(c:Component):DisplayObject { 34 | return null; 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/MenuItemArrowIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | /** 9 | * @private 10 | */ 11 | class MenuItemArrowIcon extends MenuCheckIcon { 12 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/MenuItemCheckIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | /** 8 | * @private 9 | */ 10 | class MenuItemCheckIcon extends MenuCheckIcon { 11 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/icon/RadioButtonMenuItemCheckIcon.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.icon; 6 | 7 | 8 | import flash.display.Shape; 9 | import flash.display.DisplayObject; 10 | import flash.filters.BitmapFilterType; 11 | import org.aswing.Component; 12 | import org.aswing.AbstractButton; 13 | import org.aswing.graphics.Graphics2D; 14 | import org.aswing.graphics.SolidBrush; 15 | /** 16 | * @private 17 | */ 18 | class RadioButtonMenuItemCheckIcon extends MenuCheckIcon { 19 | 20 | private var shape:Shape; 21 | 22 | public function new() { 23 | shape = new Shape(); 24 | super(); 25 | } 26 | 27 | override public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 28 | shape.graphics.clear(); 29 | g = new Graphics2D(shape.graphics); 30 | var menu:AbstractButton = cast(c, AbstractButton); 31 | if (menu.isSelected()) { 32 | g.fillCircle(new SolidBrush(c.getMideground()), x + 4, y + 5, 3); 33 | } 34 | #if(flash9) 35 | shape.filters = 36 | [new flash.filters.BevelFilter(1, 80, 0x0, 0, 0xFFFFFF, 1, 1, 1, 1, 1, BitmapFilterType.OUTER)]; 37 | #end 38 | } 39 | 40 | override public function getDisplay(c:Component):DisplayObject { 41 | return shape; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/splitpane/DividerIcon.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.splitpane; 2 | 3 | import flash.display.DisplayObject; 4 | 5 | import org.aswing.Component; 6 | import org.aswing.Icon; 7 | import org.aswing.JSplitPane; 8 | import org.aswing.graphics.Graphics2D; 9 | import org.aswing.graphics.Pen; 10 | /** 11 | * @private 12 | */ 13 | class DividerIcon implements Icon { 14 | public function new() { 15 | } 16 | 17 | public function updateIcon(com:Component, g:Graphics2D, x:Int, y:Int):Void { 18 | var w:Float = com.getWidth(); 19 | var h:Float = com.getHeight(); 20 | var ch:Float = h / 2; 21 | var cw:Float = w / 2; 22 | var divider:Divider = cast(com, Divider); 23 | //why 24 | 25 | var p:Pen = new Pen(divider.getOwner().getForeground(), 0); 26 | if (divider.getOwner().getOrientation() == JSplitPane.VERTICAL_SPLIT) { 27 | var hl:Float = Math.min(5, w - 1); 28 | g.drawLine(p, cw - hl, ch, cw + hl, ch); 29 | if (ch + 2 < h) { 30 | g.drawLine(p, cw - hl, ch + 2, cw + hl, ch + 2); 31 | } 32 | if (ch - 2 > 0) { 33 | g.drawLine(p, cw - hl, ch - 2, cw + hl, ch - 2); 34 | } 35 | } else { 36 | var h2:Float = Math.min(5, h - 1); 37 | g.drawLine(p, cw, ch - h2, cw, ch + h2); 38 | if (cw + 2 < h) { 39 | g.drawLine(p, cw + 2, ch - h2, cw + 2, ch + h2); 40 | } 41 | if (cw - 2 > 0) { 42 | g.drawLine(p, cw - 2, ch - h2, cw - 2, ch + h2); 43 | } 44 | } 45 | 46 | } 47 | 48 | public function getIconHeight(c:Component):Int { 49 | return 0; 50 | } 51 | 52 | public function getIconWidth(c:Component):Int { 53 | return 0; 54 | } 55 | 56 | public function getDisplay(c:Component):DisplayObject { 57 | return null; 58 | } 59 | 60 | 61 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/tabbedpane/ClosableTab.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.plaf.basic.tabbedpane; 2 | 3 | 4 | import org.aswing.Component; 5 | 6 | /** 7 | * The closable tab has a close button. 8 | * @author paling 9 | */ 10 | interface ClosableTab extends Tab { 11 | 12 | function getCloseButton():Component; 13 | 14 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/tabbedpane/CloseIcon.hx: -------------------------------------------------------------------------------- 1 | /** 2 | 3 | * Close Icon for tab. 4 | 5 | */ 6 | package org.aswing.plaf.basic.tabbedpane; 7 | import flash.display.DisplayObject; 8 | import flash.display.Shape; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.plaf.UIResource; 11 | import org.aswing.Component; 12 | import org.aswing.Icon; 13 | import org.aswing.ASColor; 14 | import org.aswing.graphics.Pen; 15 | 16 | class CloseIcon implements Icon implements UIResource { 17 | 18 | var width:Int; 19 | var height:Int; 20 | var shape:Shape; 21 | var color:ASColor; 22 | 23 | public function new() { 24 | width = 12; 25 | height = width; 26 | shape = new Shape(); 27 | } 28 | 29 | public function getColor():ASColor { 30 | return color; 31 | } 32 | 33 | public function updateIcon(c:Component, g:Graphics2D, x:Int, y:Int):Void { 34 | if (color == null) { 35 | color = c.getUI().getColor("ClosableTabbedPane.darkShadow"); 36 | } 37 | shape.graphics.clear(); 38 | if (!c.isEnabled()) { 39 | return; 40 | //do not paint X when not enabled 41 | } 42 | var w:Float = width / 2; 43 | g.drawLine(new Pen(getColor(), w / 3), x + (width - w) / 2, y + (width - w) / 2, x + (width + w) / 2, y + (width + w) / 2); 44 | g.drawLine(new Pen(getColor(), w / 3), x + (width - w) / 2, y + (width + w) / 2, x + (width + w) / 2, y + (width - w) / 2); 45 | } 46 | 47 | public function getIconHeight(c:Component):Int { 48 | return width; 49 | } 50 | 51 | public function getIconWidth(c:Component):Int { 52 | return height; 53 | } 54 | 55 | public function getDisplay(c:Component):DisplayObject { 56 | return shape; 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /org/aswing/plaf/basic/tree/BasicExpandControl.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.tree; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.plaf.UIResource; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.geom.IntPoint; 12 | import org.aswing.graphics.Graphics2D; 13 | import org.aswing.graphics.SolidBrush; 14 | import org.aswing.tree.TreePath; 15 | 16 | /** 17 | * @private 18 | */ 19 | class BasicExpandControl implements ExpandControl implements UIResource { 20 | 21 | public function paintExpandControl(c:Component, g:Graphics2D, bounds:IntRectangle, 22 | totalChildIndent:Int, path:TreePath, row:Int, expanded:Bool, leaf:Bool):Void { 23 | if (leaf) { 24 | return; 25 | } 26 | var w:Int = totalChildIndent; 27 | var cx:Float = bounds.x - w / 2; 28 | var cy:Float = bounds.y + bounds.height / 2; 29 | var r:Float = 4; 30 | var trig:Array; 31 | if (expanded != true) { 32 | cx -= 2; 33 | trig = [new IntPoint(Std.int(cx), Std.int(cy - r)), new IntPoint(Std.int(cx), Std.int(cy + r)), new IntPoint(Std.int(cx + r), Std.int(cy))]; 34 | } else { 35 | cy -= 2; 36 | trig = [new IntPoint(Std.int(cx - r), Std.int(cy)), new IntPoint(Std.int(cx + r), Std.int(cy)), new IntPoint(Std.int(cx), Std.int(cy + r))]; 37 | } 38 | g.fillPolygon(new SolidBrush(ASColor.BLACK), trig); 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /org/aswing/plaf/basic/tree/ExpandControl.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.plaf.basic.tree; 6 | 7 | 8 | import org.aswing.Component; 9 | import org.aswing.graphics.Graphics2D; 10 | import org.aswing.geom.IntRectangle; 11 | import org.aswing.tree.TreePath; 12 | 13 | /** 14 | * The tree expand control graphics 15 | * @private 16 | */ 17 | interface ExpandControl { 18 | 19 | function paintExpandControl(c:Component, g:Graphics2D, bounds:IntRectangle, 20 | totalChildIndent:Int, path:TreePath, row:Int, expanded:Bool, leaf:Bool):Void; 21 | } -------------------------------------------------------------------------------- /org/aswing/resizer/ResizeStrategy.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.resizer; 6 | 7 | 8 | import org.aswing.geom.IntDimension; 9 | import org.aswing.geom.IntRectangle; 10 | 11 | /** 12 | * The strategy for DefaultResizer to count the new bounds of component would be resized to. 13 | * @author paling 14 | */ 15 | interface ResizeStrategy { 16 | 17 | /** 18 | * Count and return the new bounds what the component would be resized to. 19 | * @param origBounds the original bounds before resized 20 | * @param minSize can be null, means (0, 1) 21 | * @param maxSize can be null, means (very big) 22 | * @param movedX 23 | * @param movedY 24 | */ 25 | function getBounds(origBounds:IntRectangle, minSize:IntDimension, maxSize:IntDimension, movedX:Int, movedY:Int):IntRectangle; 26 | } -------------------------------------------------------------------------------- /org/aswing/resizer/Resizer.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.resizer; 6 | 7 | 8 | import org.aswing.Component; 9 | 10 | /** 11 | * Component Resizer interface. 12 | * @author paling 13 | */ 14 | interface Resizer { 15 | 16 | /** 17 | * Sets the owner of this resizer. 18 | * If the owner is changed, the last owner will be off-dressed the resizer, the new 19 | * owner will be on-dressed. 20 | * Use null to off-dress the current owner. 21 | * @param c the new owner or null. 22 | */ 23 | function setOwner(c:Component):Void; 24 | 25 | /** 26 | *

Indicate whether need resize component directly when drag the resizer arrow. 27 | *

if set to false, there will be a rectange to represent then size what will be resized to. 28 | *

if set to true, the component will be resize directly when drag, but this is need more cpu counting. 29 | *

Default is false. 30 | * @see org.aswing.JFrame 31 | */ 32 | function setResizeDirectly(r:Bool):Void; 33 | 34 | /** 35 | * Returns whether need resize component directly when drag the resizer arrow. 36 | * @see #setResizeDirectly 37 | */ 38 | function isResizeDirectly():Bool; 39 | 40 | /** 41 | * Returns whether this resizer is enabled. 42 | */ 43 | function isEnabled():Bool; 44 | 45 | /** 46 | * Sets the resizer to enabled or not. 47 | */ 48 | function setEnabled(b:Bool):Void; 49 | } -------------------------------------------------------------------------------- /org/aswing/table/AbstractTableCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.error.ImpMissError; 9 | import org.aswing.table.TableCell; 10 | import org.aswing.JTable; 11 | import org.aswing.Component; 12 | 13 | /** 14 | * Abstract table cell. 15 | * @author senkay 16 | */ 17 | class AbstractTableCell implements TableCell { 18 | 19 | private var value:Dynamic; 20 | 21 | public function new() { 22 | } 23 | 24 | public function setTableCellStatus(table:JTable, isSelected:Bool, row:Int, column:Int):Void { 25 | var com:Component = getCellComponent(); 26 | if (isSelected) { 27 | com.setBackground(table.getSelectionBackground()); 28 | com.setForeground(table.getSelectionForeground()); 29 | } else { 30 | com.setBackground(table.getBackground()); 31 | com.setForeground(table.getForeground()); 32 | } 33 | com.setFont(table.getFont()); 34 | } 35 | 36 | public function setCellValue(value:Dynamic):Void { 37 | this.value = value; 38 | } 39 | 40 | public function getCellValue():Dynamic { 41 | return value; 42 | } 43 | 44 | /** 45 | * Subclass should override this method 46 | */ 47 | 48 | public function getCellComponent():Component { 49 | throw new ImpMissError(); 50 | return null; 51 | } 52 | } -------------------------------------------------------------------------------- /org/aswing/table/DefaultTextHeaderCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.JLabel; 9 | import org.aswing.JTable; 10 | import org.aswing.UIManager; 11 | import flash.filters.BitmapFilter; 12 | import flash.filters.DropShadowFilter; 13 | /** 14 | * Default table header cell to render text 15 | * @author paling 16 | */ 17 | class DefaultTextHeaderCell extends DefaultTextCell { 18 | 19 | public function new() { 20 | super(); 21 | super.setHorizontalAlignment(JLabel.CENTER); 22 | super.setBorder(UIManager.getBorder("TableHeader.cellBorder")); 23 | super.setBackgroundDecorator(UIManager.getGroundDecorator("TableHeader.cellBackground")); 24 | super.setOpaque(false); 25 | 26 | var f:Array = new Array(); 27 | f.push(new DropShadowFilter(1, 45, 0xFFFFFF, 0.2, 1, 1, 1, 1)); 28 | super.setTextFilters(f); 29 | 30 | } 31 | 32 | override public function setTableCellStatus(table:JTable, isSelected:Bool, row:Int, column:Int):Void { 33 | var header:JTableHeader = table.getTableHeader(); 34 | if (header != null) { 35 | super.setBackground(header.getBackground()); 36 | super.setForeground(header.getForeground()); 37 | super.setFont(header.getFont()); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /org/aswing/table/GeneralTableCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class GeneralTableCellFactory implements TableCellFactory { 12 | 13 | private var cellClass:Class; 14 | 15 | /** 16 | * Creates a TableCellFactory with specified cell class. 17 | * @param cellClass the cell class 18 | */ 19 | 20 | public function new(cellClass:Class) { 21 | this.cellClass = cellClass; 22 | } 23 | 24 | /** 25 | * Creates and returns a new table cell. 26 | * @param isHeader is it a header cell 27 | * @return the table cell 28 | */ 29 | 30 | public function createNewCell(isHeader:Bool):TableCell { 31 | return cast(Type.createInstance(cellClass, []), TableCell); 32 | } 33 | 34 | public function toString():String { 35 | return "GeneralTableCellFactory[cellClass:" + cellClass + "]"; 36 | } 37 | } -------------------------------------------------------------------------------- /org/aswing/table/GeneralTableCellFactoryUIResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.plaf.UIResource; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | class GeneralTableCellFactoryUIResource extends GeneralTableCellFactory implements UIResource { 14 | public function new(cellClass:Class) { 15 | super(cellClass); 16 | } 17 | } -------------------------------------------------------------------------------- /org/aswing/table/PropertyTranslator.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.table; 2 | 3 | 4 | /** 5 | * Property translator, it return the value of a specified property name. 6 | * Some property need translate, not directly return the real value, For example a int 7 | * value for sex, 0 means female, 1 means male, then your can implement your property translator 8 | * like this: 9 | *

10 |  * public function translate(info:Object, key:String):*{
11 |  * 		var sex:int = info[key];
12 |  * 		if(sex == 0){
13 |  * 			return "female";
14 |  * 		}else if(sex == 1){
15 |  * 			return "male";
16 |  * 		}else{
17 |  * 			return "no-sex";
18 |  * 		}
19 |  * }
20 |  * 
21 | * @author paling 22 | */ 23 | interface PropertyTranslator { 24 | 25 | function translate(info:Dynamic, key:String):Dynamic; 26 | 27 | } -------------------------------------------------------------------------------- /org/aswing/table/Resizable2.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | interface Resizable2 { 12 | 13 | function getElementCount():Int; 14 | 15 | function getLowerBoundAt(i:Int):Int; 16 | 17 | function getUpperBoundAt(i:Int):Int; 18 | 19 | function setSizeAt(newSize:Int, i:Int):Void; 20 | 21 | } -------------------------------------------------------------------------------- /org/aswing/table/Resizable2Imp1.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class Resizable2Imp1 implements Resizable2 { 12 | 13 | private var r:Resizable3; 14 | private var flag:Bool; 15 | 16 | public function new(r:Resizable3, flag:Bool) { 17 | this.r = r; 18 | this.flag = flag; 19 | } 20 | 21 | public function getElementCount():Int { 22 | return r.getElementCount(); 23 | } 24 | 25 | public function getLowerBoundAt(i:Int):Int { 26 | if (flag) { 27 | return r.getLowerBoundAt(i); 28 | } else { 29 | return r.getMidPointAt(i); 30 | } 31 | } 32 | 33 | public function getUpperBoundAt(i:Int):Int { 34 | if (flag) { 35 | return r.getMidPointAt(i); 36 | } else { 37 | return r.getUpperBoundAt(i); 38 | } 39 | } 40 | 41 | public function setSizeAt(newSize:Int, i:Int):Void { 42 | r.setSizeAt(newSize, i); 43 | } 44 | } -------------------------------------------------------------------------------- /org/aswing/table/Resizable3.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | interface Resizable3 extends Resizable2 { 12 | 13 | function getMidPointAt(i:Int):Int; 14 | 15 | } -------------------------------------------------------------------------------- /org/aswing/table/Resizable3Imp1.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class Resizable3Imp1 implements Resizable3 { 12 | 13 | private var cm:TableColumnModel; 14 | private var inverse:Bool; 15 | 16 | public function new(cm:TableColumnModel, inverse:Bool) { 17 | this.cm = cm; 18 | this.inverse = inverse; 19 | } 20 | 21 | public function getElementCount():Int { 22 | return cm.getColumnCount(); 23 | } 24 | 25 | public function getLowerBoundAt(i:Int):Int { 26 | return cm.getColumn(i).getMinWidth(); 27 | } 28 | 29 | public function getUpperBoundAt(i:Int):Int { 30 | return cm.getColumn(i).getMaxWidth(); 31 | } 32 | 33 | public function getMidPointAt(i:Int):Int { 34 | if (inverse != true) { 35 | return cm.getColumn(i).getPreferredWidth(); 36 | } else { 37 | return cm.getColumn(i).getWidth(); 38 | } 39 | } 40 | 41 | public function setSizeAt(s:Int, i:Int):Void { 42 | if (inverse != true) { 43 | cm.getColumn(i).setWidth(s); 44 | } else { 45 | cm.getColumn(i).setPreferredWidth(s); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /org/aswing/table/Resizable3Imp2.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class Resizable3Imp2 implements Resizable3 { 12 | 13 | private var cm:TableColumnModel; 14 | private var start:Int; 15 | private var end:Int; 16 | 17 | public function new(cm:TableColumnModel, start:Int, end:Int) { 18 | this.cm = cm; 19 | this.start = start; 20 | this.end = end; 21 | } 22 | 23 | public function getElementCount():Int { 24 | return end - start; 25 | } 26 | 27 | public function getLowerBoundAt(i:Int):Int { 28 | return cm.getColumn(i + start).getMinWidth(); 29 | } 30 | 31 | public function getUpperBoundAt(i:Int):Int { 32 | return cm.getColumn(i + start).getMaxWidth(); 33 | } 34 | 35 | public function getMidPointAt(i:Int):Int { 36 | return cm.getColumn(i + start).getWidth(); 37 | } 38 | 39 | public function setSizeAt(s:Int, i:Int):Void { 40 | cm.getColumn(i + start).setWidth(s); 41 | } 42 | } -------------------------------------------------------------------------------- /org/aswing/table/SelectablePoorTextCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * Texts in this cell is selectable. 10 | */ 11 | class SelectablePoorTextCell extends PoorTextCell { 12 | 13 | public function new() { 14 | super(); 15 | textField.mouseEnabled = true; 16 | textField.selectable = true; 17 | } 18 | 19 | } -------------------------------------------------------------------------------- /org/aswing/table/TableCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.Cell; 9 | import org.aswing.JTable; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | interface TableCell extends Cell { 15 | 16 | /** 17 | * Sets the table cell status, include the owner-JTable isSelected, row position, column position. 18 | * @param the cell's owner, a JTable 19 | * @param isSelected true to set the cell selected, false to set not selected. 20 | * @param row the row position 21 | * @param column the column position 22 | */ 23 | function setTableCellStatus(table:JTable, isSelected:Bool, row:Int, column:Int):Void; 24 | } -------------------------------------------------------------------------------- /org/aswing/table/TableCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.CellEditor; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | interface TableCellEditor extends CellEditor { 14 | 15 | } -------------------------------------------------------------------------------- /org/aswing/table/TableCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | /** 9 | * TableCellFactory for create cells for table 10 | * @author paling 11 | */ 12 | interface TableCellFactory { 13 | 14 | /** 15 | * Creates a new table cell. 16 | * @param isHeader is it a header cell 17 | * @return the table cell 18 | */ 19 | function createNewCell(isHeader:Bool):TableCell; 20 | } -------------------------------------------------------------------------------- /org/aswing/table/TableColumnModelEvent.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.event.ModelEvent; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | class TableColumnModelEvent extends ModelEvent { 14 | 15 | /** The index of the column from where it was moved or removed */ 16 | private var fromIndex:Int; 17 | 18 | /** The index of the column to where it was moved or added from */ 19 | private var toIndex:Int; 20 | 21 | /** 22 | * Constructs a TableColumnModelEvent object. 23 | * 24 | * @param source the TableColumnModel that originated the event 25 | * (typically this) 26 | * @param from an int specifying the first row in a range of affected rows 27 | * @param to an int specifying the last row in a range of affected rows 28 | */ 29 | 30 | public function new(source:TableColumnModel, from:Int, _to:Int) { 31 | super(source); 32 | fromIndex = from; 33 | toIndex = _to; 34 | } 35 | 36 | /** Returns the fromIndex. Valid for removed or moved events */ 37 | 38 | public function getFromIndex():Int { return fromIndex; } 39 | 40 | /** Returns the toIndex. Valid for add and moved events */ 41 | 42 | public function getToIndex():Int { return toIndex; } 43 | } -------------------------------------------------------------------------------- /org/aswing/table/TableColumnModelListener.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table; 6 | 7 | 8 | import org.aswing.table.TableColumnModel; 9 | import org.aswing.table.TableColumnModelEvent; 10 | 11 | /** 12 | * TableColumnModelListener defines the interface for an object that listens 13 | * to changes in a TableColumnModel. 14 | * 15 | * @author paling 16 | */ 17 | interface TableColumnModelListener { 18 | 19 | /** Tells listeners that a column was added to the model. */ 20 | function columnAdded(e:TableColumnModelEvent):Void; 21 | 22 | /** Tells listeners that a column was removed from the model. */ 23 | function columnRemoved(e:TableColumnModelEvent):Void; 24 | 25 | /** Tells listeners that a column was repositioned. */ 26 | function columnMoved(e:TableColumnModelEvent):Void; 27 | 28 | /** Tells listeners that a column was moved due to a margin change. */ 29 | function columnMarginChanged(source:TableColumnModel):Void; 30 | 31 | /** 32 | * Tells listeners that the selection model of the 33 | * TableColumnModel changed. 34 | */ 35 | function columnSelectionChanged(source:TableColumnModel, firstIndex:Int, lastIndex:Int, programmatic:Bool):Void; 36 | } -------------------------------------------------------------------------------- /org/aswing/table/sorter/Directive.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table.sorter; 6 | 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class Directive { 12 | public var column:Int; 13 | public var direction:Float; 14 | 15 | public function new(column:Int, direction:Float) { 16 | this.column = column; 17 | this.direction = direction; 18 | } 19 | } -------------------------------------------------------------------------------- /org/aswing/table/sorter/Row.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table.sorter; 6 | 7 | 8 | import org.aswing.table.TableModel; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | class Row { 14 | 15 | public var modelIndex:Int; 16 | public var tableSorter:TableSorter; 17 | 18 | public function new(tableSorter:TableSorter, index:Int) { 19 | this.tableSorter = tableSorter; 20 | this.modelIndex = index; 21 | } 22 | 23 | public function compareTo(o:Dynamic):Int { 24 | var row1:Int = modelIndex; 25 | var row2:Int = (cast(o, Row)).modelIndex; 26 | var sortingColumns:Array = tableSorter.getSortingColumns(); 27 | var tableModel:TableModel = tableSorter.getTableModel(); 28 | for (i in 0...sortingColumns.length) { 29 | var directive:Directive = cast(sortingColumns[i], Directive); 30 | var column:Int = directive.column; 31 | var o1:Dynamic = tableModel.getValueAt(row1, column); 32 | var o2:Dynamic = tableModel.getValueAt(row2, column); 33 | 34 | var comparison:Int = 0; 35 | // Define null less than everything, except null. 36 | if (o1 == null && o2 == null) { 37 | comparison = 0; 38 | } else if (o1 == null) { 39 | comparison = -1; 40 | } else if (o2 == null) { 41 | comparison = 1; 42 | } else { 43 | var comparator:Dynamic -> Dynamic -> Int = tableSorter.getComparator(column); 44 | comparison = comparator(o1, o2); 45 | } 46 | if (comparison != 0) { 47 | return directive.direction == TableSorter.DESCENDING ? -comparison : comparison; 48 | } 49 | } 50 | return 0; 51 | } 52 | 53 | public function getModelIndex():Int { 54 | return modelIndex; 55 | } 56 | } -------------------------------------------------------------------------------- /org/aswing/table/sorter/SortableHeaderRenderer.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table.sorter; 6 | 7 | 8 | import org.aswing.table.TableCell; 9 | import org.aswing.table.TableCellFactory; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | class SortableHeaderRenderer implements TableCellFactory { 15 | 16 | private var tableSorter:TableSorter; 17 | private var originalRenderer:TableCellFactory; 18 | 19 | public function new(originalRenderer:TableCellFactory, tableSorter:TableSorter) { 20 | this.originalRenderer = originalRenderer; 21 | this.tableSorter = tableSorter; 22 | } 23 | 24 | public function createNewCell(isHeader:Bool):TableCell { 25 | return new SortableTextHeaderCell(tableSorter); 26 | } 27 | 28 | public function getTableCellFactory():TableCellFactory { 29 | return null; 30 | } 31 | } -------------------------------------------------------------------------------- /org/aswing/table/sorter/SortableTextHeaderCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.table.sorter; 6 | 7 | 8 | import org.aswing.JTable; 9 | import org.aswing.table.DefaultTextHeaderCell; 10 | import org.aswing.UIManager; 11 | import org.aswing.JLabel; 12 | 13 | /** 14 | * @author paling 15 | */ 16 | class SortableTextHeaderCell extends DefaultTextHeaderCell { 17 | 18 | private var tableSorter:TableSorter; 19 | 20 | public function new(tableSorter:TableSorter) { 21 | super(); 22 | setBorder(UIManager.getBorder("TableHeader.sortableCellBorder")); 23 | setBackgroundDecorator(UIManager.getGroundDecorator("TableHeader.sortableCellBackground")); 24 | this.tableSorter = tableSorter; 25 | setHorizontalTextPosition(JLabel.LEFT); 26 | setIconTextGap(6); 27 | //make it user parent property 28 | setMideground(null); 29 | setStyleTune(null); 30 | } 31 | 32 | override public function setTableCellStatus(table:JTable, isSelected:Bool, row:Int, column:Int):Void { 33 | super.setTableCellStatus(table, isSelected, row, column); 34 | var modelColumn:Int = table.convertColumnIndexToModel(column); 35 | setIcon(tableSorter.getHeaderRendererIcon(modelColumn, getFont().getSize() - 2)); 36 | } 37 | } -------------------------------------------------------------------------------- /org/aswing/tree/EmptySelectionModel.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.tree; 2 | 3 | /* 4 | Copyright aswing.org, see the LICENCE.txt. 5 | */ 6 | 7 | import org.aswing.tree.DefaultTreeSelectionModel; 8 | 9 | /** 10 | * EmptySelectionModel is a TreeSelectionModel 11 | * that does not allow anything to be selected. 12 | * @author paling 13 | */ 14 | class EmptySelectionModel extends DefaultTreeSelectionModel { 15 | 16 | public function new() { 17 | super(); 18 | } 19 | 20 | /** Unique shared instance. */ 21 | private static var _sharedInstance:EmptySelectionModel; 22 | 23 | /** Returns a shared instance of an empty selection model. */ 24 | 25 | public static function sharedInstance():EmptySelectionModel { 26 | if (_sharedInstance == null) { 27 | _sharedInstance = new EmptySelectionModel(); 28 | } 29 | return _sharedInstance; 30 | } 31 | 32 | /** A null implementation that selects nothing. */ 33 | 34 | override public function setSelectionPaths(pPaths:Array, programmatic:Bool = true):Void {} 35 | /** A null implementation that adds nothing. */ 36 | 37 | override public function addSelectionPaths(pPaths:Array, programmatic:Bool = true):Void {} 38 | /** A null implementation that removes nothing. */ 39 | 40 | override public function removeSelectionPaths(pPaths:Array, programmatic:Bool = true):Void {} 41 | } -------------------------------------------------------------------------------- /org/aswing/tree/EnumerationInfo.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.tree; 2 | 3 | /* 4 | Copyright aswing.org, see the LICENCE.txt. 5 | */ 6 | import org.aswing.tree.FHTreeStateNode; 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class EnumerationInfo { 12 | 13 | /** Parent thats children are being enumerated. */ 14 | public var parent:FHTreeStateNode; 15 | /** Index of next child. An index of -1 signifies parent should be 16 | * visibled next. */ 17 | public var nextIndex:Float; 18 | /** Number of children in parent. */ 19 | public var childCount:Float; 20 | /** The number of path left to enumerat*/ 21 | public var enumCount:Float; 22 | 23 | public function new():Void { 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /org/aswing/tree/GeneralTreeCellFactory.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.tree.TreeCell; 9 | import org.aswing.tree.TreeCellFactory; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | class GeneralTreeCellFactory implements TreeCellFactory { 15 | 16 | private var cellClass:Class; 17 | 18 | /** 19 | * Creates a GeneralTreeCellFactory with specified cell class. 20 | * @param cellClass the cell class 21 | */ 22 | 23 | public function new(cellClass:Class) { 24 | this.cellClass = cellClass; 25 | } 26 | 27 | /** 28 | * Creates and returns a new tree cell. 29 | * @return the tree cell 30 | */ 31 | 32 | public function createNewCell():TreeCell { 33 | return cast(Type.createInstance(cellClass, []), TreeCell); 34 | } 35 | 36 | public function toString():String { 37 | return "GeneralTreeCellFactory[cellClass:" + cellClass + "]"; 38 | } 39 | } -------------------------------------------------------------------------------- /org/aswing/tree/GeneralTreeCellFactoryUIResource.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.plaf.UIResource; 9 | import org.aswing.tree.GeneralTreeCellFactory; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | class GeneralTreeCellFactoryUIResource extends GeneralTreeCellFactory implements UIResource { 15 | 16 | public function new(cellClass:Class) { 17 | super(cellClass); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /org/aswing/tree/MutableTreeNode.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.tree.TreeNode; 9 | 10 | /** 11 | * Defines the requirements for a tree node object that can change -- 12 | * by adding or removing child nodes, or by changing the contents 13 | * of a user object stored in the node. 14 | * 15 | * @author paling 16 | * @see org.aswing.tree.DefaultMutableTreeNode 17 | * @see org.aswing.JTree 18 | */ 19 | interface MutableTreeNode extends TreeNode { 20 | 21 | /** 22 | * Adds child to the receiver at index. 23 | * child will be messaged with setParent. 24 | */ 25 | function insert(child:MutableTreeNode, index:Int):Void; 26 | 27 | /** 28 | * Removes the child at index from the receiver. 29 | */ 30 | function removeAt(index:Int):Void; 31 | 32 | /** 33 | * Removes node from the receiver. setParent 34 | * will be messaged on node. 35 | */ 36 | function remove(node:MutableTreeNode):Void; 37 | 38 | /** 39 | * Resets the user object of the receiver to object. 40 | */ 41 | function setUserObject(object:TreeNode):Void; 42 | 43 | /** 44 | * Returns the user object. 45 | */ 46 | function getUserObject():TreeNode; 47 | 48 | /** 49 | * Removes the receiver from its parent. 50 | */ 51 | function removeFromParent():Void; 52 | 53 | /** 54 | * Sets the parent of the receiver to newParent. 55 | */ 56 | function setParent(newParent:MutableTreeNode):Void; 57 | } -------------------------------------------------------------------------------- /org/aswing/tree/NodeDimensions.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.geom.IntRectangle; 9 | 10 | /** 11 | * Used by AbstractLayoutCache to determine the size 12 | * and x origin of a particular node. 13 | * @author paling 14 | */ 15 | interface NodeDimensions { 16 | /** 17 | * Returns, by reference in bounds, the size and x origin to 18 | * place value at. The calling method is responsible for determining 19 | * the Y location. If bounds is null, a newly created 20 | * IntRectangle should be returned, 21 | * otherwise the value should be placed in bounds and returned. 22 | * 23 | * @param value the value to be represented 24 | * @param row row being queried 25 | * @param depth the depth of the row 26 | * @param expanded true if row is expanded, false otherwise 27 | * @param bounds a IntRectangle containing the size needed 28 | * to represent value 29 | * @return a IntRectangle containing the node dimensions, 30 | * or null if node has no dimension 31 | */ 32 | function countNodeDimensions(value:Dynamic, row:Int, depth:Int, expanded:Bool, bounds:IntRectangle):IntRectangle; 33 | } -------------------------------------------------------------------------------- /org/aswing/tree/PathPlaceHolder.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.tree; 2 | 3 | /* 4 | Copyright aswing.org, see the LICENCE.txt. 5 | */ 6 | import org.aswing.tree.TreePath; 7 | 8 | /** 9 | * @author paling 10 | */ 11 | class PathPlaceHolder { 12 | public var isNew:Bool; 13 | public var path:TreePath; 14 | 15 | public function new(path:TreePath, isNew:Bool) { 16 | this.path = path; 17 | this.isNew = isNew; 18 | } 19 | } -------------------------------------------------------------------------------- /org/aswing/tree/RowMapper.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | /** 9 | * Defines the requirements for an object that translates paths in 10 | * the tree into display rows. 11 | * @author paling 12 | */ 13 | interface RowMapper { 14 | /** 15 | * Returns the rows that the TreePath instances in path 16 | * are being displayed at. The receiver should return an array of 17 | * the same length as that passed in, and if one of the TreePaths 18 | * in path is not valid its entry in the array should 19 | * be set to -1. 20 | */ 21 | function getRowsForPaths(path:Array):Array; 22 | } -------------------------------------------------------------------------------- /org/aswing/tree/SearchInfo.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.tree; 2 | 3 | /* 4 | Copyright aswing.org, see the LICENCE.txt. 5 | */ 6 | import org.aswing.tree.AbstractLayoutCache; 7 | import org.aswing.tree.FHTreeStateNode; 8 | import org.aswing.tree.TreePath; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | class SearchInfo { 14 | public var node:FHTreeStateNode; 15 | public var isNodeParentNode:Bool; 16 | public var childIndex:Float; 17 | private var layoutCatch:AbstractLayoutCache; 18 | 19 | public function new(layoutCatch:AbstractLayoutCache) { 20 | this.layoutCatch = layoutCatch; 21 | } 22 | 23 | public function getPath():TreePath { 24 | if (node == null) { 25 | return null; 26 | } 27 | 28 | if (isNodeParentNode) { 29 | return node.getTreePath().pathByAddingChild(layoutCatch.getModel().getChild(node.getUserObject(), 30 | Std.int(childIndex))); 31 | } 32 | return node.getTreePath(); 33 | } 34 | } -------------------------------------------------------------------------------- /org/aswing/tree/TreeCell.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.Cell; 9 | import org.aswing.JTree; 10 | 11 | /** 12 | * @author paling 13 | */ 14 | interface TreeCell extends Cell { 15 | /** 16 | * Sets the table cell status, include the owner-JTable isSelected, row position, column position. 17 | * @param the cell's owner, a JTable 18 | * @param seleted true indicated the cell selected, false not selected. 19 | * @param expanded true the node is currently expanded, false not. 20 | * @param leaf true the node represets a leaf, false not. 21 | * @param row the row position 22 | */ 23 | function setTreeCellStatus(tree:JTree, selected:Bool, expanded:Bool, leaf:Bool, row:Int):Void; 24 | } -------------------------------------------------------------------------------- /org/aswing/tree/TreeCellEditor.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | import org.aswing.CellEditor; 9 | 10 | /** 11 | * @author paling 12 | */ 13 | interface TreeCellEditor extends CellEditor { 14 | 15 | } -------------------------------------------------------------------------------- /org/aswing/tree/TreeCellFactory.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.tree; 2 | 3 | /* 4 | Copyright aswing.org, see the LICENCE.txt. 5 | */ 6 | import org.aswing.tree.TreeCell; 7 | 8 | /** 9 | * TreeCellFactory for create cells for tree 10 | * @author paling 11 | */ 12 | interface TreeCellFactory { 13 | /** 14 | * Creates a new tree cell. 15 | * @return the tree cell 16 | */ 17 | function createNewCell():TreeCell; 18 | } -------------------------------------------------------------------------------- /org/aswing/tree/TreeNode.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | 5 | package org.aswing.tree; 6 | 7 | 8 | /** 9 | * Defines the requirements for an object that can be used as a 10 | * tree node in a JTree. 11 | * 12 | * @author paling 13 | * @see org.aswing.tree.MutableTreeNode 14 | * @see org.aswing.tree.DefaultMutableTreeNode 15 | * @see org.aswing.JTree 16 | */ 17 | interface TreeNode { 18 | function getAwmlIndex():Int; 19 | /** 20 | * Returns the child TreeNode at index 21 | * childIndex. 22 | */ 23 | function getChildAt(childIndex:Int):TreeNode; 24 | 25 | /** 26 | * Returns the number of children TreeNodes the receiver 27 | * contains. 28 | */ 29 | function getChildCount():Int; 30 | 31 | /** 32 | * Returns the parent TreeNode of the receiver. 33 | */ 34 | function getParent():TreeNode; 35 | 36 | /** 37 | * Returns the index of node in the receivers children. 38 | * If the receiver does not contain node, -1 will be 39 | * returned. 40 | */ 41 | function getIndex(node:TreeNode):Int; 42 | 43 | /** 44 | * Returns true if the receiver allows children. 45 | */ 46 | function getAllowsChildren():Bool; 47 | 48 | /** 49 | * Returns true if the receiver is a leaf. 50 | */ 51 | function isLeaf():Bool; 52 | 53 | /** 54 | * Returns the children of the receiver as an Enumeration. 55 | */ 56 | function children():Array; 57 | } -------------------------------------------------------------------------------- /org/aswing/util/ListNode.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing.util; 5 | 6 | class ListNode { 7 | /** 8 | * the data stored in this node 9 | */ 10 | private var data:Dynamic; 11 | /** 12 | * the node directly behind this node in a list 13 | */ 14 | private var nextNode:ListNode; 15 | /** 16 | * the node directly before this node in a list 17 | */ 18 | private var preNode:ListNode; 19 | 20 | public function new(_data:Dynamic, _preNode:ListNode, _nextNode:ListNode) { 21 | this.data = _data; 22 | this.nextNode = _nextNode; 23 | this.preNode = _preNode; 24 | } 25 | 26 | //setter and getter methiods 27 | 28 | public function setData(_data:Dynamic):Void { 29 | this.data = _data; 30 | } 31 | 32 | public function getData():Dynamic { 33 | return this.data; 34 | } 35 | 36 | public function setPrevNode(_preNode:ListNode):Void { 37 | this.preNode = _preNode; 38 | } 39 | 40 | public function getPrevNode():ListNode { 41 | return this.preNode; 42 | } 43 | 44 | public function setNextNode(_nextNode:ListNode):Void { 45 | this.nextNode = _nextNode; 46 | } 47 | 48 | public function getNextNode():ListNode { 49 | return this.nextNode; 50 | } 51 | 52 | public function toString():String { 53 | return "ListNode[data:" + data + "]"; 54 | } 55 | } -------------------------------------------------------------------------------- /org/aswing/util/ObjectUtils.hx: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright aswing.org, see the LICENCE.txt. 3 | */ 4 | package org.aswing.util; 5 | 6 | 7 | class ObjectUtils { 8 | 9 | /** 10 | * Deep clone object using thiswind@gmail.com 's solution 11 | */ 12 | public static function baseClone(source:Dynamic):Dynamic { 13 | 14 | 15 | return Reflect.copy(source); 16 | } 17 | 18 | /** 19 | * Checks wherever passed-in value is String. 20 | */ 21 | 22 | public static function isString(value:Dynamic):Bool { 23 | return ( Std.is(value, String)); 24 | } 25 | 26 | /** 27 | * Checks wherever passed-in value is Number. 28 | */ 29 | 30 | public static function isNumber(value:Dynamic):Bool { 31 | return ( Std.is(value, Float)); 32 | } 33 | 34 | /** 35 | * Checks wherever passed-in value is Boolean. 36 | */ 37 | 38 | public static function isBoolean(value:Dynamic):Bool { 39 | return ( Std.is(value, Bool)); 40 | } 41 | 42 | /** 43 | * Checks wherever passed-in value is Function. 44 | */ 45 | 46 | public static function isFunction(value:Dynamic):Bool { 47 | return ( Reflect.isFunction(value)); 48 | } 49 | 50 | 51 | } -------------------------------------------------------------------------------- /org/aswing/util/WeakMap.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.util; 2 | 3 | 4 | class WeakMap implements Map.IMap { 5 | public function new():Void { 6 | throw "Not implemented for this platform"; 7 | } 8 | 9 | public function set(key:K, value:V):Void { 10 | } 11 | 12 | public function get(key:K):Null { 13 | return null; 14 | } 15 | 16 | public function exists(key:K):Bool { 17 | return false; 18 | } 19 | 20 | public function remove(key:K):Bool { 21 | return false; 22 | } 23 | 24 | public function keys():Iterator { 25 | return null; 26 | } 27 | 28 | public function iterator():Iterator { 29 | return null; 30 | } 31 | 32 | public function toString():String { 33 | return null; 34 | } 35 | } -------------------------------------------------------------------------------- /org/aswing/util/WeakReference.hx: -------------------------------------------------------------------------------- 1 | package org.aswing.util; 2 | 3 | 4 | /** 5 | * WeakReference, the value will be weak referenced. 6 | * @author paling 7 | */ 8 | class WeakReference { 9 | 10 | private var weakDic:Dynamic; 11 | 12 | public function new() { 13 | 14 | } 15 | 16 | public function set_value(v:Dynamic):Dynamic { 17 | if (v == null) { 18 | weakDic = null; 19 | } else { 20 | weakDic = v; 21 | } 22 | 23 | return v; 24 | } 25 | 26 | public function get_value():Dynamic { 27 | if (weakDic != null) { 28 | 29 | 30 | return weakDic; 31 | 32 | } 33 | return null; 34 | } 35 | 36 | /** 37 | * Clear the value, same to WeakReference.value=null; 38 | */ 39 | 40 | public function clear():Void { 41 | weakDic = null; 42 | } 43 | 44 | public var value (get, set):Dynamic; 45 | } --------------------------------------------------------------------------------