Design Patterns : Elements of Reusable Object-Oriented Software


Design Patterns: Elements of Reusable Object-Oriented Software



Download 4,06 Mb.
Pdf ko'rish
bet128/288
Sana07.04.2022
Hajmi4,06 Mb.
#535140
1   ...   124   125   126   127   128   129   130   131   ...   288
Bog'liq
GOF Design Patterns
Копасов Игорь (1), Т Е Л Е Ф О Н О Г Р А М М А ЗООМ, 20201546 п.80 использ., Oliy matematika, презентация индустрия мутакил иши, 3000 most common words in English, Sun'iy intellekt, 1638511850 AE, 1638511850 AE, Hisob-raqan (Patent boji), O'RQ-600 23-MODDA, Talabaning haftalik hisoboti namunasi , iikinchi hafta amaliyoti., Таҳлил тест
Design Patterns: Elements of Reusable Object-Oriented Software 
179 
// ... 
virtual void DrawContents(); 
private: 
const char* _bitmapName; 
}; 
...and it implements DrawContents to draw the bitmap on the window: 
void IconWindow::DrawContents() { 
WindowImp* imp = GetWindowImp(); 
if (imp != 0) { 
imp->DeviceBitmap(_bitmapName, 0.0, 0.0); 


Many other variations of Window are possible. A TransientWindow may need to 
communicate with the window that created it during the dialog; hence it keeps 
a reference to that window. A PaletteWindow always floats above other windows. 
An IconDockWindow holds IconWindows and arranges them neatly. 
Window operations are defined in terms of the WindowImp interface. For example, 
DrawRect extracts four coordinates from its two Point parameters before calling 
the WindowImp operation that draws the rectangle in the window: 
void Window::DrawRect (const Point& p1, const Point& p2) { 
WindowImp* imp = GetWindowImp(); 
imp->DeviceRect(p1.X(), p1.Y(), p2.X(), p2.Y()); 

Concrete subclasses of WindowImp support different window systems. The XWindowImp 
subclass supports the X Window System: 
class XWindowImp : public WindowImp { 
public: 
XWindowImp(); 
virtual void DeviceRect(Coord, Coord, Coord, Coord); 
// remainder of public interface... 
private: 
// lots of X window system-specific state, including: 
Display* _dpy; 
Drawable _winid; // window id 


Design Patterns: Elements of Reusable Object-Oriented Software 
180 
GC _gc; // window graphic context 
}; 
For Presentation Manager (PM), we define a PMWindowImp class: 
class PMWindowImp : public WindowImp { 
public: 
PMWindowImp(); 
virtual void DeviceRect(Coord, Coord, Coord, Coord); 
// remainder of public interface... 
private: 
// lots of PM window system-specific state, including: 
HPS _hps; 
}; 
These subclasses implement WindowImp operations in terms of window system 
primitives. For example, DeviceRect is implemented for X as follows: 
void XWindowImp::DeviceRect ( 
Coord x0, Coord y0, Coord x1, Coord y1 
) { 
int x = round(min(x0, x1)); 
int y = round(min(y0, y1)); 
int w = round(abs(x0 - x1)); 
int h = round(abs(y0 - y1)); 
XDrawRectangle(_dpy, _winid, _gc, x, y, w, h); 

The PM implementation might look like this: 
void PMWindowImp::DeviceRect ( 
Coord x0, Coord y0, Coord x1, Coord y1 
) { 
Coord left = min(x0, x1); 
Coord right = max(x0, x1); 
Coord bottom = min(y0, y1); 
Coord top = max(y0, y1); 
PPOINTL point[4]; 
point[0].x = left; point[0].y = top; 



Download 4,06 Mb.

Do'stlaringiz bilan baham:
1   ...   124   125   126   127   128   129   130   131   ...   288




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

    Bosh sahifa
davlat universiteti
ta’lim vazirligi
axborot texnologiyalari
maxsus ta’lim
zbekiston respublikasi
guruh talabasi
O’zbekiston respublikasi
nomidagi toshkent
o’rta maxsus
davlat pedagogika
texnologiyalari universiteti
toshkent axborot
xorazmiy nomidagi
rivojlantirish vazirligi
pedagogika instituti
Ўзбекистон республикаси
tashkil etish
haqida tushuncha
таълим вазирлиги
vazirligi muhammad
O'zbekiston respublikasi
toshkent davlat
махсус таълим
respublikasi axborot
kommunikatsiyalarini rivojlantirish
vazirligi toshkent
saqlash vazirligi
fanidan tayyorlagan
bilan ishlash
Toshkent davlat
sog'liqni saqlash
uzbekistan coronavirus
respublikasi sog'liqni
coronavirus covid
koronavirus covid
vazirligi koronavirus
risida sertifikat
covid vaccination
qarshi emlanganlik
sertifikat ministry
vaccination certificate
Ishdan maqsad
fanidan mustaqil
matematika fakulteti
o’rta ta’lim
haqida umumiy
fanlar fakulteti
pedagogika universiteti
ishlab chiqarish
moliya instituti
fanining predmeti