|
|
|
/**********************************************************************
|
|
|
|
** Copyright (C) 2000 Trolltech AS. All rights reserved.
|
|
|
|
**
|
|
|
|
** This file is part of TQt Designer.
|
|
|
|
**
|
|
|
|
** This file may be distributed and/or modified under the terms of the
|
|
|
|
** GNU General Public License version 2 as published by the Free Software
|
|
|
|
** Foundation and appearing in the file LICENSE.GPL included in the
|
|
|
|
** packaging of this file.
|
|
|
|
**
|
|
|
|
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
|
|
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
**
|
|
|
|
** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|
|
|
**
|
|
|
|
** Contact info@trolltech.com if any conditions of this licensing are
|
|
|
|
** not clear to you.
|
|
|
|
**
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#include <klocale.h>
|
|
|
|
#include <kommanderfactory.h>
|
|
|
|
|
|
|
|
#include "kmdrmainwindow.h"
|
|
|
|
#include <tqvariant.h> // HP-UX compiler need this here
|
|
|
|
#include "widgetfactory.h"
|
|
|
|
#include "widgetdatabase.h"
|
|
|
|
#include "metadatabase.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "formwindow.h"
|
|
|
|
#include "pixmapchooser.h"
|
|
|
|
#include "tqlayout.h"
|
|
|
|
#include "listboxeditorimpl.h"
|
|
|
|
#include "listvieweditorimpl.h"
|
|
|
|
#include "iconvieweditorimpl.h"
|
|
|
|
#include "multilineeditorimpl.h"
|
|
|
|
#ifndef KOMMANDER
|
|
|
|
#include "widgetinterface.h"
|
|
|
|
#endif
|
|
|
|
#ifndef TQT_NO_TABLE
|
|
|
|
#include "tableeditorimpl.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <tqfeatures.h>
|
|
|
|
|
|
|
|
#include <tqpixmap.h>
|
|
|
|
#include <tqgroupbox.h>
|
|
|
|
#include <tqiconview.h>
|
|
|
|
#ifndef TQT_NO_TABLE
|
|
|
|
#include <tqtable.h>
|
|
|
|
#endif
|
|
|
|
#ifndef TQT_NO_SQL
|
|
|
|
#include <tqdatatable.h>
|
|
|
|
#endif
|
|
|
|
#include <tqdatetimeedit.h>
|
|
|
|
#include <tqlineedit.h>
|
|
|
|
#include <tqspinbox.h>
|
|
|
|
#include <tqmultilineedit.h>
|
|
|
|
#include <tqtextedit.h>
|
|
|
|
#include <tqlabel.h>
|
|
|
|
#include <tqlayout.h>
|
|
|
|
#include <tqwidgetstack.h>
|
|
|
|
#include <tqcombobox.h>
|
|
|
|
#include <tqtabbar.h>
|
|
|
|
#include <tqlistbox.h>
|
|
|
|
#include <tqlistview.h>
|
|
|
|
#include <tqobjectlist.h>
|
|
|
|
#include <tqlcdnumber.h>
|
|
|
|
#include <tqslider.h>
|
|
|
|
#include <tqdial.h>
|
|
|
|
#include <tqprogressbar.h>
|
|
|
|
#include <tqtextview.h>
|
|
|
|
#include <tqtextbrowser.h>
|
|
|
|
#include <tqframe.h>
|
|
|
|
#include <tqmetaobject.h>
|
|
|
|
#include <tqwizard.h>
|
|
|
|
#include <tqvaluelist.h>
|
|
|
|
#include <tqtimer.h>
|
|
|
|
#include <tqscrollbar.h>
|
|
|
|
#include <tqmainwindow.h>
|
|
|
|
#include <tqmenubar.h>
|
|
|
|
#include <tqapplication.h>
|
|
|
|
#include <tqsplitter.h>
|
|
|
|
#ifndef TQT_NO_SQL
|
|
|
|
#include "database.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//#define NO_STATIC_COLORS
|
|
|
|
#include "globaldefs.h"
|
|
|
|
|
|
|
|
/* KOMMANDER INCLUDES */
|
|
|
|
#include <lineedit.h>
|
|
|
|
#include <dialog.h>
|
|
|
|
#include <execbutton.h>
|
|
|
|
#include <closebutton.h>
|
|
|
|
#include <textedit.h>
|
|
|
|
#include <fileselector.h>
|
|
|
|
#include <textedit.h>
|
|
|
|
#include <radiobutton.h>
|
|
|
|
#include <groupbox.h>
|
|
|
|
#include <buttongroup.h>
|
|
|
|
#include <checkbox.h>
|
|
|
|
#include <combobox.h>
|
|
|
|
#include <spinboxint.h>
|
|
|
|
#include <wizard.h>
|
|
|
|
#include <tabwidget.h>
|
|
|
|
#include <subdialog.h>
|
|
|
|
#include <listbox.h>
|
|
|
|
#include <scriptobject.h>
|
|
|
|
#include <richtexteditor.h>
|
|
|
|
#include <treewidget.h>
|
|
|
|
#include <slider.h>
|
|
|
|
#include <datepicker.h>
|
|
|
|
#include <popupmenu.h>
|
|
|
|
#include "toolbox.h"
|
|
|
|
#include "fontdialog.h"
|
|
|
|
#include "aboutdialog.h"
|
|
|
|
|
|
|
|
FormWindow *find_formwindow( TQWidget *w )
|
|
|
|
{
|
|
|
|
if ( !w )
|
|
|
|
return 0;
|
|
|
|
for (;;) {
|
|
|
|
if ( w->inherits( "FormWindow" ) )
|
|
|
|
return (FormWindow*)w;
|
|
|
|
if ( !w->tqparentWidget() )
|
|
|
|
return 0;
|
|
|
|
w = w->tqparentWidget();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQLayoutWidget::paintEvent( TQPaintEvent* )
|
|
|
|
{
|
|
|
|
TQPainter p ( this );
|
|
|
|
p.setPen( red );
|
|
|
|
p.drawRect( rect() );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQDesignerTabWidget::TQDesignerTabWidget( TQWidget *tqparent, const char *name )
|
|
|
|
: TQTabWidget( tqparent, name ), dropIndicator( 0 ), dragPage( 0 ), mousePressed( false )
|
|
|
|
{
|
|
|
|
tabBar()->setAcceptDrops( true );
|
|
|
|
tabBar()->installEventFilter( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
int TQDesignerTabWidget::currentPage() const
|
|
|
|
{
|
|
|
|
return tabBar()->currentTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerTabWidget::setCurrentPage( int i )
|
|
|
|
{
|
|
|
|
tabBar()->setCurrentTab( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQString TQDesignerTabWidget::pageTitle() const
|
|
|
|
{
|
|
|
|
return ((TQTabWidget*)this)->tabLabel( TQTabWidget::currentPage() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerTabWidget::setPageTitle( const TQString& title )
|
|
|
|
{
|
|
|
|
changeTab( TQTabWidget::currentPage(), title );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerTabWidget::setPageName( const TQCString& name )
|
|
|
|
{
|
|
|
|
if ( TQTabWidget::currentPage() )
|
|
|
|
TQTabWidget::currentPage()->setName( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQCString TQDesignerTabWidget::pageName() const
|
|
|
|
{
|
|
|
|
if ( !TQTabWidget::currentPage() )
|
|
|
|
return 0;
|
|
|
|
return TQTabWidget::currentPage()->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
int TQDesignerTabWidget::count() const
|
|
|
|
{
|
|
|
|
return tabBar()->count();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TQDesignerTabWidget::eventFilter( TQObject *o, TQEvent *e )
|
|
|
|
{
|
|
|
|
if ( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(tabBar()) ) return false;
|
|
|
|
|
|
|
|
switch ( e->type() ) {
|
|
|
|
case TQEvent::MouseButtonPress: {
|
|
|
|
mousePressed = true;
|
|
|
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
|
|
|
pressPoint = me->pos();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::MouseMove: {
|
|
|
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
|
|
|
if ( mousePressed && ( pressPoint - me->pos()).manhattanLength() > TQApplication::startDragDistance() ) {
|
|
|
|
TQTextDrag *drg = new TQTextDrag( TQString::number( (long) this ) , this );
|
|
|
|
mousePressed = false;
|
|
|
|
dragPage = TQTabWidget::currentPage();
|
|
|
|
dragLabel = TQTabWidget::tabLabel( dragPage );
|
|
|
|
|
|
|
|
int index = indexOf( dragPage );
|
|
|
|
|
|
|
|
removePage( dragPage );
|
|
|
|
if ( !drg->dragMove() ) {
|
|
|
|
insertTab( dragPage, dragLabel, index );
|
|
|
|
showPage( dragPage );
|
|
|
|
}
|
|
|
|
if ( dropIndicator )
|
|
|
|
dropIndicator->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::DragLeave: {
|
|
|
|
if ( dropIndicator )
|
|
|
|
dropIndicator->hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::DragMove: {
|
|
|
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
|
|
|
if ( TQTextDrag::canDecode( de ) ) {
|
|
|
|
TQString text;
|
|
|
|
TQTextDrag::decode( de, text );
|
|
|
|
if ( text == TQString::number( (long)this ) )
|
|
|
|
de->accept();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
TQRect rect;
|
|
|
|
for ( ; index < tabBar()->count(); index++ ) {
|
|
|
|
if ( tabBar()->tabAt( index )->rect().tqcontains( de->pos() ) ) {
|
|
|
|
rect = tabBar()->tabAt( index )->rect();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( index == tabBar()->count() -1 ) {
|
|
|
|
TQRect rect2 = rect;
|
|
|
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
|
|
|
if ( rect2.tqcontains( de->pos() ) )
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! dropIndicator ) {
|
|
|
|
dropIndicator = new TQWidget( this );
|
|
|
|
dropIndicator->setBackgroundColor( red );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQPoint pos;
|
|
|
|
if ( index == tabBar()->count() )
|
|
|
|
pos = tabBar()->mapToParent( TQPoint( rect.x() + rect.width(), rect.y() ) );
|
|
|
|
else
|
|
|
|
pos = tabBar()->mapToParent( TQPoint( rect.x(), rect.y() ) );
|
|
|
|
|
|
|
|
dropIndicator->setGeometry( pos.x(), pos.y() , 3, rect.height() );
|
|
|
|
dropIndicator->show();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::Drop: {
|
|
|
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
|
|
|
if ( TQTextDrag::canDecode( de ) ) {
|
|
|
|
TQString text;
|
|
|
|
TQTextDrag::decode( de, text );
|
|
|
|
if ( text == TQString::number( (long)this ) ) {
|
|
|
|
|
|
|
|
int newIndex = 0;
|
|
|
|
for ( ; newIndex < tabBar()->count(); newIndex++ ) {
|
|
|
|
if ( tabBar()->tabAt( newIndex )->rect().tqcontains( de->pos() ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( newIndex == tabBar()->count() -1 ) {
|
|
|
|
TQRect rect2 = tabBar()->tabAt( newIndex )->rect();
|
|
|
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
|
|
|
if ( rect2.tqcontains( de->pos() ) )
|
|
|
|
newIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int oldIndex = 0;
|
|
|
|
for ( ; oldIndex < tabBar()->count(); oldIndex++ ) {
|
|
|
|
if ( tabBar()->tabAt( oldIndex )->rect().tqcontains( pressPoint ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FormWindow *fw = find_formwindow( this );
|
|
|
|
MoveTabPageCommand *cmd =
|
|
|
|
new MoveTabPageCommand( i18n("Move Tab Page" ), fw, this,
|
|
|
|
dragPage, dragLabel, newIndex, oldIndex );
|
|
|
|
fw->commandHistory()->addCommand( cmd );
|
|
|
|
cmd->execute();
|
|
|
|
de->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int TQDesignerWizard::currentPageNum() const
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < pageCount(); ++i ) {
|
|
|
|
if ( page( i ) == currentPage() )
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::setCurrentPage( int i )
|
|
|
|
{
|
|
|
|
if ( i < currentPageNum() ) {
|
|
|
|
while ( i < currentPageNum() ) {
|
|
|
|
if ( currentPageNum() == 0 )
|
|
|
|
break;
|
|
|
|
back();
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
while ( i > currentPageNum() ) {
|
|
|
|
if ( currentPageNum() == pageCount() - 1 )
|
|
|
|
break;
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TQString TQDesignerWizard::pageTitle() const
|
|
|
|
{
|
|
|
|
return title( currentPage() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::setPageTitle( const TQString& title )
|
|
|
|
{
|
|
|
|
setTitle( currentPage(), title );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::setPageName( const TQCString& name )
|
|
|
|
{
|
|
|
|
if ( TQWizard::currentPage() )
|
|
|
|
TQWizard::currentPage()->setName( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQCString TQDesignerWizard::pageName() const
|
|
|
|
{
|
|
|
|
if ( !TQWizard::currentPage() )
|
|
|
|
return 0;
|
|
|
|
return TQWizard::currentPage()->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
int TQDesignerWizard::pageNum( TQWidget *p )
|
|
|
|
{
|
|
|
|
for ( int i = 0; i < pageCount(); ++i ) {
|
|
|
|
if ( page( i ) == p )
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::addPage( TQWidget *p, const TQString &t )
|
|
|
|
{
|
|
|
|
TQWizard::addPage( p, t );
|
|
|
|
if ( removedPages.tqfind( p ) )
|
|
|
|
removedPages.remove( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::removePage( TQWidget *p )
|
|
|
|
{
|
|
|
|
TQWizard::removePage( p );
|
|
|
|
removedPages.insert( p, p );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWizard::insertPage( TQWidget *p, const TQString &t, int index )
|
|
|
|
{
|
|
|
|
TQWizard::insertPage( p, t, index );
|
|
|
|
if ( removedPages.tqfind( p ) )
|
|
|
|
removedPages.remove( p );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQMap< int, TQMap< TQString, TQVariant> > *defaultProperties = 0;
|
|
|
|
TQMap< int, TQStringList > *changedProperties = 0;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\class WidgetFactory widgetfactory.h
|
|
|
|
\brief Set of static functions for creating widgets, tqlayouts and do other stuff
|
|
|
|
|
|
|
|
The widget factory offers functions to create widgets, create and
|
|
|
|
delete tqlayouts find out other details - all based on the
|
|
|
|
WidgetDatabase's data. So the functions that use ids use the same
|
|
|
|
ids as in the WidgetDatabase.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
void WidgetFactory::saveDefaultProperties( TQWidget *w, int id )
|
|
|
|
{
|
|
|
|
TQMap< TQString, TQVariant> propMap;
|
|
|
|
TQStrList lst = w->tqmetaObject()->propertyNames( true );
|
|
|
|
for ( uint i = 0; i < lst.count(); ++i ) {
|
|
|
|
TQVariant var = w->property( lst.at( i ) );
|
|
|
|
if ( !var.isValid() && qstrcmp( "pixmap", lst.at( i ) ) == 0 )
|
|
|
|
var = TQVariant( TQPixmap() );
|
|
|
|
else if ( !var.isValid() && qstrcmp( "iconSet", lst.at( i ) ) == 0 )
|
|
|
|
var = TQVariant( TQIconSet() );
|
|
|
|
propMap.tqreplace( lst.at( i ), var );
|
|
|
|
}
|
|
|
|
defaultProperties->tqreplace( id, propMap );
|
|
|
|
}
|
|
|
|
|
|
|
|
static void saveChangedProperties( TQWidget *w, int id )
|
|
|
|
{
|
|
|
|
TQStringList l = MetaDataBase::changedProperties( TQT_TQOBJECT(w) );
|
|
|
|
changedProperties->insert( id, l );
|
|
|
|
}
|
|
|
|
|
|
|
|
EditorTabWidget::EditorTabWidget( TQWidget *tqparent, const char *name )
|
|
|
|
: TabWidget( tqparent, name ), dropIndicator( 0 ), dragPage( 0 ), mousePressed( false )
|
|
|
|
{
|
|
|
|
tabBar()->setAcceptDrops( true );
|
|
|
|
tabBar()->installEventFilter( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EditorTabWidget::currentPage() const
|
|
|
|
{
|
|
|
|
return tabBar()->currentTab();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorTabWidget::setCurrentPage( int i )
|
|
|
|
{
|
|
|
|
tabBar()->setCurrentTab( i );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQString EditorTabWidget::pageTitle() const
|
|
|
|
{
|
|
|
|
return ((TQTabWidget*)this)->tabLabel( TQTabWidget::currentPage() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorTabWidget::setPageTitle( const TQString& title )
|
|
|
|
{
|
|
|
|
changeTab( TQTabWidget::currentPage(), title );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorTabWidget::setPageName( const TQCString& name )
|
|
|
|
{
|
|
|
|
if ( TQTabWidget::currentPage() )
|
|
|
|
TQTabWidget::currentPage()->setName( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQCString EditorTabWidget::pageName() const
|
|
|
|
{
|
|
|
|
if ( !TQTabWidget::currentPage() )
|
|
|
|
return 0;
|
|
|
|
return TQTabWidget::currentPage()->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EditorTabWidget::count() const
|
|
|
|
{
|
|
|
|
return tabBar()->count();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool EditorTabWidget::eventFilter( TQObject *o, TQEvent *e )
|
|
|
|
{
|
|
|
|
if ( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(tabBar()) ) return false;
|
|
|
|
|
|
|
|
switch ( e->type() ) {
|
|
|
|
case TQEvent::MouseButtonPress: {
|
|
|
|
mousePressed = true;
|
|
|
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
|
|
|
pressPoint = me->pos();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::MouseMove: {
|
|
|
|
TQMouseEvent *me = (TQMouseEvent*)e;
|
|
|
|
if ( mousePressed && ( pressPoint - me->pos()).manhattanLength() > TQApplication::startDragDistance() ) {
|
|
|
|
TQTextDrag *drg = new TQTextDrag( TQString::number( (long) this ) , this );
|
|
|
|
mousePressed = false;
|
|
|
|
dragPage = TQTabWidget::currentPage();
|
|
|
|
dragLabel = TQTabWidget::tabLabel( dragPage );
|
|
|
|
|
|
|
|
int index = indexOf( dragPage );
|
|
|
|
|
|
|
|
removePage( dragPage );
|
|
|
|
if ( !drg->dragMove() ) {
|
|
|
|
insertTab( dragPage, dragLabel, index );
|
|
|
|
showPage( dragPage );
|
|
|
|
}
|
|
|
|
if ( dropIndicator )
|
|
|
|
dropIndicator->hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::DragLeave: {
|
|
|
|
if ( dropIndicator )
|
|
|
|
dropIndicator->hide();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::DragMove: {
|
|
|
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
|
|
|
if ( TQTextDrag::canDecode( de ) ) {
|
|
|
|
TQString text;
|
|
|
|
TQTextDrag::decode( de, text );
|
|
|
|
if ( text == TQString::number( (long)this ) )
|
|
|
|
de->accept();
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
TQRect rect;
|
|
|
|
for ( ; index < tabBar()->count(); index++ ) {
|
|
|
|
if ( tabBar()->tabAt( index )->rect().tqcontains( de->pos() ) ) {
|
|
|
|
rect = tabBar()->tabAt( index )->rect();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( index == tabBar()->count() -1 ) {
|
|
|
|
TQRect rect2 = rect;
|
|
|
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
|
|
|
if ( rect2.tqcontains( de->pos() ) )
|
|
|
|
index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! dropIndicator ) {
|
|
|
|
dropIndicator = new TQWidget( this );
|
|
|
|
dropIndicator->setBackgroundColor( red );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQPoint pos;
|
|
|
|
if ( index == tabBar()->count() )
|
|
|
|
pos = tabBar()->mapToParent( TQPoint( rect.x() + rect.width(), rect.y() ) );
|
|
|
|
else
|
|
|
|
pos = tabBar()->mapToParent( TQPoint( rect.x(), rect.y() ) );
|
|
|
|
|
|
|
|
dropIndicator->setGeometry( pos.x(), pos.y() , 3, rect.height() );
|
|
|
|
dropIndicator->show();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TQEvent::Drop: {
|
|
|
|
TQDragEnterEvent *de = (TQDragEnterEvent*) e;
|
|
|
|
if ( TQTextDrag::canDecode( de ) ) {
|
|
|
|
TQString text;
|
|
|
|
TQTextDrag::decode( de, text );
|
|
|
|
if ( text == TQString::number( (long)this ) ) {
|
|
|
|
|
|
|
|
int newIndex = 0;
|
|
|
|
for ( ; newIndex < tabBar()->count(); newIndex++ ) {
|
|
|
|
if ( tabBar()->tabAt( newIndex )->rect().tqcontains( de->pos() ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( newIndex == tabBar()->count() -1 ) {
|
|
|
|
TQRect rect2 = tabBar()->tabAt( newIndex )->rect();
|
|
|
|
rect2.setLeft( rect2.left() + rect2.width() / 2 );
|
|
|
|
if ( rect2.tqcontains( de->pos() ) )
|
|
|
|
newIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
int oldIndex = 0;
|
|
|
|
for ( ; oldIndex < tabBar()->count(); oldIndex++ ) {
|
|
|
|
if ( tabBar()->tabAt( oldIndex )->rect().tqcontains( pressPoint ) )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FormWindow *fw = find_formwindow( this );
|
|
|
|
MoveTabPageCommand *cmd =
|
|
|
|
new MoveTabPageCommand( i18n("Move Tab Page" ), fw, this,
|
|
|
|
dragPage, dragLabel, newIndex, oldIndex );
|
|
|
|
fw->commandHistory()->addCommand( cmd );
|
|
|
|
cmd->execute();
|
|
|
|
de->accept();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EditorToolBox::EditorToolBox( TQWidget *tqparent, const char *name )
|
|
|
|
: ToolBox( tqparent, name )
|
|
|
|
{
|
|
|
|
setAcceptDrops( true );
|
|
|
|
}
|
|
|
|
|
|
|
|
int EditorToolBox::currentPage() const
|
|
|
|
{
|
|
|
|
return currentIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorToolBox::setCurrentPage( int i )
|
|
|
|
{
|
|
|
|
setCurrentItem( item( i ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQString EditorToolBox::pageTitle() const
|
|
|
|
{
|
|
|
|
return itemLabel( currentIndex() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorToolBox::setPageTitle( const TQString& title )
|
|
|
|
{
|
|
|
|
setItemLabel( currentIndex(), title );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorToolBox::setPageName( const TQCString& name )
|
|
|
|
{
|
|
|
|
if ( currentItem() )
|
|
|
|
currentItem()->setName( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQCString EditorToolBox::pageName() const
|
|
|
|
{
|
|
|
|
if ( !currentItem() )
|
|
|
|
return 0;
|
|
|
|
return currentItem()->name();
|
|
|
|
}
|
|
|
|
|
|
|
|
int EditorToolBox::count() const
|
|
|
|
{
|
|
|
|
return TQToolBox::count();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! Creates a widget of the type which is registered as \a id as
|
|
|
|
child of \a tqparent. The \a name is optional. If \a init is true, the
|
|
|
|
widget is initialized with some defaults, else the plain widget is
|
|
|
|
created.
|
|
|
|
*/
|
|
|
|
|
|
|
|
TQWidget *WidgetFactory::create( int id, TQWidget *tqparent, const char *name, bool init, const TQRect *r, Qt::Orientation orient )
|
|
|
|
{
|
|
|
|
TQString n = WidgetDatabase::className(id);
|
|
|
|
//qDebug("Trying to create '%s'", n.latin1());
|
|
|
|
if (n.isEmpty())
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!defaultProperties)
|
|
|
|
{
|
|
|
|
defaultProperties = new TQMap < int, TQMap < TQString, TQVariant > >();
|
|
|
|
changedProperties = new TQMap < int, TQStringList > ();
|
|
|
|
}
|
|
|
|
|
|
|
|
TQWidget *w = 0;
|
|
|
|
TQString str = WidgetDatabase::createWidgetName(id);
|
|
|
|
const char *s = str.latin1();
|
|
|
|
w = createWidget(n, tqparent, name ? name : s, init, r, orient);
|
|
|
|
//qDebug("Trying to create '%s', widget (id=%d) - %s", s, id, w ? "successful" : "failure");
|
|
|
|
if (!w && WidgetDatabase::isCustomWidget(id))
|
|
|
|
w = createCustomWidget(tqparent, name ? name : s, MetaDataBase::customWidget(id));
|
|
|
|
if (!w)
|
|
|
|
return 0;
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
|
|
|
|
if (!defaultProperties->tqcontains(id))
|
|
|
|
saveDefaultProperties(w, id);
|
|
|
|
if (!changedProperties->tqcontains(id))
|
|
|
|
saveChangedProperties(w, id);
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Creates a tqlayout on the widget \a widget of the type \a type
|
|
|
|
which can be \c HBox, \c VBox or \c Grid.
|
|
|
|
*/
|
|
|
|
|
|
|
|
TQLayout *WidgetFactory::createLayout( TQWidget *widget, TQLayout *tqlayout, LayoutType type )
|
|
|
|
{
|
|
|
|
int spacing = MainWindow::self->currentLayoutDefaultSpacing();
|
|
|
|
int margin = 0;
|
|
|
|
|
|
|
|
if ( widget && !widget->inherits( TQLAYOUTWIDGET_OBJECT_NAME_STRING ) &&
|
|
|
|
( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(widget) ) ) ) ||
|
|
|
|
widget && widget->tqparentWidget() && widget->tqparentWidget()->inherits( "FormWindow" ) ) )
|
|
|
|
margin = MainWindow::self->currentLayoutDefaultMargin();
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQTABWIDGET_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQTabWidget*)widget)->currentPage();
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQTOOLBOX_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQToolBox*)widget)->currentItem();
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQWIZARD_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQWizard*)widget)->currentPage();
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQMainWindow*)widget)->centralWidget();
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQWIDGETSTACK_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQWidgetStack*)widget)->visibleWidget();
|
|
|
|
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(widget) );
|
|
|
|
|
|
|
|
if ( !tqlayout && widget && widget->inherits( TQGROUPBOX_OBJECT_NAME_STRING ) ) {
|
|
|
|
TQGroupBox *gb = (TQGroupBox*)widget;
|
|
|
|
gb->setColumnLayout( 0, Qt::Vertical );
|
|
|
|
gb->tqlayout()->setMargin( 0 );
|
|
|
|
gb->tqlayout()->setSpacing( 0 );
|
|
|
|
TQLayout *l;
|
|
|
|
switch ( type ) {
|
|
|
|
case HBox:
|
|
|
|
l = new TQHBoxLayout( gb->tqlayout() );
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing );
|
|
|
|
l->tqsetAlignment( AlignTop );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case VBox:
|
|
|
|
l = new TQVBoxLayout( gb->tqlayout(), spacing );
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing );
|
|
|
|
l->tqsetAlignment( AlignTop );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case Grid:
|
|
|
|
l = new TQDesignerGridLayout( gb->tqlayout() );
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(gb), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(gb), spacing );
|
|
|
|
l->tqsetAlignment( AlignTop );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if ( tqlayout ) {
|
|
|
|
TQLayout *l;
|
|
|
|
switch ( type ) {
|
|
|
|
case HBox:
|
|
|
|
l = new TQHBoxLayout( tqlayout );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
l->setSpacing( spacing );
|
|
|
|
l->setMargin( margin );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case VBox:
|
|
|
|
l = new TQVBoxLayout( tqlayout );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
l->setSpacing( spacing );
|
|
|
|
l->setMargin( margin );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case Grid: {
|
|
|
|
l = new TQDesignerGridLayout( tqlayout );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
l->setSpacing( spacing );
|
|
|
|
l->setMargin( margin );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
TQLayout *l;
|
|
|
|
switch ( type ) {
|
|
|
|
case HBox:
|
|
|
|
l = new TQHBoxLayout( widget );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
if ( widget ) {
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing );
|
|
|
|
} else {
|
|
|
|
l->setMargin( margin );
|
|
|
|
l->setSpacing( margin );
|
|
|
|
}
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case VBox:
|
|
|
|
l = new TQVBoxLayout( widget );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
if ( widget ) {
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing );
|
|
|
|
} else {
|
|
|
|
l->setMargin( margin );
|
|
|
|
l->setSpacing( margin );
|
|
|
|
}
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
case Grid: {
|
|
|
|
l = new TQDesignerGridLayout( widget );
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
if ( widget ) {
|
|
|
|
MetaDataBase::setMargin( TQT_TQOBJECT(widget), margin );
|
|
|
|
MetaDataBase::setSpacing( TQT_TQOBJECT(widget), spacing );
|
|
|
|
} else {
|
|
|
|
l->setMargin( margin );
|
|
|
|
l->setSpacing( margin );
|
|
|
|
}
|
|
|
|
MetaDataBase::addEntry( TQT_TQOBJECT(l) );
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WidgetFactory::deleteLayout( TQWidget *widget )
|
|
|
|
{
|
|
|
|
if ( !widget )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( widget->inherits( TQTABWIDGET_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQTabWidget*)widget)->currentPage();
|
|
|
|
if ( widget->inherits( TQWIZARD_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQWizard*)widget)->currentPage();
|
|
|
|
if ( widget->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQMainWindow*)widget)->centralWidget();
|
|
|
|
if ( widget->inherits( TQWIDGETSTACK_OBJECT_NAME_STRING ) )
|
|
|
|
widget = ((TQWidgetStack*)widget)->visibleWidget();
|
|
|
|
delete widget->tqlayout();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Factory functions for creating a widget of the type \a className
|
|
|
|
as child of \a tqparent with the name \a name.
|
|
|
|
|
|
|
|
If \a init is true, some initial default properties are set. This
|
|
|
|
has to be in sync with the initChangedProperties() function!
|
|
|
|
*/
|
|
|
|
|
|
|
|
TQWidget *WidgetFactory::createWidget( const TQString &className, TQWidget *tqparent, const char *name, bool init,
|
|
|
|
const TQRect *r, Qt::Orientation orient )
|
|
|
|
{
|
|
|
|
if (className == TQPUSHBUTTON_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQPushButton *b = 0;
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
b = new TQDesignerPushButton(tqparent, name);
|
|
|
|
b->setText(TQString::tqfromLatin1(name));
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
b = new TQDesignerPushButton(tqparent, name);
|
|
|
|
}
|
|
|
|
TQWidget *w = find_formwindow(b);
|
|
|
|
b->setAutoDefault(w && ((FormWindow *) w)->mainContainer()->inherits(TQDIALOG_OBJECT_NAME_STRING));
|
|
|
|
return b;
|
|
|
|
} else if (className == TQTOOLBUTTON_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
TQDesignerToolButton *tb = new TQDesignerToolButton(tqparent, name);
|
|
|
|
tb->setText("...");
|
|
|
|
return tb;
|
|
|
|
}
|
|
|
|
return new TQDesignerToolButton(tqparent, name);
|
|
|
|
} else if (className == TQCHECKBOX_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
TQDesignerCheckBox *cb = new TQDesignerCheckBox(tqparent, name);
|
|
|
|
cb->setText(TQString::tqfromLatin1(name));
|
|
|
|
return cb;
|
|
|
|
}
|
|
|
|
return new TQDesignerCheckBox(tqparent, name);
|
|
|
|
} else if (className == TQRADIOBUTTON_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
TQDesignerRadioButton *rb = new TQDesignerRadioButton(tqparent, name);
|
|
|
|
rb->setText(TQString::tqfromLatin1(name));
|
|
|
|
return rb;
|
|
|
|
}
|
|
|
|
return new TQDesignerRadioButton(tqparent, name);
|
|
|
|
} else if (className == TQGROUPBOX_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (init)
|
|
|
|
return new TQGroupBox(TQString::tqfromLatin1(name), tqparent, name);
|
|
|
|
return new TQGroupBox(tqparent, name);
|
|
|
|
} else if (className == TQBUTTONGROUP_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (init)
|
|
|
|
return new TQButtonGroup(TQString::tqfromLatin1(name), tqparent, name);
|
|
|
|
return new TQButtonGroup(tqparent, name);
|
|
|
|
} else if (className == TQICONVIEW_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
#if !defined(TQT_NO_ICONVIEW)
|
|
|
|
TQIconView *iv = new TQIconView(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
(void) new TQIconViewItem(iv, i18n("New Item"));
|
|
|
|
return iv;
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
} else if (className == TQTABLE_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
#if !defined(TQT_NO_TABLE)
|
|
|
|
if (init)
|
|
|
|
return new TQTable(3, 3, tqparent, name);
|
|
|
|
return new TQTable(tqparent, name);
|
|
|
|
#else
|
|
|
|
return 0;
|
|
|
|
#endif
|
|
|
|
#ifndef TQT_NO_SQL
|
|
|
|
} else if (className == TQDATATABLE_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
return new TQDataTable(tqparent, name);
|
|
|
|
#endif //TQT_NO_SQL
|
|
|
|
} else if (className == TQDATEEDIT_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
return new TQDateEdit(tqparent, name);
|
|
|
|
} else if (className == TQTIMEEDIT_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
return new TQTimeEdit(tqparent, name);
|
|
|
|
} else if (className == TQDATETIMEEDIT_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
return new TQDateTimeEdit(tqparent, name);
|
|
|
|
} else if (className == TQLISTBOX_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQListBox *lb = new TQListBox(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
lb->insertItem(i18n("New Item"));
|
|
|
|
lb->setCurrentItem(0);
|
|
|
|
}
|
|
|
|
return lb;
|
|
|
|
} else if (className == TQLISTVIEW_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQListView *lv = new TQListView(tqparent, name);
|
|
|
|
lv->setSorting(-1);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
lv->addColumn(i18n("Column 1"));
|
|
|
|
lv->setCurrentItem(new TQListViewItem(lv, i18n("New Item")));
|
|
|
|
}
|
|
|
|
return lv;
|
|
|
|
} else if (className == TQLINEEDIT_OBJECT_NAME_STRING)
|
|
|
|
return new TQLineEdit(tqparent, name);
|
|
|
|
else if (className == TQSPINBOX_OBJECT_NAME_STRING)
|
|
|
|
return new TQSpinBox(tqparent, name);
|
|
|
|
else if (className == TQSPLITTER_OBJECT_NAME_STRING)
|
|
|
|
return new TQSplitter(tqparent, name);
|
|
|
|
else if (className == TQMULTILINEEDIT_OBJECT_NAME_STRING)
|
|
|
|
return new TQMultiLineEdit(tqparent, name);
|
|
|
|
else if (className == TQTEXTEDIT_OBJECT_NAME_STRING)
|
|
|
|
return new TQTextEdit(tqparent, name);
|
|
|
|
else if (className == TQLABEL_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQDesignerLabel *l = new TQDesignerLabel(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
l->setText(TQString::tqfromLatin1(name));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(l));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(l), "text", true);
|
|
|
|
}
|
|
|
|
return l;
|
|
|
|
} else if (className == TQLAYOUTWIDGET_OBJECT_NAME_STRING)
|
|
|
|
return new TQLayoutWidget(tqparent, name);
|
|
|
|
else if (className == TQTABWIDGET_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQTabWidget *tw = new TQDesignerTabWidget(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
FormWindow *fw = find_formwindow(tqparent);
|
|
|
|
TQWidget *w = fw ? new TQDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab");
|
|
|
|
tw->addTab(w, i18n("Tab 1"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
w = fw ? new TQDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab");
|
|
|
|
tw->addTab(w, i18n("Tab 2"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(tw));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
}
|
|
|
|
return tw;
|
|
|
|
} else if (className == TQCOMBOBOX_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
return new TQComboBox(false, tqparent, name);
|
|
|
|
} else if (className == TQWIDGET_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (tqparent &&
|
|
|
|
(tqparent->inherits("FormWindow") || tqparent->inherits(TQWIZARD_OBJECT_NAME_STRING)
|
|
|
|
|| tqparent->inherits(TQTABWIDGET_OBJECT_NAME_STRING) || tqparent->inherits(TQTOOLBOX_OBJECT_NAME_STRING) || tqparent->inherits(TQMAINWINDOW_OBJECT_NAME_STRING)))
|
|
|
|
{
|
|
|
|
FormWindow *fw = find_formwindow(tqparent);
|
|
|
|
if (fw)
|
|
|
|
{
|
|
|
|
TQDesignerWidget *dw = new TQDesignerWidget(fw, tqparent, name);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(dw));
|
|
|
|
return dw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new TQWidget(tqparent, name);
|
|
|
|
} else if (className == TQDIALOG_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQDialog *dia = 0;
|
|
|
|
if (tqparent && tqparent->inherits("FormWindow"))
|
|
|
|
dia = new TQDesignerDialog((FormWindow *) tqparent, tqparent, name);
|
|
|
|
else
|
|
|
|
dia = new TQDialog(tqparent, name);
|
|
|
|
if (tqparent && !tqparent->inherits("MainWindow"))
|
|
|
|
dia->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
return dia;
|
|
|
|
} else if (className == TQWIZARD_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQWizard *wiz = new TQDesignerWizard(tqparent, name);
|
|
|
|
if (tqparent && !tqparent->inherits("MainWindow"))
|
|
|
|
{
|
|
|
|
wiz->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
}
|
|
|
|
if (init && tqparent && tqparent->inherits("FormWindow"))
|
|
|
|
{
|
|
|
|
TQDesignerWidget *dw = new TQDesignerWidget((FormWindow *) tqparent, wiz, "page");
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(dw));
|
|
|
|
wiz->addPage(dw, i18n("Page"));
|
|
|
|
TQTimer::singleShot(0, wiz, TQT_SLOT(next()));
|
|
|
|
}
|
|
|
|
return wiz;
|
|
|
|
} else if (className == "Spacer")
|
|
|
|
{
|
|
|
|
Spacer *s = new Spacer(tqparent, name);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(s));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true);
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "sizeType", true);
|
|
|
|
if (!r)
|
|
|
|
return s;
|
|
|
|
if (!r->isValid() || r->width() < 2 && r->height() < 2)
|
|
|
|
s->setOrientation(orient);
|
|
|
|
else if (r->width() < r->height())
|
|
|
|
s->setOrientation(Qt::Vertical);
|
|
|
|
else
|
|
|
|
s->setOrientation(Qt::Horizontal);
|
|
|
|
return s;
|
|
|
|
} else if (className == TQLCDNUMBER_OBJECT_NAME_STRING)
|
|
|
|
return new TQLCDNumber(tqparent, name);
|
|
|
|
else if (className == TQPROGRESSBAR_OBJECT_NAME_STRING)
|
|
|
|
return new TQProgressBar(tqparent, name);
|
|
|
|
else if (className == TQTEXTVIEW_OBJECT_NAME_STRING)
|
|
|
|
return new TQTextView(tqparent, name);
|
|
|
|
else if (className == TQTEXTBROWSER_OBJECT_NAME_STRING)
|
|
|
|
return new TQTextBrowser(tqparent, name);
|
|
|
|
else if (className == TQDIAL_OBJECT_NAME_STRING)
|
|
|
|
return new TQDial(tqparent, name);
|
|
|
|
else if (className == TQSLIDER_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQSlider *s = new TQSlider(tqparent, name);
|
|
|
|
if (!r)
|
|
|
|
return s;
|
|
|
|
if (!r->isValid() || r->width() < 2 && r->height() < 2)
|
|
|
|
s->setOrientation(orient);
|
|
|
|
else if (r->width() > r->height())
|
|
|
|
s->setOrientation(Qt::Horizontal);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(s));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true);
|
|
|
|
return s;
|
|
|
|
} else if (className == TQSCROLLBAR_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQScrollBar *s = new TQScrollBar(tqparent, name);
|
|
|
|
if (!r)
|
|
|
|
return s;
|
|
|
|
if (!r->isValid() || r->width() < 2 && r->height() < 2)
|
|
|
|
s->setOrientation(orient);
|
|
|
|
else if (r->width() > r->height())
|
|
|
|
s->setOrientation(Qt::Horizontal);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(s));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true);
|
|
|
|
return s;
|
|
|
|
} else if (className == TQFRAME_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
if (!init)
|
|
|
|
return new TQFrame(tqparent, name);
|
|
|
|
TQFrame *f = new TQFrame(tqparent, name);
|
|
|
|
f->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised);
|
|
|
|
return f;
|
|
|
|
} else if (className == "Line")
|
|
|
|
{
|
|
|
|
Line *l = new Line(tqparent, name);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(l));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(l), "orientation", true);
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(l), "frameShadow", true);
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(l), "frameShape", true);
|
|
|
|
if (!r)
|
|
|
|
return l;
|
|
|
|
if (!r->isValid() || r->width() < 2 && r->height() < 2)
|
|
|
|
l->setOrientation(orient);
|
|
|
|
else if (r->width() < r->height())
|
|
|
|
l->setOrientation(Qt::Vertical);
|
|
|
|
return l;
|
|
|
|
} else if (className == TQMAINWINDOW_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQMainWindow *mw = new KmdrMainWindow(tqparent, name, 0);
|
|
|
|
mw->setDockEnabled(TQt::DockMinimized, false);
|
|
|
|
TQDesignerWidget *dw = new TQDesignerWidget((FormWindow *) tqparent, mw, "central widget");
|
|
|
|
mw->setDockMenuEnabled(false);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(dw));
|
|
|
|
mw->setCentralWidget(dw);
|
|
|
|
(void) mw->statusBar();
|
|
|
|
dw->show();
|
|
|
|
return mw;
|
|
|
|
}
|
|
|
|
#ifndef TQT_NO_SQL
|
|
|
|
else if (className == TQDATABROWSER_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQWidget *w = new TQDesignerDataBrowser(tqparent, name);
|
|
|
|
if (tqparent)
|
|
|
|
w->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
return w;
|
|
|
|
} else if (className == TQDATAVIEW_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
TQWidget *w = new TQDesignerDataView(tqparent, name);
|
|
|
|
if (tqparent)
|
|
|
|
w->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef KOMMANDER
|
|
|
|
|
|
|
|
if (className == "LineEdit")
|
|
|
|
return new LineEdit(tqparent, name);
|
|
|
|
else if (className == "ListView")
|
|
|
|
{
|
|
|
|
TQListView *lv = new TQListView(tqparent, name);
|
|
|
|
lv->setSorting(-1);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
lv->addColumn(i18n("Column 1"));
|
|
|
|
lv->setCurrentItem(new TQListViewItem(lv, i18n("New Item")));
|
|
|
|
}
|
|
|
|
return lv;
|
|
|
|
}
|
|
|
|
else if (className == "Dialog")
|
|
|
|
{
|
|
|
|
TQDialog *dia = 0;
|
|
|
|
if (tqparent && tqparent->inherits("FormWindow"))
|
|
|
|
dia = new EditorDialog((FormWindow *) tqparent, tqparent, name);
|
|
|
|
else
|
|
|
|
dia = new Dialog(tqparent, name, false);
|
|
|
|
|
|
|
|
if (tqparent)
|
|
|
|
dia->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
return dia;
|
|
|
|
}
|
|
|
|
else if (className == "Wizard")
|
|
|
|
{
|
|
|
|
//qDebug("Creating Wizard...");
|
|
|
|
TQWizard *wiz;
|
|
|
|
if (tqparent && tqparent->inherits("FormWindow"))
|
|
|
|
wiz = new TQDesignerWizard(tqparent, name);
|
|
|
|
else
|
|
|
|
wiz = new Wizard(tqparent, name);
|
|
|
|
if (tqparent)
|
|
|
|
wiz->reparent(tqparent, TQPoint(0, 0), true);
|
|
|
|
if (init && tqparent && tqparent->inherits("FormWindow"))
|
|
|
|
{
|
|
|
|
TQDesignerWidget *dw = new TQDesignerWidget((FormWindow *) tqparent, wiz, "page");
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(dw));
|
|
|
|
wiz->addPage(dw, i18n("Page 1"));
|
|
|
|
wiz->addPage(dw, i18n("Page 2"));
|
|
|
|
TQTimer::singleShot(0, wiz, TQT_SLOT(next()));
|
|
|
|
}
|
|
|
|
return wiz;
|
|
|
|
}
|
|
|
|
else if (className == "TabWidget")
|
|
|
|
{
|
|
|
|
TQTabWidget *tw = new EditorTabWidget(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
FormWindow *fw = find_formwindow(tqparent);
|
|
|
|
TQWidget *w = fw ? new TQDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab");
|
|
|
|
tw->addTab(w, i18n("Tab 1"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
w = fw ? new TQDesignerWidget(fw, tw, "tab") : new TQWidget(tw, "tab");
|
|
|
|
tw->addTab(w, i18n("Tab 2"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(tw));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
}
|
|
|
|
return tw;
|
|
|
|
} else if (className == "ToolBox")
|
|
|
|
{
|
|
|
|
TQToolBox *tw = new EditorToolBox(tqparent, name);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
FormWindow *fw = find_formwindow(tqparent);
|
|
|
|
TQWidget *w = fw ? new TQDesignerWidget(fw, tw, "toolbox") : new TQWidget(tw, "toolbox");
|
|
|
|
tw->addItem(w, i18n("Page 1"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
w = fw ? new TQDesignerWidget(fw, tw, "toolbox") : new TQWidget(tw, "toolbox");
|
|
|
|
tw->addItem(w, i18n("Page 2"));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(tw));
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(w));
|
|
|
|
}
|
|
|
|
return tw;
|
|
|
|
}
|
|
|
|
else if (className == "ExecButton")
|
|
|
|
return new ExecButton(tqparent, name);
|
|
|
|
else if (className == "CloseButton")
|
|
|
|
return new CloseButton(tqparent, name);
|
|
|
|
else if (className == "SubDialog")
|
|
|
|
return new SubDialog(tqparent, name);
|
|
|
|
else if (className == "FileSelector")
|
|
|
|
return new FileSelector(tqparent, name);
|
|
|
|
else if (className == "TextEdit")
|
|
|
|
return new TextEdit(tqparent, name);
|
|
|
|
else if (className == "RadioButton")
|
|
|
|
return new RadioButton(tqparent, name);
|
|
|
|
else if (className == "ButtonGroup")
|
|
|
|
return new ButtonGroup(tqparent, name);
|
|
|
|
else if (className == "GroupBox")
|
|
|
|
return new GroupBox(tqparent, name);
|
|
|
|
else if (className == "CheckBox")
|
|
|
|
return new CheckBox(tqparent, name);
|
|
|
|
else if (className == "ComboBox")
|
|
|
|
return new ComboBox(tqparent, name);
|
|
|
|
else if (className == "SpinBoxInt")
|
|
|
|
return new SpinBoxInt(tqparent, name);
|
|
|
|
else if (className == "ListBox")
|
|
|
|
return new ListBox(tqparent, name);
|
|
|
|
else if (className == "ScriptObject")
|
|
|
|
return new ScriptObject(tqparent, name);
|
|
|
|
else if (className == "RichTextEditor")
|
|
|
|
return new RichTextEditor(tqparent, name);
|
|
|
|
else if (className == "DatePicker")
|
|
|
|
return new DatePicker(tqparent, name);
|
|
|
|
else if (className == "PopupMenu")
|
|
|
|
return new PopupMenu(tqparent, name);
|
|
|
|
else if (className == "FontDialog")
|
|
|
|
return new FontDialog(tqparent, name);
|
|
|
|
else if (className == "AboutDialog")
|
|
|
|
return new AboutDialog(tqparent, name);
|
|
|
|
else if (className == "TreeWidget")
|
|
|
|
{
|
|
|
|
TQListView *lv = new TreeWidget(tqparent, name);
|
|
|
|
lv->setSorting(-1);
|
|
|
|
if (init)
|
|
|
|
{
|
|
|
|
lv->addColumn(i18n("Column 1"));
|
|
|
|
lv->setCurrentItem(new TQListViewItem(lv, i18n("New Item")));
|
|
|
|
}
|
|
|
|
return lv;
|
|
|
|
} else if (className == "Slider")
|
|
|
|
{
|
|
|
|
Slider *s = new Slider(tqparent, name);
|
|
|
|
if (!r)
|
|
|
|
return s;
|
|
|
|
if (!r->isValid() || r->width() < 2 && r->height() < 2)
|
|
|
|
s->setOrientation(orient);
|
|
|
|
else if (r->width() > r->height())
|
|
|
|
s->setOrientation(Qt::Horizontal);
|
|
|
|
MetaDataBase::addEntry(TQT_TQOBJECT(s));
|
|
|
|
MetaDataBase::setPropertyChanged(TQT_TQOBJECT(s), "orientation", true);
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
TQWidget *w = KommanderFactory::createWidget(className, tqparent, name);
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*! Find out which type the tqlayout of the widget is. Returns \c HBox,
|
|
|
|
\c VBox, \c Grid or \c NoLayout. \a tqlayout points to this
|
|
|
|
TQWidget::tqlayout() of \a w or to 0 after the function call.
|
|
|
|
*/
|
|
|
|
|
|
|
|
WidgetFactory::LayoutType WidgetFactory::tqlayoutType( TQWidget *w, TQLayout *&tqlayout )
|
|
|
|
{
|
|
|
|
tqlayout = 0;
|
|
|
|
|
|
|
|
if ( w && w->inherits( TQTABWIDGET_OBJECT_NAME_STRING ) )
|
|
|
|
w = ((TQTabWidget*)w)->currentPage();
|
|
|
|
if ( w->inherits( TQTOOLBOX_OBJECT_NAME_STRING ) )
|
|
|
|
w = ((TQToolBox*)w)->currentItem();
|
|
|
|
if ( w && w->inherits( TQWIZARD_OBJECT_NAME_STRING ) )
|
|
|
|
w = ((TQWizard*)w)->currentPage();
|
|
|
|
if ( w && w->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) )
|
|
|
|
w = ((TQMainWindow*)w)->centralWidget();
|
|
|
|
if ( w && w->inherits( TQWIDGETSTACK_OBJECT_NAME_STRING ) )
|
|
|
|
w = ((TQWidgetStack*)w)->visibleWidget();
|
|
|
|
|
|
|
|
if ( w && w->inherits( TQSPLITTER_OBJECT_NAME_STRING ) )
|
|
|
|
return ( (TQSplitter*)w )->orientation() ==Qt::Horizontal ? HBox : VBox;
|
|
|
|
|
|
|
|
if ( !w || !w->tqlayout() )
|
|
|
|
return NoLayout;
|
|
|
|
TQLayout *lay = w->tqlayout();
|
|
|
|
|
|
|
|
if ( w->inherits( TQGROUPBOX_OBJECT_NAME_STRING ) ) {
|
|
|
|
TQObjectList *l = TQT_TQOBJECT(lay)->queryList( TQLAYOUT_OBJECT_NAME_STRING );
|
|
|
|
if ( l && l->first() )
|
|
|
|
lay = (TQLayout*)l->first();
|
|
|
|
delete l;
|
|
|
|
}
|
|
|
|
tqlayout = lay;
|
|
|
|
|
|
|
|
if ( lay->inherits( TQHBOXLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return HBox;
|
|
|
|
else if ( lay->inherits( TQVBOXLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return VBox;
|
|
|
|
else if ( lay->inherits( TQGRIDLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return Grid;
|
|
|
|
return NoLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
*/
|
|
|
|
WidgetFactory::LayoutType WidgetFactory::tqlayoutType( TQLayout *tqlayout )
|
|
|
|
{
|
|
|
|
if ( tqlayout->inherits( TQHBOXLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return HBox;
|
|
|
|
else if ( tqlayout->inherits( TQVBOXLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return VBox;
|
|
|
|
else if ( tqlayout->inherits( TQGRIDLAYOUT_OBJECT_NAME_STRING ) )
|
|
|
|
return Grid;
|
|
|
|
return NoLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\overload
|
|
|
|
*/
|
|
|
|
WidgetFactory::LayoutType WidgetFactory::tqlayoutType( TQWidget *w )
|
|
|
|
{
|
|
|
|
TQLayout *l = 0;
|
|
|
|
return tqlayoutType( w, l );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQWidget *WidgetFactory::tqlayoutParent( TQLayout *tqlayout )
|
|
|
|
{
|
|
|
|
TQObject *o = TQT_TQOBJECT(tqlayout);
|
|
|
|
while ( o ) {
|
|
|
|
if ( o->isWidgetType() )
|
|
|
|
return (TQWidget*)o;
|
|
|
|
o = o->tqparent();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Returns the widget into which tqchildren should be inserted when \a
|
|
|
|
w is a container known to the designer.
|
|
|
|
|
|
|
|
Usually that is \a w itself, sometimes it is different (e.g. a
|
|
|
|
tabwidget is known to the designer as a container but the child
|
|
|
|
widgets should be inserted into the current page of the
|
|
|
|
tabwidget. So in this case this function returns the current page of
|
|
|
|
the tabwidget.)
|
|
|
|
*/
|
|
|
|
TQWidget* WidgetFactory::containerOfWidget( TQWidget *w )
|
|
|
|
{
|
|
|
|
if ( !w )
|
|
|
|
return w;
|
|
|
|
if ( w->inherits( TQTABWIDGET_OBJECT_NAME_STRING ) )
|
|
|
|
return ((TQTabWidget*)w)->currentPage();
|
|
|
|
if ( w->inherits( TQTOOLBOX_OBJECT_NAME_STRING ) )
|
|
|
|
return ((TQToolBox*)w)->currentItem();
|
|
|
|
if ( w->inherits( TQWIZARD_OBJECT_NAME_STRING ) )
|
|
|
|
return ((TQWizard*)w)->currentPage();
|
|
|
|
if ( w->inherits( TQWIDGETSTACK_OBJECT_NAME_STRING ) )
|
|
|
|
return ((TQWidgetStack*)w)->visibleWidget();
|
|
|
|
if ( w->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) )
|
|
|
|
return ((TQMainWindow*)w)->centralWidget();
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! Returns the actual designer widget of the container \a w. This is
|
|
|
|
normally \a w itself, but might be a tqparent or grand tqparent of \a w
|
|
|
|
(e.g. when working with a tabwidget and \a w is the container which
|
|
|
|
contains and tqlayouts childs, but the actual widget known to the
|
|
|
|
designer is the tabwidget which is the tqparent of \a w. So this
|
|
|
|
function returns the tabwidget then.)
|
|
|
|
*/
|
|
|
|
|
|
|
|
TQWidget* WidgetFactory::widgetOfContainer( TQWidget *w )
|
|
|
|
{
|
|
|
|
if ( w->tqparentWidget() && w->tqparentWidget()->inherits( TQWIDGETSTACK_OBJECT_NAME_STRING ) )
|
|
|
|
w = w->tqparentWidget();
|
|
|
|
while ( w ) {
|
|
|
|
if ( WidgetDatabase::isContainer( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( TQT_TQOBJECT(w) ) ) ) ||
|
|
|
|
w && w->tqparentWidget() && w->tqparentWidget()->inherits( "FormWindow" ) )
|
|
|
|
return w;
|
|
|
|
w = w->tqparentWidget();
|
|
|
|
}
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns whether \a o is a passive interactor or not.
|
|
|
|
*/
|
|
|
|
bool WidgetFactory::isPassiveInteractor( TQObject* o )
|
|
|
|
{
|
|
|
|
if ( TQApplication::activePopupWidget() ) // if a popup is open, we have to make sure that this one is closed, else X might do funny things
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( o->inherits( TQTABBAR_OBJECT_NAME_STRING ) || ::tqqt_cast<TQToolBox*>(o->tqparent()) )
|
|
|
|
return true;
|
|
|
|
else if ( o->inherits( TQSIZEGRIP_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
else if ( o->inherits( TQTOOLBUTTON_OBJECT_NAME_STRING ) && o->tqparent() && o->tqparent()->inherits( TQTABBAR_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
else if ( o->tqparent() && o->tqparent()->inherits( TQWIZARD_OBJECT_NAME_STRING ) && o->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
else if ( o->tqparent() && o->tqparent()->inherits( TQMAINWINDOW_OBJECT_NAME_STRING ) && o->inherits( TQMENUBAR_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
else if ( o->inherits( TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
else if ( o->inherits( TQHIDEDOCK_OBJECT_NAME_STRING ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the class name of object \a o that should be used for externally (i.e. for saving)
|
|
|
|
*/
|
|
|
|
const char* WidgetFactory::classNameOf( TQObject* o )
|
|
|
|
{
|
|
|
|
if (o->inherits("TQDesignerTabWidget"))
|
|
|
|
return TQTABWIDGET_OBJECT_NAME_STRING;
|
|
|
|
#ifdef KOMMANDER
|
|
|
|
else if (o->inherits("EditorTabWidget"))
|
|
|
|
return "TabWidget";
|
|
|
|
else if (o->inherits("EditorToolBox"))
|
|
|
|
return "ToolBox";
|
|
|
|
#endif
|
|
|
|
else if (o->inherits("TQDesignerDialog"))
|
|
|
|
return TQDIALOG_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerWidget"))
|
|
|
|
return TQWIDGET_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("CustomWidget"))
|
|
|
|
return ((CustomWidget *) o)->realClassName().latin1();
|
|
|
|
else if (o->inherits("TQDesignerLabel"))
|
|
|
|
return TQLABEL_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerWizard"))
|
|
|
|
return TQWIZARD_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("EditorWizard"))
|
|
|
|
return "Wizard";
|
|
|
|
else if (o->inherits("TQDesignerPushButton"))
|
|
|
|
return TQPUSHBUTTON_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerToolButton"))
|
|
|
|
return TQTOOLBUTTON_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerRadioButton"))
|
|
|
|
return TQRADIOBUTTON_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerCheckBox"))
|
|
|
|
return TQCHECKBOX_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerMenuBar"))
|
|
|
|
return TQMENUBAR_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerToolBar"))
|
|
|
|
return TQTOOLBAR_OBJECT_NAME_STRING;
|
|
|
|
#ifndef TQT_NO_SQL
|
|
|
|
else if (o->inherits("TQDesignerDataBrowser"))
|
|
|
|
return TQDATABROWSER_OBJECT_NAME_STRING;
|
|
|
|
else if (o->inherits("TQDesignerDataView"))
|
|
|
|
return TQDATAVIEW_OBJECT_NAME_STRING;
|
|
|
|
#endif
|
|
|
|
else if (o->inherits("EditorDialog"))
|
|
|
|
return "Dialog";
|
|
|
|
return o->className();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*! As some properties are set by default when creating a widget this
|
|
|
|
functions markes this properties as changed. Has to be in sync with
|
|
|
|
createWidget()!
|
|
|
|
*/
|
|
|
|
|
|
|
|
void WidgetFactory::initChangedProperties( TQObject *o )
|
|
|
|
{
|
|
|
|
MetaDataBase::setPropertyChanged( o, "name", true );
|
|
|
|
if ( !o->inherits( "TQDesignerToolBar" ) && !o->inherits( "TQDesignerMenuBar" ) )
|
|
|
|
MetaDataBase::setPropertyChanged( o, "geometry", true );
|
|
|
|
|
|
|
|
if ( o->inherits( TQPUSHBUTTON_OBJECT_NAME_STRING ) || o->inherits(TQRADIOBUTTON_OBJECT_NAME_STRING) || o->inherits( TQCHECKBOX_OBJECT_NAME_STRING ) || o->inherits( TQTOOLBUTTON_OBJECT_NAME_STRING ) )
|
|
|
|
MetaDataBase::setPropertyChanged( o, "text", true );
|
|
|
|
else if (::tqqt_cast<TQToolButton*>(o) && ::tqqt_cast<TQToolBox*>(widgetOfContainer((TQWidget*)o->tqparent()))) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "usesTextLabel", TRUE );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "textLabel", TRUE );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "autoRaise", TRUE );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "textPosition", TRUE );
|
|
|
|
} else if ( o->inherits( TQGROUPBOX_OBJECT_NAME_STRING ) )
|
|
|
|
MetaDataBase::setPropertyChanged( o, "title", true );
|
|
|
|
else if ( o->isA( TQFRAME_OBJECT_NAME_STRING ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "frameShadow", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "frameShape", true );
|
|
|
|
} else if ( o->inherits( TQTABWIDGET_OBJECT_NAME_STRING ) || o->inherits( TQWIZARD_OBJECT_NAME_STRING ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "pageTitle", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "pageName", true );
|
|
|
|
#ifndef TQT_NO_TABLE
|
|
|
|
} else if ( o->inherits( TQTABLE_OBJECT_NAME_STRING ) && !o->inherits( TQDATATABLE_OBJECT_NAME_STRING ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "numRows", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "numCols", true );
|
|
|
|
TQTable *t = (TQTable*)o;
|
|
|
|
for ( int i = 0; i < 3; ++i ) {
|
|
|
|
t->horizontalHeader()->setLabel( i, TQString::number( i + 1 ) );
|
|
|
|
t->verticalHeader()->setLabel( i, TQString::number( i + 1 ) );
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
} else if ( ::tqqt_cast<TQToolBox*>(o) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "currentIndex", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemName", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemLabel", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemIconSet", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemToolTip", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemBackgroundMode", true );
|
|
|
|
} else if ( o->inherits( TQSPLITTER_OBJECT_NAME_STRING ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "orientation", true );
|
|
|
|
} else if ( o->inherits( "TQDesignerToolBar" ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "label", true );
|
|
|
|
} else if ( o->inherits( "TQDesignerMenuBar" ) ) {
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemName", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemNumber", true );
|
|
|
|
MetaDataBase::setPropertyChanged( o, "itemText", true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetFactory::hasSpecialEditor( int id )
|
|
|
|
{
|
|
|
|
TQString className = WidgetDatabase::className(id);
|
|
|
|
|
|
|
|
if (className == "TextEdit" || className == "ComboBox" || className == "ListBox" || className ==
|
|
|
|
"TreeWidget" || className == "TextBrowser")
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (className.mid(1) == "ListBox")
|
|
|
|
return true;
|
|
|
|
if (className.mid(1) == "ComboBox")
|
|
|
|
return true;
|
|
|
|
if (className.mid(1) == "ListView")
|
|
|
|
return true;
|
|
|
|
if (className.mid(1) == "IconView")
|
|
|
|
return true;
|
|
|
|
if (className == TQTEXTEDIT_OBJECT_NAME_STRING || className == TQMULTILINEEDIT_OBJECT_NAME_STRING)
|
|
|
|
return true;
|
|
|
|
if (className.tqcontains("Table"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetFactory::hasItems( int id )
|
|
|
|
{
|
|
|
|
TQString className = WidgetDatabase::className(id);
|
|
|
|
|
|
|
|
if (className == "ComboBox" || className == "ListBox" || className == "TreeWidget")
|
|
|
|
return true;
|
|
|
|
if (className.mid(1) == "ListBox" || className.mid(1) == "ListView" ||
|
|
|
|
className.mid(1) == "IconView" || className.mid(1) == "ComboBox" ||
|
|
|
|
className.tqcontains("Table"))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WidgetFactory::editWidget( int id, TQWidget *tqparent, TQWidget *editWidget, FormWindow *fw )
|
|
|
|
{
|
|
|
|
TQString className = WidgetDatabase::className(id);
|
|
|
|
|
|
|
|
#ifdef KOMMANDER
|
|
|
|
if (className == "ComboBox")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQCOMBOBOX_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
|
|
|
|
TQComboBox *cb = (TQComboBox *) editWidget;
|
|
|
|
|
|
|
|
ListBoxEditor *e = new ListBoxEditor(tqparent, cb->listBox(), fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
|
|
|
|
cb->update();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (className == "TextEdit" || className == "TextBrowser")
|
|
|
|
{
|
|
|
|
MultiLineEditor *e = new MultiLineEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (className == "TreeWidget")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQLISTVIEW_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
TQListView *lv = (TQListView *) editWidget;
|
|
|
|
ListViewEditor *e = new ListViewEditor(tqparent, lv, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (className == "ListBox")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQLISTBOX_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
ListBoxEditor *e = new ListBoxEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (className.mid(1) == "ListBox")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQLISTBOX_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
ListBoxEditor *e = new ListBoxEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (className.mid(1) == "ComboBox")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQCOMBOBOX_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
TQComboBox *cb = (TQComboBox *) editWidget;
|
|
|
|
ListBoxEditor *e = new ListBoxEditor(tqparent, cb->listBox(), fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
cb->update();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (className.mid(1) == "ListView")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQLISTVIEW_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
TQListView *lv = (TQListView *) editWidget;
|
|
|
|
ListViewEditor *e = new ListViewEditor(tqparent, lv, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (className.mid(1) == "IconView")
|
|
|
|
{
|
|
|
|
if (!editWidget->inherits(TQICONVIEW_OBJECT_NAME_STRING))
|
|
|
|
return;
|
|
|
|
IconViewEditor *e = new IconViewEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (className == TQMULTILINEEDIT_OBJECT_NAME_STRING || className == TQTEXTEDIT_OBJECT_NAME_STRING)
|
|
|
|
{
|
|
|
|
MultiLineEditor *e = new MultiLineEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#ifndef TQT_NO_TABLE
|
|
|
|
if (className.tqcontains("Table"))
|
|
|
|
{
|
|
|
|
TableEditor *e = new TableEditor(tqparent, editWidget, fw);
|
|
|
|
e->exec();
|
|
|
|
delete e;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetFactory::canResetProperty( TQObject *w, const TQString &propName )
|
|
|
|
{
|
|
|
|
if ( propName == "name" || propName == "geometry" )
|
|
|
|
return false;
|
|
|
|
TQStringList l = *changedProperties->tqfind( WidgetDatabase::idFromClassName( WidgetFactory::classNameOf( w ) ) );
|
|
|
|
return l.tqfindIndex( propName ) == -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WidgetFactory::resetProperty( TQObject *w, const TQString &propName )
|
|
|
|
{
|
|
|
|
const TQMetaProperty *p = w->tqmetaObject()->property( w->tqmetaObject()->
|
|
|
|
tqfindProperty( propName, true ), true );
|
|
|
|
if (!p )
|
|
|
|
return false;
|
|
|
|
return p->reset( w );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQVariant WidgetFactory::defaultValue( TQObject *w, const TQString &propName )
|
|
|
|
{
|
|
|
|
if ( propName == "wordwrap" ) {
|
|
|
|
int v = defaultValue( w, "tqalignment" ).toInt();
|
|
|
|
return TQVariant( ( v & WordBreak ) == WordBreak, 0 );
|
|
|
|
} else if ( propName == "toolTip" || propName == "whatsThis" ) {
|
|
|
|
return TQVariant( TQString::tqfromLatin1( "" ) );
|
|
|
|
} else if ( w->inherits( "CustomWidget" ) ) {
|
|
|
|
return TQVariant();
|
|
|
|
} else if ( propName == "frameworkCode" ) {
|
|
|
|
return TQVariant( true, 0 );
|
|
|
|
} else if ( propName == "tqlayoutMargin" ) {
|
|
|
|
if ( w->inherits( TQLAYOUTWIDGET_OBJECT_NAME_STRING ) )
|
|
|
|
return TQVariant( 0 );
|
|
|
|
else if ( MainWindow::self->formWindow() )
|
|
|
|
return TQVariant( MainWindow::self->formWindow()->tqlayoutDefaultMargin() );
|
|
|
|
} else if ( propName == "tqlayoutSpacing" ) {
|
|
|
|
if ( MainWindow::self->formWindow() )
|
|
|
|
return TQVariant( MainWindow::self->formWindow()->tqlayoutDefaultSpacing() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return *( *defaultProperties->tqfind( WidgetDatabase::idFromClassName( classNameOf( w ) ) ) ).tqfind( propName );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQString WidgetFactory::defaultCurrentItem( TQObject *w, const TQString &propName )
|
|
|
|
{
|
|
|
|
const TQMetaProperty *p = w->tqmetaObject()->
|
|
|
|
property( w->tqmetaObject()->tqfindProperty( propName, true ), true );
|
|
|
|
if ( !p ) {
|
|
|
|
int v = defaultValue( w, "tqalignment" ).toInt();
|
|
|
|
if ( propName == "hAlign" ) {
|
|
|
|
if ( ( v & AlignAuto ) == AlignAuto )
|
|
|
|
return "AlignAuto";
|
|
|
|
if ( ( v & AlignLeft ) == AlignLeft )
|
|
|
|
return "AlignLeft";
|
|
|
|
if ( ( v & AlignCenter ) == AlignCenter || ( v & AlignHCenter ) == AlignHCenter )
|
|
|
|
return "AlignHCenter";
|
|
|
|
if ( ( v & AlignRight ) == AlignRight )
|
|
|
|
return "AlignRight";
|
|
|
|
if ( ( v & AlignJustify ) == AlignJustify )
|
|
|
|
return "AlignJustify";
|
|
|
|
} else if ( propName == "vAlign" ) {
|
|
|
|
if ( ( v & AlignTop ) == AlignTop )
|
|
|
|
return "AlignTop";
|
|
|
|
if ( ( v & AlignCenter ) == AlignCenter || ( v & AlignVCenter ) == AlignVCenter )
|
|
|
|
return "AlignVCenter";
|
|
|
|
if ( ( v & AlignBottom ) == AlignBottom )
|
|
|
|
return "AlignBottom";
|
|
|
|
}
|
|
|
|
return TQString();
|
|
|
|
|
|
|
|
}
|
|
|
|
return p->valueToKey( defaultValue( w, propName ).toInt() );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQWidget *WidgetFactory::createCustomWidget( TQWidget *tqparent, const char *name, MetaDataBase::CustomWidget *w )
|
|
|
|
{
|
|
|
|
if ( !w )
|
|
|
|
return 0;
|
|
|
|
return new CustomWidget( tqparent, name, w );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQVariant WidgetFactory::property( TQObject *w, const char *name )
|
|
|
|
{
|
|
|
|
TQVariant v = w->property( name );
|
|
|
|
if ( v.isValid() )
|
|
|
|
return v;
|
|
|
|
return MetaDataBase::fakeProperty( w, name );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerLabel::updateBuddy()
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( myBuddy.isEmpty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
TQObjectList *l = tqtopLevelWidget()->queryList( TQWIDGET_OBJECT_NAME_STRING, myBuddy, false, true );
|
|
|
|
if ( !l || !l->first() ) {
|
|
|
|
delete l;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
TQLabel::setBuddy( (TQWidget*)l->first() );
|
|
|
|
delete l;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerWidget::paintEvent( TQPaintEvent *e )
|
|
|
|
{
|
|
|
|
formwindow->paintGrid( this, e );
|
|
|
|
}
|
|
|
|
|
|
|
|
void TQDesignerDialog::paintEvent( TQPaintEvent *e )
|
|
|
|
{
|
|
|
|
formwindow->paintGrid( this, e );
|
|
|
|
}
|
|
|
|
|
|
|
|
void EditorDialog::paintEvent( TQPaintEvent *e )
|
|
|
|
{
|
|
|
|
formwindow->paintGrid( this, e );
|
|
|
|
}
|
|
|
|
|
|
|
|
TQSizePolicy TQLayoutWidget::sizePolicy() const
|
|
|
|
{
|
|
|
|
return sp;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TQLayoutWidget::event( TQEvent *e )
|
|
|
|
{
|
|
|
|
if ( e && ( e->type() == TQEvent::ChildInserted ||
|
|
|
|
e->type() == TQEvent::ChildRemoved ||
|
|
|
|
e->type() == TQEvent::LayoutHint ||
|
|
|
|
e->type() == TQEvent::Reparent ) )
|
|
|
|
updateSizePolicy();
|
|
|
|
return TQWidget::event( e );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
This function must be called on TQLayoutWidget creation and whenever
|
|
|
|
the TQLayoutWidget's tqparent tqlayout changes (e.g., from a TQHBoxLayout
|
|
|
|
to a TQVBoxLayout), because of the (illogical) way tqlayouting works.
|
|
|
|
*/
|
|
|
|
void TQLayoutWidget::updateSizePolicy()
|
|
|
|
{
|
|
|
|
TQObjectList clo = childrenListObject();
|
|
|
|
if ( clo.isEmpty() || clo.count() == 0 ) {
|
|
|
|
sp = TQWidget::tqsizePolicy();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
TQSizePolicy::MayShrink & friends are private. Here we assume the
|
|
|
|
following:
|
|
|
|
|
|
|
|
Fixed = 0
|
|
|
|
Maximum = MayShrink
|
|
|
|
Minimum = MayGrow
|
|
|
|
Preferred = MayShrink | MayGrow
|
|
|
|
*/
|
|
|
|
|
|
|
|
int ht = (int) TQSizePolicy::Preferred;
|
|
|
|
int vt = (int) TQSizePolicy::Preferred;
|
|
|
|
|
|
|
|
if ( tqlayout() ) {
|
|
|
|
/*
|
|
|
|
tqparentLayout is set to the tqparent tqlayout if there is one and if it is
|
|
|
|
top level, in which case tqlayouting is illogical.
|
|
|
|
*/
|
|
|
|
TQLayout *tqparentLayout = 0;
|
|
|
|
if ( tqparent() && tqparent()->isWidgetType() ) {
|
|
|
|
tqparentLayout = ((TQWidget *)tqparent())->tqlayout();
|
|
|
|
if ( tqparentLayout && tqparentLayout->mainWidget()->inherits(TQLAYOUTWIDGET_OBJECT_NAME_STRING) )
|
|
|
|
tqparentLayout = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
TQObjectListIt it( childrenListObject() );
|
|
|
|
TQObject *o;
|
|
|
|
|
|
|
|
if ( tqlayout()->inherits(TQVBOXLAYOUT_OBJECT_NAME_STRING) ) {
|
|
|
|
if ( tqparentLayout && tqparentLayout->inherits(TQHBOXLAYOUT_OBJECT_NAME_STRING) )
|
|
|
|
vt = TQSizePolicy::Minimum;
|
|
|
|
else
|
|
|
|
vt = TQSizePolicy::Fixed;
|
|
|
|
|
|
|
|
while ( ( o = it.current() ) ) {
|
|
|
|
++it;
|
|
|
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
|
|
|
continue;
|
|
|
|
TQWidget *w = (TQWidget*)o;
|
|
|
|
|
|
|
|
if ( !w->tqsizePolicy().mayGrowHorizontally() )
|
|
|
|
ht &= ~TQSizePolicy::Minimum;
|
|
|
|
if ( !w->tqsizePolicy().mayShrinkHorizontally() )
|
|
|
|
ht &= ~TQSizePolicy::Maximum;
|
|
|
|
if ( w->tqsizePolicy().mayGrowVertically() )
|
|
|
|
vt |= TQSizePolicy::Minimum;
|
|
|
|
if ( w->tqsizePolicy().mayShrinkVertically() )
|
|
|
|
vt |= TQSizePolicy::Maximum;
|
|
|
|
}
|
|
|
|
} else if ( tqlayout()->inherits(TQHBOXLAYOUT_OBJECT_NAME_STRING) ) {
|
|
|
|
if ( tqparentLayout && tqparentLayout->inherits(TQVBOXLAYOUT_OBJECT_NAME_STRING) )
|
|
|
|
ht = TQSizePolicy::Minimum;
|
|
|
|
else
|
|
|
|
ht = TQSizePolicy::Fixed;
|
|
|
|
|
|
|
|
while ( ( o = it.current() ) ) {
|
|
|
|
++it;
|
|
|
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
|
|
|
continue;
|
|
|
|
TQWidget *w = (TQWidget*)o;
|
|
|
|
|
|
|
|
if ( w->tqsizePolicy().mayGrowHorizontally() )
|
|
|
|
ht |= TQSizePolicy::Minimum;
|
|
|
|
if ( w->tqsizePolicy().mayShrinkHorizontally() )
|
|
|
|
ht |= TQSizePolicy::Maximum;
|
|
|
|
if ( !w->tqsizePolicy().mayGrowVertically() )
|
|
|
|
vt &= ~TQSizePolicy::Minimum;
|
|
|
|
if ( !w->tqsizePolicy().mayShrinkVertically() )
|
|
|
|
vt &= ~TQSizePolicy::Maximum;
|
|
|
|
}
|
|
|
|
} else if ( tqlayout()->inherits(TQGRIDLAYOUT_OBJECT_NAME_STRING) ) {
|
|
|
|
ht = TQSizePolicy::Fixed;
|
|
|
|
vt = TQSizePolicy::Fixed;
|
|
|
|
if ( tqparentLayout ) {
|
|
|
|
if ( tqparentLayout->inherits(TQVBOXLAYOUT_OBJECT_NAME_STRING) )
|
|
|
|
ht = TQSizePolicy::Minimum;
|
|
|
|
else if ( tqparentLayout->inherits(TQHBOXLAYOUT_OBJECT_NAME_STRING) )
|
|
|
|
vt = TQSizePolicy::Minimum;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( ( o = it.current() ) ) {
|
|
|
|
++it;
|
|
|
|
if ( !o->isWidgetType() || ( (TQWidget*)o )->testWState( WState_ForceHide ) )
|
|
|
|
continue;
|
|
|
|
TQWidget *w = (TQWidget*)o;
|
|
|
|
|
|
|
|
if ( w->tqsizePolicy().mayGrowHorizontally() )
|
|
|
|
ht |= TQSizePolicy::Minimum;
|
|
|
|
if ( w->tqsizePolicy().mayShrinkHorizontally() )
|
|
|
|
ht |= TQSizePolicy::Maximum;
|
|
|
|
if ( w->tqsizePolicy().mayGrowVertically() )
|
|
|
|
vt |= TQSizePolicy::Minimum;
|
|
|
|
if ( w->tqsizePolicy().mayShrinkVertically() )
|
|
|
|
vt |= TQSizePolicy::Maximum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#ifdef USE_QT4
|
|
|
|
if ( tqlayout()->expandingDirections() & TQSizePolicy::Horizontally )
|
|
|
|
ht = TQSizePolicy::Expanding;
|
|
|
|
if ( tqlayout()->expandingDirections() & TQSizePolicy::Vertically )
|
|
|
|
vt = TQSizePolicy::Expanding;
|
|
|
|
#else // USE_QT4
|
|
|
|
if ( tqlayout()->expanding() & TQSizePolicy::Horizontally )
|
|
|
|
ht = TQSizePolicy::Expanding;
|
|
|
|
if ( tqlayout()->expanding() & TQSizePolicy::Vertically )
|
|
|
|
vt = TQSizePolicy::Expanding;
|
|
|
|
#endif // USE_QT4
|
|
|
|
|
|
|
|
tqlayout()->tqinvalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
sp = TQSizePolicy( (TQSizePolicy::SizeType) ht, (TQSizePolicy::SizeType) vt );
|
|
|
|
updateGeometry();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CustomWidget::paintEvent( TQPaintEvent *e )
|
|
|
|
{
|
|
|
|
if ( tqparentWidget() && tqparentWidget()->inherits( "FormWindow" ) ) {
|
|
|
|
( (FormWindow*)tqparentWidget() )->paintGrid( this, e );
|
|
|
|
} else {
|
|
|
|
TQPainter p( this );
|
|
|
|
p.fillRect( rect(), tqcolorGroup().dark() );
|
|
|
|
p.drawPixmap( ( width() - cusw->pixmap->width() ) / 2,
|
|
|
|
( height() - cusw->pixmap->height() ) / 2,
|
|
|
|
*cusw->pixmap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#include "widgetfactory.moc"
|