- Timestamp:
- Jul 23, 2012, 2:45:33 PM (13 years ago)
- Location:
- trunk/SophyaPI/PI/Quartz
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PI/Quartz/PIContainerQuartz.cpp
r3747 r4078 9 9 #include "PIContainerQuartz.h" 10 10 11 12 11 /* --Methode-- */ 13 12 PIContainerQuartz::PIContainerQuartz(PIContainerGen *par, const char *nom, … … 17 16 } 18 17 19 20 18 /* --Methode-- */ 21 19 PIContainerQuartz::~PIContainerQuartz() 22 20 { 23 21 } 24 25 22 26 23 /* --Methode-- */ … … 30 27 31 28 /* --Methode-- */ 32 HIViewRef PIContainerQuartz::GetHIViewRef()33 {34 return viewH;35 }36 37 /* --Methode-- */38 29 WindowRef PIContainerQuartz::GetWindowRef() 39 30 { 40 return HIViewGetWindow( viewH);31 return HIViewGetWindow(wdgHIView); 41 32 } -
trunk/SophyaPI/PI/Quartz/PIContainerQuartz.h
r3747 r4078 24 24 virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL); 25 25 26 virtual HIViewRef GetHIViewRef(); 27 virtual WindowRef GetWindowRef(); 26 virtual WindowRef GetWindowRef(); 28 27 }; 29 28 -
trunk/SophyaPI/PI/Quartz/PIMenuBarQuartz.cpp
r3747 r4078 143 143 else 144 144 { 145 printf("Menu Item selected %u \n", commandStruct.commandID);145 // printf("Menu Item selected %u \n", commandStruct.commandID); 146 146 fflush (stdout); 147 147 MainMenuBar->Dispatch(commandStruct, userData); -
trunk/SophyaPI/PI/Quartz/PIWindowQuartz.cpp
r3747 r4078 4 4 * 5 5 * Created by Bruno MANSOUX on Tue Apr 13 2004. 6 * Copyright (c) 2004 __MyCompanyName__. All rights reserved.7 6 * 8 7 */ … … 15 14 OSStatus err = 0; 16 15 WindowAttributes windowAttributes; 17 18 /* 19 wParent = ((PIContainer *)par)->GetWindowRef(); 20 SetPortWindowPort(wParent); 21 */ 16 HIRect bounds; 22 17 23 18 SetRect(&wdgRect,px,py,px+sx,py+sy); 24 19 windowAttributes = kWindowStandardDocumentAttributes | kWindowCompositingAttribute ; 25 20 26 err = CreateNewWindow (kDocumentWindowClass, windowAttributes,&wdgRect,&wRef);21 err = CreateNewWindow (kDocumentWindowClass, windowAttributes, &wdgRect, &wRef); 27 22 28 23 if (err) 29 24 printf ("PIWindowQuartz Create Err = %d \n",err); 30 fflush (stdout);31 25 32 26 err = SetWindowTitleWithCFString (wRef, title); 33 27 34 viewH = HIViewGetRoot(wRef); 35 InstallStandardEventHandler(GetWindowEventTarget(wRef)); /* installs the default */ 28 wdgHIView = HIViewGetRoot(wRef); 29 HIViewGetBounds (wdgHIView, &bounds); 30 31 printf("PIWindowQuartz::PIWindowQuartz Window View Bounds (%g %g) [%g %g] \n", 32 bounds.origin.x, bounds.origin.y, 33 bounds.size.width, bounds.size.height); 34 35 InstallStandardEventHandler(GetWindowEventTarget(wRef)); /* installs the default */ 36 36 } 37 37 … … 77 77 void PIWindowQuartz::Refresh() 78 78 { 79 printf("PIWindowQuartz::Refresh \n"); 79 80 SetPortWindowPort(wRef); 80 81 BeginUpdate(wRef); … … 82 83 DrawControls(wRef); 83 84 DrawGrowIcon(wRef); 85 // HIViewSetNeedsDisplay(wdgHIView, true); 84 86 EndUpdate(wRef); 85 87 ShowWindow (wRef); … … 142 144 return; 143 145 } 144 -
trunk/SophyaPI/PI/Quartz/PIWindowQuartz.h
r3747 r4078 14 14 15 15 #include "piwindowgen.h" 16 17 /* 18 EventTypeSpec windowEvents[] = {{kEventClassWindow, kEventWindowUpdate}}; 19 */ 16 #include "pieventquartz.h" 20 17 21 18 class PIWindowQuartz : public PIWindowGen … … 53 50 virtual void CallEventHandlers(unsigned long evt, int px, int py, 54 51 int k, int km, unsigned long tm); 52 55 53 protected: 56 54 WindowRef wRef; -
trunk/SophyaPI/PI/Quartz/QuartzAppTest.cpp
r3747 r4078 11 11 #include <pistdwdgquartz.h> 12 12 #include <pigraphquartz.h> 13 #include <pibwdgquartz.h> 13 14 #include <iostream> 14 15 15 16 #define NBCOTE 7 16 17 void FillDatas();18 19 PIGraphicWin* pig;20 PIGrCoord* tabx;21 PIGrCoord* taby;22 17 23 18 /* ============================== */ … … 31 26 32 27 /* ============================== */ 28 class TstBWdg : public PIBaseWdg 29 { 30 public: 31 TstBWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py); 32 virtual void Draw(PIGraphic* g, int x0, int y0, int dx, int dy); 33 void SetPolygon(); 34 void UnsetPolygon(); 35 private: 36 bool fgPolygon; 37 }; 38 39 PIWindow* windowFirst; 40 TstBWdg* twdg; 41 /* ============================== */ 33 42 QuartzApp::QuartzApp() 34 43 : PIApplication() … … 45 54 void QuartzApp::Process (PIMessage msg, PIMsgHandler* sender, void * data) 46 55 { 56 std::cout << "QuartzApp::Process " ; 57 47 58 switch(UserMsg(msg)) 48 59 { 49 60 case 777: 50 std::cout << " Erase " << std::endl; 51 pig->Erase(280,60,100,50); 61 std::cout << " Pas Polygone " << std::endl; 62 windowFirst->Refresh(); 63 twdg->UnsetPolygon(); 52 64 break; 53 65 54 66 case 2001: 55 67 std::cout << " Circle " << std::endl; 56 pig->DrawCircle(360,100,30);68 // twdg->DrawCircle(360,100,30); 57 69 break; 58 70 59 71 case 2002: 60 72 std::cout << " Polygone " << std::endl; 61 pig->DrawPolygon(tabx, taby, NBCOTE, 0); 73 twdg->SetPolygon(); 74 break; 75 76 case 2003: 77 std::cout << " Draw " << std::endl; 78 twdg->Refresh(); 79 break; 80 81 82 case 2004: 83 std::cout << " Show " << std::endl; 84 windowFirst->Refresh(); 62 85 break; 63 86 … … 78 101 } 79 102 80 81 /* ============================== */ 103 /* ============================================================================================================ */ 104 /* ============================================================================================================ */ 105 /* ============================================================================================================ */ 106 /* ============================================================================================================ */ 107 /* ============================================================================================================ */ 108 /* ============================================================================================================ */ 82 109 int main(int argc, char *argv[]) 83 110 { … … 89 116 PIOptMenu* optMenu; 90 117 PIMenubar* mBar; 91 PIWindow* windowFirst;92 118 PILabel *piLabel; 93 119 PIButton* piButton; 94 120 vector<int> points; 95 121 96 /* Creation of general graphical objects */97 98 122 mainApp = new QuartzApp(); 99 123 124 /* Creation of Menu and Menu Items */ 100 125 firstMenu = new PIMenu((PIWdg *)mainApp, (const char *)"File Menu"); 101 126 firstMenu->AppendItem("One from file", 1000); … … 106 131 107 132 underMenu = new PIMenu((PIWdg *)firstMenu,(const char *)"submenu"); 108 firstMenu->AppendCascadeMenu(underMenu, 1001);109 underMenu->AppendItem("Sub 1 from 2", 1010);110 underMenu->AppendItem("Sub 2 from 2", 1011);133 firstMenu->AppendCascadeMenu(underMenu, 1001); 134 underMenu->AppendItem("Sub 1 from 2", 1010); 135 underMenu->AppendItem("Sub 2 from 2", 1011); 111 136 112 137 figuresMenu = new PIMenu((PIWdg *)mainApp, (const char *)"Figures"); 113 figuresMenu->AppendItem("Circle",2001); 114 figuresMenu->AppendItem("Polygone",2002); 115 116 printf ("Menus created \n"); 117 fflush (stdout); 118 138 figuresMenu->AppendItem("Circle", 2001); 139 figuresMenu->AppendItem("Polygone", 2002); 140 figuresMenu->AppendItem("Draw", 2003); 141 figuresMenu->AppendItem("Show", 2004); 119 142 mBar = mainApp->Menubar(); 120 143 mBar->AppendMenu(firstMenu); 121 144 mBar->AppendMenu(figuresMenu); 122 145 123 windowFirst = new PIWindow((PIMsgHandler *)mainApp, (const char *)"Window First",PIWK_normal,600,200,50,50); 124 125 piLabel = new PILabel(windowFirst,(const char *)"Label",80,40,150,50); 126 127 piButton = new PIButton(windowFirst, "Hello",777,60,20,80,80); 128 129 optMenu = new PIOptMenu(windowFirst, "Opt Menu", 100,25,150,80); 146 /* Creation of Main Window */ 147 windowFirst = new PIWindow((PIMsgHandler *)mainApp, (const char *)"Window First",PIWK_normal, 700, 300, 50, 50); 148 149 /* Creation of general graphical objects */ 150 piLabel = new PILabel(windowFirst,(const char *)"Label", 80, 40, 150, 50); 151 152 piButton = new PIButton(windowFirst, "Hello", 777, 60, 20, 80, 80); 153 154 optMenu = new PIOptMenu(windowFirst, "Opt Menu", 100, 25, 150, 80); 130 155 popMenu = new PIMenu((PIWdg *)optMenu, (const char *)"Pop Menu",k_PopupMenu); 131 popMenu->AppendItem("pop 1", 3001);132 popMenu->AppendItem("pop 2", 3002);156 popMenu->AppendItem("pop 1", 3001); 157 popMenu->AppendItem("pop 2", 3002); 133 158 mBar->AppendPopupMenu(popMenu); 134 135 159 optMenu->AppendPDMenu(popMenu); 136 160 137 161 piLabel->SetLabel("Etiquette"); 138 139 windowFirst->Refresh(); 140 fflush (stdout); 141 142 pig = new PIGraphicWin (windowFirst); 143 // pig->SetClipRectangle(280,60,100,50); 144 145 PIGrCoord px(300); 146 PIGrCoord py(80); 162 163 /* Creation of graphic Context */ 164 twdg = new TstBWdg(windowFirst, "Test BaseQuartz", 400, 250, 300, 50); 165 windowFirst->Show(); 166 167 mainApp->Run(); // Main loop 168 169 return 0; 170 } 171 /* ============================================================================================================ */ 172 /* ============================================================================================================ */ 173 /* ============================================================================================================ */ 174 /* ============================================================================================================ */ 175 /* ============================================================================================================ */ 176 /* ============================================================================================================ */ 177 178 /* ============================================================================================================ */ 179 TstBWdg::TstBWdg(PIContainerGen *par, const char *nom, int sx, int sy, int px, int py) 180 : PIBaseWdg(par, nom, sx, sy, px, py) 181 { 182 fgPolygon = false; 183 } 184 185 /* ============================================================================================================ */ 186 void TstBWdg::Draw(PIGraphic* g, int x0, int y0, int dx, int dy) 187 { 188 std::cout << "TstBWdg::Draw "; 189 190 /* 191 CGContextRef cg = ((PIGraphicWin*)g)->GetCGContext(); 192 printf(" cg : %lx ", (unsigned long)cg); 193 CGAffineTransform cat = CGContextGetCTM (cg); 194 */ 195 196 CGAffineTransform cat = ((PIGraphicWin*)g)->GetCTM(); 197 std::cout << " CGAffineTransform : " << cat.a << " " << cat.b << " " << cat.c << " " ; 198 std::cout << cat.d << " t : " << cat.tx << " " << cat.ty << endl; 199 200 PIGrCoord px(20); 201 PIGrCoord py(30); 147 202 PIGrCoord len(150); 148 203 PIGrCoord hei(50); 149 pig->SelForeground(PI_Blue); 150 pig->DrawFBox(px, py, len, hei); 151 pig->DrawString (px, py, "Graphic Text", 1); 152 153 PIGrCoord pxfin(450); 154 PIGrCoord pyfin(130); 155 pig->SelForeground(PI_Green); 156 pig->DrawLine (px, py, pxfin, pyfin); 204 g->SelForeground(PI_Blue); 205 g->DrawFBox(px, py, len, hei); 206 207 px = 200 ; py = 50; 208 g->DrawString (px, py, "Graphic Text", 1); 209 210 px = 20 ; py = 150; 211 PIGrCoord pxfin(200); 212 PIGrCoord pyfin(230); 213 g->SelForeground(PI_Green); 214 g->DrawLine (px, py, pxfin, pyfin); 157 215 158 216 PIGrCoord deltax(60); 159 217 PIGrCoord deltay(30); 160 pig->SelForeground(PI_Red); 161 pig->DrawArc (px, py, deltax, deltay, 0., 90.); 162 163 FillDatas(); 164 165 mainApp->Run(); // Main loop 166 167 return 0; 168 } 169 170 /* ============================== */ 171 void FillDatas() 172 { 173 tabx = new PIGrCoord[NBCOTE]; 174 taby = new PIGrCoord[NBCOTE]; 175 176 tabx[0] = 80 ; tabx[1] = 100; tabx[2] = 120; tabx[3] = 140; tabx[4] = 130; tabx[5] = 110; tabx[6] = 90; 177 taby[0] = 50; taby[1] = 60; taby[2] = 70; taby[3] = 80; taby[4] = 60; taby[5] = 40; taby[6] = 20; 218 g->SelForeground(PI_Red); 219 g->DrawArc (px, py, deltax, deltay, 0., 90.); 220 221 if (fgPolygon) 222 { 223 g->SelForeground(PI_Black); 224 225 PIGrCoord tabx[NBCOTE]; 226 PIGrCoord taby[NBCOTE]; 227 std::cout << " Draw Polygon " << std::endl; 228 tabx[0] = 80 ; tabx[1] = 100; tabx[2] = 120; tabx[3] = 140; tabx[4] = 130; tabx[5] = 110; tabx[6] = 90; 229 taby[0] = 50; taby[1] = 60; taby[2] = 70; taby[3] = 80; taby[4] = 60; taby[5] = 40; taby[6] = 20; 230 231 g->DrawPolygon(tabx, taby, NBCOTE, 0); 232 } 178 233 return; 179 234 } 235 236 /* ============================================================================================================ */ 237 void TstBWdg::SetPolygon() 238 { 239 fgPolygon = true; 240 Refresh(); 241 } 242 243 /* ============================================================================================================ */ 244 void TstBWdg::UnsetPolygon() 245 { 246 fgPolygon = false; 247 Refresh(); 248 } 249
Note:
See TracChangeset
for help on using the changeset viewer.