summaryrefslogtreecommitdiffstats
path: root/kdejava/koala/test/kprogress/KProgressTest.java
blob: b42f348ae692fbdc83c5bfa4a61fceb58c4841d1 (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
88
import org.kde.qt.*;
import org.kde.koala.*;

/**
 *  Class to test KProgress widget.
 *
 *  This is a translation to java from kprogresstest.cpp in the tests library
 *  of tdeui source.
 *
 * @see KProgress
 * @see KApplication
 *
 * @author orignal unknown, java translation Kenneth J. Pouncey, kjpou@hotmail.com
 * @version 0.1
 */

public class KProgressTest {

   static String description = "Java KProgress test program";
   static String[][] options = {   };
   static String VERSION = "0.1";

   public static void main(String[] cmdLineArgs) {

      KAboutData aboutData = new KAboutData( "kprogresstest", "KProgressTest",
         VERSION, description, KAboutData.License_GPL,
         "(c) 2002, Kenneth J. Pouncey");
      aboutData.addAuthor("Kenneth J. Pouncey",null, "kjpou@hotmail.com");
      KCmdLineArgs.init( cmdLineArgs, aboutData );
      KCmdLineArgs.addCmdLineOptions( options ); // Add our own options.

      KApplication app = new KApplication();

      // parse the args
      KCmdLineArgs args = KCmdLineArgs.parsedArgs();

      MyWidget mine = new MyWidget();

      mine.setCaption(description);

      app.setMainWidget(mine);
      mine.show();

      app.exec();

      return;
   }

   private static class MyWidget extends TQWidget {

      private KProgress Progress;
      static int fwd = 0;
      static int back = 1;
      static int direction = fwd;

      public MyWidget () {
         super();
         setFixedSize(440, 80);
         Progress = new KProgress(this);
         Progress.resize(400, 40);
         Progress.move(20, 20);
         startTimer(50);
      }

      public void timerEvent(TQTimerEvent timer) {

         if (direction == fwd)  {
            if (Progress.progress() == Progress.totalSteps())
                direction = back;
            else
                Progress.advance(1);
         }
         else {
            if (Progress.progress() == 0)  { /*Progress.minValue()*/
               direction = fwd;
            }
            else
               Progress.advance(-1);
        }
      }
   }

   static {
      qtjava.initialize();
      kdejava.initialize();
   }

}