TreeViewFunctions Resize and Move Columns



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 18/02/2009 at 08:40, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   11 
    Platform:   Windows  ; Mac  ;  Mac OSX  ; 
    Language(s) :     C++  ;

    ---------
    Sorry but I can't figure out how to do resizing and moving columns in a TreeView created by code?
    Any idea anyone?

    > virtual Bool UserCanResizeCol(void* root, void* userdata, LONG lColID);
    > virtual Bool UserCanMoveCol(void* root, void* userdata, LONG lColID);
    > virtual Bool ColumnMoved(void* root, void* userdata, LONG lColID, LONG lInsertBeforeCol, LONG* plIndexMap);

    don't seem to do a lot even if I return TRUE in the first two...

    Best regards and thanks in advance
    Macm



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/02/2009 at 09:24, xxxxxxxx wrote:

    I get the feeling I have to do it all by myself (with Timer(), a polling loop, SetMousePointer(), storing the column weights and all that stuff?).

    Am I right? (Please tell me I am not :)

    Best
    Macm



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/02/2009 at 03:47, xxxxxxxx wrote:

    You probably have just forgotten to set the TREEVIEW_MOVE_COLUMN and TREEVIEW_RESIZE_HEADER container elements to TRUE.

    Here is a simple working example (just diplays the current object hierarchy)

    > \> #define ID_ACTIVEOBJECT 1000472 \> \> #include "c4d.h" \> #include "c4d_symbols.h" \> #include "c4d_colors.h" \> \> \> struct DebugNode \> { \> }; \> \> \> class Function2 : public TreeViewFunctions \> { \>      public: \>           virtual void\* GetFirst(void \*root,void \*userdata) \>           { \>                return GetActiveDocument()->GetFirstObject(); \>           } \> \>           virtual void\* GetNext(void \*root,void \*userdata,void \*obj) \>           { \>                return ((BaseObject\* )obj)->GetNext(); \>           } \> \>           virtual void\* GetPred(void \*root,void \*userdata,void \*obj) \>           { \>                return ((BaseObject\* )obj)->GetPred(); \>           } \> \>           virtual void\* GetDown(void \*root,void \*userdata,void \*obj) \>           { \>                return ((BaseObject\* )obj)->GetDown(); \>           } \> \>           virtual Bool IsSelected(void\* root, void\* userdata, void\* obj) \>           { \>                return FALSE; \>           } \> \>           virtual void Select(void\* root, void\* userdata, void\* obj, LONG mode) \>           { \>           } \> \>           virtual Bool IsOpened(void\* root, void\* userdata, void\* obj) \>           { \>                return TRUE; \>           } \> \>           virtual void Open(void\* root, void\* userdata, void\* obj, Bool onoff) \>           { \>           } \>            \>           virtual String GetName(void\* root, void\* userdata, void\* obj) \>           { \>                return ((BaseObject\* )obj)->GetName(); \>           } \> \>           virtual VLONG GetId(void\* root, void\* userdata, void\* obj) \>           { \>                return ((BaseObject\* )obj)->GetType(); \>           } \> \>           virtual LONG GetDragType(void\* root, void\* userdata, void\* obj) \>           { \>                return NOTOK; \>           } \> \>           virtual LONG GetHeaderColumnWidth(void \*root,void \*userdata,LONG col,GeUserArea \*ua) \>           { \>                if (!ua) return 0; \>                return ua->DrawGetTextWidth("8888")+4; \>           } \> \>           virtual LONG GetColumnWidth(void \*root,void \*userdata,void \*obj,LONG col, GeUserArea\* pArea) \>           { \>                return pArea->DrawGetTextWidth("0123456789"); \>           } \> \>           virtual Bool DrawHeaderCell(void \*root, void \*userdata, LONG col, DrawInfo \*drawinfo) \>           { \>                String name; \>                drawinfo->frame->DrawSetPen(COLOR_BG); \>                drawinfo->frame->DrawRectangle(drawinfo->xpos, drawinfo->ypos, drawinfo->xpos + drawinfo->width-1, drawinfo->ypos + drawinfo->height-1); \>                drawinfo->frame->DrawSetFont(FONT_STANDARD); \> \>                switch (col) \>                { \>                     case 'tree':     name = "Hierarchy"; break; \>                     case 'drt0':     name = "Column1"; break; \>                     case 'drt1':     name = "Column2"; break; \>                     case 'drt2':     name = "Column3"; break; \>                } \> \>                drawinfo->frame->DrawSetTextCol(COLOR_TEXT,COLOR_BG); \>                drawinfo->frame->DrawText(name,drawinfo->xpos+4,drawinfo->ypos); \> \>                drawinfo->frame->DrawSetPen(COLOR_EDGEWH); \>                drawinfo->frame->DrawLine(drawinfo->xpos, drawinfo->ypos, drawinfo->xpos + drawinfo->width-1, drawinfo->ypos ); \>                drawinfo->frame->DrawLine(drawinfo->xpos, drawinfo->ypos, drawinfo->xpos, drawinfo->ypos + drawinfo->height-1); \> \>                drawinfo->frame->DrawSetPen(COLOR_EDGEDK); \>                drawinfo->frame->DrawLine(drawinfo->xpos + drawinfo->width-1, drawinfo->ypos, drawinfo->xpos + drawinfo->width-1, drawinfo->ypos + drawinfo->height-1); \>                drawinfo->frame->DrawLine(drawinfo->xpos, drawinfo->ypos + drawinfo->height-1, drawinfo->xpos + drawinfo->width-1, drawinfo->ypos + drawinfo->height-1); \> \>                return TRUE; \>           } \> \> \>           virtual Bool UserCanResizeCol(void \*root, void \*userdata, LONG lColID) \>           { \>                return TRUE; \>           } \> \>           virtual Bool UserCanMoveCol(void \*root, void \*userdata, LONG lColID) \>           { \>                return TRUE; \>           } \> \>           virtual Bool ColumnMoved(void \*root, void \*userdata, LONG lColID, LONG lInsertBeforeCol, LONG\* plIndexMap, const BaseContainer\* pbcLayout) \>           { \>                return TRUE; \>           } \> \> \> \> } functable; \> \> \> class ActiveObjectDialog : public GeDialog \> { \>      private: \>           TreeViewCustomGui \*tree; \>           DebugNode root_of_docs; \> \> \>      public: \>           ActiveObjectDialog(); \> \>           virtual Bool CreateLayout(void); \>           virtual Bool InitValues(void); \>           virtual void DestroyWindow(); \>           virtual Bool Command(LONG id,const BaseContainer &msg;); \>           virtual Bool CoreMessage(LONG id,const BaseContainer &msg;); \> }; \> \> ActiveObjectDialog::ActiveObjectDialog() \> { \>      tree = NULL; \> } \> \> void ActiveObjectDialog::DestroyWindow() \> { \>      tree = NULL; \> } \> \> Bool ActiveObjectDialog::CreateLayout(void) \> { \>      // first call the parent instance \>      Bool res = GeDialog::CreateLayout(); \> \>      SetTitle("C++SDK Demo - Active Object Properties"); \> \>      GroupBegin(0,BFH_SCALEFIT|BFV_SCALEFIT,0,0,String(),0); \>           BaseContainer treedata; \>           treedata.SetBool(TREEVIEW_BORDER, TRUE); \>           treedata.SetBool(TREEVIEW_HAS_HEADER, TRUE); \>           treedata.SetBool(TREEVIEW_FIXED_LAYOUT, TRUE); \>           treedata.SetBool(TREEVIEW_MOVE_COLUMN, TRUE); \>           treedata.SetBool(TREEVIEW_RESIZE_HEADER, TRUE); \>           tree = (TreeViewCustomGui\* )AddCustomGui(10001,CUSTOMGUI_TREEVIEW,String(),BFH_SCALEFIT|BFV_SCALEFIT,0,0,treedata); \>      GroupEnd(); \> \>      if (tree) \>      { \>           BaseContainer layout; \>           layout.SetLong('tree',LV_TREE); \>           layout.SetLong('drt0',LV_USER); \>           layout.SetLong('drt1',LV_USER); \>           layout.SetLong('drt2',LV_USER); \>           tree->SetLayout(4,layout); \>      } \> \>      return res; \> } \> \> Bool ActiveObjectDialog::InitValues(void) \> { \>      // first call the parent instance \>      if (!GeDialog::InitValues()) return FALSE; \> \>      if (tree) \>      { \>           tree->SetRoot(&root;\_of_docs,&functable;,NULL); \>           tree->Refresh(); \>      } \> \>      return TRUE; \> } \> \> Bool ActiveObjectDialog::Command(LONG id,const BaseContainer &msg;) \> { \> //     switch (id) \>      { \>      } \>      return GeDialog::Command(id,msg); \> } \> \> \> \> Bool ActiveObjectDialog::CoreMessage(LONG id,const BaseContainer &msg;) \> { \> //     switch (id) \>      { \>      } \>      return GeDialog::CoreMessage(id,msg); \> } \> \> \> \> class ActiveObjectDialogCommand : public CommandData \> { \>      public: \>           ActiveObjectDialog dlg; \> \>           virtual Bool Execute(BaseDocument \*doc) \>           { \>                return dlg.Open(TRUE,ID_ACTIVEOBJECT,-1,-1,500,300); \>           } \> \>           virtual LONG GetState(BaseDocument \*doc) \>           { \>                return CMD_ENABLED; \>           } \> \>           virtual Bool RestoreLayout(void \*secret) \>           { \>                return dlg.RestoreLayout(ID_ACTIVEOBJECT,0,secret); \>           } \> }; \> \> \> Bool RegisterActiveObjectDlg(void) \> { \>      // decide by name if the plugin shall be registered - just for user convenience \>      String name=GeLoadString(IDS_ACTIVEOBJECT); if (!name.Content()) return TRUE; \>      return RegisterCommandPlugin(ID_ACTIVEOBJECT,name,0,NULL,String("C++ SDK Active Object"),gNew ActiveObjectDialogCommand); \> } \>

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 25/02/2009 at 03:54, xxxxxxxx wrote:

    Oh thanks Matthias,

    you made my day :)

    Best
    Macm


Log in to reply