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