Changeset 63 in Sophya
- Timestamp:
- Dec 5, 1997, 11:13:15 PM (28 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/ex_dessin.cc
r61 r63 152 152 DrawString(20, 75, buf); 153 153 154 if ( (kmod == PIKM_Alt) && (key == 'c') ) { 155 printf("ExBWdg::Keyboard: Test-Copy ... \n"); 156 ClaimSelection(); 157 } 158 if ( (kmod == PIKM_Alt) && (key == 'v') ) { 159 printf("ExBWdg::Keyboard: Test-Paste ... \n"); 160 RequestSelection(); 161 } 162 154 163 return; 155 164 } -
trunk/SophyaPI/PI/pibwdggen.cc
r52 r63 50 50 return; 51 51 } 52 53 /* --Methode-- */ 54 void PIBaseWdgGen::Refresh() 55 { 56 if ( IsVisible() ) { 57 Draw(); 58 CallDrawers(); 59 } 60 return; 61 } 62 63 /* --Methode-- */ 64 void PIBaseWdgGen::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 65 { 66 this->Draw(); 67 return; 68 } 69 70 /* --Methode-- */ 71 void PIBaseWdgGen::Draw() 72 { 73 #ifdef DEBUG_RZXB 74 puts("Debug_PIBaseWdgGen::Draw() Efface la fenetre par defaut ! "); 75 #endif 76 this->EraseWindow(); 77 return; 78 } 79 80 81 /* --Methode-- */ 82 void PIBaseWdgGen::Resize() 83 { 84 #ifdef DEBUG_RZXB 85 puts("Debug_PIBaseWdgGen::Resize() resize notify "); 86 #endif 87 return; 88 } 89 52 90 53 91 /* --Methode-- */ … … 173 211 drw->Attach((PIBaseWdg*)this, mDrwId); 174 212 return(mDrwId); 213 } 214 215 /* --Methode-- */ 216 void PIBaseWdgGen::MoveResizeDrawer(int id, int x0, int y0, int dx, int dy) 217 { 218 list<BWDrwId>::iterator it; 219 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 220 if ((*it).id == id) { 221 (*it).x0 = x0; (*it).y0 = y0; 222 (*it).dx = dx; (*it).dy = dy; 223 break; 224 } 225 return; 175 226 } 176 227 … … 226 277 if (fgc) ClearClipRectangle(); 227 278 228 } 279 return; 280 } 281 282 /* --Methode-- */ 283 void PIBaseWdgGen::CallDrawer(int id) 284 { 285 list<BWDrwId>::iterator it; 286 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 287 if ((*it).id == id) { 288 SaveGraphicAtt(); 289 (*it).drw->SetDrwWdg(this, (*it).x0, (*it).y0, (*it).dx, (*it).dy); 290 SetClipRectangle((*it).x0, (*it).y0, (*it).dx , (*it).dy); 291 (*it).drw->Draw(); 292 RestoreGraphicAtt(); 293 ClearClipRectangle(); 294 break; 295 } 296 return; 297 } -
trunk/SophyaPI/PI/pibwdggen.h
r61 r63 19 19 PIK_Previous = 21+0x2000, PIK_Next = 22+0x2000 } ; 20 20 21 enum PIColors { PI_ NotDefColor = -1,21 enum PIColors { PI_ColorFromMap = -2, PI_NotDefColor = -1, 22 22 PI_Black = 0, PI_White = 1, PI_Grey = 2, 23 23 PI_Red = 3, PI_Blue = 4, PI_Green = 5, … … 72 72 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0) = 0; 73 73 virtual void DrawString(int x, int y, char* s, int pos = 0) = 0; 74 virtual void DrawOpaqueString(int x, int y, char* s, int pos = 0) = 0; 74 75 virtual void DrawLine(int x1, int y1, int x2, int y2) = 0; 75 76 virtual void DrawBox(int x0, int y0, int dx, int dy) = 0; … … 89 90 virtual void SelForeground(PIColors col=PI_Black) = 0; 90 91 virtual void SelBackground(PIColors col=PI_White) = 0; 92 // virtual void SelForeground(PIColorMap* cmap, int cid) = 0; 93 // virtual void SelBackground(PIColorMap* cmap, int cid) = 0; 91 94 virtual void SelGOMode(PIGOMode mod=PI_GOCopy) = 0; 92 95 virtual void SelFont(PIFontSize sz=PI_NormalSizeFont, … … 118 121 119 122 120 // Fonction qui doit etre appelee pour rafraichir (retracer) tout 121 virtual void Refresh() = 0; 123 // Fonction qui doit etre appelee pour rafraichir la fenetre 124 virtual void Refresh(); 125 126 // Fonctions qui doivent contenir le dessin du contenu du widget lui-meme 127 virtual void Draw(); 128 virtual void Draw(int x0, int y0, int dx, int dy); 122 129 123 130 // Traitement des evenements 124 virtual void Resize() = 0; 125 virtual void Draw() = 0; 126 virtual void Draw(int x0, int y0, int dx, int dy) = 0; 127 131 virtual void Resize(); 128 132 virtual void Enter(); 129 133 virtual void Leave(); … … 146 150 int AddDrawer(PIDrawer* drw, int x0, int y0, int dx, int dy, 147 151 bool ad=false); 152 void MoveResizeDrawer(int id, int x0, int y0, int dx, int dy); 148 153 void RemoveDrawer(int id); // Ote un drawer de la liste 149 154 void DeleteDrawers(); // Ote et detruit tous les drawers 150 155 156 // Trace des Drawers ... 157 virtual void CallDrawers(int x0=0, int y0=0, int dx=0, int dy=0); 158 virtual void CallDrawer(int id); 159 151 160 // Devrait etre protected - mis ici a cause de cxx 11/07/97 Reza 152 161 struct BWDrwId { int x0, y0; int dx, dy; int id; bool ad; PIDrawer* drw; }; 153 162 154 163 protected: 155 virtual void CallDrawers(int x0, int y0, int dx, int dy); // Appel le trace des drawers156 157 164 PSFile * mPSOut; /* Fichier PostScript eventuel */ 158 165 -
trunk/SophyaPI/PI/pibwdgmac.cc
r61 r63 508 508 } 509 509 510 /* --Methode-- */510 /* --Methode-- 511 511 void PIBaseWdgMac::Refresh() 512 512 { … … 514 514 Draw(); 515 515 } 516 517 /* --Methode-- */ 518 void PIBaseWdgMac::Resize() 519 { 520 #ifdef DEBUG_RZXB 521 printf ("Debug_PIBaseWdgMac::ReSize %ld %ld NewSize= %d %d\n", 522 (long)(this), (long)(this->sdw), 523 (int)this->sdw->core.width, (int)this->sdw->core.height); 524 #endif 525 return; 526 } 527 528 /* --Methode-- */ 529 void PIBaseWdgMac::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/) 530 { 531 this->Draw(); 532 return; 533 } 534 535 /* --Methode-- */ 536 void PIBaseWdgMac::Draw() 537 { 538 #ifdef DEBUG_RZXB 539 this->PIEraseWindow(); 540 this->PIDrawFBox(10,10, XSize()*2/3, YSize()*2/3); 541 #endif 542 return; 543 } 544 545 516 J'ai mis cette fonction ds PIWdgMac::IsVisible() Reza $CHECK$ 01/12/97 517 */ 518 519 -
trunk/SophyaPI/PI/pibwdgmac.h
r61 r63 27 27 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 28 28 virtual void DrawString(int x, int y, char* s, int pos = 0); 29 virtual void DrawOpaqueString(int x, int y, char* s, int pos = 0); 29 30 virtual void DrawLine(int x1, int y1, int x2, int y2); 30 31 virtual void DrawBox(int x0, int y0, int dx, int dy); … … 61 62 virtual int GetMarkerSize(); 62 63 63 // Fonction qui doit etre appelee pour rafraichir (retracer) tout64 virtual void Refresh();65 66 // Traitement des evenements67 virtual void Resize();68 virtual void Draw();69 virtual void Draw(int x0, int y0, int dx, int dy);70 71 64 72 65 protected: -
trunk/SophyaPI/PI/pibwdgx.cc
r61 r63 171 171 else 172 172 XDrawString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 173 DefGC(), x, y, s, strlen(s)); 174 return; 175 } 176 177 /* --Methode-- */ 178 void PIBaseWdgX::DrawOpaqueString(int x, int y, char* s, int /*pos*/) 179 { 180 if(mPSOut){ 181 mPSOut->DrawString((float)x,(float)y,s,mFCol,mFAtt,mFSize); /* $CHECK$ PIFontSize ?? */ 182 } 183 else 184 XDrawImageString (XtDisplay (XtWdg()),XtWindow(XtWdg()), 173 185 DefGC(), x, y, s, strlen(s)); 174 186 return; … … 695 707 } 696 708 697 /* --Methode-- */698 void PIBaseWdgX::Refresh()699 {700 if ( (XtIsRealized(XtWdg())) &&701 (((PIXtBaseWidget)(this->XtWdg()))->core.visible) )702 { /* EraseWindow(); */ Draw(); }703 704 return;705 }706 707 708 /* --Methode-- */709 void PIBaseWdgX::Resize()710 {711 #ifdef DEBUG_PIBWDGX712 printf ("PIBaseWdgX::ReSize %ld %ld NewSize= %d %d\n",713 (long)(this), (long)(this->XtWdg()),714 (int)this->XtWdg()->core.width, (int)this->XtWdg()->core.height);715 #endif716 return;717 }718 719 /* --Methode-- */720 void PIBaseWdgX::Draw(int /*x0*/, int /*y0*/, int /*dx*/, int /*dy*/)721 {722 this->Draw();723 return;724 }725 726 /* --Methode-- */727 void PIBaseWdgX::Draw()728 {729 #ifdef DEBUG_PIBWDGX730 this->EraseWindow();731 this->DrawFBox(10,10, XSize()*2/3, YSize()*2/3);732 #endif733 CallDrawers(0,0,0,0);734 return;735 }736 737 738 /* --Methode-- */739 void PIBaseWdgX::Enter()740 {741 #ifdef DEBUG_PIBWDGX742 puts("PIBaseWdgX::Enter() enter notify ");743 #endif744 return;745 }746 747 /* --Methode-- */748 void PIBaseWdgX::Leave()749 {750 #ifdef DEBUG_PIBWDGX751 puts("PIBaseWdgX::Leave() leave notify ");752 #endif753 return;754 }755 756 757 /* --Methode-- */758 void PIBaseWdgX::But1Press(int, int)759 {760 #ifdef DEBUG_PIBWDGX761 printf ("PIBaseWdgX::But1Press PosX,Y= %d %d \n", x, y);762 #endif763 return;764 }765 766 /* --Methode-- */767 void PIBaseWdgX::But1Release(int, int)768 {769 Send(Msg(), PIMsg_Active);770 #ifdef DEBUG_PIBWDGX771 printf ("PIBaseWdgX::ButReleasePosX,Y= %d %d \n", x, y);772 #endif773 return;774 }775 776 /* --Methode-- */777 void PIBaseWdgX::But2Press(int /* x */, int /* y */)778 {779 return;780 }781 782 /* --Methode-- */783 void PIBaseWdgX::But2Release(int /* x */, int /* y */)784 {785 return;786 }787 788 /* --Methode-- */789 void PIBaseWdgX::But3Press(int /* x */, int /* y */)790 {791 return;792 }793 794 /* --Methode-- */795 void PIBaseWdgX::But3Release(int /* x */, int /* y */)796 {797 return;798 }799 800 801 /* --Methode-- */802 void PIBaseWdgX::Ptr1Move(int , int )803 {804 #ifdef DEBUG_PIBWDGX805 printf ("PIBaseWdgX::Ptr1Move PosX,Y= %d %d \n", x, y);806 #endif807 return;808 }809 810 /* --Methode-- */811 void PIBaseWdgX::Ptr2Move(int /* x */, int /* y */)812 {813 return;814 }815 816 817 /* --Methode-- */818 void PIBaseWdgX::Ptr3Move(int /* x */, int /* y */)819 {820 return;821 }822 823 /* --Methode-- */824 void PIBaseWdgX::Keyboard(int /*key*/, PIKeyModifier /*kmod*/)825 {826 827 #ifdef DEBUG_PIBWDGX828 printf("PIBaseWdgX::Keyboard: Key= %d (%c) Mod= %d \n", key, (char)key, (int)kmod);829 XFlush(XtDisplay(this->XtWdg()));830 #endif831 return;832 }833 709 834 710 -
trunk/SophyaPI/PI/pibwdgx.h
r61 r63 27 27 virtual void EraseWindow(int x0=0, int y0=0, int dx=0, int dy=0); 28 28 virtual void DrawString(int x, int y, char* s, int pos = 0); 29 virtual void DrawOpaqueString(int x, int y, char* s, int pos = 0); 29 30 virtual void DrawLine(int x1, int y1, int x2, int y2); 30 31 virtual void DrawBox(int x0, int y0, int dx, int dy); … … 71 72 virtual void SaveGraphicAtt(); 72 73 73 // Fonction qui doit etre appelee pour rafraichir (retracer) tout74 virtual void Refresh();75 76 // Traitement des evenements77 virtual void Resize();78 virtual void Draw();79 virtual void Draw(int x0, int y0, int dx, int dy);80 81 virtual void Enter();82 virtual void Leave();83 virtual void But1Press(int x, int y);84 virtual void But1Release(int x, int y);85 virtual void But2Press(int x, int y);86 virtual void But2Release(int x, int y);87 virtual void But3Press(int x, int y);88 virtual void But3Release(int x, int y);89 virtual void Ptr1Move(int x, int y);90 virtual void Ptr2Move(int x, int y);91 virtual void Ptr3Move(int x, int y);92 virtual void Keyboard(int key, PIKeyModifier kmod);93 94 inline GC DefGC() { return mDefGC; }95 74 96 75 protected: … … 98 77 void Init(); 99 78 void SelectFont(int isz, int jat); 79 inline GC DefGC() { return mDefGC; } 100 80 101 81 GC mDefGC; -
trunk/SophyaPI/PI/picmap.cc
r2 r63 1 1 #include "picmap.h" 2 2 3 #define MXMAPIDS 10 4 static int MapNCols[MXMAPIDS] = {256, 256, 256, 256, 256, 256, 256, 256, 256, 256}; 5 static char* MapNoms[MXMAPIDS] = {"Grey32","InvGrey32","ColRJ32","ColBR32", 6 "ColRV32", "Grey128", "InvGrey128", "ColRJ128", 7 "ColBR128", "Col16"}; 8 static CMapId MapIds[MXMAPIDS] = { CMAP_GREY32, CMAP_GREYINV32, CMAP_COLRJ32, 9 CMAP_COLBR32, CMAP_COLRV32, CMAP_GREY128, 10 CMAP_GREYINV128, CMAP_COLRJ128, CMAP_COLBR128, 11 CMAP_COL16 } ; 12 13 static int mColTNums[8192]; // Max 8192 tables differentes pour le moment 14 static int CTNum = 0; // Numero des tables ds mColTNum - s'incremente a chaque creation 15 16 static int NMaxTableAuto = 0; 17 static PIColorMap* mMaps[10] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL }; 18 3 19 PIColorMap::PIColorMap(CMapId id) 4 : PIColorMapNative(id) 5 { 6 if (!*maps) { // Il faut allouer les trois maps de depart 7 maps[0] = new PIColorMap(CMAP_GREY32, 0); 8 maps[1] = new PIColorMap(CMAP_GREYINV32, 0); 9 maps[2] = new PIColorMap(CMAP_COLRJ32, 0); 20 : PIColorMapNative() 21 { 22 int k, kdx; 23 string mnom; 24 25 if (NMaxTableAuto == 0) { // Il faut allouer les tables de depart 26 if ( TotNbColors() > 2048 ) NMaxTableAuto = MXMAPIDS-1; 27 else NMaxTableAuto = 3; 28 for(k=0; k<NMaxTableAuto; k++) { 29 mnom = MapNoms[k]; 30 mMaps[k] = new PIColorMap(MapIds[k], MapNCols[k], mnom); 31 } 10 32 } 11 12 switch (id) { 13 case CMAP_GREY32 : 14 CopyFrom(maps[0]); 33 34 // Protection pour valeur de Id 35 for(kdx=0; kdx<MXMAPIDS; kdx++) if (id == MapIds[kdx]) break; 36 if (kdx == MXMAPIDS) { id = MapIds[0]; kdx = 0; } 37 for(k=0; k<NMaxTableAuto; k++) 38 if (id == mMaps[k]->Type()) { 39 CopyFrom(mMaps[k]); 40 mCTId = mMaps[k]->mCTId; mColTNums[mCTId]++; 15 41 break; 16 case CMAP_GREYINV32 : 17 CopyFrom(maps[1]); 18 break; 19 case CMAP_COLRJ32 : 20 CopyFrom(maps[2]); 21 break; 22 default: 23 if (!maps[3] || maps[3]->Type() != id) { 24 if (maps[3]) 25 { 26 maps[3]->FreeColors(); 27 delete maps[3]; 28 } 29 maps[3] = new PIColorMap(id, 0); 42 } 43 if (Type() != id) { // Table pas encore trouve dans la liste 44 k = NMaxTableAuto; 45 if (!mMaps[k] || mMaps[k]->Type() != id) { 46 if ( mMaps[k] ) { 47 mColTNums[mMaps[k]->mCTId] = 1; // Je force a liberer les couleurs 48 delete mMaps[k] ; 30 49 } 31 CopyFrom(maps[3]); 50 mnom = MapNoms[kdx]; 51 mMaps[k] = new PIColorMap(MapIds[kdx], MapNCols[kdx], mnom); 52 } 53 CopyFrom(mMaps[k]); 54 mCTId = mMaps[k]->mCTId; mColTNums[mCTId]++; 32 55 } 33 56 } … … 35 58 36 59 PIColorMap::PIColorMap(string const& nom, int nCol) 37 : PIColorMapNative( nom, nCol)60 : PIColorMapNative(CMAP_OTHER, nCol, nom) 38 61 { 39 62 MakeColMap(); 40 } 41 42 PIColorMap::PIColorMap(CMapId id, int i) // Fait une veritable allocation 43 : PIColorMapNative(id,i) 63 mCTId = CTNum; 64 mColTNums[mCTId] = 1; 65 CTNum++; 66 } 67 68 PIColorMap::PIColorMap(CMapId id, int nCol, string const& nom) 69 : PIColorMapNative(id, nCol, nom) 44 70 { 45 71 MakeColMap(); 72 mCTId = CTNum; 73 mColTNums[mCTId] = 1; 74 CTNum++; 75 // printf("PIColorMap/Debug-Creation: %d %d - %s ", Type(), NCol(), Nom().c_str()); 76 // printf(" ..CRE.. %d %d \n", CTNum-1, mColTNums[CTNum-1]); 77 } 78 79 PIColorMap::PIColorMap(PIColorMap& cm) 80 { 81 CopyFrom(&cm); 82 mCTId = cm.mCTId; 83 mColTNums[mCTId]++; 46 84 } 47 85 48 86 PIColorMap::~PIColorMap() 49 87 { 50 if (mType == CMAP_OTHER) 51 FreeColors(); 52 } 88 // printf("PIColorMap/Debug-Delete: %d %d - %s ", Type(), NCol(), Nom().c_str()); 89 // printf("...DEL.CTNum,mColTNums= %d %d (%d %d) ", 90 // CTNum, mColTNums[CTNum], mCTId,mColTNums[mCTId] ); 91 mColTNums[mCTId]--; 92 if ( mColTNums[mCTId] == 0 ) { FreeColors(); mColTNums[mCTId] = 0; } 93 printf("\n"); 94 } 95 96 97 98 void PIColorMap::CleanColorMaps() 99 { 100 int k; 101 for(k=0; k<MXMAPIDS; k++) { 102 if (!mMaps[k]) continue; 103 mMaps[k]->FreeColors(); 104 delete mMaps[k]; 105 } 106 } 107 108 /* Definition d' une table de couleurs R G B */ 109 110 static float R_RGB1[16] = 111 {0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0}; 112 static float G_RGB1[16] = 113 {0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0}; 114 static float B_RGB1[16] = 115 {0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0}; 116 117 118 119 void PIColorMap::MakeColMap() 120 { 121 PIColor mycol; 122 int i,j,k; 123 124 switch (mType) { 125 126 case CMAP_GREY32 : 127 for(i=0; i<32; i++) { 128 mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32); 129 for(k=0; k<8; k++) AllocColor(mycol, i*8+k); 130 } 131 break; 132 133 134 case CMAP_GREYINV32 : 135 for(i=0; i<32; i++) { 136 mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32); 137 for(k=0; k<8; k++) AllocColor(mycol, mNCol-(i*8+k)-1); 138 } 139 break; 140 141 case CMAP_COL16 : 142 for(i=0; i<16; i++) { 143 mycol.red = (int)(R_RGB1[i]*65535.); 144 mycol.green = (int)(G_RGB1[i]*65535.); 145 mycol.blue =(int)(B_RGB1[i]*65535.) ; 146 for(k=0; k<16; k++) AllocColor(mycol, i*16+k); 147 } 148 break; 149 150 case CMAP_COLRJ32 : 151 for( i=0; i<32; i++) { 152 if (i < 12) { 153 mycol.green = mycol.blue = 0; 154 mycol.red = 21535+(i*4000); } 155 else if (i < 24) { 156 mycol.blue = 0; mycol.red = 65535; 157 mycol.green = 21535+(i-12)*4000; } 158 else { 159 mycol.green = mycol.red = 65535; 160 mycol.blue = 17535+(i-23)*6000; } 161 for(k=0; k<8; k++) AllocColor(mycol, i*8+k); 162 } 163 break; 164 165 case CMAP_COLBR32 : 166 for( i=0; i<32; i++) { 167 if (i < 5) { 168 mycol.green = mycol.red = 0; // Du bleu sombre au bleu clair 169 mycol.blue = 5535+i*15000; } 170 else if (i < 10) { 171 mycol.blue = 65535; // Plein bleu - On rajoute du vert -> bleu clair 172 mycol.green = 5535+(i-5)*9000; 173 mycol.red = 0; } 174 else if (i < 15) { 175 mycol.blue = 60000-(i-10)*15000; // On passe au vert 176 mycol.green = 41535+(i-10)*6000; 177 mycol.red = 0; } 178 else if (i < 21) { 179 mycol.blue = 0; 180 mycol.green = 65535; // Plein vert, on rajoute du rouge -> jaune 181 mycol.red = 5535+(i-15)*12000; } 182 else if (i < 27) { 183 mycol.blue = 0; // On diminue vert -> Orange 184 mycol.green = 60000-(i-21)*12000; 185 mycol.red = 65535-(i-21)*2000; } 186 else { 187 mycol.blue = 0; // Plein rouge 188 mycol.green = 0; 189 mycol.red = 57535+(i-27)*2000; } 190 191 for(k=0; k<8; k++) AllocColor(mycol, i*8+k); 192 } 193 break; 194 195 case CMAP_COLRV32 : 196 for( i=0; i<32; i++) { 197 if (i < 8) { 198 mycol.green = 15000+(i*5000); mycol.blue = 0; 199 mycol.red = 15000+(i*5000); } 200 else if (i < 21) { 201 mycol.green = 50000-(i-7)*5000; 202 if (mycol.green < 0) mycol.green = 0; 203 mycol.blue = 0; 204 mycol.red = 53535+(i-8)*1000; } 205 else { 206 mycol.green = 0; mycol.red = 65535; 207 mycol.blue = 15535+(i-21)*5000; } 208 209 for(k=0; k<8; k++) AllocColor(mycol, i*8+k); 210 } 211 break; 212 213 case CMAP_GREY128 : 214 for(i=0; i<128; i++) { 215 mycol.red = mycol.green = mycol.blue = 2035+(i*500); 216 for(k=0; k<2; k++) AllocColor(mycol, i*2+k); 217 } 218 break; 219 220 221 case CMAP_GREYINV128 : 222 for(i=0; i<128; i++) { 223 mycol.red = mycol.green = mycol.blue = 2035+(i*500); 224 for(k=0; k<2; k++) AllocColor(mycol, mNCol-(i*2+k)-1); 225 } 226 break; 227 228 case CMAP_COLRJ128 : 229 for( i=0; i<128; i++) { 230 if (i < 48) { 231 mycol.green = mycol.blue = 0; 232 mycol.red = 5375+(i*1280); } 233 else if (i < 96) { 234 mycol.blue = 0; mycol.red = 65535; 235 mycol.green = 5375+((i-48)*1280); } 236 else { 237 mycol.green = mycol.red = 65535; 238 mycol.blue = 3535+(i-96)*2000; } 239 for(k=0; k<2; k++) AllocColor(mycol, i*2+k); 240 } 241 break; 242 243 case CMAP_COLBR128 : 244 for( i=0; i<128; i++) { 245 if (i < 20) { 246 mycol.green = mycol.red = 0; // Du bleu sombre au bleu clair 247 mycol.blue = 2835+i*3300; } 248 else if (i < 36) { 249 mycol.blue = 65535; // Plein bleu - On rajoute du vert -> bleu clair 250 mycol.green = 3000+(i-20)*2000; 251 mycol.red = 0; } 252 else if (i < 56) { 253 mycol.blue = 64600-(i-36)*3400; // On passe au vert 254 mycol.green = 32300+(i-36)*1700; 255 mycol.red = 0; } 256 else if (i < 81) { 257 mycol.blue = 0; // Plein vert, on rajoute du rouge -> jaune 258 mycol.green = 65535; 259 mycol.red = 3135+(i-56)*2600; } 260 else if (i < 96) { 261 mycol.blue = 0; 262 mycol.green = 63535-(i-80)*2000; 263 mycol.red = 65535; } 264 else if (i < 112) { 265 mycol.blue = 0; 266 mycol.green = 30000-(i-96)*2000; 267 mycol.red = 65535-(i-96)*1000; } 268 else { 269 mycol.blue = 0; 270 mycol.green = 0 ; 271 mycol.red = 50535+(i-112)*1000; } 272 273 for(k=0; k<2; k++) AllocColor(mycol, i*2+k); 274 } 275 break; 276 277 default : 278 for(i=0; i<mNCol; i++) { 279 mycol.green = mycol.red = mycol.blue = 0; 280 AllocColor(mycol, i); 281 } 282 break; 283 } 284 } -
trunk/SophyaPI/PI/picmap.h
r32 r63 5 5 #include PICMAPNTV_H 6 6 7 enum CMapId 8 { 9 CMAP_OTHER = 0, 10 CMAP_GREY32 = 1, // 32 niveaux de gris * permanent 11 CMAP_GREYINV32 = 2, // 32 niveaux gris du blan au noir * permanent 12 CMAP_COLRJ32 = 3, // 32 couleurs, du Rouge au Jaune/blanc * permanent 13 CMAP_COLBR32 = 4, // 32 couleurs du bleu au rouge 14 CMAP_COLRV32 = 5, // 32 couleurs 15 CMAP_GREY128 = 6, // 128 couleurs niveaux de gris 16 CMAP_GREYINV128 = 7, // " " " " 17 CMAP_COLRJ128 = 8, // 128 couleurs du rouge au jaune/blanc 18 CMAP_COLBR128 = 9, // 128 couleurs du bleu au rouge 19 CMAP_COL16 = 10 // 16 Couleurs Arcenciel 20 }; 21 7 22 8 23 class PIColorMap : public PIColorMapNative { … … 10 25 PIColorMap(CMapId); 11 26 PIColorMap(string const& nom, int nCol); 27 PIColorMap(PIColorMap&); 12 28 virtual ~PIColorMap(); 29 30 static void CleanColorMaps(); 31 13 32 protected: 14 PIColorMap(CMapId id, int i); // Fait une veritable allocation 33 PIColorMap(CMapId id, int nc, string const& nom); // Fait l'allocation des couleurs 34 void MakeColMap(); 35 36 int mCTId; // Pour tenir trace de la derniere table qui doit liberer les couleurs 15 37 }; 16 38 -
trunk/SophyaPI/PI/picmapgen.cc
r48 r63 8 8 9 9 10 PIColorMapGen* PIColorMapGen::maps[4] = {NULL,NULL,NULL,NULL}; 10 PIColorMapGen::PIColorMapGen() 11 { 12 mNom = ""; 13 mNCol = 0; 14 mType = -1; 15 } 16 PIColorMapGen::PIColorMapGen(int id, int nc, string const& nom) 17 { 18 mNom = nom; 19 mNCol = nc; 20 mType = id; 21 } 11 22 12 int PIColorMapGen::nCols[6] = {32,32,32,32,32,16};13 char* PIColorMapGen::noms[6] = {"Grey32","InvGrey32","ColRJ32","ColBR32","ColRV32","Col16"};14 23 15 PIColorMapGen:: PIColorMapGen(CMapId)24 PIColorMapGen::~PIColorMapGen() 16 25 { 17 26 } … … 25 34 26 35 27 PIColorMapGen::PIColorMapGen(string const& nom, int nCol)28 {29 mNom = nom;30 mNCol = nCol;31 mType = CMAP_OTHER;32 }33 34 PIColorMapGen::PIColorMapGen(CMapId id, int)35 {36 if (id < CMAP_GREY32 && id > CMAP_COL16)37 id = CMAP_GREY32; // BEUARK38 mNom = noms[id - 1];39 mNCol = nCols[id - 1];40 mType = id;41 }42 43 44 PIColorMapGen::~PIColorMapGen()45 {46 }47 48 /* Definition d' une table de couleurs R G B */49 50 static float R_RGB1[16] =51 {0.0,0.00,0.0,0.0,0.0,0.00,0.0,0.6,0.8,1.0,1.00,1.0,0.75,1.0,0.85,1.0};52 static float G_RGB1[16] =53 {0.0,0.00,0.0,0.8,1.0,1.00,1.0,0.8,0.8,1.0,0.75,0.6,0.00,0.0,0.0,0.0};54 static float B_RGB1[16] =55 {0.0,0.75,1.0,1.0,1.0,0.75,0.0,0.0,0.0,0.0,0.00,0.5,0.75,1.0,0.0,0.0};56 57 58 59 void PIColorMapGen::MakeColMap()60 {61 PIColor mycol;62 63 switch (mType)64 {65 case CMAP_GREY32 :66 {for(int i=0; i<mNCol; i++)67 {68 mycol.red = mycol.green = mycol.blue = 3535+(i*62000/32);69 AllocColor(mycol, i);70 }71 break;72 }73 case CMAP_GREYINV32 :74 {for(int i=0; i<mNCol; i++)75 {76 mycol.red = mycol.green = mycol.blue = 65535-(i*62000/32);77 AllocColor(mycol, i);78 }79 break;80 }81 case CMAP_COL16 :82 {for(int i=0; i<mNCol; i++)83 {84 mycol.red = (int)(R_RGB1[i]*65535.);85 mycol.green = (int)(G_RGB1[i]*65535.);86 mycol.blue =(int)(B_RGB1[i]*65535.) ;87 AllocColor(mycol, i);88 }89 break;90 }91 case CMAP_COLRJ32 :92 {for(int i=0; i<mNCol; i++)93 {94 if (i < 12)95 { mycol.green = mycol.blue = 0;96 mycol.red = 21535+(i*4000); }97 else if (i < 24)98 { mycol.blue = 0; mycol.red = 65535;99 mycol.green = 21535+(i-12)*4000; }100 else101 { mycol.green = mycol.red = 65535;102 mycol.blue = 17535+(i-23)*6000; }103 104 AllocColor(mycol, i);105 }106 break;107 }108 case CMAP_COLBR32 :109 {for(int i=0; i<mNCol; i++)110 {111 if (i < 5)112 { mycol.green = mycol.red = 0;113 mycol.blue = 5535+i*15000; }114 else if (i < 10)115 { mycol.blue = 65535;116 mycol.green = 5535+(i-5)*9000;117 mycol.red = 0; }118 else if (i < 15)119 { mycol.blue = 60000-(i-10)*15000;120 mycol.green = 41535+(i-10)*6000;121 mycol.red = 0; }122 else if (i < 21)123 { mycol.blue = 0;124 mycol.green = 65535;125 mycol.red = 5535+(i-15)*12000; }126 else if (i < 27)127 { mycol.blue = 0;128 mycol.green = 60000-(i-21)*12000;129 mycol.red = 65535-(i-21)*2000; }130 else131 { mycol.blue = 0;132 mycol.green = 0;133 mycol.red = 57535+(i-27)*2000; }134 135 AllocColor(mycol, i);136 }137 break;138 }139 case CMAP_COLRV32 :140 {for(int i=0; i<mNCol; i++)141 {142 if (i < 8)143 { mycol.green = 15000+(i*5000); mycol.blue = 0;144 mycol.red = 15000+(i*5000); }145 else if (i < 21)146 { mycol.green = 50000-(i-7)*5000;147 if (mycol.green < 0) mycol.green = 0;148 mycol.blue = 0;149 mycol.red = 53535+(i-8)*1000; }150 else151 { mycol.green = 0; mycol.red = 65535;152 mycol.blue = 15535+(i-21)*5000; }153 154 AllocColor(mycol, i);155 }156 break;157 }158 default :159 {for(int i=0; i<mNCol; i++)160 {161 mycol.green = mycol.red = mycol.blue = 0;162 AllocColor(mycol, i);163 }164 break;165 }166 }167 }168 169 -
trunk/SophyaPI/PI/picmapgen.h
r30 r63 6 6 #include <string.h> 7 7 8 9 enum CMapId10 {11 CMAP_OTHER = 0,12 CMAP_GREY32 = 1, // 32 niveaux de gris * permanent13 CMAP_GREYINV32 = 2, // 32 niveaux gris du blan au noir * permanent14 CMAP_COLRJ32 = 3, // 32 couleurs, du Rouge au Jaune/blanc * permanent15 CMAP_COLBR32 = 4, // 32 couleurs du bleu au rouge16 CMAP_COLRV32 = 5, // 32 couleurs17 CMAP_COL16 = 6 // 16 Couleurs Arcenciel18 };19 20 8 21 9 … … 28 16 class PIColorMapGen { 29 17 public: 30 PIColorMapGen( CMapId);31 PIColorMapGen( string const& nom, int nCol); // CMapId : CMAP_OTHER automatiquement18 PIColorMapGen(); 19 PIColorMapGen(int id, int nc, string const& nom); 32 20 virtual ~PIColorMapGen(); 33 21 34 CMapId Type() const{return mType;}22 int Type() const {return mType;} 35 23 int NCol() const {return mNCol;} 36 24 string const& Nom() const {return mNom;} 37 25 38 26 virtual PIColor GetColor(int n)=0; 39 virtual voidAllocColor(PIColor const& col, int index)=0;27 virtual bool AllocColor(PIColor const& col, int index)=0; 40 28 virtual void FreeColors()=0; // Desalloue les couleurs 29 30 virtual int TotNbColors()=0; // Donne le nombre total de couleurs disponibles 31 virtual int NbAllocColors()=0; // Nb de couleurs deja allouees 41 32 protected: 42 PIColorMapGen(CMapId, int); // Fait une veritable allocation43 virtual void MakeColMap(); // Alloue la table de couleurs en appelant AllocColor44 33 void CopyFromGen(PIColorMapGen*); 45 34 virtual void CopyFrom(PIColorMapGen*)=0; 46 35 47 static int nCols[6];48 static char* noms[6];49 50 static PIColorMapGen* maps[4];51 36 52 37 int mNCol; 53 CMapIdmType;38 int mType; 54 39 string mNom; 55 40 -
trunk/SophyaPI/PI/picmapmac.cc
r34 r63 66 66 } 67 67 68 void PIColorMapMac::AllocColor(PIColor const& col, int index) 68 69 bool PIColorMapMac::AllocColor(PIColor const& col, int index) 69 70 { 70 71 ColorSpec& sp = (**mCTab).ctTable[index+2]; … … 73 74 sp.rgb.blue = col.blue; 74 75 sp.value = index+2; 76 return true; // $CHECK$ retourne true si OK - Reza 01/12/97 75 77 } 76 78 -
trunk/SophyaPI/PI/picmapmac.h
r34 r63 13 13 PIColorMapMac(string const& nom, int nCol); 14 14 virtual PIColor GetColor(int n); 15 virtual void AllocColor(PIColor const& col, int index);15 virtual bool AllocColor(PIColor const& col, int index); // $CHECK$ Reza 01/12/97(Modif) 16 16 virtual void FreeColors(); 17 17 virtual void MakeColMap(); 18 virtual int TotNbColor(); // A faire $CHECK$ Reza 01/12/97 19 virtual int NbAllocColors(); // A faire " " " 18 20 protected: 19 21 PIColorMapMac(CMapId id, int i); // Fait une veritable allocation -
trunk/SophyaPI/PI/picmapx.cc
r40 r63 9 9 10 10 /* --Methode-- */ 11 PIColorMapX::PIColorMapX( CMapId id)12 : PIColorMapGen( id)11 PIColorMapX::PIColorMapX() 12 : PIColorMapGen() 13 13 { 14 int n = nCols[id-1]; 15 mColors = new PIXColor[n]; 16 mColRGB = new PIColor[n]; 17 for(int i=0; i<n; i++) 18 { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen()); 19 mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; } 20 21 // printf("PIColorMapX::PIColorMapX(CMapId) %d %d \n", mNCol, Type()); 22 return; 14 mColors = NULL; 15 mColRGB = NULL; 23 16 } 24 17 25 18 /* --Methode-- */ 26 PIColorMapX::PIColorMapX( CMapId id, int i) // Fait une veritable allocation27 : PIColorMapGen(id, i)19 PIColorMapX::PIColorMapX(int id, int nc, string const& nom) 20 : PIColorMapGen(id, nc, nom) 28 21 { 29 22 30 int n = n Cols[id-1];23 int n = nc; 31 24 mColors = new PIXColor[n]; 32 25 mColRGB = new PIColor[n]; … … 41 34 42 35 /* --Methode-- */ 43 PIColorMapX::PIColorMapX(string const& nom, int nCol)44 : PIColorMapGen(nom, nCol)45 {46 47 int n = nCol;48 mColors = new PIXColor[n];49 mColRGB = new PIColor[n];50 for(int i=0; i<n; i++)51 { mColors[i] = BlackPixel(PIXDisplay(), PIXScreen());52 mColRGB[i].red = mColRGB[i].green = mColRGB[i].blue = 0; }53 // printf("PIColorMapX::PIColorMapX(nom, nCol) %d %d \n", mNCol, Type());54 55 return;56 57 }58 59 /* --Methode-- */60 36 PIColorMapX::~PIColorMapX() 61 37 { 62 delete[] mColors;63 delete[] mColRGB;38 if (mColors) delete[] mColors; 39 if (mColRGB) delete[] mColRGB; 64 40 } 65 41 … … 82 58 static Colormap defxcmap; 83 59 static xinicmap = 0; 60 static int NTotColors = 0; 61 static int NTotAllocCol = 0; 84 62 85 63 /* --Methode-- */ 86 voidPIColorMapX::AllocColor(PIColor const& col, int index)64 bool PIColorMapX::AllocColor(PIColor const& col, int index) 87 65 { 88 66 XColor myxcol; … … 94 72 } 95 73 96 if ( (index < 0) || (index > mNCol) ) return ;74 if ( (index < 0) || (index > mNCol) ) return(false); 97 75 98 76 if ( (col.red == 0) && (col.green == 0) && (col.blue == 0) ) … … 100 78 mColors[index] = BlackPixel(PIXDisplay(), PIXScreen()); 101 79 mColRGB[index] = col; 102 return ;80 return(true); 103 81 } 104 82 … … 108 86 109 87 110 if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) 111 { 88 if ( XAllocColor(PIXDisplay(), defxcmap, &myxcol) ) { 112 89 mColors[index] = myxcol.pixel; 113 90 mColRGB[index] = col; 114 91 // printf("PIColorMapX::AllocColor() RGB= %d %d %d \n", 115 92 // (int) col.red, (int) col.blue, (int) col.green); 93 NTotAllocCol++; 94 return(true); 116 95 } 117 else 96 else { 118 97 printf("PIColorMapX::AllocColor() Error: Pb Allocation RGB= %d %d %d \n", 119 98 (int) col.red, (int) col.blue, (int) col.green); 120 return; 99 return(false); 100 } 121 101 } 122 102 … … 153 133 } 154 134 135 136 /* --Methode-- */ 137 int PIColorMapX::TotNbColors() 138 { 139 if (NTotColors > 0) return(NTotColors); 140 Visual* vis; 141 // DefaultVisual(PIXDisplay(), PIXScreen() ); 142 int k,kk; 143 // On calcule le nombre de couleurs a partir du nb de plans image 144 kk = DefaultDepth(PIXDisplay(), PIXScreen() ); 145 NTotColors = 1; 146 for(k=0; k<kk; k++) NTotColors *= 2; 147 /* 148 printf("PIColorMapX::TotNbColor() / Debug : Nb Tot Colors = %d - D=%d - NCol=%d NP= %d \n", NTotColors, 149 DefaultDepth(PIXDisplay(), PIXScreen()), 150 DisplayCells(PIXDisplay(), PIXScreen()), 151 DisplayPlanes(PIXDisplay(), PIXScreen()) ); 152 */ 153 return(NTotColors); 154 } 155 156 /* --Methode-- */ 157 int PIColorMapX::NbAllocColors() 158 { 159 return(NTotAllocCol); 160 } 161 162 155 163 /* --Methode-- */ 156 164 void PIColorMapX::CopyFrom(PIColorMapGen* x) 157 165 { 166 if (mColors) delete mColors; 167 if (mColRGB) delete mColRGB; 158 168 CopyFromGen(x); 169 mColors = new PIXColor[mNCol]; 170 mColRGB = new PIColor[mNCol]; 159 171 for (int i=0; i<mNCol; i++) 160 172 { mColors[i] = ((PIColorMapX *)x)->mColors[i]; -
trunk/SophyaPI/PI/picmapx.h
r30 r63 9 9 class PIColorMapX : public PIColorMapGen { 10 10 public: 11 friend class PIColorMapGen; 12 friend class PIPixmapX; 13 14 PIColorMapX(CMapId); 15 PIColorMapX(string const& nom, int nCol); 11 PIColorMapX(); 12 PIColorMapX(int id, int nc, string const& nom); 13 virtual ~PIColorMapX(); 16 14 17 15 inline PIXColor Color(int index) … … 19 17 20 18 virtual PIColor GetColor(int n); 21 virtual voidAllocColor(PIColor const& col, int index);19 virtual bool AllocColor(PIColor const& col, int index); 22 20 virtual void FreeColors(); 23 // virtual void MakeColMap(); 21 22 virtual int TotNbColors(); 23 virtual int NbAllocColors(); 24 24 25 protected: 25 PIColorMapX(CMapId id, int i); // Fait une veritable allocation 26 void CopyFrom(PIColorMapGen*); 26 virtual void CopyFrom(PIColorMapGen*); 27 27 28 28 PIXColor * mColors; // La table des couleurs ... -
trunk/SophyaPI/PI/pipixmapgen.cc
r61 r63 53 53 void PIPixmapGen::SetColMap(CMapId cmapid, bool refr) 54 54 { 55 if (cmap) delete cmap; 56 cmap = new PIColorMap(cmapid); 55 if (!cmap || (cmap->Type() != cmapid) || (cmapid == CMAP_OTHER) ) { 56 if (cmap) delete cmap; 57 cmap = new PIColorMap(cmapid); 58 } 57 59 if (refr) Refresh(); 58 60 } -
trunk/SophyaPI/PI/pipixmapgen.h
r48 r63 29 29 bool refr=true, int ox=0, int oy=0); 30 30 void SetColMap(CMapId cmapid, bool refr=true); 31 inline CMapId GetColMapId() { return ( cmap->Type()); };31 inline CMapId GetColMapId() { return ((CMapId)cmap->Type()); }; 32 32 inline int NbCol() { return(cmap->NCol()); }; 33 33 -
trunk/SophyaPI/PI/piscdrawwdg.cc
r61 r63 168 168 DrawSelf(-9.e19, -9.e19, 9.e19, 9.e19); 169 169 CallScDrawers(-9.e19, -9.e19, 9.e19, 9.e19); 170 CallDrawers(0,0,0,0);171 170 } 172 171 -
trunk/SophyaPI/PI/piwdggen.h
r52 r63 11 11 void PIBeep(); 12 12 13 // Les differents types d 'accrochage aux containers13 // Les differents types d accrochage aux containers 14 14 15 15 enum PIBindingKind { … … 62 62 virtual void Manage()=0; 63 63 virtual void UnManage()=0; 64 virtual int IfManaged()=0; 64 virtual bool IfManaged()=0; 65 virtual bool IsVisible()=0; 65 66 66 67 virtual void PSPrint(PSFile *psf, int ofx=0, int ofy=0); 68 69 // Gestion de copier-coller 70 virtual bool ClaimSelection()=0; 71 virtual void LoseSelection()=0; 72 virtual void RequestSelection()=0; 73 virtual void CopyFromSelection(char *, int l)=0; 74 virtual char* SelectionString(int& len)=0; 67 75 68 76 protected: -
trunk/SophyaPI/PI/piwdgmac.cc
r23 r63 125 125 } 126 126 127 128 bool 129 PIWdgMac::IsVisible() // $CHECK$ REZA a verifier 01/12/97 130 { 131 if (mPane->IsVisible()) return(true); 132 else return(false); 133 } -
trunk/SophyaPI/PI/piwdgmac.h
r23 r63 27 27 virtual int YPos(); 28 28 virtual string Nom() { return mNom; } 29 30 virtual void Manage(); 31 virtual void UnManage(); 32 virtual bool IfManaged(); 33 virtual bool IsVisible(); 34 29 35 protected: 30 36 LPane* mPane; -
trunk/SophyaPI/PI/piwdgx.cc
r60 r63 80 80 sdw = top; 81 81 wmis = k_wmi_appshell; 82 stmng = 0;82 stmng = false; 83 83 #ifdef DEBUG_PIWdgX 84 84 printf("Debug_PIWdgX::PIWdgX(int , char * []) this=%lx top=%lx \n", (long)this, (long)sdw); … … 142 142 else wmis = k_wmi_normal ; 143 143 144 stmng = 0;144 stmng = false; 145 145 #ifdef DEBUG_PIWdgX 146 146 printf("Debug_PIWdgX::CreateXtWdg(%s) this=%lx sdw=%lx pere=%lx wmis=%d\n", nom, … … 182 182 if (wmis != k_wmi_appshell) XtManageChild(sdw); 183 183 else if (!XtIsRealized(sdw)) XtRealizeWidget(sdw); 184 stmng = 1;184 stmng = true; 185 185 return; 186 186 } … … 195 195 if (wmis != k_wmi_appshell) 196 196 XtUnmanageChild(sdw); 197 stmng = 0;198 return; 199 } 200 201 /* --Methode-- */ 202 intPIWdgX::IfManaged()197 stmng = false; 198 return; 199 } 200 201 /* --Methode-- */ 202 bool PIWdgX::IfManaged() 203 203 { 204 204 return(stmng); 205 } 206 207 /* --Methode-- */ 208 bool PIWdgX::IsVisible() 209 { 210 if ( (XtIsRealized(XtWdg())) && 211 ( (this->XtWdg())->core.visible) ) return(true); 212 else return(false); 205 213 } 206 214 … … 468 476 return(0); 469 477 } 478 479 480 static Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ, 481 XtPointer* value, unsigned long* len, int* format); 482 483 static void forXt_LoseSelection(Widget w, Atom* sel); 484 static void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ); 485 static void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 486 XtPointer value, unsigned long* len, int* format ); 487 488 static PIWdgX* curselwdg = NULL; 489 static char* selval = NULL; 490 491 492 /* Nouvelle-Fonction */ 493 Boolean forXt_ConvertSelection(Widget w, Atom* sel, Atom *targ, Atom* typ, 494 XtPointer* value, unsigned long* len, int* format) 495 { 496 if (*targ != XA_STRING) return(FALSE); 497 if (!curselwdg) return(FALSE); 498 int l; 499 *value = curselwdg->SelectionString(l); 500 *len=l; 501 *typ = XA_STRING; 502 *format = 8; 503 return(TRUE); 504 } 505 506 /* Nouvelle-Fonction */ 507 void forXt_LoseSelection(Widget w, Atom* sel) 508 { 509 if (curselwdg) curselwdg->LoseSelection(); 510 curselwdg = NULL; 511 } 512 513 /* Nouvelle-Fonction */ 514 void forXt_DoneSelection(Widget w, Atom* sel, Atom *targ) 515 { 516 if (selval) delete selval; 517 selval = NULL; 518 } 519 520 /* Nouvelle-Fonction */ 521 void forXt_SelectionValue(Widget w, XtPointer usd, Atom* sel, Atom* typ, 522 XtPointer value, unsigned long* len, int* format ) 523 { 524 printf("forXt_SelectionValue()/Debug: %lx %lx - %lx - %d \n", (unsigned long)w, 525 (unsigned long)usd, (unsigned long)value, (*len)); 526 if ( (value != NULL) && (*len > 0) ) 527 ((PIWdgX*)usd)->CopyFromSelection((char*)value, (*len)) ; 528 } 529 530 531 532 // Gestion de Copier/Coller 533 /* --Methode-- */ 534 bool PIWdgX::ClaimSelection() 535 { 536 if (XtOwnSelection(XtWdg(), XA_PRIMARY, PIXGetLastEventTime(), forXt_ConvertSelection, 537 forXt_LoseSelection, forXt_DoneSelection) ) { 538 printf("PIWdgX::ClaimSelection() - OK (Wdg= %lx)\n", (unsigned long)this); 539 curselwdg = this; 540 return (true); 541 } 542 else { 543 printf("PIWdgX::ClaimSelection() - Probleme (Wdg= %lx)\n", (unsigned long)this); 544 curselwdg = NULL; 545 return (false); 546 } 547 } 548 549 /* --Methode-- */ 550 void PIWdgX::LoseSelection() 551 { 552 printf("PIWdgX::LoseSelection() Ne fait rien !(Wdg= %lx - %lx) \n", 553 (unsigned long)this, (unsigned long)curselwdg); 554 if (curselwdg == this) curselwdg = NULL; 555 } 556 557 /* --Methode-- */ 558 void PIWdgX::RequestSelection() 559 { 560 printf("PIWdgX::RequestSelection() (Wdg= %lx - %lx) \n", 561 (unsigned long)this, (unsigned long)curselwdg); 562 XtGetSelectionValue(XtWdg(), XA_PRIMARY, XA_STRING, forXt_SelectionValue, 563 (XtPointer)this, PIXGetLastEventTime()); 564 } 565 566 /* --Methode-- */ 567 void PIWdgX::CopyFromSelection(char * sv, int l) 568 { 569 char* buff = new char[l+2]; 570 strncpy(buff, sv, l); 571 buff[l] = '\0'; 572 printf("PIWdgX::RequestSelection() L=%d [%s] \n", l, buff); 573 delete buff; 574 return; 575 } 576 577 /* --Methode-- */ 578 char* PIWdgX::SelectionString(int& len) 579 { 580 char *rs = new char[60]; 581 strcpy(rs, "Test-of-PIWdgX::SelectionString()"); 582 len = strlen(rs); 583 return(rs); 584 } -
trunk/SophyaPI/PI/piwdgx.h
r52 r63 52 52 virtual void Manage(); 53 53 virtual void UnManage(); 54 virtual int IfManaged(); 54 virtual bool IfManaged(); 55 virtual bool IsVisible(); 56 57 // Gestion de copier-coller 58 virtual bool ClaimSelection(); 59 virtual void LoseSelection(); 60 virtual void RequestSelection(); 61 virtual void CopyFromSelection(char *, int l); 62 virtual char* SelectionString(int& len); 55 63 56 64 inline SysDWdg XtWdg() const {return(sdw); }; … … 63 71 SysDWdg sdw; 64 72 WmIntState wmis; 65 intstmng;73 bool stmng; 66 74 67 75 }; -
trunk/SophyaPI/PI/pixtbase.cc
r61 r63 188 188 dx = xrec.width; dy = xrec.height; 189 189 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->Draw(x0, y0, dx, dy); 190 (((PIXtBaseWidget)wdgp)->pixtbase.objet)->CallDrawers(x0, y0, dx, dy); 190 191 } 191 192 return;
Note:
See TracChangeset
for help on using the changeset viewer.