You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
2.8 KiB
122 lines
2.8 KiB
14 years ago
|
#include <tqpopupmenu.h>
|
||
|
#include <tqwidget.h>
|
||
|
#include <tqstring.h>
|
||
|
#include <tqmessagebox.h>
|
||
|
#include <tqmultilineedit.h>
|
||
|
#include <tqkeycode.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqcursor.h>
|
||
15 years ago
|
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
#include "kstatusbar.h"
|
||
|
#include <kapplication.h>
|
||
|
#include <kmainwindow.h>
|
||
|
#include <kmenubar.h>
|
||
|
#include "kstatusbartest.h"
|
||
|
|
||
14 years ago
|
testWindow::testWindow (TQWidget *, const char *name)
|
||
15 years ago
|
: KMainWindow (0, name)
|
||
|
{
|
||
|
// Setup Menus
|
||
|
menuBar = new KMenuBar (this);
|
||
14 years ago
|
fileMenu = new TQPopupMenu;
|
||
15 years ago
|
menuBar->insertItem ("&File", fileMenu);
|
||
|
fileMenu->insertItem ("&Exit", KApplication::kApplication(),
|
||
14 years ago
|
TQT_SLOT( quit() ), ALT + Key_Q );
|
||
15 years ago
|
statusbar = new KStatusBar (this);
|
||
|
statusbar->insertItem("Zoom: XXXX", 0);
|
||
|
statusbar->insertItem("XXX", 1);
|
||
|
statusbar->insertItem("Line: XXXXX", 2);
|
||
|
|
||
|
statusbar->changeItem("Zoom: 100%", 0);
|
||
|
statusbar->changeItem("INS", 1);
|
||
|
insert = true;
|
||
|
statusbar->changeItem("Line: 13567", 2);
|
||
|
|
||
14 years ago
|
connect (statusbar, TQT_SIGNAL(pressed(int)), this, TQT_SLOT(slotPress(int)));
|
||
|
connect (statusbar, TQT_SIGNAL(released(int)), this, TQT_SLOT(slotClick(int)));
|
||
15 years ago
|
|
||
14 years ago
|
widget = new TQMultiLineEdit (this);
|
||
15 years ago
|
|
||
|
setCentralWidget(widget);
|
||
|
|
||
|
setCaption( KApplication::kApplication()->caption() );
|
||
|
|
||
14 years ago
|
smenu = new TQPopupMenu;
|
||
15 years ago
|
|
||
|
smenu->insertItem("50%");
|
||
|
smenu->insertItem("75%");
|
||
|
smenu->insertItem("100%");
|
||
|
smenu->insertItem("150%");
|
||
|
smenu->insertItem("200%");
|
||
|
smenu->insertItem("400%");
|
||
|
smenu->insertItem("oo%");
|
||
|
|
||
14 years ago
|
connect (smenu, TQT_SIGNAL(activated(int)), this, TQT_SLOT(slotMenu(int)));
|
||
15 years ago
|
}
|
||
|
|
||
|
void testWindow::slotClick(int id)
|
||
|
{
|
||
|
switch (id)
|
||
|
{
|
||
|
case 0:
|
||
|
break;
|
||
|
|
||
|
case 1:
|
||
|
if (insert == true)
|
||
|
{
|
||
|
insert = false;
|
||
|
statusbar->changeItem("OVR", 1);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
insert = true;
|
||
|
statusbar->changeItem("INS", 1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 2:
|
||
14 years ago
|
TQMessageBox::information(0, "Go to line", "Enter line number:", "where?");
|
||
15 years ago
|
statusbar->changeItem("16543", 2);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void testWindow::slotPress(int id)
|
||
|
{
|
||
|
if (id == 0)
|
||
14 years ago
|
smenu->popup(TQCursor::pos()); // This popup should understand keys up and down
|
||
15 years ago
|
}
|
||
|
|
||
|
void testWindow::slotMenu(int id)
|
||
|
{
|
||
14 years ago
|
TQString s = "Zoom: ";
|
||
15 years ago
|
s.append (smenu->text(id));
|
||
|
statusbar->changeItem(s,0);
|
||
|
}
|
||
|
|
||
|
testWindow::~testWindow ()
|
||
|
{
|
||
|
// I would delete toolbars here, but there are none
|
||
|
delete statusbar;
|
||
|
}
|
||
|
|
||
|
int main( int argc, char *argv[] )
|
||
|
{
|
||
|
KApplication *myApp = new KApplication( argc, argv, "KStatusBarTest" );
|
||
|
testWindow *test = new testWindow;
|
||
|
|
||
|
myApp->setMainWidget(test);
|
||
|
test->show();
|
||
|
test->resize(test->width(), test->height()); // I really really really dunno why it doesn't show
|
||
|
int ret = myApp->exec();
|
||
|
|
||
|
delete test;
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
|
#include "kstatusbartest.moc"
|
||
|
|