graph.pp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Florian Klaempfl
  5. This file implements the win32 gui support for the graph unit
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit Graph;
  13. interface
  14. uses
  15. windows;
  16. {$i graphh.inc}
  17. var
  18. { this procedure allows to hook keyboard messages }
  19. charmessagehandler : function(Window: hwnd; AMessage, WParam,
  20. LParam: Longint): Longint;
  21. { this procedure allows to hook mouse messages }
  22. mousemessagehandler : function(Window: hwnd; AMessage, WParam,
  23. LParam: Longint): Longint;
  24. mainwindow : HWnd;
  25. const
  26. { predefined window style }
  27. { we shouldn't set CS_DBLCLKS here }
  28. { because most dos applications }
  29. { handle double clicks on it's own }
  30. graphwindowstyle : DWord = cs_hRedraw or cs_vRedraw;
  31. windowtitle : pchar = 'Graph window application';
  32. CONST
  33. m640x200x16 = VGALo;
  34. m640x400x16 = VGAMed;
  35. m640x480x16 = VGAHi;
  36. { VESA Specific video modes. }
  37. m320x200x32k = $10D;
  38. m320x200x64k = $10E;
  39. m640x400x256 = $100;
  40. m640x480x256 = $101;
  41. m640x480x32k = $110;
  42. m640x480x64k = $111;
  43. m800x600x16 = $102;
  44. m800x600x256 = $103;
  45. m800x600x32k = $113;
  46. m800x600x64k = $114;
  47. m1024x768x16 = $104;
  48. m1024x768x256 = $105;
  49. m1024x768x32k = $116;
  50. m1024x768x64k = $117;
  51. m1280x1024x16 = $106;
  52. m1280x1024x256 = $107;
  53. m1280x1024x32k = $119;
  54. m1280x1024x64k = $11A;
  55. implementation
  56. uses
  57. strings;
  58. {
  59. Remarks:
  60. Colors in 16 color mode:
  61. ------------------------
  62. - the behavior of xor/or/and put isn't 100%:
  63. it is done using the RGB color getting from windows
  64. instead of the palette index!
  65. - palette operations aren't supported
  66. To solve these drawbacks, setpalette must be implemented
  67. by exchanging the colors in the DCs, further GetPaletteEntry
  68. must be used when doing xor/or/and operations
  69. }
  70. const
  71. InternalDriverName = 'WIN32GUI';
  72. {$i graph.inc}
  73. { used to create a file containing all calls to WM_PAINT
  74. WARNING this probably creates HUGE files PM }
  75. { $define DEBUG_WM_PAINT}
  76. var
  77. savedscreen : hbitmap;
  78. graphrunning : boolean;
  79. graphdrawing : tcriticalsection;
  80. {$ifdef DEBUG_WM_PAINT}
  81. graphdebug : text;
  82. const
  83. wm_paint_count : longint = 0;
  84. var
  85. {$endif DEBUG_WM_PAINT}
  86. bitmapdc : hdc;
  87. oldbitmap : hgdiobj;
  88. pal : ^rgbrec;
  89. // SavePtr : pointer; { we don't use that pointer }
  90. MessageThreadHandle : Handle;
  91. MessageThreadID : DWord;
  92. windc : hdc;
  93. function GetPaletteEntry(r,g,b : word) : word;
  94. var
  95. dist,i,index,currentdist : longint;
  96. begin
  97. dist:=$7fffffff;
  98. index:=0;
  99. for i:=0 to maxcolors-1 do
  100. begin
  101. currentdist:=abs(r-pal[i].red)+abs(g-pal[i].green)+
  102. abs(b-pal[i].blue);
  103. if currentdist<dist then
  104. begin
  105. index:=i;
  106. dist:=currentdist;
  107. if dist=0 then
  108. break;
  109. end;
  110. end;
  111. GetPaletteEntry:=index;
  112. end;
  113. procedure PutPixel16Win32GUI(x,y : integer;pixel : word);
  114. var
  115. c : colorref;
  116. begin
  117. x:=x+startxviewport;
  118. y:=y+startyviewport;
  119. { convert to absolute coordinates and then verify clipping...}
  120. if clippixels then
  121. begin
  122. if (x<startxviewport) or (x>(startxviewport+viewwidth)) or
  123. (y<StartyViewPort) or (y>(startyviewport+viewheight)) then
  124. exit;
  125. end;
  126. if graphrunning then
  127. begin
  128. c:=RGB(pal[pixel].red,pal[pixel].green,pal[pixel].blue);
  129. EnterCriticalSection(graphdrawing);
  130. SetPixel(bitmapdc,x,y,c);
  131. SetPixel(windc,x,y,c);
  132. LeaveCriticalSection(graphdrawing);
  133. end;
  134. end;
  135. function GetPixel16Win32GUI(x,y : integer) : word;
  136. var
  137. c : COLORREF;
  138. begin
  139. x:=x+startxviewport;
  140. y:=y+startyviewport;
  141. { convert to absolute coordinates and then verify clipping...}
  142. if clippixels then
  143. begin
  144. if (x<startxviewport) or (x>(startxviewport+viewwidth)) or
  145. (y<StartyViewPort) or (y>(startyviewport+viewheight)) then
  146. exit;
  147. end;
  148. if graphrunning then
  149. begin
  150. EnterCriticalSection(graphdrawing);
  151. c:=Windows.GetPixel(bitmapdc,x,y);
  152. LeaveCriticalSection(graphdrawing);
  153. GetPixel16Win32GUI:=GetPaletteEntry(GetRValue(c),GetGValue(c),GetBValue(c));
  154. end
  155. else
  156. begin
  157. _graphresult:=grerror;
  158. exit;
  159. end;
  160. end;
  161. procedure DirectPutPixel16Win32GUI(x,y : integer);
  162. var
  163. col : longint;
  164. c,c2 : COLORREF;
  165. begin
  166. if graphrunning then
  167. begin
  168. EnterCriticalSection(graphdrawing);
  169. col:=CurrentColor;
  170. case currentwritemode of
  171. XorPut:
  172. Begin
  173. c2:=Windows.GetPixel(bitmapdc,x,y);
  174. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) xor c2;
  175. SetPixel(bitmapdc,x,y,c);
  176. SetPixel(windc,x,y,c);
  177. End;
  178. AndPut:
  179. Begin
  180. c2:=Windows.GetPixel(bitmapdc,x,y);
  181. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) and c2;
  182. SetPixel(bitmapdc,x,y,c);
  183. SetPixel(windc,x,y,c);
  184. End;
  185. OrPut:
  186. Begin
  187. c2:=Windows.GetPixel(bitmapdc,x,y);
  188. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) or c2;
  189. SetPixel(bitmapdc,x,y,c);
  190. SetPixel(windc,x,y,c);
  191. End
  192. else
  193. Begin
  194. If CurrentWriteMode<>NotPut Then
  195. col:=CurrentColor
  196. Else col := Not(CurrentColor);
  197. c:=RGB(pal[col].red,pal[col].green,pal[col].blue);
  198. SetPixel(bitmapdc,x,y,c);
  199. SetPixel(windc,x,y,c);
  200. End
  201. end;
  202. LeaveCriticalSection(graphdrawing);
  203. end;
  204. end;
  205. procedure HLine16Win32GUI(x,x2,y: integer);
  206. var
  207. c,c2 : COLORREF;
  208. col,i : longint;
  209. oldpen,pen : HPEN;
  210. Begin
  211. if graphrunning then
  212. begin
  213. { must we swap the values? }
  214. if x>x2 then
  215. Begin
  216. x:=x xor x2;
  217. x2:=x xor x2;
  218. x:=x xor x2;
  219. end;
  220. { First convert to global coordinates }
  221. X:=X+StartXViewPort;
  222. X2:=X2+StartXViewPort;
  223. Y:=Y+StartYViewPort;
  224. if ClipPixels then
  225. Begin
  226. if LineClipped(x,y,x2,y,StartXViewPort,StartYViewPort,
  227. StartXViewPort+ViewWidth, StartYViewPort+ViewHeight) then
  228. exit;
  229. end;
  230. Case CurrentWriteMode of
  231. AndPut:
  232. Begin
  233. EnterCriticalSection(graphdrawing);
  234. col:=CurrentColor;
  235. for i:=x to x2 do
  236. begin
  237. c2:=Windows.GetPixel(bitmapdc,i,y);
  238. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) and c2;
  239. SetPixel(bitmapdc,i,y,c);
  240. SetPixel(windc,i,y,c);
  241. end;
  242. LeaveCriticalSection(graphdrawing);
  243. End;
  244. XorPut:
  245. Begin
  246. EnterCriticalSection(graphdrawing);
  247. for i:=x to x2 do
  248. begin
  249. c2:=Windows.GetPixel(bitmapdc,i,y);
  250. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) xor c2;
  251. SetPixel(bitmapdc,i,y,c);
  252. SetPixel(windc,i,y,c);
  253. end;
  254. LeaveCriticalSection(graphdrawing);
  255. End;
  256. OrPut:
  257. Begin
  258. EnterCriticalSection(graphdrawing);
  259. for i:=x to x2 do
  260. begin
  261. c2:=Windows.GetPixel(bitmapdc,i,y);
  262. c:=RGB(pal[col].red,pal[col].green,pal[col].blue) or c2;
  263. SetPixel(bitmapdc,i,y,c);
  264. SetPixel(windc,i,y,c);
  265. end;
  266. LeaveCriticalSection(graphdrawing);
  267. End
  268. Else
  269. Begin
  270. If CurrentWriteMode<>NotPut Then
  271. col:=CurrentColor
  272. Else col:=Not(CurrentColor);
  273. EnterCriticalSection(graphdrawing);
  274. c:=RGB(pal[col].red,pal[col].green,pal[col].blue);
  275. pen:=CreatePen(PS_SOLID,1,c);
  276. oldpen:=SelectObject(bitmapdc,pen);
  277. Windows.MoveToEx(bitmapdc,x,y,nil);
  278. Windows.LineTo(bitmapdc,x2,y);
  279. SelectObject(bitmapdc,oldpen);
  280. oldpen:=SelectObject(windc,pen);
  281. Windows.MoveToEx(windc,x,y,nil);
  282. Windows.LineTo(windc,x2,y);
  283. SelectObject(windc,oldpen);
  284. DeleteObject(pen);
  285. LeaveCriticalSection(graphdrawing);
  286. End;
  287. End;
  288. end;
  289. end;
  290. procedure SetRGBPaletteWin32GUI(colorNum,redValue,greenvalue,
  291. bluevalue : integer);
  292. begin
  293. if directcolor or (colornum<0) or (colornum>=maxcolor) then
  294. begin
  295. _graphresult:=grerror;
  296. exit;
  297. end;
  298. pal[colorNum].red:=redValue;
  299. pal[colorNum].green:=greenValue;
  300. pal[colorNum].blue:=blueValue;
  301. end;
  302. procedure GetRGBPaletteWin32GUI(colorNum : integer;
  303. var redValue,greenvalue,bluevalue : integer);
  304. begin
  305. if directcolor or (colornum<0) or (colornum>=maxcolor) then
  306. begin
  307. _graphresult:=grerror;
  308. exit;
  309. end;
  310. redValue:=pal[colorNum].red;
  311. greenValue:=pal[colorNum].green;
  312. blueValue:=pal[colorNum].blue;
  313. end;
  314. procedure savestate;
  315. begin
  316. end;
  317. procedure restorestate;
  318. begin
  319. end;
  320. function WindowProc(Window: HWnd; AMessage, WParam,
  321. LParam: Longint): Longint; stdcall; export;
  322. var
  323. dc : hdc;
  324. ps : paintstruct;
  325. r : rect;
  326. begin
  327. WindowProc := 0;
  328. case AMessage of
  329. wm_lbuttondown,
  330. wm_rbuttondown,
  331. wm_mbuttondown,
  332. wm_lbuttonup,
  333. wm_rbuttonup,
  334. wm_mbuttonup,
  335. wm_lbuttondblclk,
  336. wm_rbuttondblclk,
  337. wm_mbuttondblclk:
  338. {
  339. This leads to problem, i.e. the menu etc doesn't work any longer
  340. wm_nclbuttondown,
  341. wm_ncrbuttondown,
  342. wm_ncmbuttondown,
  343. wm_nclbuttonup,
  344. wm_ncrbuttonup,
  345. wm_ncmbuttonup,
  346. wm_nclbuttondblclk,
  347. wm_ncrbuttondblclk,
  348. wm_ncmbuttondblclk:
  349. }
  350. if assigned(mousemessagehandler) then
  351. WindowProc:=mousemessagehandler(window,amessage,wparam,lparam);
  352. wm_keydown,
  353. wm_keyup,
  354. wm_char:
  355. if assigned(charmessagehandler) then
  356. WindowProc:=charmessagehandler(window,amessage,wparam,lparam);
  357. wm_paint:
  358. begin
  359. {$ifdef DEBUG_WM_PAINT}
  360. inc(wm_paint_count);
  361. {$endif DEBUG_WM_PAINT}
  362. if not GetUpdateRect(Window,@r,false) then
  363. exit;
  364. EnterCriticalSection(graphdrawing);
  365. graphrunning:=true;
  366. dc:=BeginPaint(Window,@ps);
  367. {$ifdef DEBUG_WM_PAINT}
  368. Writeln(graphdebug,'WM_PAINT in ((',r.left,',',r.top,
  369. '),(',r.right,',',r.bottom,'))');
  370. {$endif def DEBUG_WM_PAINT}
  371. if graphrunning then
  372. {BitBlt(dc,0,0,maxx+1,maxy+1,bitmapdc,0,0,SRCCOPY);}
  373. BitBlt(dc,r.left,r.top,r.right,r.bottom,bitmapdc,r.left,r.top,SRCCOPY);
  374. EndPaint(Window,ps);
  375. LeaveCriticalSection(graphdrawing);
  376. Exit;
  377. end;
  378. wm_create:
  379. begin
  380. {$ifdef DEBUG_WM_PAINT}
  381. assign(graphdebug,'wingraph.log');
  382. rewrite(graphdebug);
  383. {$endif DEBUG_WM_PAINT}
  384. EnterCriticalSection(graphdrawing);
  385. dc:=GetDC(window);
  386. bitmapdc:=CreateCompatibleDC(dc);
  387. savedscreen:=CreateCompatibleBitmap(dc,maxx+1,maxy+1);
  388. ReleaseDC(window,dc);
  389. oldbitmap:=SelectObject(bitmapdc,savedscreen);
  390. windc:=GetDC(window);
  391. LeaveCriticalSection(graphdrawing);
  392. end;
  393. wm_Destroy:
  394. begin
  395. EnterCriticalSection(graphdrawing);
  396. graphrunning:=false;
  397. ReleaseDC(mainwindow,windc);
  398. SelectObject(bitmapdc,oldbitmap);
  399. DeleteObject(savedscreen);
  400. DeleteDC(bitmapdc);
  401. LeaveCriticalSection(graphdrawing);
  402. {$ifdef DEBUG_WM_PAINT}
  403. close(graphdebug);
  404. {$endif DEBUG_WM_PAINT}
  405. PostQuitMessage(0);
  406. Exit;
  407. end
  408. else
  409. WindowProc := DefWindowProc(Window, AMessage, WParam, LParam);
  410. end;
  411. end;
  412. function WinRegister: Boolean;
  413. var
  414. WindowClass: WndClass;
  415. begin
  416. WindowClass.Style := graphwindowstyle;
  417. WindowClass.lpfnWndProc := WndProc(@WindowProc);
  418. WindowClass.cbClsExtra := 0;
  419. WindowClass.cbWndExtra := 0;
  420. WindowClass.hInstance := system.MainInstance;
  421. WindowClass.hIcon := LoadIcon(0, idi_Application);
  422. WindowClass.hCursor := LoadCursor(0, idc_Arrow);
  423. WindowClass.hbrBackground := GetStockObject(BLACK_BRUSH);
  424. WindowClass.lpszMenuName := nil;
  425. WindowClass.lpszClassName := 'MyWindow';
  426. winregister:=RegisterClass(WindowClass) <> 0;
  427. end;
  428. { Create the Window Class }
  429. function WinCreate: HWnd;
  430. var
  431. hWindow: HWnd;
  432. begin
  433. hWindow := CreateWindow('MyWindow', windowtitle,
  434. ws_OverlappedWindow, 50, 50,
  435. maxx+1+2*GetSystemMetrics(SM_CXBORDER),
  436. maxy+1+2*GetSystemMetrics(SM_CYBORDER)+
  437. GetSystemMetrics(SM_CYCAPTION),
  438. 0, 0, system.MainInstance, nil);
  439. if hWindow <> 0 then begin
  440. ShowWindow(hWindow, SW_SHOW);
  441. UpdateWindow(hWindow);
  442. end;
  443. wincreate:=hWindow;
  444. end;
  445. const
  446. winregistered : boolean = false;
  447. function MessageHandleThread(p : pointer) : DWord;StdCall;
  448. var
  449. AMessage: Msg;
  450. begin
  451. if not(winregistered) then
  452. begin
  453. if not WinRegister then
  454. begin
  455. MessageBox(0, 'Register failed', nil, mb_Ok);
  456. ExitThread(1);
  457. end;
  458. winregistered:=true;
  459. end;
  460. MainWindow := WinCreate;
  461. if longint(mainwindow) = 0 then begin
  462. MessageBox(0, 'WinCreate failed', nil, mb_Ok);
  463. ExitThread(1);
  464. end;
  465. while longint(GetMessage(@AMessage, 0, 0, 0))=longint(true) do
  466. begin
  467. TranslateMessage(AMessage);
  468. DispatchMessage(AMessage);
  469. end;
  470. MessageHandleThread:=0;
  471. end;
  472. procedure InitWin32GUI16colors;
  473. var
  474. threadexitcode : longint;
  475. begin
  476. getmem(pal,sizeof(RGBrec)*maxcolor);
  477. move(DefaultColors,pal^,sizeof(RGBrec)*maxcolor);
  478. { start graph subsystem }
  479. InitializeCriticalSection(graphdrawing);
  480. graphrunning:=false;
  481. MessageThreadHandle:=CreateThread(nil,0,@MessageHandleThread,
  482. nil,0,MessageThreadID);
  483. repeat
  484. GetExitCodeThread(MessageThreadHandle,@threadexitcode);
  485. until graphrunning or (threadexitcode<>STILL_ACTIVE);
  486. if threadexitcode<>STILL_ACTIVE then
  487. _graphresult := grerror
  488. else
  489. ClearDevice;
  490. end;
  491. procedure CloseGraph;
  492. begin
  493. If not isgraphmode then
  494. begin
  495. _graphresult := grnoinitgraph;
  496. exit
  497. end;
  498. PostMessage(MainWindow,wm_destroy,0,0);
  499. PostThreadMessage(MessageThreadHandle,wm_quit,0,0);
  500. WaitForSingleObject(MessageThreadHandle,Infinite);
  501. CloseHandle(MessageThreadHandle);
  502. DeleteCriticalSection(graphdrawing);
  503. freemem(pal,sizeof(RGBrec)*maxcolor);
  504. end;
  505. {
  506. procedure line(x1,y1,x2,y2 : longint);
  507. var
  508. pen,oldpen : hpen;
  509. windc : hdc;
  510. begin
  511. if graphrunning then
  512. begin
  513. EnterCriticalSection(graphdrawing);
  514. pen:=CreatePen(PS_SOLID,4,RGB($ff,0,0));
  515. oldpen:=SelectObject(bitmapdc,pen);
  516. MoveToEx(bitmapdc,x1,y1,nil);
  517. LineTo(bitmapdc,x2,y2);
  518. SelectObject(bitmapdc,oldpen);
  519. windc:=GetDC(mainwindow);
  520. oldpen:=SelectObject(windc,pen);
  521. MoveToEx(windc,x1,y1,nil);
  522. LineTo(windc,x2,y2);
  523. SelectObject(windc,oldpen);
  524. ReleaseDC(mainwindow,windc);
  525. DeleteObject(pen);
  526. LeaveCriticalSection(graphdrawing);
  527. end;
  528. end;
  529. }
  530. { multipage support could be done by using more than one background bitmap }
  531. procedure SetVisualWin32GUI(page: word);
  532. begin
  533. end;
  534. procedure SetActiveWin32GUI(page: word);
  535. begin
  536. end;
  537. function queryadapterinfo : pmodeinfo;
  538. var
  539. mode: TModeInfo;
  540. ScreenWidth,ScreenHeight : longint;
  541. begin
  542. SaveVideoState:=savestate;
  543. RestoreVideoState:=restorestate;
  544. ScreenWidth:=GetSystemMetrics(SM_CXSCREEN);
  545. ScreenHeight:=GetSystemMetrics(SM_CYSCREEN);
  546. QueryAdapterInfo := ModeList;
  547. { If the mode listing already exists... }
  548. { simply return it, without changing }
  549. { anything... }
  550. if assigned(ModeList) then
  551. exit;
  552. InitMode(mode);
  553. { now add all standard VGA modes... }
  554. mode.DriverNumber:= VGA;
  555. mode.HardwarePages:= 0;
  556. mode.ModeNumber:=VGALo;
  557. mode.ModeName:='640 x 200 Win32GUI';
  558. mode.MaxColor := 16;
  559. mode.PaletteSize := mode.MaxColor;
  560. mode.DirectColor := FALSE;
  561. mode.MaxX := 639;
  562. mode.MaxY := 199;
  563. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  564. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  565. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  566. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  567. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  568. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  569. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  570. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  571. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  572. mode.XAspect := 10000;
  573. mode.YAspect := 10000;
  574. AddMode(mode);
  575. InitMode(mode);
  576. mode.DriverNumber:= VGA;
  577. mode.HardwarePages:= 0;
  578. mode.ModeNumber:=VGAMed;
  579. mode.ModeName:='640 x 350 Win32GUI';
  580. mode.MaxColor := 16;
  581. mode.PaletteSize := mode.MaxColor;
  582. mode.DirectColor := FALSE;
  583. mode.MaxX := 639;
  584. mode.MaxY := 349;
  585. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  586. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  587. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  588. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  589. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  590. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  591. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  592. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  593. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  594. mode.XAspect := 10000;
  595. mode.YAspect := 10000;
  596. AddMode(mode);
  597. InitMode(mode);
  598. mode.DriverNumber:= VGA;
  599. mode.HardwarePages:= 0;
  600. mode.ModeNumber:=VGAHi;
  601. mode.ModeName:='640 x 480 Win32GUI';
  602. mode.MaxColor := 16;
  603. mode.PaletteSize := mode.MaxColor;
  604. mode.DirectColor := FALSE;
  605. mode.MaxX := 639;
  606. mode.MaxY := 479;
  607. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  608. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  609. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  610. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  611. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  612. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  613. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  614. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  615. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  616. mode.XAspect := 10000;
  617. mode.YAspect := 10000;
  618. AddMode(mode);
  619. InitMode(mode);
  620. mode.DriverNumber:= VESA;
  621. mode.HardwarePages:= 0;
  622. mode.ModeNumber:=m640x400x256;
  623. mode.ModeName:='640 x 400 x 256 Win32GUI';
  624. mode.MaxColor := 256;
  625. mode.PaletteSize := mode.MaxColor;
  626. mode.DirectColor := FALSE;
  627. mode.MaxX := 639;
  628. mode.MaxY := 399;
  629. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  630. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  631. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  632. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  633. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  634. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  635. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  636. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  637. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  638. mode.XAspect := 10000;
  639. mode.YAspect := 10000;
  640. AddMode(mode);
  641. InitMode(mode);
  642. mode.DriverNumber:= VESA;
  643. mode.HardwarePages:= 0;
  644. mode.ModeNumber:=m640x480x256;
  645. mode.ModeName:='640 x 480 x 256 Win32GUI';
  646. mode.MaxColor := 256;
  647. mode.PaletteSize := mode.MaxColor;
  648. mode.DirectColor := FALSE;
  649. mode.MaxX := 639;
  650. mode.MaxY := 479;
  651. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  652. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  653. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  654. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  655. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  656. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  657. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  658. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  659. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  660. mode.XAspect := 10000;
  661. mode.YAspect := 10000;
  662. AddMode(mode);
  663. { add 800x600 only if screen is large enough }
  664. If (ScreenWidth>=800) and (ScreenHeight>=600) then
  665. begin
  666. InitMode(mode);
  667. mode.DriverNumber:= VESA;
  668. mode.HardwarePages:= 0;
  669. mode.ModeNumber:=m800x600x16;
  670. mode.ModeName:='800 x 600 x 16 Win32GUI';
  671. mode.MaxColor := 16;
  672. mode.PaletteSize := mode.MaxColor;
  673. mode.DirectColor := FALSE;
  674. mode.MaxX := 799;
  675. mode.MaxY := 599;
  676. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  677. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  678. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  679. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  680. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  681. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  682. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  683. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  684. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  685. mode.XAspect := 10000;
  686. mode.YAspect := 10000;
  687. AddMode(mode);
  688. InitMode(mode);
  689. mode.DriverNumber:= VESA;
  690. mode.HardwarePages:= 0;
  691. mode.ModeNumber:=m800x600x256;
  692. mode.ModeName:='800 x 600 x 256 Win32GUI';
  693. mode.MaxColor := 256;
  694. mode.PaletteSize := mode.MaxColor;
  695. mode.DirectColor := FALSE;
  696. mode.MaxX := 799;
  697. mode.MaxY := 599;
  698. mode.DirectPutPixel:={$ifdef fpc}@{$endif}DirectPutPixel16Win32GUI;
  699. mode.PutPixel:={$ifdef fpc}@{$endif}PutPixel16Win32GUI;
  700. mode.GetPixel:={$ifdef fpc}@{$endif}GetPixel16Win32GUI;
  701. mode.HLine := {$ifdef fpc}@{$endif}HLine16Win32GUI;
  702. mode.SetRGBPalette := {$ifdef fpc}@{$endif}SetRGBPaletteWin32GUI;
  703. mode.GetRGBPalette := {$ifdef fpc}@{$endif}GetRGBPaletteWin32GUI;
  704. mode.SetVisualPage := {$ifdef fpc}@{$endif}SetVisualWin32GUI;
  705. mode.SetActivePage := {$ifdef fpc}@{$endif}SetActiveWin32GUI;
  706. mode.InitMode := {$ifdef fpc}@{$endif}InitWin32GUI16colors;
  707. mode.XAspect := 10000;
  708. mode.YAspect := 10000;
  709. AddMode(mode);
  710. end;
  711. end;
  712. begin
  713. InitializeGraph;
  714. end.
  715. {
  716. $Log$
  717. Revision 1.1 2000-03-19 11:20:14 peter
  718. * graph unit include is now independent and the dependent part
  719. is now in graph.pp
  720. * ggigraph unit for linux added
  721. Revision 1.8 2000/03/17 22:53:20 florian
  722. * window class is registered only once => multible init/closegraphs are possible
  723. * calling cleardevice when creating the window
  724. Revision 1.7 2000/03/05 13:06:32 florian
  725. * the title can be user defined
  726. Revision 1.6 2000/01/07 16:41:52 daniel
  727. * copyright 2000
  728. Revision 1.5 1999/12/08 09:09:34 pierre
  729. + add VESA compatible mode in 16 and 256 colors
  730. Revision 1.4 1999/12/02 00:24:36 pierre
  731. * local var col was undefined
  732. + 640x200 and 640x350 modes added (VGALo and VGAMed)
  733. * WM_PAINT better handled (only requested region written)
  734. Revision 1.3 1999/11/30 22:36:53 florian
  735. * the wm_nc... messages aren't handled anymore it leads to too mch problems ...
  736. Revision 1.2 1999/11/29 22:03:39 florian
  737. * first implementation of winmouse unit
  738. Revision 1.1 1999/11/08 11:15:22 peter
  739. * move graph.inc to the target dir
  740. Revision 1.1 1999/11/03 20:23:02 florian
  741. + first release of win32 gui support
  742. }