<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360783#M1221</link>
    <description>&lt;P&gt;Thanks for the suggestion. Unfortunately I've tried all combinations of DisableDraw, EnableDraw and Invalidate calls. It seems that it has something to do with the number of the tab fields. It's clearly visible in the video that the columns are aligned well for a couple of milliseconds, but then they jump to a wrong position.&lt;/P&gt;</description>
    <pubDate>Tue, 01 Nov 2022 18:15:58 GMT</pubDate>
    <dc:creator>kovacsv</dc:creator>
    <dc:date>2022-11-01T18:15:58Z</dc:date>
    <item>
      <title>DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360645#M1219</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm targeting AC26 and I'd like to make all columns of a DG::ListBox the same width in a way that they fill up the whole width of the ListBox. It works fine, but whenever I change the number of tab fields and recalculate the layout the changes are not visible on Mac. On Windows everything works like charm, but on Mac I need to do a resize for columns to get the final width.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FK1GdhQtw6x8%3Ffeature%3Doembed&amp;amp;display_name=YouTube&amp;amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DK1GdhQtw6x8&amp;amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FK1GdhQtw6x8%2Fhqdefault.jpg&amp;amp;type=text%2Fhtml&amp;amp;schema=youtube" width="200" height="113" scrolling="no" title="DG::ListBox tab field count error" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture;" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Probably I'm doing something wrong. Here is my example code that fills the ListBox with dummy elements, and changes the number of tab field by clicking on a button.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;GRC&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;'GDLG' ID_TEST_DIALOG Modal | grow   0   0  200  100  "Test Dialog" {
/* [  1] */ Button           10   10  140  23    LargePlain "Change Tab Field Count"
/* [  2] */ SingleSelList    10   43  180  47    LargePlain  PartialItems  18 HasHeader 18
}

'DLGH' ID_TEST_DIALOG Palette_Test_Dialog {
1    ""    TestButton
2    ""    TestList
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;C++&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;class TestDialog :
    public DG::ModalDialog,
    public DG::PanelObserver,
    public DG::ButtonItemObserver
{
public:
    TestDialog () :
        DG::ModalDialog (ACAPI_GetOwnResModule (), ID_TEST_DIALOG, ACAPI_GetOwnResModule ()),
        mButton (GetReference (), 1),
        mListBox (GetReference (), 2),
        mTabFieldCount (2)
    {
        Attach (*this);
        mButton.Attach (*this);

        mListBox.SetHeaderSynchronState (true);
        FillListBox ();
    }

private:
    virtual void PanelResized (const DG::PanelResizeEvent&amp;amp; ev) override
    {
        if (ev.GetSource () == this) {
            BeginMoveResizeItems ();
            mListBox.MoveAndResize (0, 0, ev.GetHorizontalChange (), ev.GetVerticalChange ());
            EndMoveResizeItems ();
            LayoutListBoxTabs ();
        }
    }

    virtual void ButtonClicked (const DG::ButtonClickEvent&amp;amp; ev) override
    {
        if (ev.GetSource () == &amp;amp;mButton) {
            mTabFieldCount = (mTabFieldCount == 2 ? 3 : 2);
            FillListBox ();
        }
    }

    void FillListBox ()
    {
        mListBox.DeleteItem (DG::ListBox::AllItems);
        mListBox.SetTabFieldCount (mTabFieldCount);

        for (short j = 1; j &amp;lt;= mTabFieldCount; j++) {
            mListBox.SetHeaderItemText (j, GS::UniString::Printf ("header %d", j));
        }

        for (short i = 1; i &amp;lt;= 10; i++) {
            mListBox.AppendItem ();
            for (short j = 1; j &amp;lt;= mTabFieldCount; j++) {
                mListBox.SetTabItemText (DG::ListBox::BottomItem, j, GS::UniString::Printf ("item %d %d", i, j));
            }
        }

        LayoutListBoxTabs ();
    }

    void LayoutListBoxTabs ()
    {
        short tabFieldWidth = mListBox.GetItemWidth () / mTabFieldCount;
        for (short i = 1; i &amp;lt;= mTabFieldCount; i++) {
            mListBox.SetTabFieldBeginEndPosition (i, (i - 1) * tabFieldWidth, i * tabFieldWidth);
        }
    }

    DG::Button mButton;
    DG::SingleSelListBox mListBox;
    short mTabFieldCount;
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Any idea how to resolve this?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 18:33:14 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360645#M1219</guid>
      <dc:creator>kovacsv</dc:creator>
      <dc:date>2022-10-31T18:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360752#M1220</link>
      <description>&lt;P&gt;I dont know a reason, but some ideas:&lt;BR /&gt;&lt;BR /&gt;1. In FillListBox try to move call of LayoutListBox before items filling. After SetTabItemCount.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;2. Call after items filling mListBox.Redraw() or mListBox.Invalidate()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PS:&lt;BR /&gt;I am usually do filling like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;void TabSelectorLink::UpdateTable()
{
	Filter* sel = GetSelectedFilter();
	if ( !sel )
		sel = m_data.link;

	mi_list.DisableDraw();
	mi_list.DeleteItem( DG::ListBox::AllItems );

	FillList( sel );

	mi_list.EnableDraw();
	mi_list.Invalidate();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 13:01:16 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360752#M1220</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2022-11-01T13:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360783#M1221</link>
      <description>&lt;P&gt;Thanks for the suggestion. Unfortunately I've tried all combinations of DisableDraw, EnableDraw and Invalidate calls. It seems that it has something to do with the number of the tab fields. It's clearly visible in the video that the columns are aligned well for a couple of milliseconds, but then they jump to a wrong position.&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 18:15:58 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360783#M1221</guid>
      <dc:creator>kovacsv</dc:creator>
      <dc:date>2022-11-01T18:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360855#M1222</link>
      <description>&lt;P&gt;Unfortunataly I have no a Mac to try. So may be there is some mac's specific.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you tried my first idea ?&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;In the function&amp;nbsp;&lt;SPAN&gt;FillListBox move call of LayoutListBox right after mListBox.SetTabItemCount(..) line.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;There is may be a column "jump" reason.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 09:56:53 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360855#M1222</guid>
      <dc:creator>Oleg</dc:creator>
      <dc:date>2022-11-02T09:56:53Z</dc:date>
    </item>
    <item>
      <title>Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360902#M1223</link>
      <description>&lt;P&gt;Hi!&lt;BR /&gt;&lt;BR /&gt;I tried your example on macOS and I was able to resolve the issue by setting the HeaderSynchronState to 'false' and then manually changing the header count and header item width. Here are the changed functions:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt; ...
   void FillListBox ()
    {
        mListBox.DeleteItem (DG::ListBox::AllItems);
        mListBox.SetTabFieldCount (mTabFieldCount);
        mListBox.SetHeaderItemCount (mTabFieldCount);

        for (short j = 1; j &amp;lt;= mTabFieldCount; j++) {
            mListBox.SetHeaderItemText (j, GS::UniString::Printf ("header %d", j));
        }

        for (short i = 1; i &amp;lt;= 10; i++) {
            mListBox.AppendItem ();
            for (short j = 1; j &amp;lt;= mTabFieldCount; j++) {
                mListBox.SetTabItemText (DG::ListBox::BottomItem, j, GS::UniString::Printf ("item %d %d", i, j));
            }
        }

        LayoutListBoxTabs ();
    }

    void LayoutListBoxTabs ()
    {
        short tabFieldWidth = mListBox.GetItemWidth () / mTabFieldCount;
        for (short i = 1; i &amp;lt;= mTabFieldCount; i++) {
						mListBox.SetHeaderItemSize (i, tabFieldWidth);
            mListBox.SetTabFieldBeginEndPosition (i, (i - 1) * tabFieldWidth, i * tabFieldWidth);
        }
    }
...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's still a weird "two step" of resizing happening, but now it stays as intended. Maybe the "two step" visual artifact can be resolved by filling order as you've discussed with Oleg.&lt;BR /&gt;&lt;BR /&gt;My suspicion is, that the header synchron state is behaving differently on Windows and macOS.&lt;BR /&gt;&lt;BR /&gt;Hope this helps,&lt;BR /&gt;Bernd&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 15:04:55 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360902#M1223</guid>
      <dc:creator>BerndSchwarzenbacher</dc:creator>
      <dc:date>2022-11-02T15:04:55Z</dc:date>
    </item>
    <item>
      <title>Re: DG::ListBox layouting doesn't work on Mac after changing the number of tab fields</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360905#M1224</link>
      <description>&lt;P&gt;Yes, this is what I found, too. Doing manually gives better result, but still with that annoying delay in layouting. Moving the layout function earlier doesn’t solve it. Maybe I’ll end up maintaining separate list boxes for different column counts.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 06:21:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/DG-ListBox-layouting-doesn-t-work-on-Mac-after-changing-the/m-p/360905#M1224</guid>
      <dc:creator>kovacsv</dc:creator>
      <dc:date>2022-11-03T06:21:34Z</dc:date>
    </item>
  </channel>
</rss>

