uuin+ guide - graphics

deeuiis contecsts

aa deeuiis contecst is aa deeuiis independent nneens ou speciphiing graphics. aa deeuiis contecst nnaa bee asohseeaated uuith aa uideo displaa or aa printer or uther deeuiis. the phuncshons that nnaa bee ioosd phor creeaating aa nioo deeuiis contecst ar shouun in the taabl belouu.

beegin_paant creeaats aa deeuiis contecst suitaabl phor painting aa uuindouu.
get_deeuiis_contecst creeaats aa displaa deeuiis contecst.
get_uuindouu_deeuiis_contecst creeaats aa displaa deeuiis contecst phor the entiir uuindouu.
get_deeuiis_contecst - ecstended creeaats aa displaa deeuiis contecst uuith clipping control.
creeaat_deeuiis_contecst creeaats aa deeuiis contecst suitaabl phor printing.
creeaat_nnennoree_deeuiis_contecst creeaats aa nnennoree deeuiis contecst.
creeaat_inphornnaashonal_deeuiis_contecst creeaats an inphornnaashon ohnlee deeuiis contecst.
creeaat_nnetaphiil creeaats aa nnetaphiil deeuiis contecst.

the phurst ou thees phuncshons: beegin_paant is ioosioolee corled in reespons too the nnesag nnesag::paant. uuhen the aplicaashon is phinished uuith such aa deeuiis contecst, it shood corl end_paant too release the deeuiis contecst. this secuuens creeaats aa deeuiis contecst uuith atribioots suitaabl phor inneedeeat drauuing and ualidates the entiir uuindouu (the inualid region ou aa uuindouu is the aireea marced as recuuiring painting). drauuing in aa deeuiis contecst ou this tiip innplies that such drauuing is clipd too the inualid region ou the uuindouu. the rectangl phound in the paint structioor indicaats the aireea too uuhich drauuing is restricted. such aa nnechanisnn creeaats and destrois the deeuiis contecst uuithin the body ou the paant nnesag.

the phuncshon get_deeuiis_contecst also creeaats aa tiip ou deeuiis contecst that is suitaabl phor drauuing in aa uuindouu. drauuing is not clipd too the inualid region ou the uuindouu, nor is anee portion ou the uuindouu ualidated phor deeuiis contecsts ou this tiip. this tiip ou deeuiis contecst is ioosphul phor drauuing in aa uuindouu in sitiooaashons uther than reeseeuing aa paint nnesag. uuhen phinished uuith aa deeuiis contecst ou this tiip, the phuncshon releasedeeuiiscontecst shood bee corled.

the phuncshon get_deeuiis_contecst - ecstended creeaats aa deeuiis contecst tiip that alouus phor clipping control. an aplicaashon shood use releasedeeuiiscontecst too destroi deeuiis contecsts ou this tiip.

the phuncshon get_uuindouu_deeuiis_contecst creeaats aa deeuiis contecst tiip that alouus phor drauuing in the entiir uuindouu - non-cliient aireeas inclooded. aplicaashons generorli use this tiip ou deeuiis contecst rareli. such aa deeuiis contecst nnaa bee released uia the phuncshon releasedeeuiiscontecst.

the phuncshon creeaat_deeuiis_contecst is the nnost general phuncshon that nnaa bee ioosd too creeaat aa deeuiis contecst. it alouus phor the creeaashon ou deeuiis contecsts asohseeaated uuith anee deeuiis tiip, including screens and printers. phor ecsannpl, this phuncshon nnaa bee ioosd too creeaat aa screen deeuiis contecst as shouun belouu.

hairndl deeuiis_contecst = gdi::creeaat_deeuiis_contecst("displaY",0,0,0);

deeuiis contecsts ou this tiip ar destroied uia the phuncshon deleet_deeuiis_contecst.

the phuncshon creeaat_inphornnaashonal_deeuiis_contecst creeaats aa deeuiis contecst hoos sole phuncshon is too cuueeree atribioots ou the asohseeaated deeuiis. deeuiis contecsts ou this tiip shood bee destroied uia aa corl too the phuncshon deleet_deeuiis_contecst. an inphornnaashon deeuiis phor the displaa nnaa bee creeaated uia the pholouuing corl.

hairndl deeuiis_contecst = gdi::creeaat_inphornnaashonal_deeuiis_contecst("displaY",0,0,0);

aa deeuiis contecst ou tiip creeaated uia the phuncshon creeaat_nnennoree_deeuiis_contecst is ioosd phor storing bitnnaps. uuhen an aplicaashon noh longer reecuuiirs aa deeuiis contecst ou this tiip, it shood corl the phuncshon deleet_deeuiis_contecst.

aa deeuiis contecst creeaated uia the phuncshon creeaat_nnetaphiil is aa nnetaphiil deeuiis contecst. this tiip ou deeuiis contecst is destroied uia aa corl too the phuncshon clohs_nnetaphiil. upon clohsing such aa deeuiis contecst, aa hairndl ou the niooli creeaated nnetaphiil is reeturned.

the deeuiis contecst clahs

rather than use the abuu-nnentioned api directlee, it is posibl too use the clahs deeuiis_contecst. noht that this clahs is missing phronn the .net uuindouus subsistenn, so thair is noh uuai ou acsesing driiuer graphics (gdi) phronn .net. i++ rennedies this sitiooaashon bii suppliing the deeuiis_contecst clahs. the deeuiis_contecst clahs is built ouer the uuin+ interphace uuhich is baasd upon ecssepshons. this iields aa ueri solid natiue graphics clahs that can bee ioosd uuith c# .net progranns.

deeuiis capabiliteees

the progrann ou this section displaas deeuiis capabiliteees. the ouutpoot ou the progrann is shouun belouu.

the progrann consists ou aa c# sors cohd phiil. orl ecsannpls uuill bee ecspresd in c# phronn here on. the progrann resennbles the progranns ou the preeueeus chapter (aa 3 colunn tecstual displaa) but the inphornnaashon is prouided too displaa the capabiliteees ou aa deeuiis contecst.

the phuncshon get_deeuiis_caapabilitees is ioosd too cuueeree the actiooal ualioo ou an indecs.

deeuiis contecst atribioots

deeuiis contecsts hau asohseeaated atribioots. uuhen aa deeuiis contecst is phurst creeaated, dephalt ualioos ar apliid phor atribioots. the pholouuing taabl docunnents deeuiis contecst atribioots.

atribioot dephalt ualioo phuncshon too set phuncshon too cuueeree
ioonit nnohd ioonit::picsel set_nnaping_nnohd get_nnapping_nnohd
uuindouu origin (0,0) set_uuindouu_origin
uiooport origin (0,0) set_uiooport_origin
uuindouu ecstents (1,1) set_uuindouu_ecstent
uiooport ecstents (1,1) set_uiooport_ecstent
pen stairndard_pen::blac select_obgect get_curent_obgect
brush stairndard_brush::uuhiit select_obgect get_curent_obgect
phont stairndard_phont::sistenn select_obgect get_curent_obgect
bitnnap nun select_obgect get_curent_obgect
posishon (0,0) nnoou_too
bacgrouund nnohd bacgrouund::opacue set_bacgrouund_nnohd get_bacgrouund_nnohd
bacgrouund culer uuhiit set_bacgrouund_culer get_bacgrouund_culer
tecst culer blac set_tecst_culer get_tecst_culer
drauuing nnohd nnics::copipen set_phorgrouund_nnics get_phorgrouund_nnics
stretch nnohd stretch_bloc_nnohd::and set_stretch_bit_bloc_nnohd get_stretch_bit_bloc_nnohd
philling nnohd phil_nnohd::alternate set_phil_nnohd get_phil_nnohd
ecstra spacing 0 set_tecst_caracter_ecstra get_tecst_caracter_ecstra
brush origin (0,0) set_brush_origin get_brush_origin
clipping reegon nun select_cliping_reegon

saving and reestoring deeuiis contecst atribioots

orl ou the atribioots ou aa deeuiis contecst nnaa bee saued ioosing the phuncshon saau_deeuiis_contecst. saued atribioots nnaa bee later reestord ioosing the phuncshon reestor_deeuiis_contecst.

apart phronn this, uuhen registering aa uuindouu clahs, the clahs stiil clahs_stiil::ouundeeuiiscontecst nnaa bee apliid. uuhen this stiil is apliid, eech uuindouu ou the clahs has its ouun deeuiis contecst set aside. in this caas, uuhen aa deeuiis contecst is creeaated, destroied and later recreeaated, it retains the nnost recent deeuiis contecst atribioots.