#include <windows.h>
#include <iostream.h>
#include "rapidqw32.h"
RQ_INITIALIZE(WindowProcedure);
RQForm form(application, WindowProcedure);
RQMainMenu mainMenu;
RQMenuItem menuItem1("&File");
RQMenuItem menuItem2("&Open");
RQMenuItem menuItem3("-");
RQMenuItem menuItem4("E&xit");
RQMenuItem menuItem5("1. Item");
RQStatusBar statusBar;
RQComboBox comboBox;
RQListBox listBox;
RQEdit edit1;
RQButton button1;
RQButton button2;
RQLabel label1;
String str("yeah");
void buttonClick(RQButton &sender)
{
comboBox.setStyle(csDropDownList);
comboBox.setSorted(TRUE);
listBox.setSorted(TRUE);
RQ_PRINT(String("Button 1 clicked"));
RQ_PRINTLN;
RQ_PRINT(edit1.getSelStart());
RQ_PRINTLN;
RQ_SHOWMESSAGE(String("weeeee").toString());
str = String("what ever!") + "hello world!";
cout << str << endl;
cout << (String("test") == String("test")) << endl;
cout << String("test") << endl;
cout << RQ_LEN(str) << endl;
edit1.setSelStart(1);
edit1.setSelLength(2);
}
void menuItemClick(RQMenuItem &sender)
{
cout << "Menu item click " << sender.tag << endl;
form.close();
}
void comboBoxChange(RQComboBox &sender)
{
cout << "Combobox change " << sender.getItemIndex() << endl;
}
void comboBoxDrawItem(int index, int state, RECT rect, RQComboBox &sender)
{
cout << "Index " << sender.getItem(index) << " state " << state << endl;
sender.canvas.line(rect.left, rect.top, rect.right, rect.bottom, 0x0000ff);
}
void buttonMouseMove(int x, int y, int shifts, RQButton &sender)
{
cout << "x = " << x << ", y = " << y << endl;
}
void editKeyPress(byte ch, RQEdit &sender)
{
cout << "Edit key press " << ch << endl;
}
void formPaint(RQForm &sender)
{
sender.canvas.line(0, 100, 0, 0, 0x0000ff);
sender.canvas.line(0, 0, 100, 0, 0x0000ff);
sender.canvas.line(100, 0, 100, 100, 0x0000ff);
sender.canvas.line(0, 100, 100, 100, 0x0000ff);
sender.canvas.paint(10, 10, 0xff0000, 0x0000ff);
sender.font.setFontName("Arial");
sender.canvas.textOut(50, 50, "Argh!", 0x00ff00, -1);
sender.canvas.textOut(0, 0, "Argh 2!", 0xff00ff, 0x00ff00);
sender.canvas.rectangle(15,15,10,10,0);
}
BEGIN_GUI
form.center();
button1.onMouseMove = buttonMouseMove;
edit1.setMaxLength(5);
edit1.onKeyPress = editKeyPress;
edit1.setTop(180);
RQEdit edit2("wow!");
edit2.setReadOnly(TRUE);
menuItem2.setEnabled(FALSE);
menuItem4.onClick = menuItemClick;
mainMenu.setParent(form);
menuItem1.setCaption("&Test");
mainMenu.addMenu(menuItem1);
menuItem1.addMenu(menuItem2);
menuItem1.addMenu(menuItem3);
menuItem1.addMenu(menuItem4);
menuItem4.addMenu(menuItem5);
menuItem2.setChecked(TRUE);
comboBox.setParent(form);
comboBox.setTop(100);
comboBox.setItemHeight(40);
comboBox.onChange = comboBoxChange;
comboBox.addItem("1. Apples");
comboBox.addItem("2. Orange");
comboBox.addItem("3. Peach");
comboBox.addItem("4. Grapes");
comboBox.addItem("5. Grapes");
comboBox.addItem("6. Grapes");
comboBox.addItem("7. Grapes");
comboBox.addItem("8. Grapes");
comboBox.addItem("9. Grapes");
comboBox.addItem("10. Grapes");
comboBox.addItem("11. Grapes");
comboBox.addItem("12. Grapes");
comboBox.insertItem(1, "10. Watermelon");
comboBox.setItem(0, "to");
comboBox.setItemIndex(1);
listBox.setParent(form);
listBox.setLeft(200);
listBox.setTop(70);
listBox.addItem("1. school");
listBox.addItem("0. knapsack");
listBox.addItem("2. knapsack");
listBox.addItem("3. knapsack");
listBox.addItem("4. knapsack");
listBox.addItem("9. knapsack");
listBox.addItem("7. knapsack");
listBox.addItem("4. knapsack");
listBox.addItem("05 knapsack");
listBox.addItem("34 knapsack");
listBox.addItem("0. knapsack");
listBox.addItem("43 knapsack");
listBox.addItem("05 knapsack");
listBox.font.setFontName("Courier New");
form.font.setFontName("Arial");
form.font.setFontSize(12);
form.onPaint = formPaint;
button1.onClick = buttonClick;
button1.setParent(form);
button1.setCaption("My Button");
button1.setTop(30);
button1.setLeft(50);
button1.setWidth(60);
button1.onClick = buttonClick;
button1.font.setFontName("Courier");
button2.setLeft(100);
button2.setParent(form);
button2.setCaption("Button 2");
button2.setTop(50);
edit1.setParent(form);
edit2.setLeft(170);
edit2.setParent(form);
statusBar.setParent(form);
statusBar.addPanel("up");
statusBar.addPanel("down");
statusBar.setPanelWidth(0, 110);
statusBar.setPanelCaption(0, "test");
label1.setParent(form);
label1.setCaption("hello world!");
form.showModal();
END_GUI
|
|