6 Replies Latest reply: Sep 28, 2011 12:44 AM by starnight1981 RSS

    How to create a panel  same as this...

    starnight1981 Community Member

      QQ截图20110926152153.png

       

      The left is a column checkboxs,right is a list box;

       

      I want to create a   kADMMultiColumnListViewType  item,  but failed

       

      Who can give me some tips, how to create such a panel


        • 1. Re: How to create a panel  same as this...
          Harbs. CommunityMVP

          CAN YOU PLEASE NOT SHOUT?

          • 2. Re: How to create a panel  same as this...
            A. Patterson Community Member

            I believe the Action & Layers panels use a highly customized ADMHierarchyList control. To get the effect of the two columns on the far left, you have to draw the entire contents of each entry yourself. That would mean handling the clicks (so you'd have to know where the clickable boxes are in each entry), etc.


            Personally, I just put any clickable spots on the far right -- much, easier. It let me use a lot of the default drawing behaviour and simplified the math.

            • 3. Re: How to create a panel  same as this...
              Meate Community Member

              Mr. Patterson is correct, you'll have to draw it all manually.  We have a similar control, and it took a bit of work to get it to draw and respond to interactions correctly.

               

              Basically, you create a Draw proc for the hierarchy list (see ADMHierarchyList->SetDrawProc).  This function is called for each item in the list that needs to be drawn.  You get the bounds of the item and you draw whatever you want.  For example:

               

              void ADMAPI MyDialog::DrawItemProc(ADMListEntryRef entry, ADMDrawerRef drawer)

              {

                ADMHierarchyListRef hierarchyList = sADMListEntry4->GetList(entry);

               

                // get the bounds of the item to be drawn and color the rectangle white

                ADMRect entryBounds;

                sADMHierarchyList5->GetEntryTextRect(hierarchyList, &entryBounds);

                sADMDrawer->SetADMColor(drawer, kADMWhiteColor);

                sADMDrawer->FillRect(drawer, &entryBounds);

               

                // define the area where a first check box will go

                ADMRect visibleButton;

                visibleButton.top = (entryBounds.bottom - entryBounds.top - 13) / 2;

                visibleButton.bottom = visibleButton.top + 13;

                visibleButton.left = entryBounds.left + 2;

                visibleButton.right = visibleButton.left + 13;

               

                // draw the check box

                sADMDrawer->DrawSunkenRect(drawer, &visibleButton);

               

                // etc

              }

               

              To respond to a user clicking in the item, you create a Track proc (see ADMHierarchyList->SetTrackProc).  In the Track proc you get the bounds of the item and where the mouse is and you can figure out what the user clicked on.  For example:

               

              ADMBoolean ADMAPI MyDialog::TrackProc(ADMListEntryRef entry, ADMTrackerRef tracker)

              {

                ADMHierarchyListRef hierarchyList = sADMListEntry4->GetList(entry);

                ADMItemRef entryItem = sADMListEntry4->GetItem(entry);

                ADMItemRef hierarchyItem = sADMHierarchyList5->GetItem(hierarchyList);

               

                ADMModifiers modifiers = sADMTracker2->GetModifiers(tracker);

                ADMAction action = sADMTracker2->GetAction(tracker);

               

                ADMPoint point;

                sADMTracker2->GetPoint(tracker, &point);

               

                ADMRect entryBounds;

                sADMHierarchyList5->GetEntryTextRect(hierarchyList, &entryBounds);

               

                // define the area where the check box is

                ADMRect visibleButton;

                visibleButton.top = (entryBounds.bottom - entryBounds.top - 13) / 2;

                visibleButton.bottom = visibleButton.top + 13;

                visibleButton.left = entryBounds.left + 2;

                visibleButton.right = visibleButton.left + 13;

               

                // check if the mouse is over the check box and was clicked

                if (point.h >= visibleButton.left && point.h <= visibleButton.right && point.v >= visibleButton.top && point.v <= visibleButton.bottom) {

                  if (action == kADMButtonUpAction) {

                    // do something

                  }

                }

              }

              • 4. Re: How to create a panel  same as this...
                starnight1981 Community Member

                Re: CAN YOU PLEASE NOT SHOUT?

                 

                WHY?

                • 5. Re: How to create a panel  same as this...
                  Harbs. CommunityMVP

                  Because it makes it very hard to read your posts. Common courtesy...

                   

                  Harbs

                  • 6. Re: How to create a panel  same as this...
                    starnight1981 Community Member

                    Re:Because it makes it very hard to read your posts. Common courtesy...

                     

                    Harbs

                     

                     

                    Oh,my english is poor,so I pasted a picture.