Ignore:
Timestamp:
Apr 4, 2008, 2:27:12 PM (17 years ago)
Author:
mansoux
Message:

Second Version

File:
1 edited

Legend:

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

    r3470 r3479  
    1010#include "pistdwdgmosx.h"
    1111
     12vector<PIWdg*> vpiwdg;
     13
     14static void CommonControlActionCallback (ControlRef theControl, ControlPartCode partCode);
     15
    1216
    1317/* ========== PILabelQuartz ========== */
     
    5256: PITextGen(par, nom, sx, sy, px, py)
    5357{
    54         OSStatus err;
    5558        wParent = ((PIContainer *)par)->GetWindowPtr();
    5659    SetRect(&wdgRect,px,py,px+sx,py+sy);
     
    214217
    215218}
     219
     220/* ========== PIButtonQuartz ========== */
     221
     222EventTypeSpec controlEvents[] = {{kEventClassControl, kEventControlHit}};
     223
     224PIButtonQuartz::PIButtonQuartz(PIContainerQuartz *par,const char *nom, PIMessage msg,int sx, int sy, int px, int py)
     225:PIButtonGen(par,nom,msg,sx,sy,px,py)
     226{
     227        wParent = ((PIContainer *)par)->GetWindowPtr();
     228        SetPortWindowPort(wParent);
     229    SetRect(&wdgRect,px,py,px+sx,py+sy);
     230
     231    CreatePushButtonControl (par->GetWindowPtr(),&wdgRect,title,&contH);
     232    SetControlTitleWithCFString (contH, title);
     233        _actionProc = NewControlActionUPP (CommonControlActionCallback);
     234        SetControlAction (contH, _actionProc);
     235        vpiwdg.push_back(this);
     236}
     237
     238
     239PIButtonQuartz::~PIButtonQuartz()
     240{
     241}
     242
     243void PIButtonQuartz::ActivatePress(bool acp)
     244{
     245        return;
     246}       
     247
     248void PIButtonQuartz::SetLabel(string const& sText)
     249{
     250    title = CFStringCreateWithCString (NULL, sText.c_str(), kCFStringEncodingMacRoman);
     251        SetControlTitleWithCFString(contH,title);
     252        return;
     253}
     254
     255static void CommonControlActionCallback (ControlRef theControl, ControlPartCode partCode)
     256{
     257        vector<PIWdg*>::iterator it;
     258        for(it = vpiwdg.begin(); it != vpiwdg.end(); it++)
     259        {
     260            if (((*it)->GetControlRef())==theControl)
     261            {
     262                (*it)->Send((*it)->Msg(),PIMsg_Click,NULL);
     263                                printf ("click : %d \n",(int)(*it)->Msg());
     264                break;
     265            }
     266        }
     267}
     268
     269
     270/* ========== PICheckBoxQuartz ========== */
     271
     272PICheckBoxQuartz::PICheckBoxQuartz(PIContainerQuartz *par,const char *nom, PIMessage msg,int sx, int sy, int px, int py)
     273:PICheckBoxGen(par,nom,msg,sx,sy,px,py)
     274{
     275        wParent = ((PIContainer *)par)->GetWindowPtr();
     276        SetPortWindowPort(wParent);
     277    SetRect(&wdgRect,px,py,px+sx,py+sy);
     278        _state = 1;
     279    CreateCheckBoxControl (par->GetWindowPtr(),&wdgRect,title,_state,TRUE,&contH);
     280    SetControlTitleWithCFString (contH, title);
     281        _actionProc = NewControlActionUPP (CommonControlActionCallback);
     282        SetControlAction (contH, _actionProc);
     283        vpiwdg.push_back(this);
     284}
     285
     286
     287PICheckBoxQuartz::~PICheckBoxQuartz()
     288{
     289}
     290
     291void PICheckBoxQuartz::SetState(bool acp)
     292{
     293        _state = acp;
     294        return;
     295}
     296
     297bool PICheckBoxQuartz::GetState()
     298{
     299        return _state;
     300}
     301
     302/* ========== PIRadioQuartz ========== */
     303
     304PIRadioQuartz::PIRadioQuartz(PIContainerQuartz *par,const char *nom, PIMessage msg,int sx, int sy, int px, int py,int initialValue)
     305:PIWdg(par,nom,sx,sy,px,py)
     306{
     307        SetMsg(msg);
     308        wParent = ((PIContainer *)par)->GetWindowPtr();
     309        SetPortWindowPort(wParent);
     310    SetRect(&wdgRect,px,py,px+sx,py+sy);
     311    CreateRadioButtonControl (par->GetWindowPtr(),&wdgRect,title,initialValue,FALSE,&contH);
     312    SetControlTitleWithCFString (contH, title);
     313        _actionProc = NewControlActionUPP (CommonControlActionCallback);
     314        SetControlAction (contH, _actionProc);
     315        vpiwdg.push_back(this);
     316}
     317
     318PIRadioQuartz::~PIRadioQuartz()
     319{
     320}
     321
     322/* ========== PIRadioGroupQuartz ========== */
     323
     324PIRadioGroupQuartz::PIRadioGroupQuartz(PIContainerQuartz *par,const char *nom, PIMessage msg,int sx, int sy, int px, int py)
     325:PIWdg(par,nom,sx,sy,px,py)
     326{
     327        SetMsg(msg);
     328        wParent = ((PIContainer *)par)->GetWindowPtr();
     329        SetPortWindowPort(wParent);
     330    SetRect(&wdgRect,px,py,px+sx,py+sy);
     331    OSErr error;
     332        error = CreateRadioGroupControl (par->GetWindowPtr(),&wdgRect,&contH);
     333        _state = 0;
     334}
     335
     336void PIRadioGroupQuartz::AddRadioButton(PIRadio* piRadio)
     337{
     338        OSErr error;
     339        error = EmbedControl(piRadio->GetControlRef(),contH);
     340               
     341        return;
     342}
     343
     344PIRadioGroupQuartz::~PIRadioGroupQuartz()
     345{
     346}
     347
Note: See TracChangeset for help on using the changeset viewer.