#include <iostream.h>
#include "rapidqw32.h"
RQ_INITIALIZE(WindowProcedure);
RQForm form(application, WindowProcedure);
RQMainMenu mainMenu;
RQMenuItem fileItem("&File");
RQMenuItem openItem("&Open");
RQMenuItem saveItem("&Save");
RQMenuItem break1Item("-");
RQMenuItem printItem("&Print");
RQMenuItem break2Item("-");
RQMenuItem exitItem("E&xit");
RQStatusBar statusBar;
RQLabel nameLabel("Name:");
RQLabel addressLabel("Address:");
RQLabel cityLabel("City:");
RQLabel phoneLabel("Phone #:");
RQEdit nameEdit;
RQEdit addressEdit;
RQEdit cityEdit;
RQEdit phoneEdit;
RQButton addButton("&Add");
RQButton clearButton("&Clear");
RQButton sortButton("&Sort");
RQListBox listbox;
void menuItemClick (RQMenuItem& sender)
{
statusBar.setPanelCaption(0, sender.getCaption());
if (String(sender.getCaption()) == String("E&xit")) form.close();
}
void addButtonClick (RQButton& sender)
{
if (listbox.getItemCount() > 0)
listbox.addItem("--------------------------------");
listbox.addItem(nameEdit.getText());
listbox.addItem(addressEdit.getText());
listbox.addItem(cityEdit.getText());
listbox.addItem(phoneEdit.getText());
}
void clearButtonClick (RQButton& sender)
{
listbox.clear();
}
void sortButtonClick (RQButton& sender)
{
listbox.setSorted(!listbox.getSorted());
if (listbox.getSorted())
sender.setCaption("&Unsort");
else
sender.setCaption("&Sort");
}
void formPaint (RQForm& sender)
{
sender.canvas.fillRect(205, 10, 270, 110, 0xff8800);
sender.canvas.rectangle(205, 10, 270, 110, 0);
sender.font.setFontName("Arial");
sender.font.setFontSize(9);
sender.canvas.textOut(210, 15, "HELP", 0xffffff, -1);
sender.font.setFontSize(8);
sender.canvas.textOut(210, 35, "Add", 0, -1);
sender.font.setFontSize(7);
sender.canvas.textOut(210, 45, " to listbox", 0, -1);
sender.canvas.textOut(210, 55, "Clear", 0, -1);
sender.canvas.textOut(210, 65, " listbox", 0, -1);
sender.canvas.textOut(210, 75, "Sort", 0, -1);
sender.canvas.textOut(210, 85, " items", 0, -1);
}
BEGIN_GUI
mainMenu.setParent(form);
mainMenu.addMenu(fileItem);
fileItem.addMenu(openItem);
fileItem.addMenu(saveItem);
fileItem.addMenu(break1Item);
fileItem.addMenu(printItem);
fileItem.addMenu(break2Item);
fileItem.addMenu(exitItem);
openItem.onClick = menuItemClick;
saveItem.onClick = menuItemClick;
printItem.onClick = menuItemClick;
exitItem.onClick = menuItemClick;
statusBar.setParent(form);
statusBar.addPanel("Status");
nameLabel.setParent(form);
nameLabel.setTop(10); nameLabel.setLeft(10);
addressLabel.setParent(form);
addressLabel.setTop(40); addressLabel.setLeft(10);
cityLabel.setParent(form);
cityLabel.setTop(70); cityLabel.setLeft(10);
phoneLabel.setParent(form);
phoneLabel.setTop(100); phoneLabel.setLeft(10);
nameEdit.setParent(form);
nameEdit.setTop(7); nameEdit.setLeft(70);
addressEdit.setParent(form);
addressEdit.setTop(37); addressEdit.setLeft(70);
cityEdit.setParent(form);
cityEdit.setTop(67); cityEdit.setLeft(70);
phoneEdit.setParent(form);
phoneEdit.setTop(97); phoneEdit.setLeft(70);
addButton.setParent(form);
addButton.setTop(127); addButton.setLeft(10);
addButton.onClick = addButtonClick;
clearButton.setParent(form);
clearButton.setTop(127); clearButton.setLeft(100);
clearButton.onClick = clearButtonClick;
sortButton.setParent(form);
sortButton.setTop(127); sortButton.setLeft(190);
sortButton.onClick = sortButtonClick;
listbox.setParent(form);
listbox.setTop(160); listbox.setLeft(10);
listbox.setWidth(260); listbox.setHeight(150);
form.onPaint = formPaint;
form.setHeight(380); form.setWidth(290);
form.setCaption("Data entry example");
form.center();
form.showModal();
END_GUI
|