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.
324 lines
10 KiB
324 lines
10 KiB
15 years ago
|
/**********************************************************************
|
||
|
** Copyright (C) 2000 Trolltech AS. All rights reserved.
|
||
|
**
|
||
14 years ago
|
** This file is part of TQt Designer.
|
||
15 years ago
|
**
|
||
|
** 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.
|
||
|
**
|
||
14 years ago
|
** Licensees holding valid TQt Enterprise Edition or TQt Professional Edition
|
||
|
** licenses may use this file in accordance with the TQt Commercial License
|
||
15 years ago
|
** Agreement provided with the Software.
|
||
|
**
|
||
|
** 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.
|
||
|
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
||
14 years ago
|
** information about TQt Commercial License Agreements.
|
||
15 years ago
|
**
|
||
|
** Contact info@trolltech.com if any conditions of this licensing are
|
||
|
** not clear to you.
|
||
|
**
|
||
|
**********************************************************************/
|
||
|
|
||
|
#ifndef FORMWINDOW_H
|
||
|
#define FORMWINDOW_H
|
||
|
|
||
|
#include "command.h"
|
||
|
#include "metadatabase.h"
|
||
|
#include "sizehandle.h"
|
||
|
#include "actiondnd.h"
|
||
|
|
||
15 years ago
|
#include <tqwidget.h>
|
||
|
#include <tqptrdict.h>
|
||
|
#include <tqpixmap.h>
|
||
|
#include <tqwidgetlist.h>
|
||
|
#include <tqmap.h>
|
||
15 years ago
|
|
||
15 years ago
|
class TQPaintEvent;
|
||
|
class TQMouseEvent;
|
||
|
class TQKeyEvent;
|
||
|
class TQPainter;
|
||
|
class TQLabel;
|
||
15 years ago
|
class MainWindow;
|
||
15 years ago
|
class TQTimer;
|
||
|
class TQFocusEvent;
|
||
|
class TQCloseEvent;
|
||
15 years ago
|
class Resource;
|
||
15 years ago
|
class TQResizeEvent;
|
||
15 years ago
|
class BreakLayoutCommand;
|
||
15 years ago
|
class TQPixmap;
|
||
|
class TQSizeGrip;
|
||
15 years ago
|
class Project;
|
||
|
struct DesignerFormWindow;
|
||
|
class FormFile;
|
||
|
|
||
14 years ago
|
#if defined(TQ_CC_MSVC) || defined(TQ_FULL_TEMPLATE_INSTANTIATION)
|
||
15 years ago
|
#include "orderindicator.h"
|
||
|
#else
|
||
|
class OrderIndicator;
|
||
|
#endif
|
||
|
|
||
14 years ago
|
class FormWindow : public TQWidget
|
||
15 years ago
|
{
|
||
|
Q_OBJECT
|
||
13 years ago
|
|
||
14 years ago
|
TQ_PROPERTY( TQString fileName READ fileName WRITE setFileName )
|
||
15 years ago
|
|
||
|
public:
|
||
14 years ago
|
FormWindow( FormFile *f, MainWindow *mw, TQWidget *parent, const char *name = 0 );
|
||
|
FormWindow( FormFile *f, TQWidget *parent, const char *name = 0 );
|
||
15 years ago
|
~FormWindow();
|
||
|
|
||
|
void init();
|
||
|
virtual void setMainWindow( MainWindow *w );
|
||
|
|
||
15 years ago
|
virtual TQString fileName() const;
|
||
|
virtual void setFileName( const TQString &fn );
|
||
15 years ago
|
|
||
15 years ago
|
virtual TQPoint grid() const;
|
||
|
virtual TQPoint gridPoint( const TQPoint &p );
|
||
15 years ago
|
|
||
|
virtual CommandHistory *commandHistory();
|
||
|
|
||
|
virtual void undo();
|
||
|
virtual void redo();
|
||
15 years ago
|
virtual TQString copy();
|
||
14 years ago
|
virtual void paste( const TQString &cb, TQWidget *parent );
|
||
15 years ago
|
virtual void lowerWidgets();
|
||
|
virtual void raiseWidgets();
|
||
|
virtual void checkAccels();
|
||
|
|
||
14 years ago
|
virtual void layoutHorizontal();
|
||
|
virtual void layoutVertical();
|
||
|
virtual void layoutHorizontalSplit();
|
||
|
virtual void layoutVerticalSplit();
|
||
|
virtual void layoutGrid();
|
||
15 years ago
|
|
||
14 years ago
|
virtual void layoutHorizontalContainer( TQWidget *w );
|
||
|
virtual void layoutVerticalContainer( TQWidget *w );
|
||
|
virtual void layoutGridContainer( TQWidget *w );
|
||
15 years ago
|
|
||
15 years ago
|
virtual void breakLayout( TQWidget *w );
|
||
15 years ago
|
|
||
15 years ago
|
virtual void selectWidget( TQObject *w, bool select = TRUE );
|
||
15 years ago
|
virtual void selectAll();
|
||
15 years ago
|
virtual void updateSelection( TQWidget *w );
|
||
|
virtual void raiseSelection( TQWidget *w );
|
||
14 years ago
|
virtual void repaintSelection( TQWidget *w );
|
||
15 years ago
|
virtual void clearSelection( bool changePropertyDisplay = TRUE );
|
||
|
virtual void selectWidgets();
|
||
15 years ago
|
bool isWidgetSelected( TQObject *w );
|
||
|
virtual void updateChildSelections( TQWidget *w );
|
||
|
virtual void raiseChildSelections( TQWidget *w );
|
||
15 years ago
|
|
||
15 years ago
|
virtual void emitUpdateProperties( TQObject *w );
|
||
|
virtual void emitShowProperties( TQObject *w = 0 );
|
||
15 years ago
|
virtual void emitSelectionChanged();
|
||
|
|
||
|
virtual void setPropertyShowingBlocked( bool b );
|
||
|
bool isPropertyShowingBlocked() const;
|
||
|
|
||
15 years ago
|
virtual TQLabel *sizePreview() const;
|
||
|
virtual void checkPreviewGeometry( TQRect &r );
|
||
15 years ago
|
|
||
15 years ago
|
virtual TQPtrDict<TQWidget> *widgets();
|
||
|
virtual TQWidgetList selectedWidgets() const;
|
||
15 years ago
|
|
||
15 years ago
|
virtual TQWidget *designerWidget( TQObject *o ) const;
|
||
15 years ago
|
|
||
15 years ago
|
virtual void handleContextMenu( TQContextMenuEvent *e, TQWidget *w );
|
||
|
virtual void handleMousePress( TQMouseEvent *e, TQWidget *w );
|
||
|
virtual void handleMouseRelease( TQMouseEvent *e, TQWidget *w );
|
||
|
virtual void handleMouseDblClick( TQMouseEvent *e, TQWidget *w );
|
||
|
virtual void handleMouseMove( TQMouseEvent *e, TQWidget *w );
|
||
|
virtual void handleKeyPress( TQKeyEvent *e, TQWidget *w );
|
||
|
virtual void handleKeyRelease( TQKeyEvent *e, TQWidget *w );
|
||
15 years ago
|
|
||
|
virtual void updateUndoInfo();
|
||
|
|
||
|
virtual MainWindow *mainWindow() const { return mainwindow; }
|
||
|
|
||
|
bool checkCustomWidgets();
|
||
15 years ago
|
virtual void insertWidget( TQWidget *w, bool checkName = FALSE );
|
||
|
virtual void removeWidget( TQWidget *w );
|
||
15 years ago
|
virtual void deleteWidgets();
|
||
|
virtual void editAdjustSize();
|
||
|
virtual void editConnections();
|
||
|
|
||
|
virtual int numSelectedWidgets() const;
|
||
|
virtual int numVisibleWidgets() const;
|
||
|
|
||
15 years ago
|
virtual bool hasInsertedChildren( TQWidget *w ) const;
|
||
15 years ago
|
|
||
15 years ago
|
virtual TQWidget *currentWidget() const { return propertyWidget && propertyWidget->isWidgetType() ? (TQWidget*)propertyWidget : 0; } // #####
|
||
|
virtual bool unify( TQObject *w, TQString &s, bool changeIt );
|
||
15 years ago
|
|
||
|
virtual bool isCustomWidgetUsed( MetaDataBase::CustomWidget *w );
|
||
|
virtual bool isDatabaseWidgetUsed() const;
|
||
|
virtual bool isDatabaseAware() const;
|
||
|
|
||
15 years ago
|
virtual TQPoint mapToForm( const TQWidget* w, const TQPoint& ) const;
|
||
15 years ago
|
|
||
15 years ago
|
bool isMainContainer( TQObject *w ) const;
|
||
|
bool isCentralWidget( TQObject *w ) const;
|
||
|
TQWidget *mainContainer() const { return mContainer; }
|
||
|
void setMainContainer( TQWidget *w );
|
||
15 years ago
|
|
||
15 years ago
|
void paintGrid( TQWidget *w, TQPaintEvent *e );
|
||
15 years ago
|
|
||
|
bool savePixmapInline() const;
|
||
15 years ago
|
TQString pixmapLoaderFunction() const;
|
||
15 years ago
|
void setSavePixmapInline( bool b );
|
||
15 years ago
|
void setPixmapLoaderFunction( const TQString &func );
|
||
15 years ago
|
|
||
|
bool savePixmapInProject() const;
|
||
|
void setSavePixmapInProject( bool b );
|
||
|
|
||
|
void setToolFixed() { toolFixed = TRUE; }
|
||
|
|
||
15 years ago
|
void setActiveObject( TQObject *o );
|
||
15 years ago
|
|
||
15 years ago
|
TQPtrList<TQAction> &actionList() { return actions; }
|
||
|
TQAction *findAction( const TQString &name );
|
||
15 years ago
|
|
||
|
void setProject( Project *pro );
|
||
|
Project *project() const;
|
||
|
|
||
15 years ago
|
void killAccels( TQObject *top );
|
||
15 years ago
|
|
||
|
DesignerFormWindow *iFace();
|
||
|
|
||
14 years ago
|
int layoutDefaultSpacing() const;
|
||
|
int layoutDefaultMargin() const;
|
||
15 years ago
|
void setLayoutDefaultSpacing( int s );
|
||
|
void setLayoutDefaultMargin( int s );
|
||
15 years ago
|
TQString spacingFunction() const;
|
||
|
TQString marginFunction() const;
|
||
|
void setSpacingFunction( const TQString &func );
|
||
|
void setMarginFunction( const TQString &func );
|
||
15 years ago
|
bool hasLayoutFunctions() const;
|
||
|
void hasLayoutFunctions( bool b );
|
||
|
|
||
|
void initSlots();
|
||
|
FormFile *formFile() const;
|
||
|
void setFormFile( FormFile *f );
|
||
|
|
||
|
bool isFake() const { return fake; }
|
||
15 years ago
|
bool canBeBuddy( const TQWidget* ) const;
|
||
15 years ago
|
|
||
|
public slots:
|
||
15 years ago
|
virtual void widgetChanged( TQObject *w );
|
||
15 years ago
|
virtual void currentToolChanged();
|
||
|
virtual void visibilityChanged();
|
||
|
virtual void modificationChanged( bool m );
|
||
|
|
||
|
signals:
|
||
15 years ago
|
void showProperties( TQObject *w );
|
||
|
void updateProperties( TQObject *w );
|
||
15 years ago
|
void undoRedoChanged( bool undoAvailable, bool redoAvailable,
|
||
15 years ago
|
const TQString &undoCmd, const TQString &redoCmd );
|
||
15 years ago
|
void selectionChanged();
|
||
|
void modificationChanged( bool m, FormWindow *fw );
|
||
15 years ago
|
void modificationChanged( bool m, const TQString &s );
|
||
|
void fileNameChanged( const TQString &s, FormWindow *fw );
|
||
15 years ago
|
|
||
|
protected:
|
||
15 years ago
|
virtual void closeEvent( TQCloseEvent *e );
|
||
|
virtual void focusInEvent( TQFocusEvent *e );
|
||
|
virtual void focusOutEvent( TQFocusEvent *e );
|
||
|
virtual void resizeEvent( TQResizeEvent *e );
|
||
|
void mouseDoubleClickEvent( TQMouseEvent *e ) { handleMouseDblClick( e, mainContainer() ); }
|
||
|
virtual bool event( TQEvent *e );
|
||
15 years ago
|
|
||
|
private:
|
||
|
enum RectType { Insert, Rubber };
|
||
|
|
||
|
void beginUnclippedPainter( bool doNot );
|
||
|
void endUnclippedPainter();
|
||
|
void drawConnectionLine();
|
||
15 years ago
|
void drawSizePreview( const TQPoint &pos, const TQString& text );
|
||
15 years ago
|
|
||
|
void insertWidget();
|
||
|
void moveSelectedWidgets( int dx, int dy );
|
||
|
|
||
15 years ago
|
void startRectDraw( const TQPoint &p, const TQPoint &global, TQWidget *w, RectType t );
|
||
|
void continueRectDraw( const TQPoint &p, const TQPoint &global, TQWidget *w, RectType t );
|
||
15 years ago
|
void endRectDraw();
|
||
|
|
||
15 years ago
|
void checkSelectionsForMove( TQWidget *w );
|
||
|
BreakLayoutCommand *breakLayoutCommand( TQWidget *w );
|
||
15 years ago
|
|
||
15 years ago
|
bool allowMove( TQWidget *w );
|
||
15 years ago
|
|
||
|
void saveBackground();
|
||
|
void restoreConnectionLine();
|
||
15 years ago
|
void restoreRect( const TQRect &rect ) ;
|
||
15 years ago
|
|
||
|
void showOrderIndicators();
|
||
|
void updateOrderIndicators();
|
||
|
void repositionOrderIndicators();
|
||
|
void hideOrderIndicators();
|
||
|
|
||
15 years ago
|
TQWidget *containerAt( const TQPoint &pos, TQWidget *notParentOf );
|
||
15 years ago
|
|
||
|
private slots:
|
||
|
void invalidCheckedSelections();
|
||
|
void updatePropertiesTimerDone();
|
||
|
void showPropertiesTimerDone();
|
||
|
void selectionChangedTimerDone();
|
||
|
void windowsRepaintWorkaroundTimerTimeout();
|
||
|
|
||
|
private:
|
||
|
int currTool;
|
||
|
bool oldRectValid, widgetPressed, drawRubber, checkedSelectionsForMove;
|
||
|
bool validForBuddy;
|
||
15 years ago
|
TQRect currRect;
|
||
|
TQPoint rectAnchor;
|
||
|
TQPainter *unclippedPainter;
|
||
|
TQPoint sizePreviewPos;
|
||
|
TQPixmap sizePreviewPixmap;
|
||
15 years ago
|
MainWindow *mainwindow;
|
||
15 years ago
|
TQPtrList<WidgetSelection> selections;
|
||
|
TQPtrDict<WidgetSelection> usedSelections;
|
||
|
TQRect widgetGeom, rubber;
|
||
|
TQPoint oldPressPos, origPressPos;
|
||
15 years ago
|
CommandHistory commands;
|
||
15 years ago
|
TQMap<TQWidget*, TQPoint> moving;
|
||
|
TQWidget *insertParent;
|
||
|
TQObject *propertyWidget;
|
||
|
TQLabel *sizePreviewLabel;
|
||
|
TQTimer *checkSelectionsTimer;
|
||
|
TQPtrDict<TQWidget> insertedWidgets;
|
||
15 years ago
|
bool propShowBlocked;
|
||
15 years ago
|
TQTimer* updatePropertiesTimer, *showPropertiesTimer, *selectionChangedTimer,
|
||
15 years ago
|
*windowsRepaintWorkaroundTimer;
|
||
15 years ago
|
TQPoint startPos, currentPos;
|
||
|
TQWidget *startWidget, *endWidget;
|
||
|
TQPixmap *buffer;
|
||
|
TQPtrList<OrderIndicator> orderIndicators;
|
||
|
TQWidgetList orderedWidgets;
|
||
|
TQWidgetList stackedWidgets;
|
||
|
TQWidget *mContainer;
|
||
15 years ago
|
bool pixInline, pixProject;
|
||
15 years ago
|
TQString pixLoader;
|
||
15 years ago
|
bool toolFixed;
|
||
15 years ago
|
TQPtrList<TQAction> actions;
|
||
15 years ago
|
Project *proj;
|
||
|
DesignerFormWindow *iface;
|
||
15 years ago
|
TQWidget* targetContainer;
|
||
|
TQPalette restorePalette;
|
||
15 years ago
|
bool hadOwnPalette;
|
||
|
int defSpacing, defMargin;
|
||
15 years ago
|
TQString spacFunction, margFunction;
|
||
15 years ago
|
bool hasLayoutFunc;
|
||
|
FormFile *ff;
|
||
|
bool fake;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif
|