graph.inc 23 KB

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