LISTBROWSER_Borderless

Have a question about our Software Developer Kit? Ask them here.

LISTBROWSER_Borderless

Postby tbreeden » Sun Jun 30, 2013 8:43 pm

This description in the SDK ListBrowserGadg autodocs seems not
entirely accurate.

LISTBROWSER_Borderless (BOOL)
Create a view without a border. Useful if you wish the list
browser to take up the entire window and have an attached
scroller in the window border.


If this tag is used TRUE, no border is drawn, but the list browser
does not take up the entire window. The space in which the
border would have been drawn still remains.

Not a big problem, but it means that the first column is
wider than it should be. It is about 4 pixels too wide on the
screen I am using.

I wonder if there is any way to get that width?

Thanks,

Tom
User avatar
tbreeden
 
Posts: 160
Joined: Sat Jun 18, 2011 1:57 am
Location: Charlottesville, VA, USA

Re: LISTBROWSER_Borderless

Postby salass00 » Sun Jun 30, 2013 9:49 pm

@tbreeden

You need to disable spacing in the root layout by setting LAYOUT_SpaceOuter to FALSE.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 516
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: LISTBROWSER_Borderless

Postby tbreeden » Mon Jul 01, 2013 2:07 am

salass00:
You need to disable spacing in the root layout by setting LAYOUT_SpaceOuter to FALSE.

Yes, I actually found that earlier and did it, to no avail.

But the space I'm seeing is within the ListBrowser gadget, not in the layout. If you leave the
LAYOUT_SpaceOuter at something positive and set LAYOUT_FillPen to black you see that layout
outer space in black, while the persistent ListBrowser border space (which contributes to the
first column width increase) is still grey (ie, the normal background fill).

Tom
User avatar
tbreeden
 
Posts: 160
Joined: Sat Jun 18, 2011 1:57 am
Location: Charlottesville, VA, USA

Re: LISTBROWSER_Borderless

Postby salass00 » Wed Jul 10, 2013 12:17 pm

tbreeden wrote:But the space I'm seeing is within the ListBrowser gadget, not in the layout. If you leave the
LAYOUT_SpaceOuter at something positive and set LAYOUT_FillPen to black you see that layout
outer space in black, while the persistent ListBrowser border space (which contributes to the
first column width increase) is still grey (ie, the normal background fill).


If you can provide a small test program that has this problem along with C source code I code try and see what is going wrong. FWIW I just put together, compiled and tested a small program using LISTBROWSER_Borderless and I didn't get any issue as you describe.
User avatar
salass00
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 516
Joined: Sat Jun 18, 2011 4:12 pm
Location: Finland

Re: LISTBROWSER_Borderless

Postby tbreeden » Sun Jul 14, 2013 5:49 pm

If you can provide a small test program that has this problem along with C source code I code try and see what is going wrong. FWIW I just put together, compiled and tested a small program using LISTBROWSER_Borderless and I didn't get any issue as you describe.


Ok, I've coded it up in C, and it has the same behaviour. You may not have noticed the border, so I have set the ListBrowser background to
white for every item. I can't find any way to get rid of the small grey border (or about 5 pixels), which surrounds it. This area acts as if it were
part of the ListBrowser in that clicking in it will select the node, but is actually the space is added in addition to the specificed column size.
I had expected LISTBROWSER_Borderless to remove that extra space.

Ir does not really look bad; you might ask why I care. What I am doing is trying to make a subclass of ListBrowser that will give it more of
a Spreadsheet type feel, and need to know which row and column are under the mouse while the left button is down. There is no problem
if I simply add 5 pixels to the size of the first column (or to LISTBROWSER_Left) but that might not be too robust.

TstBorderless.jpg


TstBorderless.c :
Code: Select all
/*#################*/
/* TstBorderless.c */        /* 14.7.2013 */
/*#################*/
/*
   Showing extra active border space around a borderless ListBrowser.

   gcc -o TstBorderless TstBorderless.c -lauto
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>

#include <proto/dos.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/layout.h>
#include <proto/listbrowser.h>
#include <proto/utility.h>
#include <proto/window.h>

#include <classes/window.h>
#include <gadgets/listbrowser.h>
#include <intuition/intuition.h>
#include <libraries/keymap.h>
#include <utility/tagitem.h>

#define  PgmName "TstBorderless"
#define  PgmVersion  "$VER: TstBorderless 0.0 (14.7.2013) C\0"

#define NROWS 50
#define NCOLS 50
#define COLWIDTH 50

Object            *w,
                  *pg,
                  *listGad,
                  *butGad;
struct Window     *wp;
struct List        lblist;
struct ColumnInfo *ci;

typedef char string10[10];
string10          cellstr[NROWS][NCOLS];

/*----------------------------------------*/
 static void Assert(BOOL b, char msg[])
/*----------------------------------------*/
{

if (!b) {
   fprintf(stderr, "%s\n", msg);
   assert(0);
}

}

/*###########################################################################*/
/* --------------------- start of Tags Array Support  ---------------------- */
/*###########################################################################*/
struct TagsStruct {struct TagItem  *Tags;
                   int              numelems;
                   int              cntr;
                  };
int           tagcntr,
              tagsnumelems;

/*-------------------------------------------------------------*/
 static void InitTags(struct TagsStruct *TagsInfo, int numtags)
/*-------------------------------------------------------------*/
{

TagsInfo->Tags = (struct TagItem *) malloc(numtags * sizeof(struct TagItem));
Assert(TagsInfo->Tags != NULL, "Out of memory");

TagsInfo->numelems = numtags;
TagsInfo->cntr = 0;
TagsInfo->Tags[0].ti_Tag = TAG_DONE;

}

/*-----------------------------------------------------------------------------------------*/
 static void RegisterTags(struct TagsStruct *TagsInfo, struct TagItem *TagsArr, int numtags)
/*-----------------------------------------------------------------------------------------*/
{
printf("TagsArr %X\n", TagsArr);

TagsInfo->Tags = TagsArr;

TagsInfo->numelems = numtags;
TagsInfo->cntr = 0;
TagsInfo->Tags[0].ti_Tag = TAG_DONE;

}

/*--------------------------------------------------*/
 static void ResetTags(struct TagsStruct *TagsInfo)
/*-------------------------------------------------*/
{

TagsInfo->cntr = 0;
TagsInfo->Tags[0].ti_Tag = TAG_DONE;

}

/*-----------------------------------------------*/
 static void TermTags(struct TagsStruct *TagsInfo)
/*-----------------------------------------------*/
{

free(TagsInfo->Tags);
TagsInfo->Tags = NULL;

TagsInfo->numelems = 0;
TagsInfo->cntr = 0;

}

/*-------------------------------------------------------------------------*/
 static void AsgTag(struct TagsStruct *TagsInfo, uint tagcode, uint tagval)
/*-------------------------------------------------------------------------*/
{

TagsInfo->Tags[0].ti_Tag = tagcode;
TagsInfo->Tags[0].ti_Data = tagval;
TagsInfo->Tags[1].ti_Tag = TAG_DONE;
TagsInfo->cntr = 1;

}

/*-------------------------------------------------------------------------*/
 static void CatTag(struct TagsStruct *TagsInfo, uint tagcode, uint tagval)
/*-------------------------------------------------------------------------*/
{
char msg[80];

if (TagsInfo->cntr >= (TagsInfo->numelems-1)) {
   snprintf(msg, 80, "CatTag: Tags overflow, %u\n", TagsInfo->cntr);
   Assert(0, msg);
}

TagsInfo->Tags[TagsInfo->cntr].ti_Tag = tagcode;
TagsInfo->Tags[TagsInfo->cntr].ti_Data = tagval;

TagsInfo->cntr++;

TagsInfo->Tags[TagsInfo->cntr].ti_Tag = TAG_DONE;

}

/*---------------------------------------------------------------------------------------------------------*/
 static void CatTags2(struct TagsStruct *TagsInfo, uint tagcode1, uint tagval1, uint tagcode2, uint tagval2)
/*---------------------------------------------------------------------------------------------------------*/
{
CatTag(TagsInfo, tagcode1, tagval1);
CatTag(TagsInfo, tagcode2, tagval2);
}

/*-----------------------------------------------------------------------------------------------------*/
 static void CatTags3(struct TagsStruct *TagsInfo, uint tagcode1, uint tagval1, uint tagcode2, uint tagval2,
                                                   uint tagcode3, uint tagval3)
/*-----------------------------------------------------------------------------------------------------*/
{
CatTags2(TagsInfo, tagcode1, tagval1, tagcode2, tagval2);
CatTag(TagsInfo, tagcode3, tagval3);
}

/*-----------------------------------------------------------------------------------------------------*/
 static void CatTags4(struct TagsStruct *TagsInfo, uint tagcode1, uint tagval1, uint tagcode2, uint tagval2,
                                                   uint tagcode3, uint tagval3, uint tagcode4, uint tagval4)
/*-----------------------------------------------------------------------------------------------------*/
{
CatTags2(TagsInfo, tagcode1, tagval1, tagcode2, tagval2);
CatTags2(TagsInfo, tagcode3, tagval3, tagcode4, tagval4);
}
/*###########################################################################*/
/* --------------------- end of Tags Array Support -- ---------------------- */
/*###########################################################################*/


/*------------------------------------*/
 static Object* MakeRootContainer(void)
/*------------------------------------*/

{
Object   *ret;

ret = IIntuition->NewObject(NULL, "layout.gadget",
                            GA_Width,           100,
                            GA_Height,          100,
                            LAYOUT_Orientation, LAYOUT_ORIENT_HORIZ,
                            LAYOUT_SpaceOuter,  FALSE,
                            LAYOUT_SpaceInner,  FALSE,
                            LAYOUT_DeferLayout, FALSE,
                            LAYOUT_FillPen,     4,
                            TAG_DONE);
Assert(ret != NULL, "MakeRootContainer fail");

return ret;
}

/*-------------------------------------------*/
 static Object* MakeWindowObject(char *title)
/*-------------------------------------------*/
{

return IIntuition->NewObject(NULL, "window.class",
                             WA_Title,            title,
                             WA_CloseGadget,      1,
                             WA_DepthGadget,      1,
                             WA_SizeGadget,       1,
                             WA_DragBar,          1,
                             WA_Activate,         1,
                             WA_IDCMP,            IDCMP_MOUSEMOVE,
                             WA_InnerWidth,       320,
                             WA_InnerHeight,      240,
                             WINDOW_Position,     WPOS_CENTERSCREEN,
                             WINDOW_Layout,       pg,
                             TAG_DONE);
}

/*-----------------------------------*/
 static Object* MakeListObject(void)
/*-----------------------------------*/
{
int                r, c;
struct Node       *n;
Object            *ret;
struct TagsStruct  TagsInfo;
int                numtags = 6*NCOLS+10;

InitTags(&TagsInfo, numtags);

IExec->NewList(&lblist);

/* set up the ColumnInfo */
for (c = 0; c < NCOLS; c++) {       

   CatTags2(&TagsInfo, LBCIA_Column,             c,
                       LBCIA_Width,              COLWIDTH);
   CatTag(&TagsInfo,   LBCIA_DraggableSeparator, 1);
}
 
ci = IListBrowser->AllocLBColumnInfoA(NCOLS, TagsInfo.Tags);
Assert(ci != NULL, "AllocLBColumnInfoA FAIL");

/* set up the LISTBROWSER_Labels */
for (r = 0; r < NROWS; r++) {

   AsgTag(&TagsInfo, LBNA_Flags,      LBFLG_CUSTOMPENS);

   for (c = 0; c < NCOLS; c++) {

      CatTag(&TagsInfo, LBNA_Column,    c);
      CatTag(&TagsInfo, LBNCA_FGPen,    1);
      CatTag(&TagsInfo, LBNCA_BGPen,    2);

      snprintf((char *)&cellstr[r][c], 10, "%-u,%-u", r, c);     /* cell contents */

      CatTag(&TagsInfo, LBNCA_Text, (uint) &cellstr[r][c]);
 
   }

   n = IListBrowser->AllocListBrowserNodeA(NCOLS, TagsInfo.Tags);
   Assert(n != NULL, "AllocListBrowserNodeA FAIL in MakeListObject()")
   ;
   IExec->AddTail(&lblist, n);

}

ResetTags(&TagsInfo);

CatTags2(&TagsInfo,    GA_ID,                       1,
                       GA_RelVerify,                TRUE);
CatTags2(&TagsInfo,    GA_Immediate,                TRUE,
                       GA_FollowMouse,              TRUE);
CatTags2(&TagsInfo,    LISTBROWSER_Labels,          (uint) &lblist,
                       LISTBROWSER_ShowSelected,    TRUE);
CatTags2(&TagsInfo,    LISTBROWSER_VerticalProp,    0,
                       LISTBROWSER_HorizontalProp,  0);

CatTag(&TagsInfo,      LISTBROWSER_Borderless,      TRUE);

CatTag(&TagsInfo,      LISTBROWSER_ColumnInfo,      (uint) ci);

CatTags2(&TagsInfo,    LISTBROWSER_VertSeparators,  TRUE,
                       LISTBROWSER_HorizSeparators, TRUE);

CatTag(&TagsInfo,      LISTBROWSER_VirtualWidth,    NCOLS*COLWIDTH);      /* this works around the AutoVirtualWidth bug w/ fixed widths */

ret = IIntuition->NewObjectA(NULL, "listbrowser.gadget", TagsInfo.Tags);

Assert(ret != NULL, "MakeObject FAIL");

TermTags(&TagsInfo);

return ret;
}

/*---------------------------------------------------*/
 static void AddToContainer(Object *cont, Object *gad)
/*---------------------------------------------------*/
{
uint               uRes;

uRes = IIntuition->SetAttrs(cont, LAYOUT_AddChild, (uint) gad,
                                  CHILD_MinWidth,  100,
                                  CHILD_MinHeight, 100);

}

/*---------------------------*/
 static void OpenTheWndo(void)
/*---------------------------*/
{

pg = MakeRootContainer();

listGad = MakeListObject();
AddToContainer(pg, listGad);

w = MakeWindowObject(PgmVersion);
Assert(w != NULL, "MakeWindowObject FAIL");

wp = (struct Window *)IIntuition->IDoMethod(w, WM_OPEN);
Assert(wp != NULL, "WM_OPEN fail");

/*ILayout->RethinkLayout((struct Gadget *) pg, wp, NULL, TRUE);*/

}

/*------------------------------*/
 int main(int argc, char *argv[])
/*------------------------------*/
{
struct wmHandle  msg;
int16  code = 0;
int    i;
uint32 sigmask = 0;
uint32 siggot;
int    gadgleft,
       winborderleft;
uint32 result = 0;
BOOL done = FALSE;

w = NULL;

OpenTheWndo();

IIntuition->GetAttr(WINDOW_SigMask, w, &sigmask);
winborderleft = wp->BorderLeft;
IIntuition->GetAttr(GA_Left, listGad, (uint32 *) &gadgleft);

while (!done) {

   siggot = IExec->Wait(sigmask | SIGBREAKF_CTRL_C);
   done = (siggot & SIGBREAKF_CTRL_C);

   while ((result = IIntuition->IDoMethod(w, WM_HANDLEINPUT, &code))) {
      switch(result & WMHI_CLASSMASK) {
         case WMHI_CLOSEWINDOW:
            done = TRUE;
            break;
         case WMHI_MOUSEMOVE:
            printf("gx= %i\n", wp->MouseX-gadgleft);
            break;
      }
   }
}

IIntuition->DisposeObject(w);
IListBrowser->FreeListBrowserList(&lblist);
IListBrowser->FreeLBColumnInfo(ci);

}


Thanks,

Tom
User avatar
tbreeden
 
Posts: 160
Joined: Sat Jun 18, 2011 1:57 am
Location: Charlottesville, VA, USA


Return to SDK Support

Who is online

Users browsing this forum: No registered users and 1 guest