Creating an LTextButton

Creating an LTextButton

Post by garg » Wed, 12 Jul 2006 16:35:37


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->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

Creating an LTextButton

Post by David Phil » Wed, 12 Jul 2006 23:35:51

n article < XXXX@XXXXX.COM >,
"garg" < XXXX@XXXXX.COM > wrote:

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
those that follow it down to make room.
LPane* CViewColumn::CreateSubPane(SInt32 index, ResIDT inPPobID, Boolean

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

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


pane->PutInside(this, false);

// make an attempt to order the subPanes array the way the caller
if(NULL == (pIth = GetSubPane(index)) || pane != pIth){
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;
height = ithLoc.v + myScroll.v - myLoc.v + ithSiz.height;
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);


return pane;


Creating an LTextButton

Post by garg » Fri, 14 Jul 2006 00:29:45

I'm sorry, but I didn't understand your reply

my problem is not inserting visual elements into a created view
I have no problem creating LStaticText or LPushButton.

I have problems creating an LTextButton

The avialable ctors are LTextButton() and LTextButton(LStream*)
I tried both with no success

does anyone have a working code that creates LTextButton???

thanks in advance

Creating an LTextButton

Post by garg » Fri, 14 Jul 2006 15:23:03

Finally, I have managed to create a button and see it
the problem is that when creating the button with the default ctor, you
cannot change the textTraits and the SelectedStyle

does anyone knows how it can be changed? (I don't know how to use the
LStream* ctor so I cannot use it)


Creating an LTextButton

Post by David Phil » Fri, 14 Jul 2006 15:26:43

In article < XXXX@XXXXX.COM >,

The following works fine for me:

LStream* l = new LHandleStream();

SPaneInfo paneInfo = {0, 115, 16, true, true, {0,0,0,0}, 14, 61 + 26
0, (LView*) -1};
SControlInfo conInfo = {0, 0, 0, 1};
ResIDT textTraitsID = Txtr_SystemFont;
SInt16 selectedStyle = bold || underline;
l->WriteData(&paneInfo, sizeof paneInfo);
l->WriteData(&conInfo, sizeof conInfo);
l->WritePString("\pHello World!");
l->WriteData(&textTraitsID, sizeof textTraitsID);
l->WriteData(&selectedStyle, sizeof selectedStyle);
l->SetMarker(0, streamFrom_Start);
LTextButton* tmpBut = new LTextButton(l);
delete l;

Creating an LTextButton

Post by garg » Fri, 14 Jul 2006 15:57:07

thank you, thank you, thank you!!!