1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
|
/***************************************************************************
rinputdialog.cpp - description
-------------------
begin : Mon Sep 27 1999
copyright : (C) 1999 by Andreas Mustun
email : andrew@ribbonsoft.com
***************************************************************************/
/****************************************************************************
** rinputdialog.cpp 1998/09/03 A. Mustun RibbonSoft
**
** Copyright (C) 1998 RibbonSoft. All rights reserved.
**
*****************************************************************************/
#include <qkeycode.h>
#include "rcombobox.h"
#include "rgraphic.h"
#include "rlabel.h"
#include "rlineedit.h"
#include "rconfig.h"
#include "rinputdialog.h"
#include "rlog.h"
#include "rprgdef.h"
#include "rpushbutton.h"
// Constructor for a textline input:
//
RInputDialog::RInputDialog(const char* _label,
int _maxLen,
const char* _default,
QWidget* _parent,
const char* _name)
:QDialog(_parent, _name, true, WStyle_NormalBorder)
{
cInput=0;
createStaticElements(_label);
eInput = new RLineEdit(this, "einput");
if(_default) eInput->setText(_default);
eInput->setGeometry(75, 42, width()-150, 20);
eInput->setMaxLength(_maxLen);
eInput->setFocus();
}
// Constructor for a combobox input
// Label (Message)
// Max length for input
// Default value
// Typ of combobox ('l'=Layer)
// Parent widget
//
RInputDialog::RInputDialog(const char* _label,
const char* _default,
char _typ,
bool _rw,
RGraphic* _graphic,
QWidget* _parent,
const char* _name)
:QDialog(_parent, _name, true, WStyle_NormalBorder)
{
eInput=0;
createStaticElements(_label);
cInput = new RComboBox(_rw, this, "cinput");
if(_default) cInput->setEditText(_default);
cInput->setGeometry(75, 42, width()-150, 20);
cInput->setFocus();
switch(_typ) {
// Fill in Layers:
//
case 'l':
if(_graphic) cInput->fillInLayers(_graphic, false);
break;
default:
break;
}
}
// Destructor:
//
RInputDialog::~RInputDialog()
{
}
// Create elements which are the same for all input dialogs:
//
void
RInputDialog::createStaticElements(const char* _label)
{
setCaption(DEF_APPNAME);
setFixedSize(DEF_INPUTDLG_WIDTH, DEF_INPUTDLG_HEIGHT);
lText = new RLabel(_label, this, "ltext");
lText->setAlignment(AlignCenter);
if(lText->sizeHint().width()+20>DEF_INPUTDLG_WIDTH) {
setFixedWidth(lText->sizeHint().width()+20);
}
if(lText->sizeHint().height()+70>DEF_INPUTDLG_HEIGHT) {
setFixedHeight(lText->sizeHint().height()+70);
}
lText->setGeometry( 10, 10, width()-10, 30 );
bOk = new RPushButton( RMES(46), this );
bOk->setGeometry( width()-150, 80, 70, 20 );
bOk->setAccel( Key_Return );
connect( bOk, SIGNAL(clicked()), SLOT(accept()) );
bCancel = new RPushButton( RMES(47), this );
//bCancel->setGeometry( 10+(width()-20)/3, 80, (width()-20)/3, 20 );
bCancel->setGeometry( width()-80, 80, 70, 20 );
bCancel->setAccel( Key_Escape );
connect( bCancel, SIGNAL(clicked()), SLOT(reject()) );
/*
bHelp = new RPushButton(RMES(48), this);
bHelp->setGeometry(10+(width()-20)/3*2, 80, (width()-20)/3, 20);
bHelp->setAccel(Key_F1);
*/
}
// Get the user input:
//
const char*
RInputDialog::getInput()
{
if(eInput) {
return eInput->text().latin1();
}
else {
if(cInput) {
return cInput->currentText().latin1();
}
else {
return 0;
}
}
}
// EOF
|