diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 90825e2392b2d70e43c7a25b8a3752299a933894 (patch) | |
tree | e33aa27f02b74604afbfd0ea4f1cfca8833d882a /qtjava/javalib/examples/textedit | |
download | tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.tar.gz tdebindings-90825e2392b2d70e43c7a25b8a3752299a933894.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebindings@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'qtjava/javalib/examples/textedit')
19 files changed, 1454 insertions, 0 deletions
diff --git a/qtjava/javalib/examples/textedit/Main.java b/qtjava/javalib/examples/textedit/Main.java new file mode 100644 index 00000000..c1597460 --- /dev/null +++ b/qtjava/javalib/examples/textedit/Main.java @@ -0,0 +1,30 @@ +/*************************************************************************** +* $Id$ +** +* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +* This file is part of an example program for Qt. This example +* program may be used, distributed and modified without limitation. +** +****************************************************************************/ + +import org.kde.qt.*; + +public class Main { + +public static void main(String[] args) +{ + QApplication a = new QApplication( args ); + TextEdit mw = new TextEdit(); + mw.setCaption( "Richtext Editor" ); + mw.resize( 640, 800 ); + mw.show(); + a.connect( a, Qt.SIGNAL(" lastWindowClosed()"), a, Qt.SLOT(" quit()") ); + a.exec(); + return; +} + + static { + qtjava.initialize(); + } +} diff --git a/qtjava/javalib/examples/textedit/TextEdit.java b/qtjava/javalib/examples/textedit/TextEdit.java new file mode 100644 index 00000000..c4adfa7a --- /dev/null +++ b/qtjava/javalib/examples/textedit/TextEdit.java @@ -0,0 +1,494 @@ +/*************************************************************************** +* $Id$ +** +* Copyright (C) 1992-2000 Trolltech AS. All rights reserved. +** +* This file is part of an example program for Qt. This example +* program may be used, distributed and modified without limitation. +** +****************************************************************************/ + +import org.kde.qt.*; +import java.util.HashMap; + +class TextEdit extends QMainWindow +{ + + +private QAction actionTextBold, + actionTextUnderline, + actionTextItalic, + actionTextColor, + actionAlignLeft, + actionAlignCenter, + actionAlignRight, + actionAlignJustify; + QComboBox comboStyle, + comboFont, + comboSize; +private QTabWidget tabWidget; +private HashMap filenames = new HashMap(); + + + +TextEdit( ) +{ + this(null, null); +} + +TextEdit( QWidget parent, String name ) +{ + super( parent, name ); + setupFileActions(); + setupEditActions(); + setupTextActions(); + + tabWidget = new QTabWidget( this ); + connect( tabWidget, SIGNAL(" currentChanged( QWidget )"), + this, SLOT(" editorChanged( QWidget )") ); + setCentralWidget( tabWidget ); + + if ( qApp().args().length == 0 ) { + load( "example.html" ); + } else { + for ( int i = 0; i < qApp().args().length; ++i ) + load( qApp().args()[ i ] ); + } +} + +void setupFileActions() +{ + QToolBar tb = new QToolBar( this ); + tb.setLabel( "File Actions" ); + QPopupMenu menu = new QPopupMenu( this ); + menuBar().insertItem( tr( "&File" ), menu ); + + QAction a; + a = new QAction( tr( "New" ), new QIconSet(new QPixmap( "filenew.xpm" )), tr( "&New..." ), new QKeySequence(CTRL + Key_N), this, "fileNew" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileNew()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Open" ), new QIconSet(new QPixmap( "fileopen.xpm" )), tr( "&Open..." ), new QKeySequence(CTRL + Key_O), this, "fileOpen" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileOpen()") ); + a.addTo( tb ); + a.addTo( menu ); + menu.insertSeparator(); + a = new QAction( tr( "Save" ), new QIconSet(new QPixmap( "filesave.xpm" )), tr( "&Save..." ), new QKeySequence(CTRL + Key_S), this, "fileSave" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileSave()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Save As" ), new QIconSet(new QPixmap()), tr( "Save &As..." ), new QKeySequence(0), this, "fileSaveAs" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileSaveAs()") ); + a.addTo( menu ); + menu.insertSeparator(); + a = new QAction( tr( "Print" ), new QIconSet(new QPixmap( "fileprint.xpm" )), tr( "&Print..." ), new QKeySequence(CTRL + Key_P), this, "filePrint" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" filePrint()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Close" ), new QIconSet(new QPixmap()), tr( "&Close" ), new QKeySequence(0), this, "fileClose" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileClose()") ); + a.addTo( menu ); + a = new QAction( tr( "Exit" ), new QIconSet(new QPixmap()), tr( "E&xit" ), new QKeySequence(0), this, "fileExit" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" fileExit()") ); + a.addTo( menu ); +} + +void setupEditActions() +{ + QToolBar tb = new QToolBar( this ); + tb.setLabel( "Edit Actions" ); + QPopupMenu menu = new QPopupMenu( this ); + menuBar().insertItem( tr( "&Edit" ), menu ); + + QAction a; + a = new QAction( tr( "Undo" ), new QIconSet(new QPixmap( "editundo.xpm" )), tr( "&Undo" ), new QKeySequence(CTRL + Key_Z), this, "editUndo" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" editUndo()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Redo" ), new QIconSet(new QPixmap( "editredo.xpm" )), tr( "&Redo" ), new QKeySequence(CTRL + Key_Y), this, "editRedo" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" editRedo()") ); + a.addTo( tb ); + a.addTo( menu ); + menu.insertSeparator(); + a = new QAction( tr( "Copy" ), new QIconSet(new QPixmap( "editcopy.xpm" )), tr( "&Copy" ), new QKeySequence(CTRL + Key_C), this, "editCopy" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" editCopy()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Cut" ), new QIconSet(new QPixmap( "editcut.xpm" )), tr( "Cu&t" ), new QKeySequence(CTRL + Key_X), this, "editCut" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" editCut()") ); + a.addTo( tb ); + a.addTo( menu ); + a = new QAction( tr( "Paste" ), new QIconSet(new QPixmap( "editpaste.xpm" )), tr( "&Paste" ), new QKeySequence(CTRL + Key_V), this, "editPaste" ); + connect( a, SIGNAL(" activated()"), this, SLOT(" editPaste()") ); + a.addTo( tb ); + a.addTo( menu ); +} + +void setupTextActions() +{ + QToolBar tb = new QToolBar( this ); + tb.setLabel( "Format Actions" ); + QPopupMenu menu = new QPopupMenu( this ); + menuBar().insertItem( tr( "F&ormat" ), menu ); + + comboStyle = new QComboBox( false, tb ); + comboStyle.insertItem( "Standard" ); + comboStyle.insertItem( "Bullet List (Disc)" ); + comboStyle.insertItem( "Bullet List (Circle)" ); + comboStyle.insertItem( "Bullet List (Square)" ); + comboStyle.insertItem( "Ordered List (Decimal)" ); + comboStyle.insertItem( "Ordered List (Alpha lower)" ); + comboStyle.insertItem( "Ordered List (Alpha upper)" ); + connect( comboStyle, SIGNAL(" activated( int )"), + this, SLOT(" textStyle( int )") ); + + comboFont = new QComboBox( true, tb ); + QFontDatabase db = new QFontDatabase(); + comboFont.insertStringList( (String[]) db.families().toArray(new String[0]) ); + connect( comboFont, SIGNAL(" activated( String )"), + this, SLOT(" textFamily( String )") ); + comboFont.lineEdit().setText( QApplication.font().family() ); + + comboSize = new QComboBox( true, tb ); + int[] sizes = db.standardSizes(); + for (int i = 0; i < sizes.length; i++ ) + comboSize.insertItem( Integer.toString(sizes[i]) ); + connect( comboSize, SIGNAL(" activated( String )"), + this, SLOT(" textSize( String )") ); + comboSize.lineEdit().setText( Integer.toString( QApplication.font().pointSize() ) ); + + actionTextBold = new QAction( tr( "Bold" ), new QIconSet(new QPixmap( "textbold.xpm" )), tr( "&Bold" ), new QKeySequence(CTRL + Key_B), this, "textBold" ); + connect( actionTextBold, SIGNAL(" activated()"), this, SLOT(" textBold()") ); + actionTextBold.addTo( tb ); + actionTextBold.addTo( menu ); + actionTextBold.setToggleAction( true ); + actionTextItalic = new QAction( tr( "Italic" ), new QIconSet(new QPixmap( "textitalic.xpm" )), tr( "&Italic" ), new QKeySequence(CTRL + Key_I), this, "textItalic" ); + connect( actionTextItalic, SIGNAL(" activated()"), this, SLOT(" textItalic()") ); + actionTextItalic.addTo( tb ); + actionTextItalic.addTo( menu ); + actionTextItalic.setToggleAction( true ); + actionTextUnderline = new QAction( tr( "Underline" ), new QIconSet(new QPixmap( "textunder.xpm" )), tr( "&Underline" ), new QKeySequence(CTRL + Key_U), this, "textUnderline" ); + connect( actionTextUnderline, SIGNAL(" activated()"), this, SLOT(" textUnderline()") ); + actionTextUnderline.addTo( tb ); + actionTextUnderline.addTo( menu ); + actionTextUnderline.setToggleAction( true ); + menu.insertSeparator(); + + QActionGroup grp = new QActionGroup( this ); + grp.setExclusive( true ); + connect( grp, SIGNAL(" selected( QAction )"), this, SLOT(" textAlign( QAction )") ); + + actionAlignLeft = new QAction( tr( "Left" ), new QIconSet(new QPixmap( "textleft.xpm" )), tr( "&Left" ), new QKeySequence(CTRL + Key_L), grp, "textLeft" ); + actionAlignLeft.addTo( tb ); + actionAlignLeft.addTo( menu ); + actionAlignLeft.setToggleAction( true ); + actionAlignCenter = new QAction( tr( "Center" ), new QIconSet(new QPixmap( "textcenter.xpm" )), tr( "C&enter" ), new QKeySequence(CTRL + Key_E), grp, "textCenter" ); + actionAlignCenter.addTo( tb ); + actionAlignCenter.addTo( menu ); + actionAlignCenter.setToggleAction( true ); + actionAlignRight = new QAction( tr( "Right" ), new QIconSet(new QPixmap( "textright.xpm" )), tr( "&Right" ), new QKeySequence(CTRL + Key_R), grp, "textRight" ); + actionAlignRight.addTo( tb ); + actionAlignRight.addTo( menu ); + actionAlignRight.setToggleAction( true ); + actionAlignJustify = new QAction( tr( "Justify" ), new QIconSet(new QPixmap( "textjustify.xpm" )), tr( "&Justify" ), new QKeySequence(CTRL + Key_J), grp, "textjustify" ); + actionAlignJustify.addTo( tb ); + actionAlignJustify.addTo( menu ); + actionAlignJustify.setToggleAction( true ); + + menu.insertSeparator(); + + QPixmap pix = new QPixmap( 16, 16 ); + pix.fill( black() ); + actionTextColor = new QAction( tr( "Color" ), new QIconSet(pix), tr( "&Color..." ), new QKeySequence(0), this, "textColor" ); + connect( actionTextColor, SIGNAL(" activated()"), this, SLOT(" textColor()") ); + actionTextColor.addTo( tb ); + actionTextColor.addTo( menu ); +} + +void load( String f ) +{ + if ( !QFile.exists( f ) ) + return; + QTextEdit edit = new QTextEdit( tabWidget ); + doConnections( edit ); + tabWidget.addTab( edit, new QFileInfo( f ).fileName() ); + QFile file = new QFile( f ); + if ( !file.open( QIODevice.IO_ReadOnly ) ) + return; + QTextStream ts = new QTextStream( file ); + edit.setText( ts.read() ); + tabWidget.showPage( edit ); + edit.viewport().setFocus(); + filenames.put( edit, f ); +} + +QTextEdit currentEditor() +{ + if ( tabWidget.currentPage() != null && + tabWidget.currentPage().inherits( "QTextEdit" ) ) + return (QTextEdit)tabWidget.currentPage(); + return null; +} + +void doConnections( QTextEdit e ) +{ + connect( e, SIGNAL(" currentFontChanged( QFont )"), + this, SLOT(" fontChanged( QFont )") ); + connect( e, SIGNAL(" currentColorChanged( QColor )"), + this, SLOT(" colorChanged( QColor )") ); + connect( e, SIGNAL(" currentAlignmentChanged( int )"), + this, SLOT(" alignmentChanged( int )") ); +} + +void fileNew() +{ + QTextEdit edit = new QTextEdit( tabWidget ); + edit.setTextFormat( RichText ); + doConnections( edit ); + tabWidget.addTab( edit, tr( "noname" ) ); + tabWidget.showPage( edit ); + edit.viewport().setFocus(); +} + +void fileOpen() +{ + String fn = QFileDialog.getOpenFileName( "", tr( "HTML-Files (*.htm *.html);;All Files (*)" ), this ); + if ( !fn.equals("") ) + load( fn ); +} + +void fileSave() +{ + if ( currentEditor() == null ) + return; + String fn; + if ( !filenames.containsKey( currentEditor() ) ) { + fileSaveAs(); + } else { + QFile file = new QFile( (String) filenames.get( currentEditor() ) ); + if ( !file.open( QIODevice.IO_WriteOnly ) ) + return; + QTextStream ts = new QTextStream( file ); + ts.writeRawBytes(currentEditor().text(), currentEditor().text().length()); + } +} + +void fileSaveAs() +{ + if ( currentEditor() == null ) + return; + String fn = QFileDialog.getSaveFileName( "", tr( "HTML-Files (*.htm *.html);;All Files (*)" ), this ); + if ( !fn.equals("") ) { + filenames.put( currentEditor(), fn ); + fileSave(); + tabWidget.setTabLabel( currentEditor(), new QFileInfo( fn ).fileName() ); + } +} + +void filePrint() +{ + if ( currentEditor() == null ) + return; + QPrinter printer = new QPrinter(); + printer.setFullPage(true); + if ( printer.setup( this ) ) { + QPainter p = new QPainter( printer ); + // Check that there is a valid device to print to. + if ( p.device() == null ) return; + QPaintDeviceMetrics metrics = new QPaintDeviceMetrics( p.device() ); + int dpix = metrics.logicalDpiX(); + int dpiy = metrics.logicalDpiY(); + int margin = 72; // pt + QRect body = new QRect( margin * dpix / 72, margin * dpiy / 72, + metrics.width() - margin * dpix / 72 * 2, + metrics.height() - margin * dpiy / 72 * 2 ); + QFont font = new QFont( "times", 10 ); + QSimpleRichText richText = new QSimpleRichText( currentEditor().text(), font, currentEditor().context(), currentEditor().styleSheet(), + currentEditor().mimeSourceFactory(), body.height() ); + richText.setWidth( p, body.width() ); + QRect view = new QRect( body.topLeft(), body.bottomRight() ); + int page = 1; + do { + richText.draw( p, body.left(), body.top(), view, colorGroup() ); + view.moveBy( 0, body.height() ); + p.translate( 0 , -body.height() ); + p.setFont( font ); + p.drawText( view.right() - p.fontMetrics().width( Integer.toString(page) ), + view.bottom() + p.fontMetrics().ascent() + 5, Integer.toString(page) ); + if ( view.top() >= richText.height() ) + break; + printer.newPage(); + page++; + } while (true); + } +} + +void fileClose() +{ +// delete currentEditor(); + if ( currentEditor() != null ) + currentEditor().viewport().setFocus(); +} + +void fileExit() +{ + qApp().quit(); +} + +void editUndo() +{ + if ( currentEditor() == null ) + return; + currentEditor().undo(); +} + +void editRedo() +{ + if ( currentEditor() == null ) + return; + currentEditor().redo(); +} + +void editCut() +{ + if ( currentEditor() == null ) + return; + currentEditor().cut(); +} + +void editCopy() +{ + if ( currentEditor() == null ) + return; + currentEditor().copy(); +} + +void editPaste() +{ + if ( currentEditor() == null ) + return; + currentEditor().paste(); +} + +void textBold() +{ + if ( currentEditor() == null ) + return; + currentEditor().setBold( actionTextBold.isOn() ); +} + +void textUnderline() +{ + if ( currentEditor() == null ) + return; + currentEditor().setUnderline( actionTextUnderline.isOn() ); +} + +void textItalic() +{ + if ( currentEditor() == null ) + return; + currentEditor().setItalic( actionTextItalic.isOn() ); +} + +void textFamily( String f ) +{ + if ( currentEditor() == null ) + return; + currentEditor().setFamily( f ); + currentEditor().viewport().setFocus(); +} + +void textSize( String p ) +{ + if ( currentEditor() == null ) + return; + currentEditor().setPointSize( Integer.parseInt(p) ); + currentEditor().viewport().setFocus(); +} + +void textStyle( int i ) +{ + if ( currentEditor() == null ) + return; + if ( i == 0 ) + currentEditor().setParagType( QStyleSheetItem.DisplayBlock, QStyleSheetItem.ListDisc ); + else if ( i == 1 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListDisc ); + else if ( i == 2 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListCircle ); + else if ( i == 3 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListSquare ); + else if ( i == 4 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListDecimal ); + else if ( i == 5 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListLowerAlpha ); + else if ( i == 6 ) + currentEditor().setParagType( QStyleSheetItem.DisplayListItem, QStyleSheetItem.ListUpperAlpha ); + currentEditor().viewport().setFocus(); +} + +void textColor() +{ + if ( currentEditor() == null ) + return; + QColor col = QColorDialog.getColor( currentEditor().color(), this ); + if ( !col.isValid() ) + return; + currentEditor().setColor( col ); + QPixmap pix = new QPixmap( 16, 16 ); + pix.fill( black() ); + actionTextColor.setIconSet( new QIconSet(pix) ); +} + +void textAlign( QAction a ) +{ + if ( currentEditor() == null ) + return; + if ( a == actionAlignLeft ) + currentEditor().setAlignment( AlignLeft ); + else if ( a == actionAlignCenter ) + currentEditor().setAlignment( AlignHCenter ); + else if ( a == actionAlignRight ) + currentEditor().setAlignment( AlignRight ); + else if ( a == actionAlignJustify ) + currentEditor().setAlignment( AlignJustify ); +} + +void fontChanged( QFont f ) +{ + comboFont.lineEdit().setText( f.family() ); + comboSize.lineEdit().setText( Integer.toString( f.pointSize() ) ); + actionTextBold.setOn( f.bold() ); + actionTextItalic.setOn( f.italic() ); + actionTextUnderline.setOn( f.underline() ); +} + +void colorChanged( QColor c ) +{ + QPixmap pix = new QPixmap( 16, 16 ); + pix.fill( c ); + actionTextColor.setIconSet( new QIconSet(pix) ); +} + +void alignmentChanged( int a ) +{ + if ( ( a == AlignAuto ) || ( a & AlignLeft ) != 0) + actionAlignLeft.setOn( true ); + else if ( ( a & AlignHCenter ) != 0 ) + actionAlignCenter.setOn( true ); + else if ( ( a & AlignRight ) != 0 ) + actionAlignRight.setOn( true ); + else if ( ( a & AlignJustify ) != 0 ) + actionAlignJustify.setOn( true ); +} + +void editorChanged( QWidget w ) +{ + if ( currentEditor() == null ) + return; + fontChanged( currentEditor().font() ); + colorChanged( currentEditor().color() ); + alignmentChanged( currentEditor().alignment() ); +} +} diff --git a/qtjava/javalib/examples/textedit/editcopy.xpm b/qtjava/javalib/examples/textedit/editcopy.xpm new file mode 100644 index 00000000..cc6fb7a6 --- /dev/null +++ b/qtjava/javalib/examples/textedit/editcopy.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c #8b8bfd", +"X c #3c3cfd", +"o c #000082", +"O c Gray0", +"+ c None", +"@ c Gray0", +"# c Gray0", +/* pixels */ +"++++++++++++++++++++++", +"++++++++++++++++++++++", +"OOOOOOOO++++++++++++++", +"O OO+++++++++++++", +"O OOOO O O++++++++++++", +"O O O+++++++++++", +"O OOOO Ooooooooo++++++", +"O Oo oo+++++", +"O OOOOO o OOOO oXo++++", +"O o o.Xo+++", +"O OOOOO o OOOO o .Xo++", +"O o oooooo+", +"O OOOOO o OOOO o+", +"O o o+", +"O OOOOO o OOOOOOOOO o+", +"O o o+", +"OOOOOOOOo OOOOOOOOO o+", +"++++++++o o+", +"++++++++o OOOOOOOOO o+", +"++++++++o o+", +"++++++++ooooooooooooo+", +"++++++++++++++++++++++" +}; diff --git a/qtjava/javalib/examples/textedit/editcut.xpm b/qtjava/javalib/examples/textedit/editcut.xpm new file mode 100644 index 00000000..2391adda --- /dev/null +++ b/qtjava/javalib/examples/textedit/editcut.xpm @@ -0,0 +1,32 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 4 1", +" c Gray100", +". c #000082", +"X c Gray0", +"o c None", +/* pixels */ +"oooooooooooooooooooooo", +"oooooooXoooooXoooooooo", +"oooooooXoooooXoooooooo", +"oooooooXoooooXoooooooo", +"oooooooXooooXXoooooooo", +"oooooooXXoooXooooooooo", +"ooooooooXoooXooooooooo", +"ooooooooXXoXXooooooooo", +"oooooooooXXXoooooooooo", +"oooooooooXXXoooooooooo", +"ooooooooooXooooooooooo", +"ooooooooo.X.oooooooooo", +"oooooooo..o...oooooooo", +"ooooooo.o.o.oo.ooooooo", +"oooooo.oo.o.ooo.oooooo", +"ooooo.ooo.o.oooo.ooooo", +"oooo.oooo.o.oooo.ooooo", +"oooo.oooo.oo.ooo.ooooo", +"oooo.oooo.oo.oo.oooooo", +"oooo.ooo.oooo..ooooooo", +"ooooo...oooooooooooooo", +"oooooooooooooooooooooo" +}; diff --git a/qtjava/javalib/examples/textedit/editpaste.xpm b/qtjava/javalib/examples/textedit/editpaste.xpm new file mode 100644 index 00000000..3f775920 --- /dev/null +++ b/qtjava/javalib/examples/textedit/editpaste.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c Yellow", +"X c #c6c3c6", +"o c #848284", +"O c #848200", +"+ c #000084", +"@ c Gray0", +"# c None", +/* pixels */ +"######################", +"#######@@@@@##########", +"##@@@@@@...@@@@@@#####", +"#@@@@@@.....@@@@@@####", +"@@oOo@@.@@@.@@oOo@@###", +"@oOo@XXXXXXXXX@oOo@###", +"@OoO@XXXXXXXXX@OoO@###", +"@oOo@@@@@@@@@@@oOo@###", +"@OoOoOoOoOoOoOoOoO@###", +"@oOoOoOoOoOoOoOoOo@###", +"@OoOoOoO++++++++++@###", +"@oOoOoOo+ + +###", +"@OoOoOoO+ +++++ + +##", +"@oOoOoOo+ + +#", +"@OoOoOoO+ +++++ + +", +"@oOoOoOo+ ++++++", +"@OoOoOoO+ +++++ +", +"@oOoOoOo+ +", +"@OoOoOoO+ ++++++++++ +", +"#@@@@@@@+ +", +"########++++++++++++++", +"######################" +}; diff --git a/qtjava/javalib/examples/textedit/editredo.xpm b/qtjava/javalib/examples/textedit/editredo.xpm new file mode 100644 index 00000000..46dc0331 --- /dev/null +++ b/qtjava/javalib/examples/textedit/editredo.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c #848284", +"X c #000084", +"o c Gray0", +"O c None", +"+ c Gray0", +"@ c Gray0", +"# c Gray0", +/* pixels */ +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOO.XXXXXXOOOOOOOOOOO", +"OOOXXXXXXXXXXOOOOOOXOO", +"OO.XXOOOOOOXXXXOOOXXOO", +"OOXXOOOOOOOOOXXXOXXXOO", +"OOXXOOOOOOOOOOXXXXXXOO", +"OOXXOOOOOOOOOOOXXXXXOO", +"OOXXOOOOOOOOOOXXXXXXOO", +"OOXXOOOOOOOOOXXXXXXXOO", +"OO.XXOOOOOOOXXXXXXXXOO", +"OOOXXX.OOOOOOOOOOOOOOO", +"OOOOXXXOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO" +}; diff --git a/qtjava/javalib/examples/textedit/editundo.xpm b/qtjava/javalib/examples/textedit/editundo.xpm new file mode 100644 index 00000000..229c1636 --- /dev/null +++ b/qtjava/javalib/examples/textedit/editundo.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c #848284", +"X c #000084", +"o c Gray0", +"O c None", +"+ c Gray0", +"@ c Gray0", +"# c Gray0", +/* pixels */ +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOXXXXXX.OOOO", +"OOXOOOOOOXXXXXXXXXXOOO", +"OOXXOOOXXXXOOOOOOXX.OO", +"OOXXXOXXXOOOOOOOOOXXOO", +"OOXXXXXXOOOOOOOOOOXXOO", +"OOXXXXXOOOOOOOOOOOXXOO", +"OOXXXXXXOOOOOOOOOOXXOO", +"OOXXXXXXXOOOOOOOOOXXOO", +"OOXXXXXXXXOOOOOOOXX.OO", +"OOOOOOOOOOOOOOO.XXXOOO", +"OOOOOOOOOOOOOOOXXXOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO" +}; diff --git a/qtjava/javalib/examples/textedit/example.html b/qtjava/javalib/examples/textedit/example.html new file mode 100644 index 00000000..56023031 --- /dev/null +++ b/qtjava/javalib/examples/textedit/example.html @@ -0,0 +1,340 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> +<title>Qt Toolkit - QLabel Class</title><style type="text/css"><!-- +h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; } +a:link { color: #004faf; text-decoration: none } +a:visited { color: #672967; text-decoration: none }body { background: white; color: black; } +--></style> +</head><body bgcolor="#ffffff"> + +<h1 align=center>QLabel Class Reference</h1><br clear="all"> +<p> +The QLabel widget provides a static information display +<a href="#details">More...</a> +<p> +<code>#include <<a href="qlabel-h.html">qlabel.h</a>></code> +<p> +Inherits <a href="qframe.html">QFrame</a>. +<p><a href="qlabel-members.html">List of all member functions.</a> +<h2>Public Members</h2> +<ul> +<li><div class="fn"><a href="#39107d"><b>QLabel</b></a> ( QWidget * parent, const char * name=0, WFlags f=0 ) </div> +<li><div class="fn"><a href="#2bafbb"><b>QLabel</b></a> ( const QString & text, QWidget * parent, const char * name=0, WFlags f=0 ) </div> +<li><div class="fn"><a href="#5514c7"><b>QLabel</b></a> ( QWidget * buddy, const QString &, QWidget * parent, const char * name=0, WFlags f=0 ) </div> +<li><div class="fn"><a href="#9958af"><b>~QLabel</b></a> () </div> +<li><div class="fn">QString <a href="#72cf09"><b>text</b></a> () const</div> +<li><div class="fn">QPixmap* <a href="#101ecb"><b>pixmap</b></a> () const</div> +<li><div class="fn">QMovie* <a href="#7dcdfe"><b>movie</b></a> () const</div> +<li><div class="fn">TextFormat <a href="#0b92ed"><b>textFormat</b></a> () const</div> +<li><div class="fn">void <a href="#5de3f9"><b>setTextFormat</b></a> ( TextFormat ) </div> +<li><div class="fn">int <a href="#2fcaa3"><b>alignment</b></a> () const</div> +<li><div class="fn">virtual void <a href="#1f406e"><b>setAlignment</b></a> ( int ) </div> +<li><div class="fn">int <a href="#e3c907"><b>indent</b></a> () const</div> +<li><div class="fn">void <a href="#ed9b8b"><b>setIndent</b></a> ( int ) </div> +<li><div class="fn">bool autoResize () const <em>(obsolete)</em></div> +<li><div class="fn">virtual void setAutoResize ( bool ) <em>(obsolete)</em></div> +<li><div class="fn">bool <a href="#7e1f73"><b>hasScaledContents</b></a> () const</div> +<li><div class="fn">void <a href="#e9e3cf"><b>setScaledContents</b></a> ( bool ) </div> +<li><div class="fn">virtual void <a href="#191701"><b>setBuddy</b></a> ( QWidget * ) </div> +<li><div class="fn">QWidget* <a href="#123954"><b>buddy</b></a> () const</div> +</ul> +<h2>Public Slots</h2> +<ul> +<li><div class="fn">virtual void <a href="#dffb43"><b>setText</b></a> ( const QString & ) </div> +<li><div class="fn">virtual void <a href="#f3f301"><b>setPixmap</b></a> ( const QPixmap & ) </div> +<li><div class="fn">virtual void <a href="#60de9f"><b>setMovie</b></a> ( const QMovie & ) </div> +<li><div class="fn">virtual void <a href="#301e3c"><b>setNum</b></a> ( int ) </div> +<li><div class="fn">virtual void <a href="#1a8f6a"><b>setNum</b></a> ( double ) </div> +<li><div class="fn">void <a href="#be73f3"><b>clear</b></a> () </div> +</ul> +<h2>Protected Members</h2> +<ul> +<li><div class="fn">virtual void <a href="#fac264"><b>drawContents</b></a> ( QPainter * ) </div> +<li><div class="fn">virtual void <a href="#479dd2"><b>drawContentsMask</b></a> ( QPainter * ) </div> +</ul> +<h2>Properties</h2> +<table border=1 cellpadding=3 cellspacing=0> +<tr><th>Type<th>Name<th>READ<th>WRITE<th>Options +<tr><td>QString<td>text<td>text<td>setText<td> +<tr><td>TextFormat<td>textFormat<td>textFormat<td>setTextFormat<td> +<tr><td>QPixmap<td>pixmap<td>pixmap<td>setPixmap<td> +<tr><td>bool<td>scaledContents<td>hasScaledContents<td>setScaledContents<td> +<tr><td>Alignment<td>alignment<td>alignment<td>setAlignment<td> +<tr><td>int<td>indent<td>indent<td>setIndent<td> +</table> +<p> +<hr><h2><a name="details"></a>Detailed Description</h2> +The QLabel widget provides a static information display +<p> +QLabel is used for displaying information in the form of text or +image to the user. No user interaction functionality is +provided. The visual appearance of the label can be configured in +various ways, and it can be used for specifying a focus accelerator +key for another widget. +<p>A QLabel can contain any of the following content types: +<ul> +<li> A plain text: set by passing a <a href="qstring.html">QString</a> to <a href="#dffb43">setText</a>(). +<li> A rich text: set by passing a QString that contains a rich text to setText(). +<li> A pixmap: set by passing a <a href="qpixmap.html">QPixmap</a> to <a href="#f3f301">setPixmap</a>(). +<li> A movie: set by passing a <a href="qmovie.html">QMovie</a> to <a href="#60de9f">setMovie</a>(). +<li> A number: set by passing an <em>int</em> or a <em>double</em> to <a href="#1a8f6a">setNum</a>(), which converts the number to plain text. +<li> Nothing: The same as an empty plain text. This is the default. Set by <a href="#be73f3">clear</a>(). +</ul> +<p>When the content is changed using any of these functions, any +previous content is cleared. +<p>The look of a QLabel can be tuned in several ways. All the settings +of <a href="qframe.html">QFrame</a> are available for specifying a widget frame. The +positioning of the content within the QLabel widget area can be +tuned with <a href="#1f406e">setAlignment</a>() and <a href="#ed9b8b">setIndent</a>(). For example, this code +sets up a sunken panel with a two-line text in the bottom right +corner (both lines being flush with the right side of the label): +<p><pre> <a href="qlabel.html">QLabel</a> *label = new <a href="qlabel.html">QLabel</a>; + label-><a href="qframe.html#c0d758">setFrameStyle</a>( QFrame::Panel | QFrame::Sunken ); + label-><a href="#dffb43">setText</a>( "first line\nsecond line" ); + label-><a href="#1f406e">setAlignment</a>( AlignBottom | AlignRight ); +</pre> +<p>A QLabel is often used as a label for another, interactive +widget. For this use, QLabel provides a handy mechanism for adding +an accelerator key (see <a href="qaccel.html">QAccel</a>) that will set the keyboard focus to +the other widget (called the QLabel's "buddy"). Example: +<p><pre> <a href="qlineedit.html">QLineEdit</a>* phoneEdit = new <a href="qlineedit.html">QLineEdit</a>( this, "phoneEdit" ); + <a href="qlabel.html">QLabel</a>* phoneLabel = new <a href="qlabel.html">QLabel</a>( phoneEdit, "&Phone:", this, "phoneLabel" ); +</pre> +<p>In this example, keyboard focus is transferred to the label's buddy +(the <a href="qlineedit.html">QLineEdit</a>) when the user presses <dfn>Alt-P.</dfn> You can also +use the <a href="#191701">setBuddy</a>() function to accomplish the same. +<p> +<p>See also <a href="qlineedit.html">QLineEdit</a>, <a href="qtextview.html">QTextView</a>, <a href="qpixmap.html">QPixmap</a>, <a href="qmovie.html">QMovie</a> and <a href="guibooks.html#fowler">GUI Design Handbook: Label</a> +<p>Examples: + <a href="cursor-cursor-cpp.html#QLabel">cursor/cursor.cpp</a> + <a href="layout-layout-cpp.html#QLabel">layout/layout.cpp</a> + <a href="popup-popup-cpp.html#QLabel">popup/popup.cpp</a> + <a href="menu-menu-cpp.html#QLabel">menu/menu.cpp</a> + <a href="progress-progress-cpp.html#QLabel">progress/progress.cpp</a> + <a href="qmag-qmag-cpp.html#QLabel">qmag/qmag.cpp</a> + <a href="movies-main-cpp.html#QLabel">movies/main.cpp</a> + <a href="customlayout-main-cpp.html#QLabel">customlayout/main.cpp</a> + +<hr><h2>Member Function Documentation</h2> +<h3 class="fn"><a name="5514c7"></a>QLabel::QLabel ( <a href="qwidget.html">QWidget</a> * buddy, const <a href="qstring.html">QString</a> & text, <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3> +<p>Constructs a label with a text and a buddy. +<p>The <em>text</em> is set with <a href="#dffb43">setText</a>(). The <em>buddy</em> is set with <a href="#191701">setBuddy</a>(). +<p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a> +constructor. +<p>See also <a href="#dffb43">setText</a>(), <a href="#191701">setBuddy</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>(). +<h3 class="fn"><a name="39107d"></a>QLabel::QLabel ( <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3> +<p>Constructs an empty label. +<p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a> +constructor. +<p>See also <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>(). +<h3 class="fn"><a name="2bafbb"></a>QLabel::QLabel ( const <a href="qstring.html">QString</a> & text, <a href="qwidget.html">QWidget</a> * parent, const char * name=0, WFlags f=0 )</h3> +<p>Constructs a label with a text. The <em>text</em> is set with <a href="#dffb43">setText</a>(). +<p>The <em>parent, name</em> and <em>f</em> arguments are passed to the <a href="qframe.html">QFrame</a> +constructor. +<p>See also <a href="#dffb43">setText</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#c0d758">setFrameStyle</a>() and <a href="#ed9b8b">setIndent</a>(). +<h3 class="fn"><a name="9958af"></a>QLabel::~QLabel ()</h3> +<p>Destructs the label. +<h3 class="fn">int <a name="2fcaa3"></a>QLabel::alignment () const</h3> +<p>Returns the alignment setting. +<p>See also <a href="#1f406e">setAlignment</a>(). +<h3 class="fn">bool <a name="75b2a1"></a>QLabel::autoResize () const</h3> +<p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p> +<p>Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing +is disabled. +<p>Auto-resizing is disabled by default. +<p>See also <a href="#c0e104">setAutoResize</a>(). +<h3 class="fn"><a href="qwidget.html">QWidget</a> * <a name="123954"></a>QLabel::buddy () const</h3> +<p>Returns the buddy of this label, or 0 if no buddy is currently set. +<p>See also <a href="#191701">setBuddy</a>(). +<h3 class="fn">void <a name="be73f3"></a>QLabel::clear () <code>[slot]</code></h3> +<p>Clears any label contents. Equivalent with <a href="#dffb43">setText</a>( "" ). +<h3 class="fn">void <a name="fac264"></a>QLabel::drawContents ( <a href="qpainter.html">QPainter</a> * p ) <code>[virtual protected]</code></h3> +<p>Draws the label contents using the painter <em>p.</em> +<p>Reimplemented from <a href="qframe.html#99e687">QFrame.</a> +<h3 class="fn">void <a name="479dd2"></a>QLabel::drawContentsMask ( <a href="qpainter.html">QPainter</a> * p ) <code>[virtual protected]</code></h3> +<p>Draws the label contents mask using the painter <em>p.</em> +Used only in transparent mode. +<p>See also <a href="qwidget.html#c7a335">QWidget::setAutoMask</a>();. +<p>Reimplemented from <a href="qframe.html#4cbf11">QFrame.</a> +<h3 class="fn">void <a name="0435a2"></a>QLabel::fontChange ( const <a href="qfont.html">QFont</a> & ) <code>[virtual protected]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#570a8f">QWidget.</a> +<h3 class="fn">bool <a name="7e1f73"></a>QLabel::hasScaledContents () const</h3> +<p>Returns whether the label will scale its contents to fill all +available space. +<p>See also <a href="#e9e3cf">setScaledContents</a>(). +<h3 class="fn">int <a name="dae451"></a>QLabel::heightForWidth ( int w ) const <code>[virtual]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#2e8476">QWidget.</a> +<h3 class="fn">int <a name="e3c907"></a>QLabel::indent () const</h3> +<p>Returns the indent of the label. +<p>See also <a href="#ed9b8b">setIndent</a>(). +<h3 class="fn"><a href="qsize.html">QSize</a> <a name="53c8c7"></a>QLabel::minimumSizeHint () const <code>[virtual]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#3f0fc2">QWidget.</a> +<h3 class="fn"><a href="qmovie.html">QMovie</a>* <a name="7dcdfe"></a>QLabel::movie () const</h3> +<p>If the label contains a movie, returns a pointer to it. Otherwise, +returns 0. +<p>See also <a href="#60de9f">setMovie</a>(). +<h3 class="fn"><a href="qpixmap.html">QPixmap</a> * <a name="101ecb"></a>QLabel::pixmap () const</h3> +<p>If the label contains a pixmap, returns a pointer to it. Otherwise, +returns 0. +<p>See also <a href="#f3f301">setPixmap</a>(). +<h3 class="fn">void <a name="3cb6e7"></a>QLabel::resizeEvent ( <a href="qresizeevent.html">QResizeEvent</a> * e ) <code>[virtual protected]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#28c156">QWidget.</a> +<h3 class="fn">void <a name="1f406e"></a>QLabel::setAlignment ( int alignment ) <code>[virtual]</code></h3> +<p>Sets the alignment of the label contents. +<p>The <em>alignment</em> must be a bitwise OR of <a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a> +values. The <code>WordBreak, ExpandTabs, SingleLine</code> and <code>ShowPrefix</code> flags apply only if the label contains a plain text, and +are otherwise ignored. The <code>DontClip</code> flag is always ignored. +<p>If the label has a buddy, the <code>ShowPrefix</code> flag is forced to TRUE. +<p>The default alignment is <code>AlignLeft | AlignVCenter | +ExpandTabs</code> if the label doesn't have a buddy and +<code>AlignLeft | AlignVCenter | ExpandTabs | ShowPrefix </code> if +the label has a buddy. +<p>See also <a href="qt.html#AlignmentFlags">Qt::AlignmentFlags</a>, <a href="#2fcaa3">alignment</a>(), <a href="#191701">setBuddy</a>() and <a href="#dffb43">setText</a>(). +<p>Examples: + <a href="cursor-cursor-cpp.html#setAlignment">cursor/cursor.cpp</a> + <a href="layout-layout-cpp.html#setAlignment">layout/layout.cpp</a> + <a href="popup-popup-cpp.html#setAlignment">popup/popup.cpp</a> + <a href="qmag-qmag-cpp.html#setAlignment">qmag/qmag.cpp</a> + <a href="customlayout-main-cpp.html#setAlignment">customlayout/main.cpp</a> +<h3 class="fn">void <a name="1b6d73"></a>QLabel::setAutoMask ( bool b ) <code>[virtual]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#c7a335">QWidget.</a> +<h3 class="fn">void <a name="c0e104"></a>QLabel::setAutoResize ( bool enable ) <code>[virtual]</code></h3> +<p><b>This function is obsolete.</b> It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.<p> +Enables auto-resizing if <em>enable</em> is TRUE, or disables it if <em>enable</em> is FALSE. +<p>When auto-resizing is enabled, the label will resize itself to fit +the contents whenever the contents change. The top left corner is +not moved. This is useful for QLabel widgets that are not managed by +a <a href="qlayout.html">QLayout</a> (e.g. top-level widgets). +<p>Auto-resizing is disabled by default. +<p>See also <a href="#75b2a1">autoResize</a>(), <a href="qwidget.html#ab3108">adjustSize</a>() and <a href="#614dd5">sizeHint</a>(). +<h3 class="fn">void <a name="191701"></a>QLabel::setBuddy ( <a href="qwidget.html">QWidget</a> * buddy ) <code>[virtual]</code></h3> +<p>Sets the buddy of this label to <em>buddy.</em> +<p>When the user presses the accelerator key indicated by this label, +the keyboard focus is transferred to the label's buddy widget. +<p>The buddy mechanism is only available for QLabels that contain a +plain text in which one letter is prefixed with '&'. It is this +letter that is set as the accelerator key. The letter is displayed +underlined, and the '&' is not displayed (i.e. the <code>ShowPrefix</code> +alignment flag is turned on; see <a href="#1f406e">setAlignment</a>()). +<p>In a dialog, you might create two data entry widgets and a label for +each, and set up the geometry layout so each label is just to the +left of its data entry widget (its "buddy"), somewhat like this: +<p><pre> <a href="qlineedit.html">QLineEdit</a> *nameEd = new <a href="qlineedit.html">QLineEdit</a>( this ); + <a href="qlabel.html">QLabel</a> *nameLb = new <a href="qlabel.html">QLabel</a>( "&Name:", this ); + nameLb-><a href="#191701">setBuddy</a>( nameEd ); + <a href="qlineedit.html">QLineEdit</a> *phoneEd = new <a href="qlineedit.html">QLineEdit</a>( this ); + <a href="qlabel.html">QLabel</a> *phoneLb = new <a href="qlabel.html">QLabel</a>( "&Phone:", this ); + phoneLb-><a href="#191701">setBuddy</a>( phoneEd ); + // ( layout setup not shown ) +</pre> +<p>With the code above, the focus jumps to the Name field when the user +presses Alt-N, and to the Phone field when the user presses Alt-P. +<p>To unset a previously set buddy, call this function with <em>buddy</em> +set to 0. +<p>See also <a href="#123954">buddy</a>(), <a href="#dffb43">setText</a>(), <a href="qaccel.html">QAccel</a> and <a href="#1f406e">setAlignment</a>(). +<p>Examples: + <a href="layout-layout-cpp.html#setBuddy">layout/layout.cpp</a> +<h3 class="fn">void <a name="ed9b8b"></a>QLabel::setIndent ( int indent )</h3> +<p>Sets the indent of the label to <em>indent</em> pixels. +<p>The indent applies to the left edge if <a href="#2fcaa3">alignment</a>() is <code>AlignLeft,</code> +to the right edge if alignment() is <code>AlignRight,</code> to the top edge +if alignment() is <code>AlignTop,</code> and to to the bottom edge if +alignment() is <code>AlignBottom.</code> +<p>If <em>indent</em> is negative, or if no indent has been set, the label +computes the effective indent as follows: If <a href="qframe.html#e0ccef">frameWidth</a>() is 0, the +effective indent becomes 0. If frameWidth() is greater than 0, the +effective indent becomes half the width of the "x" character of the +widget's current <a href="qwidget.html#3a7237">font</a>(). +<p>If <em>indent</em> is non-negative, the effective indent is <em>indent</em> +pixels. +<p>See also <a href="#e3c907">indent</a>(), <a href="#1f406e">setAlignment</a>(), <a href="qframe.html#e0ccef">frameWidth</a>() and <a href="qwidget.html#3a7237">font</a>(). +<p>Examples: + <a href="movies-main-cpp.html#setIndent">movies/main.cpp</a> +<h3 class="fn">void <a name="60de9f"></a>QLabel::setMovie ( const <a href="qmovie.html">QMovie</a> & movie ) <code>[virtual slot]</code></h3> +<p>Sets the label contents to <em>movie.</em> Any previous content is cleared. +<p>The buddy accelerator, if any, is disabled. +<p>The label resizes itself if auto-resizing is enabled. +<p>See also <a href="#7dcdfe">movie</a>() and <a href="#191701">setBuddy</a>(). +<h3 class="fn">void <a name="1a8f6a"></a>QLabel::setNum ( double num ) <code>[virtual slot]</code></h3> +<p>Sets the label contents to a plain text containing the printed value +of <em>num.</em> Does nothing if this is equal to the current contents of +the label. Any previous content is cleared. +<p>The buddy accelerator, if any, is disabled. +<p>The label resizes itself if auto-resizing is enabled. +<p>See also <a href="#dffb43">setText</a>(), <a href="qstring.html#01d80b">QString::setNum</a>() and <a href="#191701">setBuddy</a>(). +<h3 class="fn">void <a name="301e3c"></a>QLabel::setNum ( int num ) <code>[virtual slot]</code></h3> +<p>Sets the label contents to a plain text containing the printed value +of <em>num.</em> Does nothing if this is equal to the current contents of +the label. Any previous content is cleared. +<p>The buddy accelerator, if any, is disabled. +<p>The label resizes itself if auto-resizing is enabled. +<p>See also <a href="#dffb43">setText</a>(), <a href="qstring.html#01d80b">QString::setNum</a>() and <a href="#191701">setBuddy</a>(). +<h3 class="fn">void <a name="f3f301"></a>QLabel::setPixmap ( const <a href="qpixmap.html">QPixmap</a> & pixmap ) <code>[virtual slot]</code></h3> +<p>Sets the label contents to <em>pixmap.</em> Any previous content is cleared. +<p>The buddy accelerator, if any, is disabled. +<p>The label resizes itself if auto-resizing is enabled. +<p>See also <a href="#101ecb">pixmap</a>() and <a href="#191701">setBuddy</a>(). +<h3 class="fn">void <a name="e9e3cf"></a>QLabel::setScaledContents ( bool enable )</h3> +<p>When called with <em>enable</em> == TRUE, and the label shows a pixmap, +it will scale the pixmap to fill available space. +<p>See also <a href="#7e1f73">hasScaledContents</a>(). +<h3 class="fn">void <a name="dffb43"></a>QLabel::setText ( const <a href="qstring.html">QString</a> & text ) <code>[virtual slot]</code></h3> +<p>Sets the label contents to <em>text,</em> or does nothing if <em>text</em> is +equal to the current contents of the label. Any previous content is +cleared. +<p><em>text</em> will be interpreted either as a plain text or as a rich +text, depending on the text format setting; see <a href="#5de3f9">setTextFormat</a>(). The +default setting is <code>AutoText,</code> i.e. QLabel will try to auto-detect +the format of <em>text.</em> +<p>If <em>text</em> is interpreted as a plain text, and a buddy has been set, +the buddy accelerator key is updated from the new text. +<p>The label resizes itself if auto-resizing is enabled. +<p>Note that Qlabel is well suited to display small rich text documents +only. For large documents, use <a href="qtextview.html">QTextView</a> instead. It will flicker +less on resize and can also provide a scrollbar if necessary. +<p>See also <a href="#72cf09">text</a>(), <a href="#5de3f9">setTextFormat</a>(), <a href="#191701">setBuddy</a>() and <a href="#1f406e">setAlignment</a>(). +<p>Examples: + <a href="cursor-cursor-cpp.html#setText">cursor/cursor.cpp</a> + <a href="layout-layout-cpp.html#setText">layout/layout.cpp</a> + <a href="popup-popup-cpp.html#setText">popup/popup.cpp</a> + <a href="qmag-qmag-cpp.html#setText">qmag/qmag.cpp</a> + <a href="customlayout-main-cpp.html#setText">customlayout/main.cpp</a> +<h3 class="fn">void <a name="5de3f9"></a>QLabel::setTextFormat ( <a href="qt.html#TextFormat">Qt::TextFormat</a> format )</h3> +<p>Sets the text format to <em>format.</em> See the <a href="qt.html#TextFormat">Qt::TextFormat</a> enum for +an explanation of the possible options. +<p>The default format is <code>AutoText.</code> +<p>See also <a href="#0b92ed">textFormat</a>() and <a href="#dffb43">setText</a>(). +<h3 class="fn"><a href="qsize.html">QSize</a> <a name="614dd5"></a>QLabel::sizeHint () const <code>[virtual]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Examples: + <a href="layout-layout-cpp.html#sizeHint">layout/layout.cpp</a> +<p>Reimplemented from <a href="qwidget.html#290bcd">QWidget.</a> +<h3 class="fn"><a href="qsizepolicy.html">QSizePolicy</a> <a name="26e1d9"></a>QLabel::sizePolicy () const <code>[virtual]</code></h3> +<p>Reimplemented for internal reasons; the API is not affected. +<p>Reimplemented from <a href="qwidget.html#2d5d13">QWidget.</a> +<h3 class="fn"><a href="qstring.html">QString</a> <a name="72cf09"></a>QLabel::text () const</h3> +<p>Returns the label text. If the content is a plain or a rich text, +this is the string that was passed to <a href="#dffb43">setText</a>(). Otherwise, it is an +empty/null string. +<p>See also <a href="#dffb43">setText</a>(), <a href="#1a8f6a">setNum</a>() and <a href="#be73f3">clear</a>(). +<h3 class="fn">Qt::TextFormat <a name="0b92ed"></a>QLabel::textFormat() const</h3> +<p>Returns the current text format. +<p>See also <a href="#5de3f9">setTextFormat</a>(). +<hr><p> +Search the documentation, FAQ, qt-interest archive and more (uses +<a href="http://www.trolltech.com">www.trolltech.com</a>):<br> +<form method=post action="http://www.trolltech.com/search.cgi"> +<input type=hidden name="version" value="3.0.0-snapshot"><nobr> +<input size="50" name="search"><input type=submit value="Search"> +</nobr></form><hr><p> +This file is part of the <a href="index.html">Qt toolkit</a>, +copyright © 1995-2000 +<a href="http://www.trolltech.com">Trolltech</a>, all rights reserved.<p><address><hr><div align="center"> +<table width="100%" cellspacing="0" border="0"><tr> +<td>Copyright © 2000 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> +<td align="right"><div align="right">Qt version 3.0.0-snapshot</div> +</table></div></address></body></html> diff --git a/qtjava/javalib/examples/textedit/filenew.xpm b/qtjava/javalib/examples/textedit/filenew.xpm new file mode 100644 index 00000000..884d7cbb --- /dev/null +++ b/qtjava/javalib/examples/textedit/filenew.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c Gray76", +"X c Gray53", +"o c Gray36", +"O c Gray18", +"+ c Gray0", +"@ c None", +"# c Gray0", +/* pixels */ +"@@@@@@@@@@@@@@@@@@@@@@", +"@@@@++++++++++@@@@@@@@", +"@@@@+ +O+@@@@@@@", +"@@@@+ +oO+@@@@@@", +"@@@@+ +XoO+@@@@@", +"@@@@+ +.XoO+@@@@", +"@@@@+ + .XoO+@@@", +"@@@@+ +++++++@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+ +@@@", +"@@@@+++++++++++++++@@@", +"@@@@@@@@@@@@@@@@@@@@@@", +"@@@@@@@@@@@@@@@@@@@@@@" +}; diff --git a/qtjava/javalib/examples/textedit/fileopen.xpm b/qtjava/javalib/examples/textedit/fileopen.xpm new file mode 100644 index 00000000..82effcf7 --- /dev/null +++ b/qtjava/javalib/examples/textedit/fileopen.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c Yellow", +"X c #848200", +"o c Gray0", +"O c None", +"+ c Gray0", +"@ c Gray0", +"# c Gray0", +/* pixels */ +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO", +"OOOOOOOOOOOOooooOOOOoO", +"OOOOOOOOOOOoOOOOooOooO", +"OOOOOOOOOOOOOOOOOOoooO", +"OOOOOOOOOOOOOOOOOooooO", +"OooooOOOOOOOOOOOoooooO", +"o. . ooooooooooOOOOOOO", +"o . . . . . . oOOOOOOO", +"o. . . . . . .oOOOOOOO", +"o . . . . . . oOOOOOOO", +"o. . . ooooooooooooooo", +"o . . ooXXXXXXXXXXXXoo", +"o. . ooXXXXXXXXXXXXooO", +"o . ooXXXXXXXXXXXXooOO", +"o. ooXXXXXXXXXXXXooOOO", +"o ooXXXXXXXXXXXXooOOOO", +"oooXXXXXXXXXXXXooOOOOO", +"ooXXXXXXXXXXXXooOOOOOO", +"oooooooooooooooOOOOOOO", +"OOOOOOOOOOOOOOOOOOOOOO" +}; diff --git a/qtjava/javalib/examples/textedit/fileprint.xpm b/qtjava/javalib/examples/textedit/fileprint.xpm new file mode 100644 index 00000000..8701d460 --- /dev/null +++ b/qtjava/javalib/examples/textedit/fileprint.xpm @@ -0,0 +1,117 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 89 1", +" c Gray0", +". c #101008081010", +"X c #101010101010", +"o c #101010101818", +"O c #181810101818", +"+ c #181818181818", +"@ c #181818182121", +"# c #212118182121", +"$ c Gray13", +"% c #212121212929", +"& c #292921212929", +"* c Gray16", +"= c #292929293131", +"- c #313129293131", +"; c #313131313131", +": c #313131313939", +"> c #393931313939", +", c #393939393939", +"< c #393939394242", +"1 c #424239394242", +"2 c Gray26", +"3 c #4a4a4a4a5252", +"4 c #5a5a52525a5a", +"5 c #5a5a5a5a6363", +"6 c #6b6b63636b6b", +"7 c Gray42", +"8 c #6b6b6b6b7373", +"9 c #73736b6b7373", +"0 c #7b7b73737b7b", +"q c #7b7b73738484", +"w c #0808ffff0808", +"e c #2929ffff2929", +"r c #3131ffff3131", +"t c #5a5acece5a5a", +"y c #6b6bffff6363", +"u c #7b7bffff7b7b", +"i c #84847b7b8484", +"p c #84847b7b8c8c", +"a c #8c8c7b7b9494", +"s c #848484848c8c", +"d c #8c8c84848c8c", +"f c Gray55", +"g c #8c8c84849494", +"h c #8c8c8c8c9494", +"j c #94948c8c9494", +"k c #94948c8c9c9c", +"l c Gray58", +"z c #949494949c9c", +"x c #9c9c94949c9c", +"c c Gray61", +"v c #9c9c9494a5a5", +"b c #9c9c9c9ca5a5", +"n c #a5a59c9ca5a5", +"m c #a5a59c9cadad", +"M c #adad9c9cadad", +"N c #a5a5a5a5a5a5", +"B c #a5a5a5a5adad", +"V c #adada5a5adad", +"C c Gray68", +"Z c #adadadadb5b5", +"A c #b5b5adadb5b5", +"S c Gray71", +"D c Gray74", +"F c #9494c6c69494", +"G c #9c9ccecea5a5", +"H c #bdbdd6d6bdbd", +"J c #c0c0c0c0c0c0", +"K c #c6c6c6c6c6c6", +"L c #cecec6c6cece", +"P c #cececececece", +"I c #cecececed6d6", +"U c #d6d6ceced6d6", +"Y c #d6d6cecedede", +"T c Gray84", +"R c #d6d6d6d6dede", +"E c #deded6d6dede", +"W c Gray87", +"Q c #deded6d6e7e7", +"! c #dedededee7e7", +"~ c #d6d6ffffd6d6", +"^ c #e7e7dedee7e7", +"/ c #e7e7e7e7e7e7", +"( c #e7e7e7e7efef", +") c #efefe7e7efef", +"_ c #efefefefefef", +"` c #e7e7ffffe7e7", +"' c Gray97", +"] c Gray100", +"[ c None", +/* pixels */ +"[[[[[[SDPPPPKKDDCD[[[[", +"[[[[[[D_/////___WD[[[[", +"[[[[[[DKKKPPKKKKDK[[[[", +"[[[[[[SDDDDSDDSSCD[[[[", +"[[[[[KCKDKKKDDDKS[[[[[", +"[[[[[DDSDDDDDDKKS[[[[[", +"[[[[[DSKDDDDDKDKC[[[[[", +"[[[[[KDDDDDDDDDDS[[[[[", +"[[[[[CP/WWWWWWTWNNZ[[[", +"[[[Dc9STPTPTPTWWj427S[", +"[[Dziq0000000pag8<%@2N", +"[DcE(!ERRRRUYGtFn2##O<", +"Db)]]]]]]]]]~ewePa;@X#", +"V']]]]]]]]]]`yru]Q0@ #", +"BRILITRRW^!E!RHUILhO @", +"jAZVBmBnmmNmnmMvzh6o #", +"jZZmBnnnbnbbbbvxxg6o +", +"lmmnbnbbbvcvxxxvjs6O 3", +"jBnnvcvxvcvxvxzjhd8o+C", +"lsdgfgdhgdhhjhjkhg6+l[", +"S9%@$%&&&=--::>>:-:l[[", +"[[C511,:;;;**%++.2c[[[" +}; diff --git a/qtjava/javalib/examples/textedit/filesave.xpm b/qtjava/javalib/examples/textedit/filesave.xpm new file mode 100644 index 00000000..71cbd331 --- /dev/null +++ b/qtjava/javalib/examples/textedit/filesave.xpm @@ -0,0 +1,36 @@ +/* XPM */ +static char *magick[] = { +/* columns rows colors chars-per-pixel */ +"22 22 8 1", +" c Gray100", +". c #cab5d1", +"X c #c1c1c1", +"o c #848200", +"O c Gray0", +"+ c None", +"@ c Gray0", +"# c Gray0", +/* pixels */ +"++++++++++++++++++++++", +"+OOOOOOOOOOOOOOOOOOOO+", +"+OooOXXXXXXXXXXXXOXXO+", +"+OooOXXXXXXXXXXXXOXXO+", +"+OooOXXXXXXXXX.XXOOOO+", +"+OooOXXX..XXXXXXXOooO+", +"+OooOXXX..XXXXXXXOooO+", +"+OooOXXXXXXXXXXXXOooO+", +"+OooOXXXXXXXXXXXXOooO+", +"+OooOXXXXXXXXXXXXOooO+", +"+OooOXXXXXXXXXXXXOooO+", +"+OoooOOOOOOOOOOOOoooO+", +"+OooooooooooooooooooO+", +"+OooooooooooooooooooO+", +"+OoooOOOOOOOOOOOOOooO+", +"+OoooOOOOOOOOOXXXOooO+", +"+OoooOOOOOOOOOXXXOooO+", +"+OoooOOOOOOOOOXXXOooO+", +"+OoooOOOOOOOOOXXXOooO+", +"+OoooOOOOOOOOOXXXOooO+", +"++OOOOOOOOOOOOOOOOOO++", +"++++++++++++++++++++++" +}; diff --git a/qtjava/javalib/examples/textedit/textbold.xpm b/qtjava/javalib/examples/textedit/textbold.xpm new file mode 100644 index 00000000..8398e2ec --- /dev/null +++ b/qtjava/javalib/examples/textedit/textbold.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * bold_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ......... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ........ ", +" ... .... ", +" ... .... ", +" ... ... ", +" ... ... ", +" ... ... ", +" ... ... ", +" .......... ", +" ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textcenter.xpm b/qtjava/javalib/examples/textedit/textcenter.xpm new file mode 100644 index 00000000..837152f6 --- /dev/null +++ b/qtjava/javalib/examples/textedit/textcenter.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * center_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textitalic.xpm b/qtjava/javalib/examples/textedit/textitalic.xpm new file mode 100644 index 00000000..329e66d3 --- /dev/null +++ b/qtjava/javalib/examples/textedit/textitalic.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * italic_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ..... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ... ", +" ..... ", +" ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textjustify.xpm b/qtjava/javalib/examples/textedit/textjustify.xpm new file mode 100644 index 00000000..75b4a274 --- /dev/null +++ b/qtjava/javalib/examples/textedit/textjustify.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * block_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textleft.xpm b/qtjava/javalib/examples/textedit/textleft.xpm new file mode 100644 index 00000000..a63e7cef --- /dev/null +++ b/qtjava/javalib/examples/textedit/textleft.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * left_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textright.xpm b/qtjava/javalib/examples/textedit/textright.xpm new file mode 100644 index 00000000..3e896bd7 --- /dev/null +++ b/qtjava/javalib/examples/textedit/textright.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * right_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ............. ", +" ", +" ................. ", +" ", +" ", +" "}; diff --git a/qtjava/javalib/examples/textedit/textunder.xpm b/qtjava/javalib/examples/textedit/textunder.xpm new file mode 100644 index 00000000..ec962a74 --- /dev/null +++ b/qtjava/javalib/examples/textedit/textunder.xpm @@ -0,0 +1,27 @@ +/* XPM */ +static char * under_xpm[] = { +"22 22 2 1", +" c None", +". c #000000", +" ", +" ", +" ", +" ", +" ..... .... ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... . ", +" ... .. ", +" ... .. ", +" ...... ", +" ", +" ............ ", +" ", +" ", +" "}; |