Quantcast
Channel: ArchiCAD-Talk - Developer Forum
Viewing all articles
Browse latest Browse all 564

How to create checkbox column in listview

$
0
0
Author:IanTr
Posted: Thu Nov 23, 2017 5:16 am (GMT+1)


I have 2 questions:

(1) I am trying to put a column of checkboxes into my listboxes...
Currently doing something like:

DGListSetDialItemOnTabField ( IDD_BACKSYNC, GetListIDFromDialog( pEntry->GetEntryType() ), 2, DG_LIST_UNCHECKEDICON );

IDD_BACKSYNC is the id of the dialog.
GetListIDFromDialog( pEntry->GetEntryType() ) returns an enum of the listbox that is the same value as in .grc file.

2 is the 2nd column.

but not seeing any checkbox.

Seems like I'm doing this incorrectly.

(2)

// THIS LINE WILL CREATE A BLACK, when it should be red.
DGListSetTabItemBackgroundColor ( IDD_BACKSYNC, GetListIDFromDialog( pEntry->GetEntryType() ), DG::ListBox::BottomItem, 1, 255, 0, 0 );


=============================================
Code:


'GDLG'  32505  Modal            337  259 800   600  "Sync From Fuzor To ArchiCAD" {
/* [  1] */ Button                36  543   100   30   LargePlain  "Select All"
/* [  2] */ Button               200  543   100   30   LargePlain  "Select None"
/* [  3] */ Button               350  543   100   30   LargePlain  "Sync Selected"
/* [  4] */ Button               515  543   100   30   LargePlain  "Exit"
/* [  5] */ SingleSelList          10  20    760   100   LargePlain  PartialItems VScroll 18 HasHeader 18
/* [  6] */ SingleSelList          10  120   760   100   LargePlain  PartialItems VScroll 18 HasHeader 18
/* [  7] */ SingleSelList          10  220   760   100   LargePlain  PartialItems VScroll 18 HasHeader 18
/* [  8] */ SingleSelList          10  320   760   100   LargePlain  PartialItems VScroll 18 HasHeader 18
/* [  9] */ SingleSelList          10  420   760   100   LargePlain  PartialItems VScroll 18 HasHeader 18
}


class BackSyncDialog : public DG::ModalDialog,
                     public DG::ButtonItemObserver
   {
   public:
      BackSyncDialog ( std::vector<BackSyncBaseTask*> &syncEntries );
      ~BackSyncDialog ();

   // Results after running modal dlg
   public:
      void FillData(std::vector<BackSyncBaseTask*> &syncEntries );
   protected:
      DG::Dialog& GetReference ()
      {
         return *this;
      }

      std::wstring GetHeader ( BackSyncTaskType );
      short GetListIDFromDialog ( BackSyncTaskType );

      DG::SingleSelListBox & GetParentListByEntryType ( BackSyncTaskType a_eEntry );
   private:
      enum {
         BtnSelectAllId = 1,
         BtnSelectNoneId = 2,
         BtnSyncSelectedId = 3,
         BtnExitId = 4,
         LstViewFamilyPlacementId = 5,
         LstViewObjectRefitId = 6,
         LstViewDeletionId = 7,
         LstViewMaterialSwitchId = 8,
         LstViewMaterialPropertyId = 9
      };

      DG::SingleSelListBox   FamilyPlacementList;
      DG::SingleSelListBox   ObjectRefitList;
      DG::SingleSelListBox   DeletionList;
      DG::SingleSelListBox   MaterialSwitchList;
      DG::SingleSelListBox   MaterialPropertyList;;

   };
   
   void BackSyncDialog::FillData(std::vector<BackSyncBaseTask*> &syncEntries )
   {
      static const int c_dwNumFields = 4;
      static const int c_COLOR_STATUS = 30;
      static const int c_CHECK_FIELD_WIDTH = 30;
      static const int c_NAME_WIDTH = 200;
      static const int c_DESCRIPTION = 300;
      for ( short i = 0; i < BackSync_Max; i++ )
      {
         DG::SingleSelListBox & group = GetParentListByEntryType ( (BackSyncTaskType)i );
         group.SetTabFieldCount(c_dwNumFields);
         group.SetHeaderSynchronState ( false );

         short pos = 0;
         group.SetTabFieldProperties(1, pos, pos + c_COLOR_STATUS, DG::ListBox::Left, DG::ListBox::EndTruncate, true, true);
         pos += c_COLOR_STATUS;
         group.SetTabFieldProperties(2, pos, pos + c_CHECK_FIELD_WIDTH, DG::ListBox::Left, DG::ListBox::EndTruncate, true, true);
         pos += c_CHECK_FIELD_WIDTH;
         group.SetTabFieldProperties(3, pos, pos + c_NAME_WIDTH, DG::ListBox::Left, DG::ListBox::EndTruncate, true, true);
         pos += c_NAME_WIDTH;
         group.SetTabFieldProperties(4, pos, pos + c_DESCRIPTION, DG::ListBox::Left, DG::ListBox::EndTruncate, true, true);
         pos += c_DESCRIPTION;
         
         GS::UniString header( GetHeader((BackSyncTaskType)i).c_str());
         DBPrintf ( "Setting header for: %ls\n", header.ToUStr().Get());
         group.SetHeaderItemText ( 1, header );
      }
      
      for ( int i = 0; i < syncEntries.size(); i++)
      {
         BackSyncBaseTask *pEntry = syncEntries.at(i);

         DG::SingleSelListBox & group = GetParentListByEntryType( pEntry->GetEntryType() );
         group.AppendItem();
         GS::UniString name( pEntry->GetEntryName().c_str() );
         GS::UniString description ( pEntry->GetEntryDescription().c_str());
         
         group.SetItemValue(DG::ListBox::BottomItem, reinterpret_cast<DGUserData>(pEntry));
         // GetLIstIDFromDialog will return LstViewFamilyPlacementId ... LstViewMaterialPropertyId
         // THIS LINE WILL CREATE A BLACK, when it should be red.
         DGListSetTabItemBackgroundColor ( IDD_BACKSYNC, GetListIDFromDialog( pEntry->GetEntryType() ), DG::ListBox::BottomItem, 1, 255, 0, 0 );
         
         
         // THE BELOW LINE DOESN'T SHOW A CHECKBOX WITH UNCHECKED ICON.
         DGListSetDialItemOnTabField ( IDD_BACKSYNC, GetListIDFromDialog( pEntry->GetEntryType() ), 2, DG_LIST_UNCHECKEDICON );
   
         group.SetTabItemText(DG::ListBox::BottomItem, 3, name );
         group.SetTabItemText(DG::ListBox::BottomItem, 4, description );
         DBPrintf ( "%d: name:%ls desc:%ls\n", i, name.ToUStr().Get(), description.ToUStr().Get());      
      }
      ....

   }

}


Viewing all articles
Browse latest Browse all 564

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>