Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I would like to change the Cell GroupOpener appearance.

Cell GroupOpener

In the present Mathematica design it is too small and can be missed by a reader unfamiliar with Mma. I know, how to change its color through the OptionInspector.

Now, how can I put there something instead of the check-mark that is there at present? For example, a gray triangle that has been there previously, of something more complex, some graphics of my own design

Edit: To answer the question of Silva below: This is how the Cell GroupOpener looks like at my machine operating on Windows XP, Mma 9.0.1.

enter image description here

Now on my other machine with Windows 7 and same Mma version the GroupOpener looks like a tiny check-mark. It is hardly visible and it is more difficult to operate (i.e. to open and close). For example, visually it is difficult to distinguish the closed from the open one. I am sorry, being presently at the machine with the XP I cannot provide an image for the GroupOpener at Win7.

Now, it is not too bad, as long as it concerns myself, this or that GroupOpener presentation is it. However, I am creating documents to give away, and need that inexperienced people would easily identify the GroupOpener and easily operate with it. So I would like to be able to control its appearance.

share|improve this question
    
I am not sure I understand what you are asking, but you should look at Opener > Options > Appearance in the Documentation Center where this is discussed. –  m_goldberg Apr 14 at 15:40
    
Is this question about changing a notebook's style or is it about controlling the appearance of an Opener control in code? –  m_goldberg Apr 14 at 15:43
    
@m_goldberg I guess OP is asking about the Cell GroupOpeners. –  Silvia Apr 14 at 15:50
1  
@Alexei I think a screenshot would help to clarify your question. And I think the GroupOpener is disabled by default, so it might be helpful to explain what is this GroupOpener and how to enable them. Also, I can see the Cell GroupOpeners are "check-mark" under Windows, but are they the same under Mac / Linux? In other words, it might be helpful to clarify if your question is OS related. –  Silvia Apr 14 at 16:02
1  
I guess it's doable by using Dynamic in CellDingbat or similar options. –  Silvia Apr 15 at 11:34

2 Answers 2

up vote 7 down vote accepted

According to the documentation, CellGroupData supports Dynamic-object as its status. So with the help of CellGrouping -> Manual, we can design our own "CellGroup opener". It can be a Button or EventHandler placed in CellDingbat, CellFrameLabels, etc. Here is a simple demostration (tested in Mathematica 9.0.1 and 10.0 pre-release on Windows 8.1):

animation demo for self-made CellGroup opener

openerIconOpen = 
  GraphicsBox[{RGBColor[0.26, 0.59, 0.26], 
    PolygonBox[{{0, -0.25`}, {-0.3`, 0.25`}, {0.3`, 0.25`}, {0, -0.25`}}]}, 
  ImageSize -> 15, PlotRange -> All];

openerIconClosed = 
  GraphicsBox[{RGBColor[0.8, 0.16, 0.17], 
    PolygonBox[{{0.5, 0}, {0, -0.3}, {0, 0.3}, {0.5, 0}}]}, 
   ImageSize -> 15, PlotRange -> All];

cellopenflag$1 = True;
    cellopenflag$2 = False;

Clear[openerBoxFunc]
openerBoxFunc[flag_] := TagBox[
                               DynamicBox[If[flag, $CellContext`openerIconOpen, $CellContext`openerIconClosed]],
                               EventHandlerTag[{"MouseClicked" :> (flag = ! flag)}]
                              ]

cellBodys = {
             "This is a Text Cell.",
             BoxData[RowBox[{"Another Text Cell with GridBox: ", GridBox[{{"a", "b", "c"}}, GridBoxDividers -> {"Rows" -> {{True}}, "Columns" -> {{True}}}]}]],
             BoxData[RowBox[{"1", "-", "2"}]],
             BoxData[RowBox[{"-", "1"}]],
             BoxData[DynamicBox[GridBox[{{"cellopenflag$1", "cellopenflag$2"}, {cellopenflag$1, cellopenflag$2}}, GridBoxDividers -> {"Rows" -> {{True}}, "Columns" -> {{True}}}]]]
            };

Notebook[{
   (* Start of group 1: *)
   Cell[CellGroupData[{
      (* Cell 1: *)
      Cell[cellBodys[[1]], "Text",
           CellDingbat -> openerBoxFunc[$CellContext`cellopenflag$1]
          ],
      (* Cell 2: *)
      Cell[cellBodys[[2]], "Text"],
      (* Start of group 2: *)
      Cell[CellGroupData[{
         (* Cell 3: *)
         Cell[cellBodys[[3]], "Input",
              CellDingbat -> openerBoxFunc[$CellContext`cellopenflag$2]
             ],
         (* Cell 4: *)
         Cell[cellBodys[[4]], "Output"]
         },
         Dynamic[$CellContext`cellopenflag$2]
        ]](* <- End of group 2. *)
      },
      Dynamic[$CellContext`cellopenflag$1]
     ]](* <- End of group 1. *),
   (* Cell 5: *)
   Cell[cellBodys[[5]], "Text"]
   }(* <- End of Notebook body. *),
  CellGrouping -> Manual,
  ShowGroupOpener -> False
  ] // NotebookPut
share|improve this answer
    
This is a neat implementation. Is it possible to design a template with this type of functionality? In my initial attempts, editing a stylesheet complains when trying to add the option CellDingbat -> openerBoxFunc[...] –  bobthechemist Jun 19 at 16:58
    
@bobthechemist Thanks! Maybe we can define the openerBoxFunc in the stylesheet. –  Silvia Jun 19 at 17:02
    
@bobthechemist After another thought, I think it might be better to post process a completed Notebook than to integrate the function in stylesheet... –  Silvia Jun 19 at 17:27
    
@Silvia Great. Is it possible to make analogous thing by hand, rather thjan programmatically. For example, would it be possible to open the background cell code (Sift+Ctrl+E) and edit it such that this functionality would be included? –  Alexei Boulbitch Jun 20 at 7:29
    
@AlexeiBoulbitch Thanks for accepting! Unfortunately I don't think it's possible to access CellGroupData[...] by the Shift+Ctrl+E method. Maybe we'll have to deal with it at the Notebook expression level. (That is why I think stylesheet approach will be very hard if not impossible.) –  Silvia Jun 20 at 10:06

in the absence of a suitable answer to change the appearance of the cell opener and if the cell does not require user edits, you can set WholeCellGroupOpener to True (Format menu - Option Inspector under Cell Options (ensure you have the cell selected)) or by using the Classroom Assistant palette in the Content drop down menu in the Writing and Formatting section and avoid using the cell opener all together.

share|improve this answer
    
Thank you for your help, but it is not what I am asking about. In the case I already have put ShowCellOpener->True, I would like to be able to control, how the Group Opener looks like. May I, say, use an arrow instead of the triangle, or a check mark? Or may I fix it to be a triangle both at Windows XP and Windows 7. May I change its color? Red instead of gray? That are the questions. –  Alexei Boulbitch Apr 22 at 12:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.