Changeset 2529 in Sophya
- Timestamp:
- Apr 27, 2004, 11:49:37 PM (21 years ago)
- Location:
- trunk/SophyaPI/PI
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/pibwdggen.cc
r2528 r2529 531 531 vector<BWDrwId>::iterator it; 532 532 for(it = mDrwList.begin(); it != mDrwList.end(); it++) 533 if ((*it).id == id) return( !(*it).autoszp );533 if ((*it).id == id) return( (*it).autoszp ); 534 534 return false; 535 535 } -
trunk/SophyaPI/PI/pidrwtools.cc
r2528 r2529 885 885 class PIDrwPosSizeEvH : public PIEventHandler { 886 886 public: 887 PIDrwPosSizeEvH(PIBaseWdg* bwdg); 887 PIDrwPosSizeEvH(PIBaseWdg* bwdg, bool fgxor=true); 888 void CheckBeforeDelete(); 888 889 virtual void ProcessEvent(); 890 889 891 protected: 892 void ComputeResizeZone(); 893 void ComputeMoveZone(); 894 inline void ComputeDrawerZone() 895 { x1 = _x1; y1 = _y1; x2 = _x2-_x1; y2 = _y2-_y1; } 896 897 890 898 PIBaseWdg* mBWdg; 899 bool _fgxor; 891 900 int _x1, _y1, _x2, _y2; 901 PIGrCoord x1, y1, x2, y2; 892 902 bool _elastic; 893 903 int _ipx, _ipy; … … 896 906 bool _rsz; // true -> resize option 897 907 bool _okend; 908 bool _rmok; 898 909 }; 899 910 900 911 /* --Methode-- */ 901 PIDrwPosSizeEvH::PIDrwPosSizeEvH(PIBaseWdg* bwdg )912 PIDrwPosSizeEvH::PIDrwPosSizeEvH(PIBaseWdg* bwdg, bool fgxor) 902 913 { 903 914 mBWdg = bwdg; 915 _fgxor = fgxor; 904 916 _x1 = _y1 = _x2 = _y2 = -1; 905 917 _ipx = _ipy = -1; … … 908 920 _rsz = false; 909 921 _okend = false; 922 _rmok = false; 910 923 if (bwdg == NULL) return; 911 924 int aid = bwdg->GetActiveDrawerId(); 912 925 if (aid < 0) return; 913 PIGrCoord x1, y1, x2, y2;914 926 915 927 _elastic = false; … … 933 945 _y1 = y1; _y2 = y2; 934 946 } 935 _x2 -= _x1; _y2 -= _y1;936 cout << "DBG: x1=" << _x1 << " y1=" << _y1 << " x2=" << _x2 << " y2=" << _y2 << endl;937 947 938 948 PIGraphic* gr = mBWdg->WindowGraphic(); … … 941 951 PILineAtt gline = gr->GetLineAtt(); 942 952 PIColors gcol = gr->GetForeground(); 943 gr->SelForeground(PI_Magenta); 944 gr->SelGOMode(PI_GOXOR); 953 if (_fgxor) { 954 gr->SelForeground(PI_Magenta); 955 gr->SelGOMode(PI_GOXOR); 956 } 957 else { 958 gr->SelForeground(PI_HighlightBlue); 959 gr->SelGOMode(PI_GOCopy); 960 } 945 961 gr->SelLine(PI_ThinLine); 962 ComputeDrawerZone(); 946 963 gr->DrawBox(x1,y1, x2, y2); 947 x1 = _x1+0.9*(_x2-_x1); 948 y1 = _y1+0.9*(_y2-_y1); 964 ComputeResizeZone(); 949 965 gr->DrawFBox(x1,y1, x2, y2); 950 x1 = _x1+0.4*(_x2-_x1); 951 x2 = _x2-0.4*(_x2-_x1); 952 y1 = _y1+0.4*(_y2-_y1); 953 y2 = _y2-0.4*(_y2-_y1); 966 ComputeMoveZone(); 954 967 gr->DrawBox(x1,y1, x2, y2); 955 968 gr->SelGOMode(gmod); … … 957 970 gr->SelForeground(gcol); 958 971 959 cout << "DBG- Adding Event-Handler " << endl;972 // cout << "DBG- Adding Event-Handler " << endl; 960 973 mBWdg->AddEventHandler(this, PIEvent_But1Press|PIEvent_Ptr1Move|PIEvent_But1Release); 961 974 } 975 /* --Methode-- */ 976 void PIDrwPosSizeEvH::CheckBeforeDelete() 977 { 978 if (!_rmok) 979 mBWdg->RemoveEventHandler(this); 980 _rmok = true; 981 } 982 983 /* --Methode-- */ 984 void PIDrwPosSizeEvH::ComputeResizeZone() 985 { 986 int dx = (int)(0.05*(_x2-_x1)); 987 int dy = (int)(0.05*(_y2-_y1)); 988 int maxdx = (int)(0.20*(_x2-_x1)); 989 int maxdy = (int)(0.20*(_y2-_y1)); 990 if (dx < 20) dx = 20; 991 if (dx > maxdx) dx = maxdx; 992 if (dy < 20) dx = 20; 993 if (dy > maxdy) dy = maxdy; 994 int dxy = (dx < dy) ? dx : dy ; 995 x1 = _x2-dxy; y1 = _y2-dxy; 996 x2 = y2 = dxy; 997 } 998 999 /* --Methode-- */ 1000 void PIDrwPosSizeEvH::ComputeMoveZone() 1001 { 1002 int dx = (int)(0.08*(_x2-_x1)); 1003 int dy = (int)(0.08*(_y2-_y1)); 1004 int maxdx = (int)(0.20*(_x2-_x1)); 1005 int maxdy = (int)(0.20*(_y2-_y1)); 1006 if (dx < 20) dx = 20; 1007 if (dx > maxdx) dx = maxdx; 1008 if (dy < 20) dx = 20; 1009 if (dy > maxdy) dy = maxdy; 1010 int dxy = (dx < dy) ? dx : dy ; 1011 x1 = (_x1+_x2)*0.5-dxy; 1012 y1 = (_y1+_y2)*0.5-dxy; 1013 x2 = y2 = 2*dxy; 1014 } 962 1015 963 1016 /* --Methode-- */ … … 965 1018 { 966 1019 int delx, dely; 967 PIGrCoord x1,y1,x2,y2;1020 int ix1,iy1,ix2,iy2; 968 1021 x1 = _x1; x2 = _x2; 969 1022 y1 = _y1; y2 = _y2; … … 977 1030 PIColors gcol = gr->GetForeground(); 978 1031 979 cout << " DBG - PIDrwPosSizeEvH::ProcessEvent() EventType=" << EventType() << endl;980 1032 switch (EventType()) { 981 1033 case PIEvent_But1Press : 982 1034 // Zone de changement de taille 983 x1 = _x1+0.9*(_x2-_x1); 984 y1 = _y1+0.9*(_y2-_y1); 985 if ( (GetPosX() >= (int)x1) && (GetPosX() <= (int)x2) && 986 (GetPosY() >= (int)y1) && ((GetPosY() <= (int)y2) ) ) 1035 ComputeResizeZone(); 1036 ix1 = x1; iy1 = y1; 1037 ix2 = _x2; iy2 = _y2; 1038 if ( (GetPosX() >= ix1) && (GetPosX() <= ix2) && 1039 (GetPosY() >= iy1) && ((GetPosY() <= iy2) ) ) 987 1040 { fgok = true; _rsz = true; } 988 x1 = _x1+0.4*(_x2-_x1); 989 x2 = _x2-0.4*(_x2-_x1); 990 y1 = _y1+0.4*(_y2-_y1); 991 y2 = _y2-0.4*(_y2-_y1); 992 if ( (GetPosX() >= (int)x1) && (GetPosX() <= (int)x2) && 993 (GetPosY() >= (int)y1) && ((GetPosY() <= (int)y2) ) ) 1041 ComputeMoveZone(); 1042 ix1 = x1; iy1 = y1; 1043 ix2 = (int)x2+ix1; iy2 = (int)y2+iy1; 1044 if ( (GetPosX() >= ix1) && (GetPosX() <= ix2) && 1045 (GetPosY() >= iy1) && ((GetPosY() <= iy2) ) ) 994 1046 { fgok = true; _rsz = false; } 995 cout << " DBG-GetPosX()= " << GetPosX() << " GetPosY()= " << GetPosY() << endl;996 if (GetPosX() < 5) fgok = false;997 1047 if (!fgok) _okend = true; 998 1048 else { … … 1010 1060 _cpy = GetPosY(); 1011 1061 1012 gr->SelForeground(PI_Magenta); 1013 gr->SelGOMode(PI_GOXOR); 1062 if (_fgxor) { 1063 gr->SelForeground(PI_Magenta); 1064 gr->SelGOMode(PI_GOXOR); 1065 } 1066 else { 1067 gr->SelForeground(mBWdg->GetBackgroundColor()); 1068 gr->SelGOMode(PI_GOCopy); 1069 } 1014 1070 gr->SelLine(PI_ThinLine); 1015 1071 1072 ComputeDrawerZone(); 1016 1073 gr->DrawBox(x1,y1, x2, y2); 1017 x1 = _x1+0.9*(_x2-_x1); 1018 y1 = _y1+0.9*(_y2-_y1); 1074 ComputeResizeZone(); 1019 1075 gr->DrawFBox(x1,y1, x2, y2); 1020 x1 = _x1+0.4*(_x2-_x1); 1021 x2 = _x2-0.4*(_x2-_x1); 1022 y1 = _y1+0.4*(_y2-_y1); 1023 y2 = _y2-0.4*(_y2-_y1); 1076 ComputeMoveZone(); 1024 1077 gr->DrawBox(x1,y1, x2, y2); 1025 1078 … … 1029 1082 if (!_rsz) { _x1 += delx; _y1 += dely; } 1030 1083 1031 x1 = _x1; x2 = _x2;1032 y1 = _y1; y2 = _y2;1084 if (!_fgxor) gr->SelForeground(PI_HighlightBlue); 1085 ComputeDrawerZone(); 1033 1086 gr->DrawBox(x1,y1, x2, y2); 1034 x1 = _x1+0.9*(_x2-_x1); 1035 y1 = _y1+0.9*(_y2-_y1); 1087 ComputeResizeZone(); 1036 1088 gr->DrawFBox(x1,y1, x2, y2); 1037 x1 = _x1+0.4*(_x2-_x1); 1038 x2 = _x2-0.4*(_x2-_x1); 1039 y1 = _y1+0.4*(_y2-_y1); 1040 y2 = _y2-0.4*(_y2-_y1); 1089 ComputeMoveZone(); 1041 1090 gr->DrawBox(x1,y1, x2, y2); 1042 1091 gr->SelGOMode(gmod); … … 1047 1096 1048 1097 case PIEvent_But1Release : 1098 if (_ipx < 0) return; 1049 1099 if (_okend) { 1050 // On enleve le handler et on efface de rectangle de resize/move 1100 // On efface de rectangle de resize/move 1101 if (_fgxor) { 1102 gr->SelForeground(PI_Magenta); 1103 gr->SelGOMode(PI_GOXOR); 1104 } 1105 else { 1106 gr->SelForeground(mBWdg->GetBackgroundColor()); 1107 gr->SelGOMode(PI_GOCopy); 1108 } 1109 gr->SelLine(PI_ThinLine); 1051 1110 1052 gr->SelForeground(PI_Magenta); 1053 gr->SelGOMode(PI_GOXOR); 1054 gr->SelLine(PI_ThinLine); 1055 1056 gr->DrawBox(x1,y1, x2, y2); 1057 x1 = _x1+0.9*(_x2-_x1); 1058 y1 = _y1+0.9*(_y2-_y1); 1059 gr->DrawFBox(x1,y1, x2, y2); 1060 x1 = _x1+0.4*(_x2-_x1); 1061 x2 = _x2-0.4*(_x2-_x1); 1062 y1 = _y1+0.4*(_y2-_y1); 1063 y2 = _y2-0.4*(_y2-_y1); 1064 gr->DrawBox(x1,y1, x2, y2); 1111 ComputeDrawerZone(); 1112 gr->DrawBox(x1,y1, x2, y2); 1113 ComputeResizeZone(); 1114 gr->DrawFBox(x1,y1, x2, y2); 1115 ComputeMoveZone(); 1116 gr->DrawBox(x1,y1, x2, y2); 1065 1117 gr->SelGOMode(gmod); 1066 1118 gr->SelLine(gline); 1067 1119 gr->SelForeground(gcol); 1068 1069 cout << " DBG- mBWdg->RemoveEventHandler(this); " << endl;1120 // On enleve le handler 1121 // cout << " DBG- mBWdg->RemoveEventHandler(this); " << endl; 1070 1122 mBWdg->RemoveEventHandler(this); 1071 1123 _rmok = true; 1072 1124 return; 1073 1125 } 1074 1126 1075 if (_ipx < 0) return;1127 // Nouvelle position / taille 1076 1128 delx = GetPosX()-_cpx; 1077 1129 dely = GetPosY()-_cpy; 1078 1079 gr->SelForeground(PI_Magenta); 1080 gr->SelGOMode(PI_GOXOR); 1081 gr->SelLine(PI_ThinLine); 1082 1130 _x2 += delx; 1131 _y2 += dely; 1132 if (!_rsz) { _x1 += delx; _y1 += dely; } 1133 if (_elastic) { 1134 x1 = (double)_x1/(double)mBWdg->XSize(); 1135 x2 = (double)_x2/(double)mBWdg->XSize(); 1136 y1 = (double)_y1/(double)mBWdg->YSize(); 1137 y2 = (double)_y2/(double)mBWdg->YSize(); 1138 } 1139 else { 1140 x1 = _x1; x2 = _x2; 1141 y1 = _y1; y2 = _y2; 1142 } 1143 if (_defrect) { 1144 mBWdg->SetDefaultDrawRectangle(x1, y1, x2, y2, _elastic); 1145 // cout << "DBG-SetDefaultDrawRectangle() x1,y1=" << _x1 << "," << _y1 1146 // << " x2,y2=" << _x2 << "," << _y2 << endl; 1147 } 1148 else { 1149 aid = mBWdg->GetActiveDrawerId(); 1150 mBWdg->MoveResizeDrawer(aid, x1, y1, x2, y2, _elastic); 1151 // cout << "DBG-MoveResizeDrawer() x1,y1=" << _x1 << "," << _y1 1152 // << " x2,y2=" << _x2 << "," << _y2 << endl; 1153 } 1154 mBWdg->Refresh(); 1155 1156 if (_fgxor) { 1157 gr->SelForeground(PI_Magenta); 1158 gr->SelGOMode(PI_GOXOR); 1159 } 1160 else { 1161 gr->SelForeground(PI_HighlightBlue); 1162 gr->SelGOMode(PI_GOCopy); 1163 } 1164 ComputeDrawerZone(); 1083 1165 gr->DrawBox(x1,y1, x2, y2); 1084 x1 = _x1+0.9*(_x2-_x1); 1085 y1 = _y1+0.9*(_y2-_y1); 1166 ComputeResizeZone(); 1086 1167 gr->DrawFBox(x1,y1, x2, y2); 1087 x1 = _x1+0.4*(_x2-_x1); 1088 x2 = _x2-0.4*(_x2-_x1); 1089 y1 = _y1+0.4*(_y2-_y1); 1090 y2 = _y2-0.4*(_y2-_y1); 1091 gr->DrawBox(x1,y1, x2, y2); 1168 ComputeMoveZone(); 1169 gr->DrawBox(x1,y1, x2, y2); 1170 1092 1171 gr->SelGOMode(gmod); 1093 1172 gr->SelLine(gline); 1094 1173 gr->SelForeground(gcol); 1095 1174 1096 // Nouvelle position / taille1097 _x2 += delx;1098 _y2 += dely;1099 if (!_rsz) { _x1 += delx; _y1 += dely; }1100 1101 x1 = _x1; x2 = _x2;1102 y1 = _y1; y2 = _y2;1103 gr->DrawBox(x1,y1, x2, y2);1104 x1 = _x1+0.9*(_x2-_x1);1105 y1 = _y1+0.9*(_y2-_y1);1106 gr->DrawFBox(x1,y1, x2, y2);1107 x1 = _x1+0.4*(_x2-_x1);1108 x2 = _x2-0.4*(_x2-_x1);1109 y1 = _y1+0.4*(_y2-_y1);1110 y2 = _y2-0.4*(_y2-_y1);1111 gr->DrawBox(x1,y1, x2, y2);1112 gr->RestoreGraphicAtt();1113 1114 aid = mBWdg->GetActiveDrawerId();1115 if (aid < 0) return;1116 1117 if (_elastic) {1118 x1 = (double)_x1/(double)mBWdg->XSize();1119 x2 = (double)_x2/(double)mBWdg->XSize()+(double)_x1;1120 y1 = (double)_y1/(double)mBWdg->YSize();1121 y2 = (double)_y2/(double)mBWdg->YSize()+(double)_y1;1122 }1123 else {1124 x1 = _x1; x2 = _x2+_x1;1125 y1 = _y1; y2 = _y2+_y1;1126 }1127 if (_defrect)1128 // mBWdg->SetDefaultDrawRectangle(x1, y1, x2, y2, _elastic);1129 cout << "DBG-SetDefaultDrawRectangle() x1,y1=" << _x1 << "," << _y11130 << " x2,y2=" << _x2 << "," << _y2 << endl;1131 else // mBWdg->MoveResizeDrawer(aid, x1, y1, x2, y2, _elastic);1132 cout << "DBG-MoveResizeDrawer() x1,y1=" << _x1 << "," << _y11133 << " x2,y2=" << _x2 << "," << _y2 << endl;1134 1135 mBWdg->Refresh();1136 1175 break; 1137 1176 … … 1144 1183 //------------------------------------------------------------ 1145 1184 /* --Methode-- */ 1146 PIDrwMgrMenu::PIDrwMgrMenu(PIBaseWdg* bwdg )1185 PIDrwMgrMenu::PIDrwMgrMenu(PIBaseWdg* bwdg, bool fgxor) 1147 1186 : PIMenu(bwdg, "PIDrwMgrMenu", k_PopupMenu) 1148 1187 { 1149 1188 mBWdg = bwdg; 1150 1189 mListDrw = NULL; 1190 mFgxor = fgxor; 1151 1191 mEvH = NULL; 1152 1192 … … 1184 1224 AppendPDMenu(mListDrw); 1185 1225 } 1226 PIDrawer* actdr = mBWdg->GetActiveDrawer(); 1227 if (actdr) actdr->HighLight(true); 1186 1228 } 1187 1229 … … 1190 1232 { 1191 1233 if (mListDrw) delete mListDrw; 1192 if (mEvH) delete mEvH; 1234 if (mEvH) { 1235 mEvH->CheckBeforeDelete(); 1236 delete mEvH; 1237 } 1193 1238 } 1194 1239 … … 1204 1249 case 401 : 1205 1250 if (aid >= 0) PIDrwTools::ShowPIDrwTools(mBWdg); 1206 //if (actdrw != NULL) actdrw->HighLight(false);1251 if (actdrw != NULL) actdrw->HighLight(false); 1207 1252 break; 1208 1253 case 402 : 1209 1254 if (actdrw != NULL) { 1210 1255 PIDrwOptionStringWindow::ShowDrwOptionStringWindow(actdrw); 1211 //actdrw->HighLight(false);1256 actdrw->HighLight(false); 1212 1257 } 1213 1258 break; … … 1215 1260 if (actdrw != NULL) { 1216 1261 actdrw->ShowControlWindow(mBWdg); 1217 //actdrw->HighLight(false);1262 actdrw->HighLight(false); 1218 1263 } 1219 1264 break; 1220 1265 case 404 : 1221 1266 if (mEvH) delete mEvH; 1222 mEvH = new PIDrwPosSizeEvH(mBWdg); 1267 if (actdrw != NULL) actdrw->HighLight(false); 1268 mEvH = new PIDrwPosSizeEvH(mBWdg, mFgxor); 1223 1269 break; 1224 1270 case 405 : … … 1235 1281 break; 1236 1282 default : 1237 //if (actdrw != NULL) actdrw->HighLight(false);1283 if (actdrw != NULL) actdrw->HighLight(false); 1238 1284 if (msg >= 1000) 1239 1285 mBWdg->SetActiveDrawer(msg-1000); -
trunk/SophyaPI/PI/pidrwtools.h
r2528 r2529 88 88 class PIDrwMgrMenu : public PIMenu { 89 89 public: 90 PIDrwMgrMenu(PIBaseWdg* bwdg );90 PIDrwMgrMenu(PIBaseWdg* bwdg, bool fgxor=true); 91 91 virtual ~PIDrwMgrMenu(); 92 92 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); … … 94 94 PIMenu* mListDrw; 95 95 PIBaseWdg* mBWdg; 96 bool mFgxor; 96 97 PIDrwPosSizeEvH* mEvH; 97 98 }; -
trunk/SophyaPI/PI/piscdrawwdg.cc
r2528 r2529 96 96 FreeLimits(); 97 97 xEndDrag = yEndDrag = xBegDrag = yBegDrag = 0; 98 AddDrawer(mBDrw, true, false, false, false);98 AddDrawer(mBDrw, true, false, false, true); 99 99 100 100 // Pour afficher les coordonnees courante (click-bouton-1) … … 158 158 else if (key == 'D' || key == 'd') { 159 159 if (mDrwMen) delete mDrwMen; 160 mDrwMen = new PIDrwMgrMenu(this );160 mDrwMen = new PIDrwMgrMenu(this, true); 161 161 mDrwMen->Show(); 162 162 } … … 428 428 int nid = FindNearestDrawerId(x,y); 429 429 SetActiveDrawerId(nid); 430 PIDrawer* actdr = GetActiveDrawer();431 if (actdr) {432 actdr->HighLight(true);433 }430 // PIDrawer* actdr = GetActiveDrawer(); 431 // if (actdr) { 432 // actdr->HighLight(true); 433 // } 434 434 return; 435 435 } … … 476 476 PIDrawer* actdr = GetActiveDrawer(); 477 477 if (actdr) { 478 actdr->HighLight(false);478 // actdr->HighLight(false); 479 479 if (mDrwMen) delete mDrwMen; 480 480 mDrwMen = new PIDrwMgrMenu(this); 481 mDrwMen->Show(this, x, y); 482 } 481 mDrwMen->Show(); 482 } 483 483 484 return; 484 485 } -
trunk/SophyaPI/PI/piversion.h
r2426 r2529 2 2 #define PIVERSION_H_SEEN 3 3 4 #define PI_VERSIONNUMBER 3.9 64 #define PI_VERSIONNUMBER 3.97 5 5 6 6 #endif
Note:
See TracChangeset
for help on using the changeset viewer.