summaryrefslogtreecommitdiffstats
path: root/qtjava/javalib/examples/dragdrop/Main.java
blob: 3bf475dfef0853c059cdc22593220d5dc392bc0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/***************************************************************************
* $Id$
**
* Ritual main() for Qt applications
**
* Copyright (C) 1996 by 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.trinitydesktop.qt.*;

public class Main {


static DropSite addStuff( TQWidget  parent, boolean image )
{
	return addStuff(parent, image, false);
}

static DropSite addStuff( TQWidget  parent, boolean image, boolean secret )
{
    TQVBoxLayout  tll = new TQVBoxLayout( parent, 10 );
    DropSite  d = new DropSite( parent );
    d.setFrameStyle( TQFrame.Sunken + TQFrame.WinPanel );
    tll.addWidget( d );
    if ( image ) {
	TQPixmap stuff = new TQPixmap();
	if ( !stuff.load( "trolltech.bmp" ) ) {
	    stuff = new TQPixmap(20,20);
	    stuff.fill(Qt.green());
	}
	d.setPixmap( stuff );
    } else {
	d.setText("Drag and Drop");
    }
    d.setFont(new TQFont("Helvetica",18));
    if ( secret ) {
	SecretSource s = new SecretSource( (byte) 42, parent );
	tll.addWidget( s );
	d.setSecretSource( s);
    }

    TQLabel  format = new TQLabel( "\n\n\n\nNone\n\n\n\n", parent );
    tll.addWidget( format );
    tll.activate();
    parent.resize( parent.sizeHint() );

    TQObject.connect( d, Qt.TQ_SIGNAL("message(String)"),
		      format, Qt.TQ_SLOT("setText(String)") );
	return d;
}




public static void main( String[] args )
{
    TQApplication a = new TQApplication( args );

    TQWidget mw = new TQWidget();
    DropSite d1 = addStuff( mw, true );
    mw.setCaption( "Qt Example - Drag and Drop" );
    mw.show();

    TQWidget mw2 = new TQWidget();
    DropSite d2 = addStuff( mw2, false );
    mw2.setCaption( "Qt Example - Drag and Drop" );
    mw2.show();

    TQWidget mw3 = new TQWidget();
    DropSite d3 = addStuff( mw3, true, true );
    mw3.setCaption( "Qt Example - Drag and Drop" );
    mw3.show();

    TQObject.connect(Qt.qApp(),Qt.TQ_SIGNAL("lastWindowClosed()"),Qt.qApp(),Qt.TQ_SLOT("quit()"));
    a.exec();
	return;
}

static {
	qtjava.initialize();
}

}