Setting the size of a scrollgroup

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

On 01/03/2005 at 06:42, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   8.x 
Platform:   Windows  ; Mac  ;  Mac OSX  ; 
Language(s) :   C.O.F.F.E.E  ;

---------
Is there any way to define the size of a scrollgroup? For example, I want the scrollgroup to have 200 pixels wide and be the height of the dialog window. Then, I want to populate it with several independent lines of text. Possible?

Rui Batista

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

On 01/03/2005 at 07:08, xxxxxxxx wrote:

Ok, what I want is simple. Check out this image (Photoshop mockup) :

I want to have a scroll area where I can place lines of text. I want to be able to click on each line and know what item I clicked. This should be easy enough. How can I do this in COFFEE? Thank you VERY, VERY MUCH in advance for any help.

Rui Batista

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

On 02/03/2005 at 14:00, xxxxxxxx wrote:

Come on guys. Don't tell me something as simple as this is not possible. I can't believe it isn't :-(

Rui Batista

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

On 02/03/2005 at 15:27, xxxxxxxx wrote:

Hi Rui,

Cinema 4D uses a Java-like GUI manager. That means, for the most part, you cannot control location and size of GUI elements. In some cases, you can set the size in a Resource file, but not always programmatically. You can only set the size of a ScrollGroup using a Resource. There is no size option for AddScrollGroupBegin().

*****************

You definitely need a GeUserArea. I think that this had been decided upon previously. The GeUserArea, which has no ability to use gadgets, requires that you program the desired behaviour and display management yourself. Not even sure if a ScrollGroup will be useable unless you draw in a bitmap displayed in the UserArea and set the scrollbars according to what portion of it is displayed/hidden.

You maintain an ordered list of items (e.g.: an array, linked-list). You pass the list to your UserArea during Draw()s (Draw() requests the list). Then you display the list using GeUserArea draw methods.

For selection and other actions, you will need to add an InputEvent() method to your GeUserArea and handle mouse and keyboard events in whatever way has the desired effect. For instance, item selection via mouse will require that you maintain an upper offset (pixels) of the list display and an item height (pixels) to make selection determinations.

Currently, I'm making a Material shader tree node system which requires that I 'emulate' something similar to (but far better than, one hopes) the XPresso XGroup editing window. This means a fully windowed GUI with multi-selection. I've nearly completed the GUI - working on 'connections' between nodes.

Let me see what I can quickly code - always hard to shift gears from C++ to COFFEE and back, though. ;)

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

On 02/03/2005 at 18:15, xxxxxxxx wrote:

Okay, here's a start. Not sure how to coordinate the scrollbars with the UserArea size and number of items - i.e.: can't get UserArea GetWidth() and GetHeight() to work.

  
////////////////////////////////////////////////////////////////  
// lvdialog.coh  
////////////////////////////////////////////////////////////////  
////////////////////////////////////////////////////////////////  
  
class MyListItem  
{  
     private:  
          var text;  
          var selected;  
     public:  
          MyListItem(txt);  
          GetText();  
          Select(tf);  
          IsSelected();  
}  
MyListItem::MyListItem(txt)  
{  
     text = txt;  
     selected = FALSE;  
}  
MyListItem::GetText()  
{  
     return text;  
}  
MyListItem::Select(tf)  
{  
     selected = tf;  
}  
MyListItem::IsSelected()  
{  
     return selected;  
}  
  
// MyUserArea ***************************************  
class MyUserArea : GeUserArea  
{  
     private:  
          var list;  
          var theDialog;  
          var width, height;  
          var cellHeight;  
          var frameHeight;  
          var offsetX, offsetY;  
     public:  
          MyUserArea(id,dlg);  
          Init();  
          Sized(w,h);  
          Draw(x1, y1, x2, y2);  
          InputEvent(msg);  
          GetOffsetX();  
          GetOffsetY();  
          GetVisibleX();  
          GetVisibleY();  
          SetList(list);  
}  
// Constructor  
MyUserArea::MyUserArea(id,dlg)  
{  
     super(id,dlg);  
     theDialog = dlg;  
}  
// GeUserArea.Init  
MyUserArea::Init()  
{  
     var fh = DrawGetFontHeight();  
     cellHeight = fh + (fh/2);  
     frameHeight = fh/4;  
     offsetX = offsetY = 0;  
     return TRUE;  
}  
// GeUserArea.Sized  
MyUserArea::Sized(w, h)  
{  
     width = w;  
     height = h;  
     return TRUE;  
}  
// GeUserArea.Draw  
MyUserArea::Draw(x1, y1, x2, y2)  
{  
     // No flicker  
     OffScreenOn();  
     SetClippingRegion(x1,y1,x2,y2);  
     // Clear area  
     DrawSetPen(vector(0.5));  
     DrawRectangle(x1,y1,x2,y2);  
     // Draw all List Items  
     var n;  
     for (n = 0; n < 10; n++)  
     {  
          if (list[n]->IsSelected())  
               DrawSetTextPen(vector(1.0), vector(0.5));  
          else  
               DrawSetTextPen(vector(0.0), vector(0.5));  
          DrawText(list[n]->GetText(), 8, (i*cellHeight)+frameHeight);  
     }  
     return TRUE;  
}  
// GeUserArea.InputEvent  
MyUserArea::InputEvent(msg)  
{  
     var dev = msg->GetData(BFM_INPUT_DEVICE);  
     if (dev == BFM_INPUT_MOUSE)  
     {  
          var chn = msg->GetData(BFM_INPUT_CHANNEL);  
          var qua = msg->GetData(BFM_INPUT_QUALIFIER);  
       
          var action = new(BaseContainer, BFM_ACTION);  
          action->SetData(BFM_ACTION_ID,GetId());  
          action->SetData(BFM_ACTION_VALUE,0);  
          var mx, my;  
       
          // Left Button  
          if (chn == BFM_INPUT_MOUSELEFT)  
          {  
               var n, j;  
               var pY;  
               var dc = msg->GetData(BFM_INPUT_DOUBLECLICK);  
               my = msg->GetData(BFM_INPUT_Y);  
               my = Global2LocalY(my);  
       
               // Is mouse over ListItem  
               for (n = 0; n < 10; n++)  
               {                 
                    pY = (n*cellHeight)+offsetY;  
                    if ((my >= pY) && (my < (pY+cellHeight))) break;  
               }  
               // Do Something with ListItem  
               if (n < 10)  
               {  
                    // Add to selection  
                    if (qua == QSHIFT) list[n]->Select(TRUE);  
                    // Remove from selection  
                    else if (qua == QCTRL) list[n]->Select(FALSE);  
                    // Remove all current selections, select this one  
                    else  
                    {  
                         for (j = 0; j < 10; j++)  
                             list[j]->Select(FALSE);  
                         Redraw();  
                         list[n]->Select(TRUE);  
                    }  
               }  
               // Remove all current selections  
               else  
               {  
                    for (j = 0; j < 10; j++)  
                         list[j]->Select(FALSE);  
               }  
               Redraw();  
       
               SendParentMessage(action);  
          }  
          return TRUE;  
     }  
     return FALSE;  
}  
MyUserArea::GetOffsetX()  
{  
     return offsetX;  
}  
MyUserArea::GetOffsetY()  
{  
     return offsetY;  
}  
MyUserArea::GetVisibleX()  
{  
     width;  
}  
MyUserArea::GetVisibleY()  
{  
     var visible = (10 * cellHeight) - height;  
     if (visible <= 0) return 0;  
     return visible;  
}  
MyUserArea::SetList(ls)  
{  
     list = ls;  
}  
  
// LVDialog ***************************************  
enum  
{  
     GROUP_MAIN = 4000,  
     GROUP_SCROLL,  
     ID_LVUSERAREA  
}  
  
// CLASS: List View Dialog  
class LVDialog : GeDialog  
{  
     private:  
          var a;  
          var userarea;  
     public:  
          LVDialog();  
          CreateLayout();  
          Init();  
          Message(msg);  
          Command(id, msg);  
          GetList();  
}  
// Constructor  
LVDialog::LVDialog()  
{  
     super(PLUGIN_MENU_ID);  
     a = new(array,10);  
     a[0] = new(MyListItem,"Item 1");  
     a[1] = new(MyListItem,"Item 2");  
     a[2] = new(MyListItem,"Item 3");  
     a[3] = new(MyListItem,"Item 4");  
     a[4] = new(MyListItem,"Item 5");  
     a[5] = new(MyListItem,"Item 6");  
     a[6] = new(MyListItem,"Item 7");  
     a[7] = new(MyListItem,"Item 8");  
     a[8] = new(MyListItem,"Item 9");  
     a[9] = new(MyListItem,"Long, Long, Long Item 10");  
}  
// Layout Dialog GUI  
LVDialog::CreateLayout()  
{  
     SetTitle(resource->GetString(PLUGIN_MENU_TEXT)+" v"+resource->GetString(PLUGIN_MENU_VERSION));  
     AddGroupBeginV(GROUP_MAIN,BFH_SCALEFIT|BFV_SCALEFIT,1,"",0);  
     {  
          AddGroupBorderSpace(4,4,4,4);  
          AddGroupSpace(4,4);  
          AddScrollGroupBegin(GROUP_SCROLL, BFH_SCALEFIT|BFV_SCALEFIT, SCROLLGROUP_VERT|SCROLLGROUP_HORIZ);  
          {  
               AddGroupBeginV(0,BFH_SCALEFIT|BFV_SCALEFIT,1,"",0);  
               {  
                    AddGroupBorder(BORDER_IN);  
                    AddUserArea(ID_LVUSERAREA, BFH_SCALEFIT|BFV_SCALEFIT, 0, 0);  
                    userarea = new(MyUserArea,ID_LVUSERAREA,this);  
               }  
               AddGroupEnd();  
          }  
          AddScrollGroupEnd();  
     }  
     AddGroupEnd();  
     return TRUE;  
}  
LVDialog::Init()  
{  
     userarea->SetList(a);  
}  
LVDialog::Message(msg)  
{  
     return super::Message(msg);  
}  
LVDialog::Command(id, msg)  
{  
}  

Again, it's a static list, but it should be straight forward to make it variable. You can also change the text background during selection if you like.

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

On 03/03/2005 at 03:32, xxxxxxxx wrote:

Wow Robert!!! Thank you very much. I will give it a go. I'll let you know how it came out.

Rui Batista