Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 6.91 KB | None | 0 0
  1. package;
  2.  
  3. import qt.core.Application;
  4. import qt.core.Orientation;
  5. import qt.layout.HBoxLayout;
  6. import qt.layout.VBoxLayout;
  7. import qt.styles.StyleFactory;
  8. import qt.widgets.CheckBox;
  9. import qt.widgets.Label;
  10. import qt.widgets.LineEdit;
  11. import qt.widgets.MainWindow;
  12. import qt.widgets.ProgressBar;
  13. import qt.widgets.PushButton;
  14. import qt.widgets.RadioButton;
  15. import qt.widgets.ScrollArea;
  16. import qt.widgets.Slider;
  17. import qt.widgets.Widget;
  18.  
  19. @:buildXml('
  20.    <files id="haxe">
  21.        <compilerflag value="-IC:\\Qt\\5.7\\msvc2015_64\\include"/>
  22.    </files>
  23.    <target id="haxe">
  24.        <lib name="C:/Qt/5.7/msvc2015_64/lib/Qt5Core.lib" />
  25.        <lib name="C:/Qt/5.7/msvc2015_64/lib/Qt5Widgets.lib" />
  26.        <lib name="C:/Qt/5.7/msvc2015_64/lib/Qt5Gui.lib" />
  27.    </target>
  28. ')
  29.  
  30. class Main {
  31.     static function main() {
  32.         //Application.style = StyleFactory.create("Fusion");
  33.         //Application.style = StyleFactory.create("plastique");
  34.          
  35.        
  36.         var app = new Application();
  37.        
  38.         //trace(StyleFactory.create("Plastique"));
  39.        
  40.         var main = new MainWindow();
  41.         main.resize(640, 480);
  42.         main.show();
  43.        
  44.         var mainLayout = new HBoxLayout();
  45.         mainLayout.spacing = 0;
  46.         mainLayout.setContentsMargins(0, 0, 0, 0);
  47.         var central = new Widget();
  48.         //central.layout = mainLayout;
  49.        
  50.         var root = new Widget();
  51.         root.parent = central;
  52.         root.layout = mainLayout;
  53.        
  54.         var col1 = new Widget();
  55.         var col1Layout = new VBoxLayout();
  56.         col1Layout.spacing = 0;
  57.         col1Layout.setContentsMargins(0, 0, 0, 0);
  58.         col1.layout = col1Layout;
  59.         mainLayout.addWidget(col1);
  60.        
  61.         var vbox = new Widget();
  62.         //vbox.parent = central;
  63.         var vboxLayout = new VBoxLayout();
  64.         //vboxLayout.setContentsMargins(0, 0, 0, 0);
  65.         var button = new PushButton(); button.text = "Button 1"; vboxLayout.addWidget(button);
  66.         var button = new PushButton(); button.text = "Button 2"; vboxLayout.addWidget(button);
  67.         var button = new PushButton(); button.text = "Button 3"; vboxLayout.addWidget(button);
  68.         vbox.layout = vboxLayout;
  69.         col1Layout.addWidget(vbox);
  70.        
  71.         var hbox = new Widget();
  72.         var hboxLayout = new HBoxLayout();
  73.         var button = new PushButton(); button.text = "Button 1"; hboxLayout.addWidget(button);
  74.         var button = new PushButton(); button.text = "Button 2"; hboxLayout.addWidget(button);
  75.         var button = new PushButton(); button.text = "Button 3"; hboxLayout.addWidget(button);
  76.         hbox.layout = hboxLayout;
  77.         col1Layout.addWidget(hbox);
  78.  
  79.         var hbox = new Widget();
  80.         var hboxLayout = new HBoxLayout();
  81.         var button = new CheckBox(); button.text = "Check 1"; hboxLayout.addWidget(button);
  82.         var button = new CheckBox(); button.text = "Check 2"; hboxLayout.addWidget(button);
  83.         var button = new CheckBox(); button.text = "Check 3"; hboxLayout.addWidget(button);
  84.         hbox.layout = hboxLayout;
  85.         col1Layout.addWidget(hbox);
  86.        
  87.         var hbox = new Widget();
  88.         var hboxLayout = new HBoxLayout();
  89.         var button = new RadioButton(); button.text = "Option 1"; hboxLayout.addWidget(button);
  90.         var button = new RadioButton(); button.text = "Option 2"; hboxLayout.addWidget(button);
  91.         var button = new RadioButton(); button.text = "Option 3"; hboxLayout.addWidget(button);
  92.         hbox.layout = hboxLayout;
  93.         col1Layout.addWidget(hbox);
  94.        
  95.  
  96.         var hbox = new Widget();
  97.         var hboxLayout = new HBoxLayout();
  98.         var label = new Label(); label.text = "Label"; hboxLayout.addWidget(label);
  99.         var button = new PushButton(); button.text = "Click Me!"; hboxLayout.addWidget(button);
  100.         button.connectClicked(function() { label.text = "Thanks!"; });
  101.         hbox.layout = hboxLayout;
  102.         col1Layout.addWidget(hbox);
  103.        
  104.        
  105.         var hbox = new Widget();
  106.         var hboxLayout = new HBoxLayout();
  107.         var progress = new ProgressBar();
  108.         progress.value = 50;
  109.         hboxLayout.addWidget(progress);
  110.         var slider = new Slider();
  111.         slider.value = 50;
  112.         slider.orientation = Orientation.Horizontal;
  113.         hboxLayout.addWidget(slider);
  114.         hbox.layout = hboxLayout;
  115.         col1Layout.addWidget(hbox);
  116.        
  117.        
  118.        
  119.         var hbox = new Widget();
  120.         var hboxLayout = new HBoxLayout();
  121.         var lineEdit = new LineEdit();
  122.         lineEdit.text = "Line edit";
  123.         hboxLayout.addWidget(lineEdit);
  124.         hbox.layout = hboxLayout;
  125.         col1Layout.addWidget(hbox);
  126.        
  127.        
  128.        
  129.        
  130.         var col2 = new Widget();
  131.         var col2Layout = new VBoxLayout();
  132.         col2Layout.spacing = 0;
  133.         col2Layout.setContentsMargins(0, 0, 0, 0);
  134.         col2.layout = col2Layout;
  135.         mainLayout.addWidget(col2);
  136.        
  137.        
  138.         var vbox = new Widget();
  139.         var vboxLayout = new VBoxLayout();
  140.         var scrollArea = new ScrollArea();
  141.         vboxLayout.addWidget(scrollArea);
  142.         vbox.layout = vboxLayout;
  143.        
  144.         var scrollContents = new Widget();
  145.         var scrollContentsLayout = new VBoxLayout();
  146.         for (a in 0...20) {
  147.             var b = new PushButton();
  148.             b.text = "Button " + a;
  149.             scrollContentsLayout.addWidget(b);
  150.         }
  151.         scrollContents.layout = scrollContentsLayout;
  152.         scrollArea.widget = scrollContents;
  153.        
  154.         col2Layout.addWidget(vbox);
  155.        
  156.         /*
  157.         var vbox = new Widget();
  158.         //vbox.parent = central;
  159.         var vboxLayout = new VBoxLayout();
  160.         //vboxLayout.setContentsMargins(0, 0, 0, 0);
  161.         var button = new PushButton(); button.text = "Button 1"; vboxLayout.addWidget(button);
  162.         var button = new PushButton(); button.text = "Button 2"; vboxLayout.addWidget(button);
  163.         var button = new PushButton(); button.text = "Button 3"; vboxLayout.addWidget(button);
  164.         vbox.layout = vboxLayout;
  165.         col2Layout.addWidget(vbox);
  166.         */
  167.        
  168.        
  169.        
  170.        
  171.        
  172.         //central.layout = mainLayout;
  173.         main.centralWindow = central;
  174.        
  175.         /*
  176.         var button = new PushButton();
  177.         button.parent = central;
  178.         button.text = "&Test1";
  179.         button.x = 10;
  180.         button.y = 10;
  181.         button.connectClicked(clickHandler);
  182.  
  183.         var checkbox = new CheckBox();
  184.         checkbox.parent = central;
  185.         checkbox.text = "Test2";
  186.         checkbox.x = 10;
  187.         checkbox.y = 40;
  188.         checkbox.connectClicked(function(checked:Bool = false) {
  189.             trace("Checkbox clicked: " + checked);
  190.         });
  191.         */
  192.        
  193.         central.show();
  194.         app.exec();
  195.     }
  196.    
  197.     static function clickHandler() {
  198.         trace("Button clicked!");
  199.     }
  200. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement