[2] | 1 | #include <stdio.h>
|
---|
[18] | 2 | #include <X11/cursorfont.h>
|
---|
[2] | 3 | #include "piapplx.h"
|
---|
| 4 | #include "picontainerx.h"
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | #define DEBUG_APPLX
|
---|
| 8 |
|
---|
[18] | 9 | static Cursor a_curs[3];
|
---|
| 10 | static bool a_fgcur=false;
|
---|
| 11 |
|
---|
[2] | 12 | /* --Methode-- */
|
---|
| 13 | PIApplicationX::PIApplicationX(int sx, int sy, int narg, char *arg[])
|
---|
| 14 | : PIApplicationGen()
|
---|
| 15 | {
|
---|
| 16 | int sxt, syt;
|
---|
| 17 |
|
---|
| 18 | #ifdef DEBUG_APPLX
|
---|
| 19 | puts("PIApplicationX::PIApplicationX()_info : App creation");
|
---|
| 20 | #endif
|
---|
| 21 | mStop = true;
|
---|
| 22 | topwdg = new PIWdgX(narg, arg);
|
---|
| 23 |
|
---|
| 24 | intcont = new PIContainerX((PIMsgHandler *)this, topwdg, "MBCont",
|
---|
| 25 | 10, 10, 0, 0);
|
---|
| 26 | menubar = new PIMenubar(this, "DefMenubar");
|
---|
[7] | 27 | Menubar()->SetBinding(true, true, true, false);
|
---|
[2] | 28 | sxt = ( sx > Menubar()->XSize() ) ? sx : Menubar()->XSize();
|
---|
| 29 | syt = ( sy > 0 ) ? sy : 0;
|
---|
[7] | 30 | //syt += Menubar()->YSize();
|
---|
| 31 | syt += 40;
|
---|
[2] | 32 | MBCont()->SetSize(sxt, syt);
|
---|
| 33 | if ( (sx > 0) && (sy > 0) )
|
---|
| 34 | {
|
---|
| 35 | topcont = new PIContainerX(MBCont(), "TopLevelCont",
|
---|
[7] | 36 | sx, sy, 0, 40);
|
---|
| 37 | topcont->SetBinding(true, true, true, true);
|
---|
[2] | 38 | topcont->Show();
|
---|
| 39 | }
|
---|
| 40 | else topcont = MBCont();
|
---|
| 41 |
|
---|
| 42 | MBCont()->Show();
|
---|
| 43 | topwdg->Manage();
|
---|
[18] | 44 |
|
---|
| 45 | if (!a_fgcur)
|
---|
| 46 | {
|
---|
| 47 | Display *mdsp;
|
---|
| 48 | mdsp = XtDisplay (topwdg->XtWdg());
|
---|
| 49 | a_curs[0] = XCreateFontCursor(mdsp, XC_arrow);
|
---|
| 50 | a_curs[1] = XCreateFontCursor(mdsp, XC_X_cursor);
|
---|
| 51 | a_curs[2] = XCreateFontCursor(mdsp, XC_watch);
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 | mState = -1;
|
---|
| 55 | SetReady();
|
---|
[2] | 56 | }
|
---|
| 57 |
|
---|
| 58 | /* --Methode-- */
|
---|
| 59 | PIApplicationX::~PIApplicationX()
|
---|
| 60 | {
|
---|
| 61 | #ifdef DEBUG_APPLX
|
---|
| 62 | puts("PIApplicationX::~PIApplicationX()_info : App delete");
|
---|
| 63 | #endif
|
---|
[18] | 64 | Display *mdsp;
|
---|
| 65 | mdsp = XtDisplay (topwdg->XtWdg());
|
---|
[2] | 66 | topwdg->Unmanage();
|
---|
[6] | 67 | delete menubar;
|
---|
| 68 | if (topcont != MBCont()) delete topcont;
|
---|
| 69 | delete intcont;
|
---|
[2] | 70 | delete topwdg;
|
---|
[18] | 71 | XtCloseDisplay(mdsp);
|
---|
| 72 | return;
|
---|
[2] | 73 | }
|
---|
| 74 |
|
---|
| 75 | /* --Methode-- */
|
---|
| 76 | void PIApplicationX::Run()
|
---|
| 77 | {
|
---|
| 78 | XEvent evt;
|
---|
| 79 | #ifdef DEBUG_APPLX
|
---|
| 80 | puts("PIApplicationX::Run()_info : App Run ");
|
---|
| 81 | #endif
|
---|
| 82 |
|
---|
| 83 | topwdg->SetSize(MBCont()->XSize(), MBCont()->YSize());
|
---|
| 84 |
|
---|
| 85 | while (mStop)
|
---|
| 86 | {
|
---|
| 87 | XtNextEvent(&evt);
|
---|
| 88 | XtDispatchEvent(&evt);
|
---|
| 89 | }
|
---|
| 90 | return;
|
---|
| 91 | }
|
---|
[18] | 92 |
|
---|
| 93 |
|
---|
| 94 | /* --Methode-- */
|
---|
| 95 | void PIApplicationX::SetReady()
|
---|
| 96 | {
|
---|
| 97 | if (mState != kReadyState)
|
---|
| 98 | {
|
---|
| 99 | Display * mdsp;
|
---|
| 100 | mState = kReadyState;
|
---|
| 101 | mdsp = XtDisplay (topwdg->XtWdg());
|
---|
| 102 | XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[0]);
|
---|
| 103 | XFlush(mdsp);
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /* --Methode-- */
|
---|
| 108 | void PIApplicationX::SetBusy()
|
---|
| 109 | {
|
---|
| 110 | if (mState != kBusyState)
|
---|
| 111 | {
|
---|
| 112 | Display * mdsp;
|
---|
| 113 | mState = kBusyState;
|
---|
| 114 | mdsp = XtDisplay (topwdg->XtWdg());
|
---|
| 115 | // if ( XtIsRealized(topwdg->XtWdg()) )
|
---|
| 116 | XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[2]);
|
---|
| 117 | XFlush(mdsp);
|
---|
| 118 | }
|
---|
| 119 | return;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | /* --Methode-- */
|
---|
| 123 | void PIApplicationX::SetBlocked()
|
---|
| 124 | {
|
---|
| 125 | if (mState != kBlockedState)
|
---|
| 126 | {
|
---|
| 127 | Display * mdsp;
|
---|
| 128 | mState = kBlockedState;
|
---|
| 129 | mdsp = XtDisplay (topwdg->XtWdg());
|
---|
| 130 | XDefineCursor(mdsp, XtWindow(topwdg->XtWdg()), a_curs[1]);
|
---|
| 131 | XFlush(mdsp);
|
---|
| 132 | }
|
---|
| 133 | }
|
---|