Do you know any patterns for GUI programming? (Not patterns on designing GUIs)

I'm looking for patterns that concern coding parts of a GUI. Not as global as MVC , that I'm quite familiar with, but patterns and good ideas and best practices concerning single controls and inputs.

Let say I want to make a control that display some objects that may overlap. Now if I click on an object, I need to find out what to do (Just finding the object I can do in several ways, such as an quad-tree and Z-order, thats not the problem). And also I might hold down a modifier key, or some object is active from the beginning, making the selection or whatever a bit more complicated. Should I have an object instance representing a screen object, handle the user-action when clicked, or a master class. etc.. What kind of patterns or solutions are there for problems like this?


I think to be honest you a better just boning up on your standard design patterns and applying them to the individual problems that you face in developing your UI.

While there are common UI "themes" (such as dealing with modifier keys) the actual implementation may vary widely.

I have O'Reilly's Head First Design Patterns and The Poster, which I have found invaluable!

Shameless Plug : These links are using my associates ID.


Object-Oriented Design and Patterns by Cay Horstmann has a chapter entitled "Patterns and GUI Programming". In that chapter, Horstmann touches on the following patterns:

  • Observer Layout Managers and the
  • Strategy Pattern Components,
  • Containers, and the Composite Pattern
  • Scroll Bars and the Decorator Pattern

  • I don't think the that benefit of design patterns come from trying to find a design pattern to fit a problem. You can however use some heuristics to help clean up your design in this quite a bit, like keeping the UI as decoupled as possible from the rest of the objects in your system.

    There is a pattern that might help out in this case, the Observer Pattern.

    链接地址: http://www.djcxy.com/p/8820.html

    上一篇: 如何让WPF中的控件填充可用空间?

    下一篇: 你知道GUI编程的任何模式吗? (不是设计GUI的模式)