Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -1,10 +1,9 @@
|
|||
GUI, add, Edit,Number w50 vUserInput, 0 ; Number Specifies Numbers-only, but other characters can still be pasted in,
|
||||
GUI, add, Edit,Number w50 vUserInput gMakeSure, 0 ; Number Specifies Numbers-only, but other characters can still be pasted in,
|
||||
; Making our own check necessary. (MakeSure)
|
||||
|
||||
GUI, add, Button, gIncrement, Increment ; Instead of an increment button, the UpDown control could be used, but this was not specified.
|
||||
GUI, add, Button, gRando, Random
|
||||
Gui, Show, W200 y200, Title ; Shows the GUI with a width and height of 200px
|
||||
SetTimer, MakeSure, 1000 ; Runs MakeSure every second
|
||||
return ; End Auto-Execute Section
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include <QIntValidator>
|
||||
#include <QMessageBox>
|
||||
#include <QTime>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
qsrand(QTime::currentTime().msec());
|
||||
|
||||
QApplication app(argc, argv);
|
||||
|
||||
auto *edit = new QLineEdit("0");
|
||||
edit->setValidator(new QIntValidator());
|
||||
|
||||
auto *incButton = new QPushButton("&Increment");
|
||||
QObject::connect(incButton, &QPushButton::clicked,
|
||||
[edit]() { edit->setText( QString::number(edit->text().toInt() + 1)); } );
|
||||
|
||||
auto *rndButton = new QPushButton("&Random");
|
||||
QObject::connect(rndButton, &QPushButton::clicked,
|
||||
[edit]() {
|
||||
auto result = QMessageBox(
|
||||
QMessageBox::Warning,
|
||||
"Random",
|
||||
"Overwrite current value with a random number ?",
|
||||
QMessageBox::Ok | QMessageBox::Cancel
|
||||
).exec();
|
||||
|
||||
if (result == QMessageBox::Ok)
|
||||
edit->setText( QString::number(qrand()));
|
||||
} );
|
||||
|
||||
auto *vbox = new QVBoxLayout;
|
||||
vbox->addWidget(edit);
|
||||
vbox->addWidget(incButton);
|
||||
vbox->addWidget(rndButton);
|
||||
|
||||
QWidget mainWindow;
|
||||
mainWindow.setLayout(vbox);
|
||||
mainWindow.show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
;; Using the LTK library...
|
||||
|
||||
(defun gui-test ()
|
||||
"the main window for the input test"
|
||||
(ltk:with-ltk ()
|
||||
(ltk:wm-title ltk:*tk* "GUI Test")
|
||||
(ltk:bind ltk:*tk* "<Alt-q>" (lambda (evt)
|
||||
(declare (ignore evt))
|
||||
(setf ltk:*exit-mainloop* t)))
|
||||
(let* (;; Initializing random generator
|
||||
(*random-state* (make-random-state t))
|
||||
;; Creating widgets
|
||||
(the-input (make-instance 'ltk:entry
|
||||
:text "0"
|
||||
:validate :key))
|
||||
(f (make-instance 'ltk:frame))
|
||||
(btn1 (make-instance 'ltk:button :text "random" :master f))
|
||||
(btn2 (make-instance 'ltk:button :text "increment" :master f)))
|
||||
;; Associating actions with widgets
|
||||
(ltk:bind btn1 "<Button-1>"
|
||||
(lambda (evt)
|
||||
(declare (ignore evt))
|
||||
(when (ltk:ask-yesno "Really reset to random?" :title "Question")
|
||||
(setf (ltk:text the-input) (write-to-string (random 10000))))))
|
||||
(ltk:bind btn2 "<Button-1>"
|
||||
(lambda (evt)
|
||||
(declare (ignore evt))
|
||||
(setf (ltk:text the-input)
|
||||
(write-to-string (1+ (parse-integer (ltk:text the-input)))))))
|
||||
(ltk:format-wish "~A configure -validatecommand {string is int %P}"
|
||||
(ltk:widget-path the-input))
|
||||
(ltk:focus the-input)
|
||||
;; Placing widgets on the window
|
||||
(ltk:pack the-input :side :top)
|
||||
(ltk:pack f :side :bottom)
|
||||
(ltk:pack btn1 :side :left)
|
||||
(ltk:pack btn2 :side :right))))
|
||||
|
||||
(gui-test)
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#import system.
|
||||
#import forms.
|
||||
#import extensions.
|
||||
|
||||
#class Window
|
||||
|
||||
{
|
||||
#field form.
|
||||
#field btmIncrement.
|
||||
#field btmRandom.
|
||||
#field txtNumber.
|
||||
|
||||
#constructor new
|
||||
[
|
||||
form := SDIDialog new.
|
||||
btmIncrement := Button new.
|
||||
btmRandom := Button new.
|
||||
txtNumber := Edit new.
|
||||
|
||||
form controls
|
||||
+= btmIncrement
|
||||
+= btmRandom
|
||||
+= txtNumber.
|
||||
|
||||
form set &caption:"Rosseta Code".
|
||||
form set &x:100 &y:100.
|
||||
form set &width:160 &height:120.
|
||||
|
||||
txtNumber set &x:7 &y:7.
|
||||
txtNumber set &width:140 &height:25.
|
||||
txtNumber set &caption:"0".
|
||||
|
||||
btmIncrement set &x:7 &y:35.
|
||||
btmIncrement set &width:140 &height:25.
|
||||
btmIncrement set &caption:"Increment".
|
||||
btmIncrement set &onClick:args
|
||||
|
||||
[ $self $onButtonIncrementClick. ].
|
||||
|
||||
btmRandom set &x:7 &y:65.
|
||||
btmRandom set &width:140 &height:25.
|
||||
btmRandom set &caption:"Random".
|
||||
btmRandom set &onClick:args
|
||||
|
||||
[ $self $onButtonRandomClick. ].
|
||||
]
|
||||
|
||||
#method $onButtonIncrementClick
|
||||
[
|
||||
#var number := txtNumber value toInt.
|
||||
|
||||
number := number + 1.
|
||||
$self $changeTextBoxValue:number.
|
||||
]
|
||||
|
||||
#method $onButtonRandomClick
|
||||
[
|
||||
(messageDialog open &caption:"Inf" &question:"Really reset to random value?")?
|
||||
[
|
||||
$self $changeTextBoxValue:(randomGenerator eval:99999999).
|
||||
].
|
||||
]
|
||||
|
||||
#method $changeTextBoxValue : number
|
||||
[
|
||||
txtNumber set &caption:(number literal).
|
||||
]
|
||||
|
||||
#method => form.
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
use GTK::Simple;
|
||||
|
||||
my GTK::Simple::App $app .= new(title => 'GUI component interaction');
|
||||
|
||||
$app.set_content(
|
||||
my $box = GTK::Simple::VBox.new(
|
||||
my $value = GTK::Simple::Entry.new(text => '0'),
|
||||
my $increment = GTK::Simple::Button.new(label => 'Increment'),
|
||||
my $random = GTK::Simple::Button.new(label => 'Random'),
|
||||
)
|
||||
);
|
||||
|
||||
$app.size_request(400, 100);
|
||||
$app.border_width = 20;
|
||||
$box.spacing = 10;
|
||||
|
||||
$value.changed.tap: {
|
||||
($value.text ||= '0') ~~ s:g/<-[0..9]>//;
|
||||
}
|
||||
|
||||
$increment.clicked.tap: {
|
||||
$value.text += 1;
|
||||
}
|
||||
|
||||
$random.clicked.tap: {
|
||||
# Dirty hack to work around the fact that GTK::Simple doesn't provide
|
||||
# access to GTK message dialogs yet :P
|
||||
if run «zenity --question --text "Reset to random value?"» {
|
||||
$value.text = (^100).pick;
|
||||
}
|
||||
}
|
||||
|
||||
$app.run;
|
||||
Loading…
Add table
Add a link
Reference in a new issue