You should look at composite and decorating patterns. In fact, a case study (Lexi word processor) in GoF's book (Design Patters, Gamma, etc.) is of great importance - creating a hierarchy of user interface elements that may or may not contain a set of widgets inside them.
The case study provides an excellent point for such a user interface design and covers many things that you may not consider necessary to consider.
source share