Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet176/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   172   173   174   175   176   177   178   179   ...   288
Bog'liq
GOF Design Patterns

Design Patterns: Elements of Reusable Object-Oriented Software 
261 
Dialog* dialog = new Dialog(application, PRINT_TOPIC); 
Button* button = new Button(dialog, PAPER_ORIENTATION_TOPIC); 
We can invoke the help request by calling HandleHelp on anyobject on the chain. 
To start the search at the button object, justcall HandleHelp on it: 
button->HandleHelp(); 
In this case, the button will handle the request immediately. Notethat any 
HelpHandler class could be made the successor ofDialog. Moreover, its successor 
could be changeddynamically. So no matter where a dialog is used, you'll get 
theproper context-dependent help information for it. 
Known Uses 
Several class libraries use the Chain of Responsibility pattern tohandle user 
events. They use different names for the Handler class,but the idea is the same: 
When the user clicks the mouse or presses akey, an event gets generated and passed 
along the chain.MacApp [App89] and ET++ [WGM88] call it "EventHandler,"Symantec's 
TCL library [Sym93b] calls it "Bureaucrat," andNeXT's AppKit [Add94] uses the 
name "Responder." 
The Unidraw framework for graphical editors defines Command objectsthat 
encapsulate requests to Component and ComponentViewobjects [VL90]. Commands are 
requests in the sensethat a component or component view may interpret a command 
to performan operation. This corresponds to the "requests as objects"approach 
described in Implementation. Components and component viewsmay be structured 
hierarchically. A component or a component view mayforward command interpretation 
to its parent, which may in turnforward it to its parent, and so on, thereby forming 
a chain ofresponsibility. 
ET++ uses Chain of Responsibility to handle graphical update. Agraphical object 
calls the InvalidateRect operation whenever it mustupdate a part of its appearance. 
A graphical object can't handleInvalidateRect by itself, because it doesn't know 
enough about itscontext. For example, a graphical object can be enclosed in 
objectslike Scrollers or Zoomers that transform its coordinate system. Thatmeans 
the object might be scrolled or zoomed so that it's partiallyout of view. Therefore 
the default implementation of InvalidateRectforwards the request to the enclosing 
container object. The lastobject in the forwarding chain is a Window instance. 
By the timeWindow receives the request, the invalidation rectangle is guaranteedto 
be transformed properly. The Window handles InvalidateRect bynotifying the window 
system interface and requesting an update. 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   172   173   174   175   176   177   178   179   ...   288




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish