Changeset 4078 in Sophya for trunk/SophyaPI


Ignore:
Timestamp:
Jul 23, 2012, 2:45:33 PM (13 years ago)
Author:
garnier
Message:

last modifications from bruno

Location:
trunk/SophyaPI/PI/Quartz
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PI/Quartz/PIContainerQuartz.cpp

    r3747 r4078  
    99#include "PIContainerQuartz.h"
    1010
    11 
    1211/* --Methode-- */
    1312PIContainerQuartz::PIContainerQuartz(PIContainerGen *par, const char *nom,
     
    1716}
    1817
    19 
    2018/* --Methode-- */
    2119PIContainerQuartz::~PIContainerQuartz()
    2220{
    2321}
    24 
    2522
    2623/* --Methode-- */
     
    3027
    3128/* --Methode-- */
    32 HIViewRef PIContainerQuartz::GetHIViewRef()
    33 {
    34     return viewH;
    35 }
    36 
    37 /* --Methode-- */
    3829WindowRef PIContainerQuartz::GetWindowRef()
    3930{
    40     return HIViewGetWindow(viewH);
     31    return HIViewGetWindow(wdgHIView);
    4132}
  • trunk/SophyaPI/PI/Quartz/PIContainerQuartz.h

    r3747 r4078  
    2424    virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
    2525       
    26     virtual HIViewRef GetHIViewRef();
    27         virtual WindowRef GetWindowRef();
     26    virtual WindowRef GetWindowRef();
    2827};
    2928
  • trunk/SophyaPI/PI/Quartz/PIMenuBarQuartz.cpp

    r3747 r4078  
    143143    else
    144144    {
    145                 printf("Menu Item selected %u \n", commandStruct.commandID);
     145                // printf("Menu Item selected %u \n", commandStruct.commandID);
    146146                fflush (stdout);               
    147147                MainMenuBar->Dispatch(commandStruct, userData);
  • trunk/SophyaPI/PI/Quartz/PIWindowQuartz.cpp

    r3747 r4078  
    44 *
    55 *  Created by Bruno MANSOUX on Tue Apr 13 2004.
    6  *  Copyright (c) 2004 __MyCompanyName__. All rights reserved.
    76 *
    87 */
     
    1514    OSStatus err = 0;
    1615    WindowAttributes windowAttributes;
    17    
    18         /*
    19         wParent = ((PIContainer *)par)->GetWindowRef();
    20         SetPortWindowPort(wParent);
    21         */
     16        HIRect bounds;
    2217       
    2318    SetRect(&wdgRect,px,py,px+sx,py+sy);
    2419        windowAttributes = kWindowStandardDocumentAttributes | kWindowCompositingAttribute ;
    2520       
    26         err = CreateNewWindow (kDocumentWindowClass,windowAttributes,&wdgRect,&wRef);
     21        err = CreateNewWindow (kDocumentWindowClass, windowAttributes, &wdgRect, &wRef);
    2722
    2823    if (err)
    2924        printf ("PIWindowQuartz Create Err = %d \n",err);
    30     fflush (stdout);
    3125   
    3226    err = SetWindowTitleWithCFString (wRef, title);
    3327
    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 */     
    3636}
    3737
     
    7777void PIWindowQuartz::Refresh()
    7878{
     79        printf("PIWindowQuartz::Refresh \n");
    7980    SetPortWindowPort(wRef);
    8081    BeginUpdate(wRef);
     
    8283    DrawControls(wRef);
    8384    DrawGrowIcon(wRef);
     85        // HIViewSetNeedsDisplay(wdgHIView, true);
    8486    EndUpdate(wRef);
    8587    ShowWindow (wRef);
     
    142144    return;
    143145}
    144 
  • trunk/SophyaPI/PI/Quartz/PIWindowQuartz.h

    r3747 r4078  
    1414
    1515#include "piwindowgen.h"
    16 
    17 /*
    18 EventTypeSpec windowEvents[] = {{kEventClassWindow, kEventWindowUpdate}};
    19 */
     16#include "pieventquartz.h"
    2017
    2118class PIWindowQuartz : public PIWindowGen
     
    5350  virtual void           CallEventHandlers(unsigned long evt, int px, int py,
    5451                                           int k, int km, unsigned long tm);
     52
    5553protected:
    5654    WindowRef   wRef;
  • trunk/SophyaPI/PI/Quartz/QuartzAppTest.cpp

    r3747 r4078  
    1111#include <pistdwdgquartz.h>
    1212#include <pigraphquartz.h>
     13#include <pibwdgquartz.h>
    1314#include <iostream>
    1415
    1516#define NBCOTE 7
    16 
    17 void FillDatas();
    18 
    19 PIGraphicWin* pig;
    20 PIGrCoord* tabx;
    21 PIGrCoord* taby;
    2217
    2318/* ============================== */
     
    3126
    3227/* ============================== */
     28class TstBWdg : public PIBaseWdg
     29{
     30public:
     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();
     35private:
     36        bool fgPolygon;
     37};
     38
     39PIWindow* windowFirst;
     40TstBWdg* twdg;
     41/* ============================== */
    3342QuartzApp::QuartzApp()
    3443: PIApplication()
     
    4554void QuartzApp::Process (PIMessage msg, PIMsgHandler* sender, void * data)
    4655{
     56  std::cout << "QuartzApp::Process " ;
     57 
    4758  switch(UserMsg(msg))   
    4859        {       
    4960                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();
    5264                break;
    5365
    5466                case 2001:
    5567                std::cout << " Circle " << std::endl;
    56                 pig->DrawCircle(360,100,30);
     68                // twdg->DrawCircle(360,100,30);
    5769                break;
    5870               
    5971                case 2002:
    6072                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();
    6285                break;
    6386               
     
    78101}
    79102
    80 
    81 /* ============================== */
     103/* ============================================================================================================ */
     104/* ============================================================================================================ */
     105/* ============================================================================================================ */
     106/* ============================================================================================================ */
     107/* ============================================================================================================ */
     108/* ============================================================================================================ */
    82109int main(int argc, char *argv[])
    83110{
     
    89116        PIOptMenu* optMenu; 
    90117    PIMenubar* mBar;
    91     PIWindow* windowFirst;     
    92118        PILabel *piLabel;
    93119    PIButton* piButton;
    94120    vector<int> points;
    95121
    96     /* Creation of general graphical objects */
    97 
    98122    mainApp = new QuartzApp();
    99123
     124    /* Creation of Menu and Menu Items */
    100125    firstMenu = new PIMenu((PIWdg *)mainApp, (const char *)"File Menu");
    101126    firstMenu->AppendItem("One from file", 1000);
     
    106131       
    107132        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);
    111136
    112137        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);
    119142    mBar = mainApp->Menubar();
    120143    mBar->AppendMenu(firstMenu);
    121144    mBar->AppendMenu(figuresMenu);
    122145       
    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);
    130155        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);
    133158        mBar->AppendPopupMenu(popMenu);
    134 
    135159        optMenu->AppendPDMenu(popMenu);
    136160       
    137161        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/* ============================================================================================================ */
     179TstBWdg::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/* ============================================================================================================ */
     186void 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);
    147202        PIGrCoord len(150);
    148203        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);
    157215
    158216        PIGrCoord deltax(60);
    159217        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        }
    178233        return;
    179234}
     235
     236/* ============================================================================================================ */
     237void TstBWdg::SetPolygon()
     238{
     239        fgPolygon = true;
     240        Refresh();
     241}
     242
     243/* ============================================================================================================ */
     244void TstBWdg::UnsetPolygon()
     245{
     246        fgPolygon = false;
     247        Refresh();
     248}
     249
Note: See TracChangeset for help on using the changeset viewer.