Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Mac > OOP Powerplant for Mac > Re: Creating an...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 6 Topic 459 of 484
Post > Topic >>

Re: Creating an LTextButton

by David Phillip Oster <oster@[EMAIL PROTECTED] > Jul 11, 2006 at 02:35 PM

In article <1152603337.832191.86770@[EMAIL PROTECTED]
>,
 "garg" <eladmena@[EMAIL PROTECTED]
> wrote:

> Hello,
> 
> I'm trying to create an LTextButton and place it inside a specific
> pane, after running the code the button doesn't appear
> 
> here's the code (the tmpBut->PutInside was omitted)
> 
> LStream* l = new LStream();
> 
> SPaneInfo paneInfo = {0, 115, 16, true, true, {0,0,0,0}, 14, 91 + 26 ,
> 0, FlowsScroller};
> 
> SControlInfo conInfo;
> conInfo.valueMessage = kSwitch2Panel1;
> conInfo.value = 0;
> conInfo.minValue = 1; //?
> conInfo.maxValue = 0; //?
> 
> ResIDT	textTraitsID = Txtr_SystemFont;
> SInt16	selectedStyle = bold || underline;
> LStr255	lButText = "abcd";
> 
> l->WriteData(&paneInfo, sizeof(SPaneInfo));
> l->WriteData(&conInfo, sizeof(SControlInfo));
> l->WritePString(lButText);
> l->WriteData(&textTraitsID, sizeof(ResIDT));
> l->WriteData(&selectedStyle, sizeof(SInt16));
> 
> l->SetMarker(0, streamFrom_End);
> 
> LTextButton* tmpBut = new LTextButton(l);
> 
> I'm sure the problem is within the LStream, but couldn't figure out
> what it is
> I also tried creating the LTextButton using the default ctor and then
> apply to it some attributes, but no luck there either
> 
> does anyone know how to solve this?
> 
> thanks in advance
> Elad

The easiest way is draw the button in Constructor in a separate 
top-level view, then instantiate that view into your view. Here's a code 
fragment from a working program:

/* CreateSubPane - 
   installs the pane verticaly after its predecessors, and visually 
moves 
      those that follow it down to make room.
 */
LPane* CViewColumn::CreateSubPane(SInt32 index, ResIDT inPPobID, Boolean 
inRefresh){
   SetDefaultAttachable(NULL);

   void        *valp = NULL;
   LPane       *pane;
   LPane       *pIth;
   SInt32         height;
   SDimension16   dim;
   SDimension32   mySize;
   LCommander*    saveCommander;

   saveCommander = LCommander::GetDefaultCommander();
   try{
      valp = UReanimator::ReadObjects('PPob', inPPobID);
   }catch(LException &err){
      LCommander::SetDefaultCommander(saveCommander);
      throw;
   }
   LCommander::SetDefaultCommander(saveCommander);
   pane = reinterpret_cast<LPane*>(valp);
   pane = dynamic_cast<LPane*>(pane);

   Assert_(pane);
   ThrowIfNil_(pane);

   pane->PutInside(this, false);

   // make an attempt to order the subPanes array the way the caller 
asked.
   if(NULL == (pIth = GetSubPane(index))  || pane != pIth){
      mSubPanes.Remove(pane);
      mSubPanes.InsertItemsAt(1, index, pane);
   }

   // visually place after previous pane
   height = 0;
   if(NULL != (pIth = GetSubPane(index-1))){
      SPoint32    ithLoc;
      SPoint32    myLoc;
      SPoint32    myScroll;
      SDimension16   ithSiz;
      GetFrameLocation(myLoc);
      GetScrollPosition(myScroll);
      pIth->GetFrameLocation(ithLoc);
      pIth->GetFrameSize(ithSiz);
      height = ithLoc.v + myScroll.v - myLoc.v + ithSiz.height;
   }
   pane->GetFrameSize(dim);
   GetImageSize(mySize);
   if(mySize.height < height + dim.height){
      ResizeImageBy(0, height + dim.height - mySize.height, inRefresh);
   }
   pane->PlaceInSuperImageAt(0, height, inRefresh);

   // place panes after this visually after this
   if(index != mSubPanes.GetCount()){
      SInt32         i;

      for(i = index+1;i <= mSubPanes.GetCount();i++){
         if(NULL != (pIth = GetSubPane(i))){
            pIth->MoveBy(0,  dim.height, inRefresh);
         }
      }
   }

   pane->FinishCreate();
   pane->Show();

   return pane;
}
 




 6 Posts in Topic:
Creating an LTextButton
"garg" <elad  2006-07-11 00:35:37 
Re: Creating an LTextButton
David Phillip Oster <o  2006-07-11 14:35:51 
Re: Creating an LTextButton
"garg" <elad  2006-07-12 08:29:45 
Re: Creating an LTextButton
"garg" <elad  2006-07-12 23:23:03 
Re: Creating an LTextButton
David Phillip Oster <o  2006-07-13 06:26:43 
Re: Creating an LTextButton
"garg" <elad  2006-07-12 23:57:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 21:57:06 CST 2008.