wviews.pas 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566
  1. {
  2. $Id$
  3. This file is part of the Free Pascal Integrated Development Environment
  4. Copyright (c) 1998 by Berczi Gabor
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$I globdir.inc}
  12. unit WViews;
  13. interface
  14. uses Objects,Drivers,Views,Menus,Dialogs;
  15. const
  16. evIdle = $8000;
  17. cmLocalMenu = 54100;
  18. cmUpdate = 54101;
  19. cmListFocusChanged = 54102;
  20. mfUserBtn1 = $00010000;
  21. mfUserBtn2 = $00020000;
  22. mfUserBtn3 = $00040000;
  23. mfUserBtn4 = $00080000;
  24. mfCantCancel = $00100000;
  25. cmUserBtn1 = $fee0;
  26. cmUserBtn2 = $fee1;
  27. cmUserBtn3 = $fee2;
  28. cmUserBtn4 = $fee3;
  29. CPlainCluster = #7#8#9#9;
  30. type
  31. longstring = {$ifdef TP}string{$else}ansistring{$endif};
  32. PCenterDialog = ^TCenterDialog;
  33. TCenterDialog = object(TDialog)
  34. constructor Init(var Bounds: TRect; ATitle: TTitleStr);
  35. end;
  36. PAdvancedMenuBox = ^TAdvancedMenuBox;
  37. TAdvancedMenuBox = object(TMenuBox)
  38. function NewSubView(var Bounds: TRect; AMenu: PMenu;
  39. AParentMenu: PMenuView): PMenuView; virtual;
  40. function Execute: Word; virtual;
  41. end;
  42. PAdvancedMenuPopUp = ^TAdvancedMenuPopup;
  43. TAdvancedMenuPopUp = object(TMenuPopup)
  44. function NewSubView(var Bounds: TRect; AMenu: PMenu;
  45. AParentMenu: PMenuView): PMenuView; virtual;
  46. function Execute: Word; virtual;
  47. end;
  48. PAdvancedMenuBar = ^TAdvancedMenuBar;
  49. TAdvancedMenuBar = object(TMenuBar)
  50. constructor Init(var Bounds: TRect; AMenu: PMenu);
  51. function NewSubView(var Bounds: TRect; AMenu: PMenu;
  52. AParentMenu: PMenuView): PMenuView; virtual;
  53. procedure Update; virtual;
  54. function GetMenuItem(cm : word) : PMenuItem;
  55. procedure HandleEvent(var Event: TEvent); virtual;
  56. function Execute: Word; virtual;
  57. end;
  58. PAdvancedStaticText = ^TAdvancedStaticText;
  59. TAdvancedStaticText = object(TStaticText)
  60. procedure SetText(S: string); virtual;
  61. end;
  62. PAdvancedListBox = ^TAdvancedListBox;
  63. TAdvancedListBox = object(TListBox)
  64. Default: boolean;
  65. procedure FocusItem(Item: sw_integer); virtual;
  66. procedure HandleEvent(var Event: TEvent); virtual;
  67. constructor Load(var S: TStream);
  68. procedure Store(var S: TStream);
  69. end;
  70. PNoUpdateButton = ^TNoUpdateButton;
  71. TNoUpdateButton = object(TButton)
  72. procedure HandleEvent(var Event: TEvent); virtual;
  73. end;
  74. TLocalMenuListBox = object(TAdvancedListBox)
  75. procedure HandleEvent(var Event: TEvent); virtual;
  76. procedure LocalMenu(P: TPoint); virtual;
  77. function GetLocalMenu: PMenu; virtual;
  78. function GetCommandTarget: PView; virtual;
  79. private
  80. LastLocalCmd: word;
  81. end;
  82. PColorStaticText = ^TColorStaticText;
  83. TColorStaticText = object(TAdvancedStaticText)
  84. Color: word;
  85. DontWrap: boolean;
  86. Delta: TPoint;
  87. constructor Init(var Bounds: TRect; AText: String; AColor: word; AWrap: boolean);
  88. function GetPalette: PPalette; virtual;
  89. procedure Draw; virtual;
  90. constructor Load(var S: TStream);
  91. procedure Store(var S: TStream);
  92. end;
  93. PHSListBox = ^THSListBox;
  94. THSListBox = object(TLocalMenuListBox)
  95. constructor Init(var Bounds: TRect; ANumCols: Word; AHScrollBar, AVScrollBar: PScrollBar);
  96. function SaveToFile(const AFileName: string): boolean; virtual;
  97. function SaveAs: Boolean; virtual;
  98. end;
  99. PDlgWindow = ^TDlgWindow;
  100. TDlgWindow = object(TDialog)
  101. constructor Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer);
  102. end;
  103. PAdvancedStatusLine = ^TAdvancedStatusLine;
  104. TAdvancedStatusLine = object(TStatusLine)
  105. StatusText: PString;
  106. function GetStatusText: string; virtual;
  107. procedure SetStatusText(const S: string); virtual;
  108. procedure ClearStatusText; virtual;
  109. procedure Draw; virtual;
  110. end;
  111. PDropDownListBox = ^TDropDownListBox;
  112. PDDHelperLB = ^TDDHelperLB;
  113. TDDHelperLB = object(TLocalMenuListBox)
  114. constructor Init(ALink: PDropDownListBox; var Bounds: TRect; ANumCols: Word; AScrollBar: PScrollBar);
  115. procedure HandleEvent(var Event: TEvent); virtual;
  116. procedure SetState(AState: Word; Enable: Boolean); virtual;
  117. procedure SelectItem(Item: Sw_Integer); virtual;
  118. function GetText(Item,MaxLen: Sw_Integer): String; virtual;
  119. function GetLocalMenu: PMenu; virtual;
  120. function GetCommandTarget: PView; virtual;
  121. private
  122. Link : PDropDownListBox;
  123. LastTT: longint;
  124. InClose: boolean;
  125. end;
  126. TDropDownListBox = object(TView)
  127. Text: string;
  128. Focused: sw_integer;
  129. List: PCollection;
  130. constructor Init(var Bounds: TRect; ADropLineCount: Sw_integer; AList: PCollection);
  131. procedure HandleEvent(var Event: TEvent); virtual;
  132. function GetText(Item: pointer; MaxLen: sw_integer): string; virtual;
  133. procedure NewList(AList: PCollection); virtual;
  134. procedure CreateListBox(var R: TRect);
  135. procedure DropList(Drop: boolean); virtual;
  136. function GetItemCount: sw_integer; virtual;
  137. procedure FocusItem(Item: sw_integer); virtual;
  138. function LBGetLocalMenu: PMenu; virtual;
  139. function LBGetCommandTarget: PView; virtual;
  140. procedure SetState(AState: Word; Enable: Boolean); virtual;
  141. procedure Draw; virtual;
  142. function GetPalette: PPalette; virtual;
  143. destructor Done; virtual;
  144. private
  145. DropLineCount: Sw_integer;
  146. ListDropped : boolean;
  147. ListBox : PDDHelperLB;
  148. SB : PScrollBar;
  149. end;
  150. PGroupView = ^TGroupView;
  151. TGroupView = object(TLabel)
  152. constructor Init(var Bounds: TRect; AText: String; ALink: PView);
  153. procedure Draw; virtual;
  154. end;
  155. PPlainCheckBoxes = ^TPlainCheckBoxes;
  156. TPlainCheckBoxes = object(TCheckBoxes)
  157. function GetPalette: PPalette; virtual;
  158. end;
  159. PPlainRadioButtons = ^TPlainRadioButtons;
  160. TPlainRadioButtons = object(TRadioButtons)
  161. function GetPalette: PPalette; virtual;
  162. end;
  163. PPanel = ^TPanel;
  164. TPanel = object(TGroup)
  165. constructor Init(var Bounds: TRect);
  166. end;
  167. PAdvMessageBox = ^TAdvMessageBox;
  168. TAdvMessageBox = object(TDialog)
  169. CanCancel: boolean;
  170. procedure HandleEvent(var Event: TEvent); virtual;
  171. end;
  172. procedure InsertOK(ADialog: PDialog);
  173. procedure InsertButtons(ADialog: PDialog);
  174. procedure Bug(const S: string; Params: pointer);
  175. procedure ErrorBox(const S: string; Params: pointer);
  176. procedure WarningBox(const S: string; Params: pointer);
  177. procedure InformationBox(const S: string; Params: pointer);
  178. function OKCancelBox(const S: string; Params: pointer): word;
  179. function ConfirmBox(const S: string; Params: pointer; CanCancel: boolean): word;
  180. function ChoiceBox(const S: string; Params: pointer; Buttons: array of string; CanCancel: boolean): word;
  181. procedure ShowMessage(Msg: string);
  182. procedure HideMessage;
  183. function SearchMenuItem(Menu: PMenu; Cmd: word): PMenuItem;
  184. procedure SetMenuItemParam(Menu: PMenuItem; Param: string);
  185. function IsSubMenu(P: PMenuItem): boolean;
  186. function IsSeparator(P: PMenuItem): boolean;
  187. function UpdateMenu(M: PMenu): boolean;
  188. function SearchSubMenu(M: PMenu; Index: Sw_integer): PMenuItem;
  189. procedure AppendMenuItem(M: PMenu; I: PMenuItem);
  190. procedure RemoveMenuItem(Menu: PMenu; I: PMenuItem);
  191. function GetMenuItemBefore(Menu:PMenu; BeforeOf: PMenuItem): PMenuItem;
  192. procedure NotImplemented;
  193. function ColorIndex(Color: byte): word;
  194. var FormatParams : array[1..20] of longint;
  195. FormatParamCount : integer;
  196. FormatParamStrs : array[1..10] of string;
  197. FormatParamStrCount: integer;
  198. procedure ClearFormatParams;
  199. procedure AddFormatParam(P: pointer);
  200. procedure AddFormatParamInt(L: longint);
  201. procedure AddFormatParamChar(C: char);
  202. procedure AddFormatParamStr(const S: string);
  203. function FormatStrF(const Format: string; var Params): string;
  204. function FormatStrStr(const Format, Param: string): string;
  205. function FormatStrStr2(const Format, Param1,Param2: string): string;
  206. function FormatStrStr3(const Format, Param1,Param2,Param3: string): string;
  207. function FormatStrInt(const Format: string; L: longint): string;
  208. const UserButtonName : array[1..4] of string[40] = ('User~1~','User~2~','User~3~','User~4~');
  209. procedure InitAdvMsgBox;
  210. function AdvMessageBox(const Msg: String; Params: Pointer; AOptions: longint): Word;
  211. function AdvMessageBoxRect(var R: TRect; const Msg: String; Params: Pointer; AOptions: longint): Word;
  212. procedure DoneAdvMsgBox;
  213. procedure RegisterWViews;
  214. implementation
  215. uses Mouse,
  216. Resource,
  217. {$ifdef WinClipSupported}
  218. WinClip,
  219. FpConst,
  220. {$endif WinClipSupported}
  221. FVConsts,
  222. App,MsgBox,StdDlg,
  223. WConsts,WUtils;
  224. {$ifndef NOOBJREG}
  225. const
  226. RAdvancedListBox: TStreamRec = (
  227. ObjType: 1120;
  228. VmtLink: Ofs(TypeOf(TAdvancedListBox)^);
  229. Load: @TAdvancedListBox.Load;
  230. Store: @TAdvancedListBox.Store
  231. );
  232. RColorStaticText: TStreamRec = (
  233. ObjType: 1121;
  234. VmtLink: Ofs(TypeOf(TColorStaticText)^);
  235. Load: @TColorStaticText.Load;
  236. Store: @TColorStaticText.Store
  237. );
  238. RHSListBox: TStreamRec = (
  239. ObjType: 1122;
  240. VmtLink: Ofs(TypeOf(THSListBox)^);
  241. Load: @THSListBox.Load;
  242. Store: @THSListBox.Store
  243. );
  244. RDlgWindow: TStreamRec = (
  245. ObjType: 1123;
  246. VmtLink: Ofs(TypeOf(TDlgWindow)^);
  247. Load: @TDlgWindow.Load;
  248. Store: @TDlgWindow.Store
  249. );
  250. {$endif}
  251. const
  252. MessageDialog : PCenterDialog = nil;
  253. UserButtonCmd : array[Low(UserButtonName)..High(UserButtonName)] of word = (cmUserBtn1,cmUserBtn2,cmUserBtn3,cmUserBtn4);
  254. {$ifdef WinClipSupported}
  255. FromWinClipCmds : TCommandSet = ([cmPasteWin]);
  256. {$endif WinClipSupported}
  257. function ColorIndex(Color: byte): word;
  258. begin
  259. ColorIndex:=(Color and $0f)+(Color and $0f) shl 4;
  260. end;
  261. {*****************************************************************************
  262. TCenterDialog
  263. *****************************************************************************}
  264. constructor TCenterDialog.Init(var Bounds: TRect; ATitle: TTitleStr);
  265. begin
  266. inherited Init(Bounds,ATitle);
  267. Options:=Options or ofCentered;
  268. end;
  269. function TAdvancedMenuBox.NewSubView(var Bounds: TRect; AMenu: PMenu;
  270. AParentMenu: PMenuView): PMenuView;
  271. begin
  272. NewSubView := New(PAdvancedMenuBox, Init(Bounds, AMenu, AParentMenu));
  273. end;
  274. function TAdvancedMenuBox.Execute: word;
  275. type
  276. MenuAction = (DoNothing, DoSelect, DoReturn);
  277. var
  278. AutoSelect: Boolean;
  279. Action: MenuAction;
  280. Ch: Char;
  281. Result: Word;
  282. ItemShown, P: PMenuItem;
  283. {$ifdef WinClipSupported}
  284. PPW: PMenuItem;
  285. WinClipEmpty: boolean;
  286. {$endif WinClipSupported}
  287. Target: PMenuView;
  288. R: TRect;
  289. E: TEvent;
  290. MouseActive: Boolean;
  291. function IsDisabled(Item: PMenuItem): boolean;
  292. var Found: boolean;
  293. begin
  294. Found:=Item^.Disabled or IsSeparator(Item);
  295. if (Found=false) and (IsSubMenu(Item)=false) then
  296. Found:=CommandEnabled(Item^.Command)=false;
  297. IsDisabled:=Found;
  298. end;
  299. procedure TrackMouse;
  300. var
  301. Mouse: TPoint;
  302. R: TRect;
  303. begin
  304. MakeLocal(E.Where, Mouse);
  305. Current := Menu^.Items;
  306. while Current <> nil do
  307. begin
  308. GetItemRect(Current, R);
  309. if R.Contains(Mouse) then
  310. begin
  311. MouseActive := True;
  312. Break;
  313. end;
  314. Current := Current^.Next;
  315. end;
  316. if (Current<>nil) and IsDisabled(Current) then
  317. begin
  318. Current:=nil;
  319. MouseActive:=false;
  320. end;
  321. end;
  322. procedure TrackKey(FindNext: Boolean);
  323. procedure NextItem;
  324. begin
  325. Current := Current^.Next;
  326. if Current = nil then Current := Menu^.Items;
  327. end;
  328. procedure PrevItem;
  329. var
  330. P: PMenuItem;
  331. begin
  332. P := Current;
  333. if P = Menu^.Items then P := nil;
  334. repeat NextItem until Current^.Next = P;
  335. end;
  336. begin
  337. if Current <> nil then
  338. repeat
  339. if FindNext then NextItem else PrevItem;
  340. until (Current^.Name <> nil) and (IsDisabled(Current)=false);
  341. end;
  342. function MouseInOwner: Boolean;
  343. var
  344. Mouse: TPoint;
  345. R: TRect;
  346. begin
  347. MouseInOwner := False;
  348. if (ParentMenu <> nil) and (ParentMenu^.Size.Y = 1) then
  349. begin
  350. ParentMenu^.MakeLocal(E.Where, Mouse);
  351. ParentMenu^.GetItemRect(ParentMenu^.Current, R);
  352. MouseInOwner := R.Contains(Mouse);
  353. end;
  354. end;
  355. function MouseInMenus: Boolean;
  356. var
  357. P: PMenuView;
  358. begin
  359. P := ParentMenu;
  360. while (P <> nil) and (P^.MouseInView(E.Where)=false) do
  361. P := P^.ParentMenu;
  362. MouseInMenus := P <> nil;
  363. end;
  364. function TopMenu: PMenuView;
  365. var
  366. P: PMenuView;
  367. begin
  368. P := @Self;
  369. while P^.ParentMenu <> nil do P := P^.ParentMenu;
  370. TopMenu := P;
  371. end;
  372. begin
  373. AutoSelect := False; E.What:=evNothing;
  374. Result := 0;
  375. ItemShown := nil;
  376. {$ifdef WinClipSupported}
  377. PPW:=SearchMenuItem(Menu,cmPasteWin);
  378. if Assigned(PPW) then
  379. begin
  380. WinClipEmpty:=GetTextWinClipboardSize=0;
  381. SetCmdState(FromWinClipCmds,Not WinClipEmpty);
  382. PPW^.disabled:=WinClipEmpty;
  383. end;
  384. {$endif WinClipSupported}
  385. Current := Menu^.Default;
  386. MouseActive := False;
  387. if UpdateMenu(Menu) then
  388. begin
  389. if Current<>nil then
  390. if Current^.Disabled then
  391. TrackKey(true);
  392. repeat
  393. Action := DoNothing;
  394. {$ifdef WinClipSupported}
  395. If Assigned(PPW) then
  396. begin
  397. If WinClipEmpty and (GetTextWinClipboardSize>0) then
  398. begin
  399. WinClipEmpty:=false;
  400. SetCmdState(FromWinClipCmds,true);
  401. PPW^.disabled:=WinClipEmpty;
  402. DrawView;
  403. end
  404. else if Not WinClipEmpty and (GetTextWinClipboardSize=0) then
  405. begin
  406. WinClipEmpty:=true;
  407. SetCmdState(FromWinClipCmds,false);
  408. PPW^.disabled:=WinClipEmpty;
  409. DrawView;
  410. end;
  411. end;
  412. {$endif WinClipSupported}
  413. GetEvent(E);
  414. case E.What of
  415. evMouseDown:
  416. if MouseInView(E.Where) or MouseInOwner then
  417. begin
  418. TrackMouse;
  419. if Size.Y = 1 then AutoSelect := True;
  420. end else Action := DoReturn;
  421. evMouseUp:
  422. begin
  423. TrackMouse;
  424. if MouseInOwner then
  425. Current := Menu^.Default
  426. else
  427. if (Current <> nil) and (Current^.Name <> nil) then
  428. Action := DoSelect
  429. else
  430. if MouseActive or MouseInView(E.Where) then Action := DoReturn
  431. else
  432. begin
  433. Current := Menu^.Default;
  434. if Current = nil then Current := Menu^.Items;
  435. Action := DoNothing;
  436. end;
  437. end;
  438. evMouseMove:
  439. if E.Buttons <> 0 then
  440. begin
  441. TrackMouse;
  442. if not (MouseInView(E.Where) or MouseInOwner) and
  443. MouseInMenus then Action := DoReturn;
  444. end;
  445. evKeyDown:
  446. case CtrlToArrow(E.KeyCode) of
  447. kbUp, kbDown:
  448. if Size.Y <> 1 then
  449. TrackKey(CtrlToArrow(E.KeyCode) = kbDown) else
  450. if E.KeyCode = kbDown then AutoSelect := True;
  451. kbLeft, kbRight:
  452. if ParentMenu = nil then
  453. TrackKey(CtrlToArrow(E.KeyCode) = kbRight) else
  454. Action := DoReturn;
  455. kbHome, kbEnd:
  456. if Size.Y <> 1 then
  457. begin
  458. Current := Menu^.Items;
  459. if E.KeyCode = kbEnd then TrackKey(False);
  460. end;
  461. kbEnter:
  462. begin
  463. if Size.Y = 1 then AutoSelect := True;
  464. Action := DoSelect;
  465. end;
  466. kbEsc:
  467. begin
  468. Action := DoReturn;
  469. if (ParentMenu = nil) or (ParentMenu^.Size.Y <> 1) then
  470. ClearEvent(E);
  471. end;
  472. else
  473. Target := @Self;
  474. Ch := GetAltChar(E.KeyCode);
  475. if Ch = #0 then Ch := E.CharCode else Target := TopMenu;
  476. P := Target^.FindItem(Ch);
  477. if P = nil then
  478. begin
  479. P := TopMenu^.HotKey(E.KeyCode);
  480. if (P <> nil) and CommandEnabled(P^.Command) then
  481. begin
  482. Result := P^.Command;
  483. Action := DoReturn;
  484. end
  485. end else
  486. if Target = @Self then
  487. begin
  488. if Size.Y = 1 then AutoSelect := True;
  489. Action := DoSelect;
  490. Current := P;
  491. end else
  492. if (ParentMenu <> Target) or (ParentMenu^.Current <> P) then
  493. Action := DoReturn;
  494. end;
  495. evCommand:
  496. if E.Command = cmMenu then
  497. begin
  498. AutoSelect := False;
  499. if ParentMenu <> nil then Action := DoReturn;
  500. end else Action := DoReturn;
  501. end;
  502. if ItemShown <> Current then
  503. begin
  504. ItemShown := Current;
  505. DrawView;
  506. end;
  507. if (Action = DoSelect) or ((Action = DoNothing) and AutoSelect) then
  508. if Current <> nil then with Current^ do if Name <> nil then
  509. if Command = 0 then
  510. begin
  511. if E.What and (evMouseDown + evMouseMove) <> 0 then PutEvent(E);
  512. GetItemRect(Current, R);
  513. R.A.X := R.A.X + Origin.X;
  514. R.A.Y := R.B.Y + Origin.Y;
  515. R.B := Owner^.Size;
  516. if Size.Y = 1 then Dec(R.A.X);
  517. Target := TopMenu^.NewSubView(R, SubMenu, @Self);
  518. Result := Owner^.ExecView(Target);
  519. Dispose(Target, Done);
  520. end else if Action = DoSelect then Result := Command;
  521. if (Result <> 0) and CommandEnabled(Result) then
  522. begin
  523. Action := DoReturn;
  524. ClearEvent(E);
  525. end
  526. else
  527. Result := 0;
  528. until Action = DoReturn;
  529. end;
  530. if E.What <> evNothing then
  531. if (ParentMenu <> nil) or (E.What = evCommand) then PutEvent(E);
  532. if Current <> nil then
  533. begin
  534. Menu^.Default := Current;
  535. Current := nil;
  536. DrawView;
  537. end;
  538. Execute := Result;
  539. end;
  540. function TAdvancedMenuPopup.NewSubView(var Bounds: TRect; AMenu: PMenu;
  541. AParentMenu: PMenuView): PMenuView;
  542. begin
  543. NewSubView := New(PAdvancedMenuBox, Init(Bounds, AMenu, AParentMenu));
  544. end;
  545. function TAdvancedMenuPopup.Execute: word;
  546. type
  547. MenuAction = (DoNothing, DoSelect, DoReturn);
  548. var
  549. AutoSelect: Boolean;
  550. Action: MenuAction;
  551. Ch: Char;
  552. Result: Word;
  553. ItemShown, P: PMenuItem;
  554. Target: PMenuView;
  555. R: TRect;
  556. E: TEvent;
  557. MouseActive: Boolean;
  558. function IsDisabled(Item: PMenuItem): boolean;
  559. var Found: boolean;
  560. begin
  561. Found:=Item^.Disabled or IsSeparator(Item);
  562. if (Found=false) and (IsSubMenu(Item)=false) then
  563. Found:=CommandEnabled(Item^.Command)=false;
  564. IsDisabled:=Found;
  565. end;
  566. procedure TrackMouse;
  567. var
  568. Mouse: TPoint;
  569. R: TRect;
  570. { OldC: PMenuItem;}
  571. begin
  572. MakeLocal(E.Where, Mouse);
  573. { OldC:=Current;}
  574. Current := Menu^.Items;
  575. while Current <> nil do
  576. begin
  577. GetItemRect(Current, R);
  578. if R.Contains(Mouse) then
  579. begin
  580. MouseActive := True;
  581. Break;
  582. end;
  583. Current := Current^.Next;
  584. end;
  585. if (Current<>nil) and IsDisabled(Current) then
  586. begin
  587. Current:={OldC}nil;
  588. MouseActive:=false;
  589. end;
  590. end;
  591. procedure TrackKey(FindNext: Boolean);
  592. procedure NextItem;
  593. begin
  594. Current := Current^.Next;
  595. if Current = nil then Current := Menu^.Items;
  596. end;
  597. procedure PrevItem;
  598. var
  599. P: PMenuItem;
  600. begin
  601. P := Current;
  602. if P = Menu^.Items then P := nil;
  603. repeat NextItem until Current^.Next = P;
  604. end;
  605. begin
  606. if Current <> nil then
  607. repeat
  608. if FindNext then NextItem else PrevItem;
  609. until (Current^.Name <> nil) and (IsDisabled(Current)=false);
  610. end;
  611. function MouseInOwner: Boolean;
  612. var
  613. Mouse: TPoint;
  614. R: TRect;
  615. begin
  616. MouseInOwner := False;
  617. if (ParentMenu <> nil) and (ParentMenu^.Size.Y = 1) then
  618. begin
  619. ParentMenu^.MakeLocal(E.Where, Mouse);
  620. ParentMenu^.GetItemRect(ParentMenu^.Current, R);
  621. MouseInOwner := R.Contains(Mouse);
  622. end;
  623. end;
  624. function MouseInMenus: Boolean;
  625. var
  626. P: PMenuView;
  627. begin
  628. P := ParentMenu;
  629. while (P <> nil) and (P^.MouseInView(E.Where)=false) do
  630. P := P^.ParentMenu;
  631. MouseInMenus := P <> nil;
  632. end;
  633. function TopMenu: PMenuView;
  634. var
  635. P: PMenuView;
  636. begin
  637. P := @Self;
  638. while P^.ParentMenu <> nil do P := P^.ParentMenu;
  639. TopMenu := P;
  640. end;
  641. begin
  642. AutoSelect := False; E.What:=evNothing;
  643. Result := 0;
  644. ItemShown := nil;
  645. Current := Menu^.Default;
  646. MouseActive := False;
  647. if UpdateMenu(Menu) then
  648. begin
  649. if Current<>nil then
  650. if Current^.Disabled then
  651. TrackKey(true);
  652. repeat
  653. Action := DoNothing;
  654. GetEvent(E);
  655. case E.What of
  656. evMouseDown:
  657. if MouseInView(E.Where) or MouseInOwner then
  658. begin
  659. TrackMouse;
  660. if Size.Y = 1 then AutoSelect := True;
  661. end else Action := DoReturn;
  662. evMouseUp:
  663. begin
  664. TrackMouse;
  665. if MouseInOwner then
  666. Current := Menu^.Default
  667. else
  668. if (Current <> nil) and (Current^.Name <> nil) then
  669. Action := DoSelect
  670. else
  671. if MouseActive or MouseInView(E.Where) then Action := DoReturn
  672. else
  673. begin
  674. Current := Menu^.Default;
  675. if Current = nil then Current := Menu^.Items;
  676. Action := DoNothing;
  677. end;
  678. end;
  679. evMouseMove:
  680. if E.Buttons <> 0 then
  681. begin
  682. TrackMouse;
  683. if not (MouseInView(E.Where) or MouseInOwner) and
  684. MouseInMenus then Action := DoReturn;
  685. end;
  686. evKeyDown:
  687. case CtrlToArrow(E.KeyCode) of
  688. kbUp, kbDown:
  689. if Size.Y <> 1 then
  690. TrackKey(CtrlToArrow(E.KeyCode) = kbDown) else
  691. if E.KeyCode = kbDown then AutoSelect := True;
  692. kbLeft, kbRight:
  693. if ParentMenu = nil then
  694. TrackKey(CtrlToArrow(E.KeyCode) = kbRight) else
  695. Action := DoReturn;
  696. kbHome, kbEnd:
  697. if Size.Y <> 1 then
  698. begin
  699. Current := Menu^.Items;
  700. if E.KeyCode = kbEnd then TrackKey(False);
  701. end;
  702. kbEnter:
  703. begin
  704. if Size.Y = 1 then AutoSelect := True;
  705. Action := DoSelect;
  706. end;
  707. kbEsc:
  708. begin
  709. Action := DoReturn;
  710. if (ParentMenu = nil) or (ParentMenu^.Size.Y <> 1) then
  711. ClearEvent(E);
  712. end;
  713. else
  714. Target := @Self;
  715. Ch := GetAltChar(E.KeyCode);
  716. if Ch = #0 then Ch := E.CharCode else Target := TopMenu;
  717. P := Target^.FindItem(Ch);
  718. if P = nil then
  719. begin
  720. P := TopMenu^.HotKey(E.KeyCode);
  721. if (P <> nil) and CommandEnabled(P^.Command) then
  722. begin
  723. Result := P^.Command;
  724. Action := DoReturn;
  725. end
  726. end else
  727. if Target = @Self then
  728. begin
  729. if Size.Y = 1 then AutoSelect := True;
  730. Action := DoSelect;
  731. Current := P;
  732. end else
  733. if (ParentMenu <> Target) or (ParentMenu^.Current <> P) then
  734. Action := DoReturn;
  735. end;
  736. evCommand:
  737. if E.Command = cmMenu then
  738. begin
  739. AutoSelect := False;
  740. if ParentMenu <> nil then Action := DoReturn;
  741. end else Action := DoReturn;
  742. end;
  743. if ItemShown <> Current then
  744. begin
  745. ItemShown := Current;
  746. DrawView;
  747. end;
  748. if (Action = DoSelect) or ((Action = DoNothing) and AutoSelect) then
  749. if Current <> nil then with Current^ do if Name <> nil then
  750. if Command = 0 then
  751. begin
  752. if E.What and (evMouseDown + evMouseMove) <> 0 then PutEvent(E);
  753. GetItemRect(Current, R);
  754. R.A.X := R.A.X + Origin.X;
  755. R.A.Y := R.B.Y + Origin.Y;
  756. R.B := Owner^.Size;
  757. if Size.Y = 1 then Dec(R.A.X);
  758. Target := TopMenu^.NewSubView(R, SubMenu, @Self);
  759. Result := Owner^.ExecView(Target);
  760. Dispose(Target, Done);
  761. end else if Action = DoSelect then Result := Command;
  762. if (Result <> 0) and CommandEnabled(Result) then
  763. begin
  764. Action := DoReturn;
  765. ClearEvent(E);
  766. end
  767. else
  768. Result := 0;
  769. until Action = DoReturn;
  770. end;
  771. if E.What <> evNothing then
  772. if (ParentMenu <> nil) or (E.What = evCommand) then PutEvent(E);
  773. if Current <> nil then
  774. begin
  775. Menu^.Default := Current;
  776. Current := nil;
  777. DrawView;
  778. end;
  779. Execute := Result;
  780. end;
  781. constructor TAdvancedMenuBar.Init(var Bounds: TRect; AMenu: PMenu);
  782. begin
  783. inherited Init(Bounds, AMenu);
  784. EventMask:=EventMask or evBroadcast;
  785. GrowMode:=gfGrowHiX;
  786. end;
  787. function TAdvancedMenuBar.NewSubView(var Bounds: TRect; AMenu: PMenu;
  788. AParentMenu: PMenuView): PMenuView;
  789. begin
  790. NewSubView := New(PAdvancedMenuBox, Init(Bounds, AMenu, AParentMenu));
  791. end;
  792. procedure TAdvancedMenuBar.Update;
  793. begin
  794. UpdateMenu(Menu);
  795. DrawView;
  796. end;
  797. function TAdvancedMenuBar.GetMenuItem(cm : word) : PMenuItem;
  798. type
  799. PItemChain = ^TItemChain;
  800. TItemChain = record
  801. Next : PMenuItem;
  802. Up : PItemChain;
  803. end;
  804. var Cur : PMenuItem;
  805. Up,NUp : PItemChain;
  806. begin
  807. Cur:=Menu^.Items;
  808. Up:=nil;
  809. if cm=0 then
  810. begin
  811. GetMenuItem:=nil;
  812. exit;
  813. end;
  814. while assigned(Cur) and (Cur^.Command<>cm) do
  815. begin
  816. if (Cur^.Command=0) and assigned(Cur^.SubMenu) and
  817. assigned(Cur^.Name) and
  818. assigned(Cur^.SubMenu^.Items) then
  819. {subMenu}
  820. begin
  821. If assigned(Cur^.Next) then
  822. begin
  823. New(Nup);
  824. Nup^.Up:=Up;
  825. Nup^.next:=Cur^.Next;
  826. Up:=Nup;
  827. end;
  828. Cur:=Cur^.SubMenu^.Items;
  829. end
  830. else
  831. { normal item }
  832. begin
  833. if assigned(Cur^.Next) then
  834. Cur:=Cur^.Next
  835. else if assigned(Up) then
  836. begin
  837. Cur:=Up^.next;
  838. NUp:=Up;
  839. Up:=Up^.Up;
  840. Dispose(NUp);
  841. end
  842. else
  843. Cur:=Nil;
  844. end;
  845. end;
  846. GetMenuItem:=Cur;
  847. While assigned(Up) do
  848. begin
  849. NUp:=Up;
  850. Up:=Up^.up;
  851. Dispose(NUp);
  852. end;
  853. end;
  854. procedure TAdvancedMenuBar.HandleEvent(var Event: TEvent);
  855. begin
  856. case Event.What of
  857. evBroadcast :
  858. case Event.Command of
  859. cmCommandSetChanged : Update;
  860. cmUpdate : Update;
  861. end;
  862. end;
  863. inherited HandleEvent(Event);
  864. end;
  865. function TAdvancedMenuBar.Execute: word;
  866. type
  867. MenuAction = (DoNothing, DoSelect, DoReturn);
  868. var
  869. AutoSelect: Boolean;
  870. Action: MenuAction;
  871. Ch: Char;
  872. Result: Word;
  873. ItemShown, P: PMenuItem;
  874. Target: PMenuView;
  875. R: TRect;
  876. E: TEvent;
  877. MouseActive: Boolean;
  878. function IsDisabled(Item: PMenuItem): boolean;
  879. var Dis : boolean;
  880. begin
  881. Dis:=Item^.Disabled or IsSeparator(Item);
  882. if (Dis=false) and (IsSubMenu(Item)=false) then
  883. Dis:=CommandEnabled(Item^.Command)=false;
  884. IsDisabled:=Dis;
  885. end;
  886. procedure TrackMouse;
  887. var
  888. Mouse: TPoint;
  889. R: TRect;
  890. OldC: PMenuItem;
  891. begin
  892. MakeLocal(E.Where, Mouse);
  893. OldC:=Current;
  894. Current := Menu^.Items;
  895. while Current <> nil do
  896. begin
  897. GetItemRect(Current, R);
  898. if R.Contains(Mouse) then
  899. begin
  900. MouseActive := True;
  901. Break;
  902. end;
  903. Current := Current^.Next;
  904. end;
  905. if (Current<>nil) and IsDisabled(Current) then
  906. Current:=nil;
  907. end;
  908. procedure TrackKey(FindNext: Boolean);
  909. procedure NextItem;
  910. begin
  911. Current := Current^.Next;
  912. if Current = nil then Current := Menu^.Items;
  913. end;
  914. procedure PrevItem;
  915. var
  916. P: PMenuItem;
  917. begin
  918. P := Current;
  919. if P = Menu^.Items then P := nil;
  920. repeat NextItem until Current^.Next = P;
  921. end;
  922. begin
  923. if Current <> nil then
  924. repeat
  925. if FindNext then NextItem else PrevItem;
  926. until (Current^.Name <> nil) and (IsDisabled(Current)=false);
  927. end;
  928. function MouseInOwner: Boolean;
  929. var
  930. Mouse: TPoint;
  931. R: TRect;
  932. begin
  933. MouseInOwner := False;
  934. if (ParentMenu <> nil) and (ParentMenu^.Size.Y = 1) then
  935. begin
  936. ParentMenu^.MakeLocal(E.Where, Mouse);
  937. ParentMenu^.GetItemRect(ParentMenu^.Current, R);
  938. MouseInOwner := R.Contains(Mouse);
  939. end;
  940. end;
  941. function MouseInMenus: Boolean;
  942. var
  943. P: PMenuView;
  944. begin
  945. P := ParentMenu;
  946. while (P <> nil) and not P^.MouseInView(E.Where) do P := P^.ParentMenu;
  947. MouseInMenus := P <> nil;
  948. end;
  949. function TopMenu: PMenuView;
  950. var
  951. P: PMenuView;
  952. begin
  953. P := @Self;
  954. while P^.ParentMenu <> nil do P := P^.ParentMenu;
  955. TopMenu := P;
  956. end;
  957. begin
  958. AutoSelect := False; E.What:=evNothing;
  959. Result := 0;
  960. ItemShown := nil;
  961. Current := Menu^.Default;
  962. MouseActive := False;
  963. if UpdateMenu(Menu) then
  964. begin
  965. if Current<>nil then
  966. if Current^.Disabled then
  967. TrackKey(true);
  968. repeat
  969. Action := DoNothing;
  970. GetEvent(E);
  971. case E.What of
  972. evMouseDown:
  973. if MouseInView(E.Where) or MouseInOwner then
  974. begin
  975. TrackMouse;
  976. if Size.Y = 1 then AutoSelect := True;
  977. end else Action := DoReturn;
  978. evMouseUp:
  979. begin
  980. TrackMouse;
  981. if MouseInOwner then
  982. Current := Menu^.Default
  983. else
  984. if (Current <> nil) and (Current^.Name <> nil) then
  985. Action := DoSelect
  986. else
  987. if MouseActive or MouseInView(E.Where) then Action := DoReturn
  988. else
  989. begin
  990. Current := Menu^.Default;
  991. if Current = nil then Current := Menu^.Items;
  992. Action := DoNothing;
  993. end;
  994. end;
  995. evMouseMove:
  996. if E.Buttons <> 0 then
  997. begin
  998. TrackMouse;
  999. if not (MouseInView(E.Where) or MouseInOwner) and
  1000. MouseInMenus then Action := DoReturn;
  1001. end;
  1002. evKeyDown:
  1003. case CtrlToArrow(E.KeyCode) of
  1004. kbUp, kbDown:
  1005. if Size.Y <> 1 then
  1006. TrackKey(CtrlToArrow(E.KeyCode) = kbDown) else
  1007. if E.KeyCode = kbDown then AutoSelect := True;
  1008. kbLeft, kbRight:
  1009. if ParentMenu = nil then
  1010. TrackKey(CtrlToArrow(E.KeyCode) = kbRight) else
  1011. Action := DoReturn;
  1012. kbHome, kbEnd:
  1013. if Size.Y <> 1 then
  1014. begin
  1015. Current := Menu^.Items;
  1016. if E.KeyCode = kbEnd then TrackKey(False);
  1017. end;
  1018. kbEnter:
  1019. begin
  1020. if Size.Y = 1 then AutoSelect := True;
  1021. Action := DoSelect;
  1022. end;
  1023. kbEsc:
  1024. begin
  1025. Action := DoReturn;
  1026. if (ParentMenu = nil) or (ParentMenu^.Size.Y <> 1) then
  1027. ClearEvent(E);
  1028. end;
  1029. else
  1030. Target := @Self;
  1031. Ch := GetAltChar(E.KeyCode);
  1032. if Ch = #0 then Ch := E.CharCode else Target := TopMenu;
  1033. P := Target^.FindItem(Ch);
  1034. if P = nil then
  1035. begin
  1036. P := TopMenu^.HotKey(E.KeyCode);
  1037. if (P <> nil) and CommandEnabled(P^.Command) then
  1038. begin
  1039. Result := P^.Command;
  1040. Action := DoReturn;
  1041. end
  1042. end else
  1043. if Target = @Self then
  1044. begin
  1045. if Size.Y = 1 then AutoSelect := True;
  1046. Action := DoSelect;
  1047. Current := P;
  1048. end else
  1049. if (ParentMenu <> Target) or (ParentMenu^.Current <> P) then
  1050. Action := DoReturn;
  1051. end;
  1052. evCommand:
  1053. if E.Command = cmMenu then
  1054. begin
  1055. AutoSelect := False;
  1056. if ParentMenu <> nil then Action := DoReturn;
  1057. end else Action := DoReturn;
  1058. end;
  1059. if ItemShown <> Current then
  1060. begin
  1061. ItemShown := Current;
  1062. DrawView;
  1063. end;
  1064. if (Action = DoSelect) or ((Action = DoNothing) and AutoSelect) then
  1065. if Current <> nil then with Current^ do if Name <> nil then
  1066. if Command = 0 then
  1067. begin
  1068. if E.What and (evMouseDown + evMouseMove) <> 0 then PutEvent(E);
  1069. GetItemRect(Current, R);
  1070. R.A.X := R.A.X + Origin.X;
  1071. R.A.Y := R.B.Y + Origin.Y;
  1072. R.B := Owner^.Size;
  1073. if Size.Y = 1 then Dec(R.A.X);
  1074. Target := TopMenu^.NewSubView(R, SubMenu, @Self);
  1075. Result := Owner^.ExecView(Target);
  1076. Dispose(Target, Done);
  1077. end else if Action = DoSelect then Result := Command;
  1078. if (Result <> 0) and CommandEnabled(Result) then
  1079. begin
  1080. Action := DoReturn;
  1081. ClearEvent(E);
  1082. end
  1083. else
  1084. Result := 0;
  1085. until Action = DoReturn;
  1086. end;
  1087. if E.What <> evNothing then
  1088. if (ParentMenu <> nil) or (E.What = evCommand) then PutEvent(E);
  1089. if Current <> nil then
  1090. begin
  1091. Menu^.Default := Current;
  1092. Current := nil;
  1093. DrawView;
  1094. end;
  1095. Execute := Result;
  1096. end;
  1097. procedure TAdvancedStaticText.SetText(S: string);
  1098. begin
  1099. if Text<>nil then DisposeStr(Text);
  1100. Text:=NewStr(S);
  1101. DrawView;
  1102. end;
  1103. procedure TAdvancedListBox.FocusItem(Item: sw_integer);
  1104. var OFocused: sw_integer;
  1105. begin
  1106. OFocused:=Focused;
  1107. inherited FocusItem(Item);
  1108. if Focused<>OFocused then
  1109. Message(Owner,evBroadcast,cmListFocusChanged,@Self);
  1110. end;
  1111. procedure TAdvancedListBox.HandleEvent(var Event: TEvent);
  1112. begin
  1113. case Event.What of
  1114. evMouseDown :
  1115. if MouseInView(Event.Where) {and (Event.Double)} then
  1116. begin
  1117. inherited HandleEvent(Event);
  1118. if Event.Double then
  1119. if Range>Focused then
  1120. SelectItem(Focused);
  1121. end;
  1122. evBroadcast :
  1123. case Event.Command of
  1124. cmListItemSelected :
  1125. Message(Owner,evBroadcast,cmDefault,nil);
  1126. end;
  1127. end;
  1128. if assigned(VScrollBar) then
  1129. VScrollBar^.HandleEvent(Event);
  1130. if assigned(HScrollBar) then
  1131. HScrollBar^.HandleEvent(Event);
  1132. inherited HandleEvent(Event);
  1133. end;
  1134. constructor TColorStaticText.Init(var Bounds: TRect; AText: String; AColor: word; AWrap: boolean);
  1135. begin
  1136. inherited Init(Bounds,AText);
  1137. DontWrap:=not AWrap;
  1138. Color:=AColor;
  1139. end;
  1140. function TColorStaticText.GetPalette: PPalette;
  1141. begin
  1142. GetPalette:=nil;
  1143. end;
  1144. procedure TColorStaticText.Draw;
  1145. procedure MoveColorTxt(var b;const curs:string;c:word);
  1146. var
  1147. p : ^word;
  1148. i : sw_integer;
  1149. col : byte;
  1150. tilde : boolean;
  1151. begin
  1152. tilde:=false;
  1153. col:=lo(c);
  1154. p:=@b;
  1155. i:=0;
  1156. while (i<length(Curs)) do
  1157. begin
  1158. Inc(i);
  1159. case CurS[i] of
  1160. #1 :
  1161. begin
  1162. Inc(i);
  1163. Col:=ord(curS[i]);
  1164. end;
  1165. #2 :
  1166. begin
  1167. if tilde then
  1168. col:=hi(Color)
  1169. else
  1170. col:=lo(Color)
  1171. end;
  1172. '~' :
  1173. begin
  1174. tilde:=not tilde;
  1175. if tilde then
  1176. col:=hi(Color)
  1177. else
  1178. col:=lo(Color)
  1179. end;
  1180. else
  1181. begin
  1182. p^:=(col shl 8) or ord(curs[i]);
  1183. inc(p);
  1184. end;
  1185. end;
  1186. end;
  1187. end;
  1188. var
  1189. C: word;
  1190. Center: Boolean;
  1191. I, J, L, P, Y: Sw_Integer;
  1192. B: TDrawBuffer;
  1193. S: String;
  1194. T: string;
  1195. CurS: string;
  1196. TildeCount,Po: Sw_integer;
  1197. TempS: string;
  1198. begin
  1199. if Size.X=0 then Exit;
  1200. C:=Color;
  1201. if (C and $0f)=((C and $f0) shr 4) then
  1202. C:=GetColor(C and $0f);
  1203. if DontWrap=false then
  1204. begin
  1205. GetText(S);
  1206. L := Length(S);
  1207. P := 1;
  1208. Y := 0;
  1209. Center := False;
  1210. while Y < Size.Y do
  1211. begin
  1212. MoveChar(B, ' ', Lo(C), Size.X);
  1213. if P <= L then
  1214. begin
  1215. if S[P] = #3 then
  1216. begin
  1217. Center := True;
  1218. Inc(P);
  1219. end;
  1220. I := P;
  1221. repeat
  1222. J := P;
  1223. while (P <= L) and (S[P] = ' ') do Inc(P);
  1224. while (P <= L) and (S[P] <> ' ') and (S[P] <> #13) do Inc(P);
  1225. until (P > L) or (P >= I + Size.X) or (S[P] = #13);
  1226. TildeCount:=0; TempS:=copy(S,I,P-I);
  1227. repeat
  1228. Po:=Pos('~',TempS);
  1229. if Po>0 then begin Inc(TildeCount); Delete(TempS,1,Po); end;
  1230. until Po=0;
  1231. if P > I + Size.X + TildeCount then
  1232. if J > I then P := J else P := I + Size.X;
  1233. T:=copy(S,I,P-I);
  1234. if Center then J := (Size.X - {P + I}CStrLen(T)) div 2 else J := 0;
  1235. MoveColorTxt(B[J],T,C);
  1236. while (P <= L) and (S[P] = ' ') do Inc(P);
  1237. if (P <= L) and (S[P] = #13) then
  1238. begin
  1239. Center := False;
  1240. Inc(P);
  1241. if (P <= L) and (S[P] = #10) then Inc(P);
  1242. end;
  1243. end;
  1244. WriteLine(0, Y, Size.X, 1, B);
  1245. Inc(Y);
  1246. end;
  1247. end { Wrap=false } else
  1248. begin
  1249. GetText(S);
  1250. I:=1;
  1251. for Y:=0 to Size.Y-1 do
  1252. begin
  1253. MoveChar(B, ' ', Lo(C), Size.X);
  1254. CurS:='';
  1255. if S<>'' then
  1256. begin
  1257. P:=Pos(#13,S);
  1258. if P=0 then P:=length(S)+1;
  1259. CurS:=copy(S,1,P-1);
  1260. CurS:=copy(CurS,Delta.X+1,High(CurS));
  1261. CurS:=copy(CurS,1,MaxViewWidth);
  1262. Delete(S,1,P);
  1263. end;
  1264. if CurS<>'' then
  1265. MoveColorTxt(B,CurS,C);
  1266. WriteLine(0,Y,Size.X,1,B);
  1267. end;
  1268. end;
  1269. end;
  1270. constructor TColorStaticText.Load(var S: TStream);
  1271. begin
  1272. inherited Load(S);
  1273. S.Read(Color,SizeOf(Color));
  1274. S.Read(DontWrap,SizeOf(DontWrap));
  1275. S.Read(Delta,SizeOf(Delta));
  1276. end;
  1277. procedure TColorStaticText.Store(var S: TStream);
  1278. begin
  1279. inherited Store(S);
  1280. S.Write(Color,SizeOf(Color));
  1281. S.Write(DontWrap,SizeOf(DontWrap));
  1282. S.Write(Delta,SizeOf(Delta));
  1283. end;
  1284. constructor THSListBox.Init(var Bounds: TRect; ANumCols: Word; AHScrollBar, AVScrollBar: PScrollBar);
  1285. begin
  1286. inherited Init(Bounds,ANumCols,AVScrollBar);
  1287. HScrollBar:=AHScrollBar;
  1288. if assigned(VScrollBar) then
  1289. VScrollBar^.SetStep(Bounds.B.Y-Bounds.A.Y-2,1);
  1290. if assigned(HScrollBar) then
  1291. HScrollBar^.SetStep(Bounds.B.X-Bounds.A.X-2,1);
  1292. end;
  1293. function THSListBox.SaveToFile(const AFileName: string): boolean;
  1294. var OK: boolean;
  1295. S: PBufStream;
  1296. i, count : sw_integer;
  1297. st : string;
  1298. begin
  1299. New(S, Init(AFileName,stCreate,4096));
  1300. OK:=Assigned(S) and (S^.Status=stOK);
  1301. if OK then
  1302. begin
  1303. if assigned(List) then
  1304. Count:=List^.Count
  1305. else
  1306. Count:=0;
  1307. for i:=0 to Count-1 do
  1308. begin
  1309. st:=GetText(i,High(st));
  1310. S^.Write(St[1],length(St));
  1311. if i<Count then
  1312. S^.Write(EOL[1],length(EOL));
  1313. OK:=(S^.Status=stOK);
  1314. if not OK then
  1315. break;
  1316. end;
  1317. end;
  1318. if Assigned(S) then Dispose(S, Done);
  1319. SaveToFile:=OK;
  1320. end;
  1321. function THSListBox.SaveAs: Boolean;
  1322. var
  1323. DefExt,Title,Filename : string;
  1324. Re : word;
  1325. begin
  1326. SaveAs := False;
  1327. Filename:='listbox.txt';
  1328. DefExt:='*.txt';
  1329. Title:='Save list box content';
  1330. Re:=Application^.ExecuteDialog(New(PFileDialog, Init(DefExt,
  1331. Title, label_name, fdOkButton, FileId)), @FileName);
  1332. if Re <> cmCancel then
  1333. SaveAs := SaveToFile(FileName);
  1334. end;
  1335. constructor TDlgWindow.Init(var Bounds: TRect; ATitle: TTitleStr; ANumber: Sw_Integer);
  1336. begin
  1337. inherited Init(Bounds,ATitle);
  1338. Number:=ANumber;
  1339. Flags:=Flags or (wfMove + wfGrow + wfClose + wfZoom);
  1340. end;
  1341. procedure TLocalMenuListBox.LocalMenu(P: TPoint);
  1342. var M: PMenu;
  1343. MV: PAdvancedMenuPopUp;
  1344. R: TRect;
  1345. Re: word;
  1346. begin
  1347. M:=GetLocalMenu;
  1348. if M=nil then Exit;
  1349. if LastLocalCmd<>0 then
  1350. M^.Default:=SearchMenuItem(M,LastLocalCmd);
  1351. Desktop^.GetExtent(R);
  1352. MakeGlobal(P,R.A); {Desktop^.MakeLocal(R.A,R.A);}
  1353. New(MV, Init(R, M));
  1354. Re:=Application^.ExecView(MV);
  1355. if M^.Default=nil then LastLocalCmd:=0
  1356. else LastLocalCmd:=M^.Default^.Command;
  1357. Dispose(MV, Done);
  1358. if Re<>0 then
  1359. Message(GetCommandTarget,evCommand,Re,@Self);
  1360. end;
  1361. function TLocalMenuListBox.GetLocalMenu: PMenu;
  1362. begin
  1363. GetLocalMenu:=nil;
  1364. { Abstract;}
  1365. end;
  1366. function TLocalMenuListBox.GetCommandTarget: PView;
  1367. begin
  1368. GetCommandTarget:=@Self;
  1369. end;
  1370. procedure TLocalMenuListBox.HandleEvent(var Event: TEvent);
  1371. var DontClear: boolean;
  1372. P: TPoint;
  1373. begin
  1374. case Event.What of
  1375. evMouseDown :
  1376. if MouseInView(Event.Where) and (Event.Buttons=mbRightButton) then
  1377. begin
  1378. MakeLocal(Event.Where,P); Inc(P.X); Inc(P.Y);
  1379. LocalMenu(P);
  1380. ClearEvent(Event);
  1381. end;
  1382. evKeyDown :
  1383. begin
  1384. DontClear:=false;
  1385. case Event.KeyCode of
  1386. kbAltF10 : Message(@Self,evCommand,cmLocalMenu,@Self);
  1387. else DontClear:=true;
  1388. end;
  1389. if DontClear=false then ClearEvent(Event);
  1390. end;
  1391. evCommand :
  1392. begin
  1393. DontClear:=false;
  1394. case Event.Command of
  1395. cmLocalMenu :
  1396. begin
  1397. P:=Cursor; Inc(P.X); Inc(P.Y);
  1398. LocalMenu(P);
  1399. end;
  1400. else DontClear:=true;
  1401. end;
  1402. if not DontClear then ClearEvent(Event);
  1403. end;
  1404. end;
  1405. inherited HandleEvent(Event);
  1406. end;
  1407. function TAdvancedStatusLine.GetStatusText: string;
  1408. var S: string;
  1409. begin
  1410. if StatusText=nil then S:='' else S:=StatusText^;
  1411. GetStatusText:=S;
  1412. end;
  1413. procedure TAdvancedStatusLine.SetStatusText(const S: string);
  1414. begin
  1415. if StatusText<>nil then DisposeStr(StatusText);
  1416. StatusText:=NewStr(S);
  1417. DrawView;
  1418. end;
  1419. procedure TAdvancedStatusLine.ClearStatusText;
  1420. begin
  1421. SetStatusText('');
  1422. end;
  1423. procedure TAdvancedStatusLine.Draw;
  1424. var B: TDrawBuffer;
  1425. C: word;
  1426. S: string;
  1427. begin
  1428. S:=GetStatusText;
  1429. if S='' then inherited Draw else
  1430. begin
  1431. C:=GetColor(1);
  1432. MoveChar(B,' ',C,Size.X);
  1433. MoveStr(B[1],S,C);
  1434. WriteLine(0,0,Size.X,Size.Y,B);
  1435. end;
  1436. end;
  1437. procedure Bug(const S: string; Params: pointer);
  1438. begin
  1439. ErrorBox(FormatStrStr(msg_bugcheckfailed,S),Params);
  1440. end;
  1441. procedure ErrorBox(const S: string; Params: pointer);
  1442. begin
  1443. AdvMessageBox(S,Params,mfError+mfInsertInApp+mfOKButton);
  1444. end;
  1445. procedure WarningBox(const S: string; Params: pointer);
  1446. begin
  1447. AdvMessageBox(S,Params,mfWarning+mfInsertInApp+mfOKButton);
  1448. end;
  1449. procedure InformationBox(const S: string; Params: pointer);
  1450. begin
  1451. AdvMessageBox(S,Params,mfInformation+mfInsertInApp+mfOKButton);
  1452. end;
  1453. function OKCancelBox(const S: string; Params: pointer): word;
  1454. begin
  1455. OKCancelBox:=AdvMessageBox(S,Params,mfInformation+mfInsertInApp+mfOKButton+mfCancelButton);
  1456. end;
  1457. function b2i(B: boolean): longint;
  1458. begin
  1459. if b then b2i:=1 else b2i:=0;
  1460. end;
  1461. function ConfirmBox(const S: string; Params: pointer; CanCancel: boolean): word;
  1462. begin
  1463. ConfirmBox:=AdvMessageBox(S,Params,mfConfirmation+mfInsertInApp+mfYesButton+mfNoButton+
  1464. b2i(CanCancel)*mfCancelButton+b2i(not CanCancel)*mfCantCancel);
  1465. end;
  1466. function ChoiceBox(const S: string; Params: pointer; Buttons: array of string; CanCancel: boolean): word;
  1467. var BtnMask,M: longint;
  1468. I,BtnCount: integer;
  1469. begin
  1470. BtnCount:=Min(High(Buttons)-Low(Buttons)+1,High(UserButtonName)-Low(UserButtonName)+1);
  1471. BtnMask:=0; M:=mfUserBtn1;
  1472. for I:=Low(Buttons) to Low(Buttons)+BtnCount-1 do
  1473. begin
  1474. UserButtonName[Low(UserButtonName)+I-Low(Buttons)]:=Buttons[I];
  1475. BtnMask:=BtnMask or M; M:=M shl 1;
  1476. end;
  1477. ChoiceBox:=AdvMessageBox(S,Params,mfConfirmation+BtnMask+
  1478. b2i(CanCancel)*mfCancelButton+b2i(not CanCancel)*mfCantCancel);
  1479. end;
  1480. function IsSeparator(P: PMenuItem): boolean;
  1481. begin
  1482. IsSeparator:=(P<>nil) and (P^.Name=nil) and (P^.HelpCtx=hcNoContext);
  1483. end;
  1484. function IsSubMenu(P: PMenuItem): boolean;
  1485. begin
  1486. IsSubMenu:=(P<>nil) and (P^.Name<>nil) and (P^.Command=0) and (P^.SubMenu<>nil);
  1487. end;
  1488. function SearchMenuItem(Menu: PMenu; Cmd: word): PMenuItem;
  1489. var P,I: PMenuItem;
  1490. begin
  1491. I:=nil;
  1492. if Menu=nil then P:=nil else P:=Menu^.Items;
  1493. while (P<>nil) and (I=nil) do
  1494. begin
  1495. if IsSubMenu(P) then
  1496. I:=SearchMenuItem(P^.SubMenu,Cmd);
  1497. if I=nil then
  1498. if P^.Command=Cmd then I:=P else
  1499. P:=P^.Next;
  1500. end;
  1501. SearchMenuItem:=I;
  1502. end;
  1503. procedure SetMenuItemParam(Menu: PMenuItem; Param: string);
  1504. begin
  1505. if Menu=nil then Exit;
  1506. if Menu^.Param<>nil then DisposeStr(Menu^.Param);
  1507. Menu^.Param:=NewStr(Param);
  1508. end;
  1509. function UpdateMenu(M: PMenu): boolean;
  1510. var P: PMenuItem;
  1511. Enable,
  1512. IsEnabled: boolean;
  1513. begin
  1514. if M=nil then begin UpdateMenu:=false; Exit; end;
  1515. P:=M^.Items; IsEnabled:=false;
  1516. while (P<>nil) do
  1517. begin
  1518. if IsSubMenu(P) then
  1519. begin
  1520. P^.Disabled:=not UpdateMenu(P^.SubMenu);
  1521. if not P^.Disabled then
  1522. IsEnabled:=true;
  1523. end
  1524. else
  1525. begin
  1526. if not IsSeparator(P) and
  1527. Application^.CommandEnabled(P^.Command) then
  1528. begin
  1529. p^.disabled:=false;
  1530. IsEnabled:=true;
  1531. end;
  1532. end;
  1533. P:=P^.Next;
  1534. end;
  1535. UpdateMenu:=IsEnabled;
  1536. end;
  1537. function SearchSubMenu(M: PMenu; Index: Sw_integer): PMenuItem;
  1538. var P,C: PMenuItem;
  1539. Count: Sw_integer;
  1540. begin
  1541. P:=nil; Count:=-1;
  1542. if M<>nil then C:=M^.Items else C:=nil;
  1543. while (C<>nil) and (P=nil) do
  1544. begin
  1545. if IsSubMenu(C) then
  1546. begin
  1547. Inc(Count);
  1548. if Count=Index then P:=C;
  1549. end;
  1550. C:=C^.Next;
  1551. end;
  1552. SearchSubMenu:=P;
  1553. end;
  1554. procedure AppendMenuItem(M: PMenu; I: PMenuItem);
  1555. var P: PMenuItem;
  1556. begin
  1557. if (M=nil) or (I=nil) then Exit;
  1558. I^.Next:=nil;
  1559. if M^.Items=nil then M^.Items:=I else
  1560. begin
  1561. P:=M^.Items;
  1562. while (P^.Next<>nil) do P:=P^.Next;
  1563. P^.Next:=I;
  1564. end;
  1565. end;
  1566. procedure DisposeMenuItem(P: PMenuItem);
  1567. begin
  1568. if P<>nil then
  1569. begin
  1570. if IsSubMenu(P) then DisposeMenu(P^.SubMenu) else
  1571. if IsSeparator(P)=false then
  1572. if P^.Param<>nil then DisposeStr(P^.Param);
  1573. if P^.Name<>nil then DisposeStr(P^.Name);
  1574. Dispose(P);
  1575. end;
  1576. end;
  1577. procedure RemoveMenuItem(Menu: PMenu; I: PMenuItem);
  1578. var P,PrevP: PMenuItem;
  1579. begin
  1580. if (Menu=nil) or (I=nil) then Exit;
  1581. P:=Menu^.Items; PrevP:=nil;
  1582. while (P<>nil) do
  1583. begin
  1584. if P=I then
  1585. begin
  1586. if Menu^.Items<>I then PrevP^.Next:=P^.Next
  1587. else Menu^.Items:=P^.Next;
  1588. DisposeMenuItem(P);
  1589. Break;
  1590. end;
  1591. PrevP:=P; P:=P^.Next;
  1592. end;
  1593. end;
  1594. function GetMenuItemBefore(Menu: PMenu; BeforeOf: PMenuItem): PMenuItem;
  1595. var P,C: PMenuItem;
  1596. begin
  1597. P:=nil;
  1598. if Menu<>nil then C:=Menu^.Items else C:=nil;
  1599. while (C<>nil) do
  1600. begin
  1601. if C^.Next=BeforeOf then begin P:=C; Break; end;
  1602. C:=C^.Next;
  1603. end;
  1604. GetMenuItemBefore:=P;
  1605. end;
  1606. procedure NotImplemented;
  1607. begin
  1608. InformationBox(msg_functionnotimplemented,nil);
  1609. end;
  1610. procedure InsertButtons(ADialog: PDialog);
  1611. var R : TRect;
  1612. W,H : Sw_integer;
  1613. X : Sw_integer;
  1614. X1,X2: Sw_integer;
  1615. begin
  1616. with ADialog^ do
  1617. begin
  1618. GetExtent(R);
  1619. W:=R.B.X-R.A.X; H:=(R.B.Y-R.A.Y);
  1620. R.Assign(0,0,W,H+3); ChangeBounds(R);
  1621. X:=W div 2; X1:=X div 2+1; X2:=X+X1-1;
  1622. R.Assign(X1-3,H,X1+7,H+2);
  1623. Insert(New(PButton, Init(R, btn_OK, cmOK, bfDefault)));
  1624. R.Assign(X2-7,H,X2+3,H+2);
  1625. Insert(New(PButton, Init(R, btn_Cancel, cmCancel, bfNormal)));
  1626. SelectNext(true);
  1627. end;
  1628. end;
  1629. procedure InsertOK(ADialog: PDialog);
  1630. var BW: Sw_integer;
  1631. R: TRect;
  1632. begin
  1633. with ADialog^ do
  1634. begin
  1635. GetBounds(R); R.Grow(0,1); Inc(R.B.Y);
  1636. ChangeBounds(R);
  1637. BW:=10;
  1638. R.A.Y:=R.B.Y-2; R.B.Y:=R.A.Y+2;
  1639. R.A.X:=R.A.X+(R.B.X-R.A.X-BW) div 2; R.B.X:=R.A.X+BW;
  1640. Insert(New(PButton, Init(R, btn_OK, cmOK, bfDefault)));
  1641. SelectNext(true);
  1642. end;
  1643. end;
  1644. procedure ShowMessage(Msg: string);
  1645. var R: TRect;
  1646. Width: Sw_integer;
  1647. begin
  1648. Width:=length(Msg)+4*2;
  1649. if Width<(Desktop^.Size.X div 2) then Width:=(Desktop^.Size.X div 2);
  1650. R.Assign(0,0,Width,5);
  1651. New(MessageDialog, Init(R, ''));
  1652. with MessageDialog^ do
  1653. begin
  1654. Flags:=0;
  1655. GetExtent(R); R.Grow(-4,-2);
  1656. if copy(Msg,1,1)<>^C then Msg:=^C+Msg;
  1657. Insert(New(PStaticText, Init(R, Msg)));
  1658. end;
  1659. Application^.Insert(MessageDialog);
  1660. end;
  1661. procedure HideMessage;
  1662. begin
  1663. if MessageDialog<>nil then
  1664. begin
  1665. Application^.Delete(MessageDialog);
  1666. Dispose(MessageDialog, Done);
  1667. MessageDialog:=nil;
  1668. end;
  1669. end;
  1670. constructor TDDHelperLB.Init(ALink: PDropDownListBox; var Bounds: TRect; ANumCols: Word; AScrollBar: PScrollBar);
  1671. begin
  1672. inherited Init(Bounds,ANumCols,AScrollBar);
  1673. EventMask:=EventMask or (evMouseMove+evIdle);
  1674. { Options:=Options or ofPreProcess;}
  1675. Link:=ALink;
  1676. end;
  1677. procedure TDDHelperLB.SetState(AState: Word; Enable: Boolean);
  1678. {var OState: longint;}
  1679. begin
  1680. { OState:=State;}
  1681. inherited SetState(AState,Enable);
  1682. { if (((State xor OState) and sfFocused)<>0) and (GetState(sfFocused)=false) then
  1683. Link^.DropList(false);}
  1684. end;
  1685. function TDDHelperLB.GetText(Item,MaxLen: Sw_Integer): String;
  1686. var P: pointer;
  1687. S: string;
  1688. begin
  1689. P:=List^.At(Item);
  1690. if Link=nil then S:='' else
  1691. S:=Link^.GetText(P,MaxLen);
  1692. GetText:=S;
  1693. end;
  1694. function TDDHelperLB.GetLocalMenu: PMenu;
  1695. begin
  1696. GetLocalMenu:=Link^.LBGetLocalMenu;
  1697. end;
  1698. function TDDHelperLB.GetCommandTarget: PView;
  1699. begin
  1700. GetCommandTarget:=Link^.LBGetCommandTarget;
  1701. end;
  1702. procedure TDDHelperLB.HandleEvent(var Event: TEvent);
  1703. const
  1704. MouseAutosToSkip = 4;
  1705. var
  1706. Mouse : TPoint;
  1707. OldItem, NewItem : Sw_Integer;
  1708. ColWidth : sw_integer;
  1709. Count : Sw_Word;
  1710. GoSelectItem: sw_integer;
  1711. MouseWhere: TPoint;
  1712. begin
  1713. GoSelectItem:=-1;
  1714. TView.HandleEvent(Event);
  1715. case Event.What of
  1716. evMouseDown :
  1717. if MouseInView(Event.Where)=false then
  1718. GoSelectItem:=-2
  1719. else
  1720. begin
  1721. ColWidth := Size.X div NumCols + 1;
  1722. OldItem := Focused;
  1723. MakeLocal(Event.Where, Mouse);
  1724. if MouseInView(Event.Where) then
  1725. NewItem := Mouse.Y + (Size.Y * (Mouse.X div ColWidth)) + TopItem
  1726. else
  1727. NewItem := OldItem;
  1728. Count := 0;
  1729. repeat
  1730. if NewItem <> OldItem then
  1731. begin
  1732. FocusItemNum(NewItem);
  1733. DrawView;
  1734. end;
  1735. OldItem := NewItem;
  1736. MakeLocal(Event.Where, Mouse);
  1737. if MouseInView(Event.Where) then
  1738. NewItem := Mouse.Y + (Size.Y * (Mouse.X div ColWidth)) + TopItem
  1739. else
  1740. begin
  1741. if NumCols = 1 then
  1742. begin
  1743. if Event.What = evMouseAuto then Inc(Count);
  1744. if Count = MouseAutosToSkip then
  1745. begin
  1746. Count := 0;
  1747. if Mouse.Y < 0 then NewItem := Focused-1
  1748. else if Mouse.Y >= Size.Y then NewItem := Focused+1;
  1749. end;
  1750. end
  1751. else
  1752. begin
  1753. if Event.What = evMouseAuto then Inc(Count);
  1754. if Count = MouseAutosToSkip then
  1755. begin
  1756. Count := 0;
  1757. if Mouse.X < 0 then NewItem := Focused-Size.Y
  1758. else if Mouse.X >= Size.X then NewItem := Focused+Size.Y
  1759. else if Mouse.Y < 0 then
  1760. NewItem := Focused - Focused mod Size.Y
  1761. else if Mouse.Y > Size.Y then
  1762. NewItem := Focused - Focused mod Size.Y + Size.Y - 1;
  1763. end
  1764. end;
  1765. end;
  1766. until not MouseEvent(Event, evMouseMove + evMouseAuto);
  1767. FocusItemNum(NewItem);
  1768. DrawView;
  1769. if Event.Double and (Range > Focused) then SelectItem(Focused);
  1770. ClearEvent(Event);
  1771. GoSelectItem:=Focused;
  1772. end;
  1773. evMouseMove,evMouseAuto:
  1774. if GetState(sfFocused) then
  1775. if MouseInView(Event.Where) then
  1776. begin
  1777. MakeLocal(Event.Where,Mouse);
  1778. FocusItemNum(TopItem+Mouse.Y);
  1779. ClearEvent(Event);
  1780. end;
  1781. evKeyDown :
  1782. begin
  1783. if (Event.KeyCode=kbEsc) then
  1784. begin
  1785. GoSelectItem:=-2;
  1786. ClearEvent(Event);
  1787. end else
  1788. if (Event.CharCode = ' ') and (Focused < Range) then
  1789. begin
  1790. GoSelectItem:=Focused;
  1791. NewItem := Focused;
  1792. end
  1793. else
  1794. case CtrlToArrow(Event.KeyCode) of
  1795. kbUp : NewItem := Focused - 1;
  1796. kbDown : NewItem := Focused + 1;
  1797. kbRight: if NumCols > 1 then NewItem := Focused + Size.Y else Exit;
  1798. kbLeft : if NumCols > 1 then NewItem := Focused - Size.Y else Exit;
  1799. kbPgDn : NewItem := Focused + Size.Y * NumCols;
  1800. kbPgUp : NewItem := Focused - Size.Y * NumCols;
  1801. kbHome : NewItem := TopItem;
  1802. kbEnd : NewItem := TopItem + (Size.Y * NumCols) - 1;
  1803. kbCtrlPgDn: NewItem := Range - 1;
  1804. kbCtrlPgUp: NewItem := 0;
  1805. else
  1806. Exit;
  1807. end;
  1808. FocusItemNum(NewItem);
  1809. DrawView;
  1810. ClearEvent(Event);
  1811. end;
  1812. evBroadcast :
  1813. case Event.Command of
  1814. cmReceivedFocus :
  1815. if (Event.InfoPtr<>@Self) and (InClose=false) then
  1816. begin
  1817. GoSelectItem:=-2;
  1818. end;
  1819. else
  1820. if Options and ofSelectable <> 0 then
  1821. if (Event.Command = cmScrollBarClicked) and
  1822. ((Event.InfoPtr = HScrollBar) or (Event.InfoPtr = VScrollBar)) then
  1823. Select
  1824. else
  1825. if (Event.Command = cmScrollBarChanged) then
  1826. begin
  1827. if (VScrollBar = Event.InfoPtr) then
  1828. begin
  1829. FocusItemNum(VScrollBar^.Value);
  1830. DrawView;
  1831. end
  1832. else
  1833. if (HScrollBar = Event.InfoPtr) then
  1834. DrawView;
  1835. end;
  1836. end;
  1837. evIdle :
  1838. begin
  1839. MouseWhere.X:=MouseWhereX shr 3; MouseWhere.Y:=MouseWhereY shr 3;
  1840. if MouseInView(MouseWhere)=false then
  1841. if abs(GetDosTicks-LastTT)>=1 then
  1842. begin
  1843. LastTT:=GetDosTicks;
  1844. MakeLocal(MouseWhere,Mouse);
  1845. if ((Mouse.Y<-1) or (Mouse.Y>=Size.Y)) and
  1846. ((0<=Mouse.X) and (Mouse.X<Size.X)) then
  1847. if Range>0 then
  1848. if Mouse.Y<0 then
  1849. FocusItemNum(Focused-(0-Mouse.Y))
  1850. else
  1851. FocusItemNum(Focused+(Mouse.Y-(Size.Y-1)));
  1852. end;
  1853. end;
  1854. end;
  1855. if (Range>0) and (GoSelectItem<>-1) then
  1856. begin
  1857. InClose:=true;
  1858. if GoSelectItem=-2 then
  1859. Link^.DropList(false)
  1860. else
  1861. SelectItem(GoSelectItem);
  1862. end;
  1863. end;
  1864. procedure TDDHelperLB.SelectItem(Item: Sw_Integer);
  1865. begin
  1866. inherited SelectItem(Item);
  1867. Link^.FocusItem(Focused);
  1868. Link^.DropList(false);
  1869. end;
  1870. constructor TDropDownListBox.Init(var Bounds: TRect; ADropLineCount: Sw_integer; AList: PCollection);
  1871. begin
  1872. inherited Init(Bounds);
  1873. Options:=Options or (ofSelectable);
  1874. EventMask:=EventMask or (evBroadcast);
  1875. DropLineCount:=ADropLineCount;
  1876. NewList(AList);
  1877. end;
  1878. procedure TDropDownListBox.HandleEvent(var Event: TEvent);
  1879. var DontClear: boolean;
  1880. Count: sw_integer;
  1881. begin
  1882. case Event.What of
  1883. evKeyDown :
  1884. if GetState(sfFocused) then
  1885. begin
  1886. DontClear:=false;
  1887. Count:=GetItemCount;
  1888. if Count>0 then
  1889. case Event.KeyCode of
  1890. kbUp :
  1891. if Focused>0 then
  1892. FocusItem(Focused-1);
  1893. kbDown :
  1894. if Focused<Count-1 then
  1895. FocusItem(Focused+1);
  1896. kbHome :
  1897. FocusItem(0);
  1898. kbEnd :
  1899. FocusItem(Count-1);
  1900. kbPgDn :
  1901. DropList(true);
  1902. else DontClear:=true;
  1903. end;
  1904. if DontClear=false then ClearEvent(Event);
  1905. end;
  1906. evBroadcast :
  1907. case Event.Command of
  1908. { cmReleasedFocus :
  1909. if (ListBox<>nil) and (Event.InfoPtr=ListBox) then
  1910. DropList(false);}
  1911. cmListItemSelected :
  1912. if (ListBox<>nil) and (Event.InfoPtr=ListBox) then
  1913. begin
  1914. FocusItem(ListBox^.Focused);
  1915. Text:=GetText(List^.At(Focused),High(Text));
  1916. DrawView;
  1917. DropList(false);
  1918. end;
  1919. end;
  1920. evMouseDown :
  1921. if MouseInView(Event.Where) then
  1922. begin
  1923. DropList(not ListDropped);
  1924. ClearEvent(Event);
  1925. end;
  1926. end;
  1927. inherited HandleEvent(Event);
  1928. end;
  1929. function TDropDownListBox.GetText(Item: pointer; MaxLen: Sw_integer): string;
  1930. var S: string;
  1931. begin
  1932. S:=GetStr(Item);
  1933. GetText:=copy(S,1,MaxLen);
  1934. end;
  1935. procedure TDropDownListBox.NewList(AList: PCollection);
  1936. begin
  1937. if List<>nil then Dispose(List, Done); List:=nil;
  1938. List:=AList; FocusItem(0);
  1939. end;
  1940. procedure TDropDownListBox.CreateListBox(var R: TRect);
  1941. var R2: TRect;
  1942. begin
  1943. R2.Copy(R); R2.A.X:=R2.B.X-1;
  1944. New(SB, Init(R2));
  1945. Dec(R.B.X);
  1946. New(ListBox, Init(@Self,R,1,SB));
  1947. end;
  1948. procedure TDropDownListBox.DropList(Drop: boolean);
  1949. var R: TRect;
  1950. LB: PListBox;
  1951. begin
  1952. if (ListDropped=Drop) then Exit;
  1953. if Drop then
  1954. begin
  1955. R.Assign(Origin.X+1,Origin.Y+Size.Y,Origin.X+Size.X,Origin.Y+Size.Y+DropLineCount);
  1956. if Owner<>nil then Owner^.Lock;
  1957. CreateListBox(R);
  1958. if SB<>nil then
  1959. Owner^.Insert(SB);
  1960. if ListBox<>nil then
  1961. begin
  1962. ListBox^.NewList(List);
  1963. ListBox^.FocusItem(Focused);
  1964. Owner^.Insert(ListBox);
  1965. end;
  1966. if Owner<>nil then Owner^.UnLock;
  1967. end
  1968. else
  1969. begin
  1970. if Owner<>nil then Owner^.Lock;
  1971. if ListBox<>nil then
  1972. begin
  1973. { ListBox^.List:=nil;}
  1974. LB:=ListBox; ListBox:=nil; { this prevents GPFs while deleting }
  1975. Dispose(LB, Done);
  1976. end;
  1977. if SB<>nil then
  1978. begin
  1979. Dispose(SB, Done);
  1980. SB:=nil;
  1981. end;
  1982. Select;
  1983. if Owner<>nil then Owner^.UnLock;
  1984. end;
  1985. ListDropped:=Drop;
  1986. DrawView;
  1987. end;
  1988. function TDropDownListBox.GetItemCount: sw_integer;
  1989. var Count: sw_integer;
  1990. begin
  1991. if assigned(List)=false then Count:=0 else
  1992. Count:=List^.Count;
  1993. GetItemCount:=Count;
  1994. end;
  1995. procedure TDropDownListBox.FocusItem(Item: sw_integer);
  1996. var P: pointer;
  1997. begin
  1998. Focused:=Item;
  1999. if assigned(ListBox) and (Item>=0) then
  2000. ListBox^.FocusItem(Item);
  2001. if (GetItemCount>0) and (Focused>=0) then
  2002. begin
  2003. P:=List^.At(Focused);
  2004. Text:=GetText(P,Size.X-4);
  2005. end;
  2006. DrawView;
  2007. end;
  2008. function TDropDownListBox.LBGetLocalMenu: PMenu;
  2009. begin
  2010. LBGetLocalMenu:=nil;
  2011. end;
  2012. function TDropDownListBox.LBGetCommandTarget: PView;
  2013. begin
  2014. LBGetCommandTarget:=@Self;
  2015. end;
  2016. procedure TDropDownListBox.SetState(AState: Word; Enable: Boolean);
  2017. begin
  2018. inherited SetState(AState,Enable);
  2019. if (AState and (sfSelected + sfActive + sfFocused)) <> 0 then DrawView;
  2020. end;
  2021. procedure TDropDownListBox.Draw;
  2022. var B: TDrawBuffer;
  2023. C,TextC: word;
  2024. LC: char;
  2025. begin
  2026. if GetState(sfFocused)=false then
  2027. begin
  2028. C:=GetColor(2);
  2029. TextC:=GetColor(2);
  2030. end
  2031. else
  2032. begin
  2033. C:=GetColor(3);
  2034. TextC:=GetColor(3);
  2035. end;
  2036. MoveChar(B,' ',C,Size.X);
  2037. MoveStr(B[1],copy(Text,1,Size.X-2),TextC);
  2038. if ListDropped then LC:=#30 else LC:=#31;
  2039. MoveChar(B[Size.X-2],LC,C,1);
  2040. WriteLine(0,0,Size.X,Size.Y,B);
  2041. end;
  2042. function TDropDownListBox.GetPalette: PPalette;
  2043. const P: string[length(CListViewer)] = CListViewer;
  2044. begin
  2045. GetPalette:=@P;
  2046. end;
  2047. destructor TDropDownListBox.Done;
  2048. begin
  2049. if ListDropped then DropList(false);
  2050. inherited Done;
  2051. end;
  2052. constructor TGroupView.Init(var Bounds: TRect; AText: String; ALink: PView);
  2053. begin
  2054. inherited Init(Bounds,AText,ALink);
  2055. end;
  2056. procedure TGroupView.Draw;
  2057. var B: TDrawBuffer;
  2058. FrameC,LabelC: word;
  2059. begin
  2060. FrameC:=GetColor(1);
  2061. if Light then
  2062. LabelC:=GetColor(2)+GetColor(4) shl 8
  2063. else
  2064. LabelC:=GetColor(1)+GetColor(3) shl 8;
  2065. { First Line }
  2066. MoveChar(B[0],'Ú',FrameC,1);
  2067. MoveChar(B[1],'Ä',FrameC,Size.X-2);
  2068. MoveChar(B[Size.X-1],'¿',FrameC,1);
  2069. if Text<>nil then
  2070. begin
  2071. MoveCStr(B[1],' '+Text^+' ',LabelC);
  2072. end;
  2073. WriteLine(0,0,Size.X,1,B);
  2074. { Mid Lines }
  2075. MoveChar(B[0],'³',FrameC,1);
  2076. MoveChar(B[1],' ',FrameC,Size.X-2);
  2077. MoveChar(B[Size.X-1],'³',FrameC,1);
  2078. WriteLine(0,1,Size.X,Size.Y-2,B);
  2079. { Last Line }
  2080. MoveChar(B[0],'À',FrameC,1);
  2081. MoveChar(B[1],'Ä',FrameC,Size.X-2);
  2082. MoveChar(B[Size.X-1],'Ù',FrameC,1);
  2083. WriteLine(0,Size.Y-1,Size.X,1,B);
  2084. end;
  2085. function TPlainCheckBoxes.GetPalette: PPalette;
  2086. const P: string[length(CPlainCluster)] = CPlainCluster;
  2087. begin
  2088. GetPalette:=@P;
  2089. end;
  2090. function TPlainRadioButtons.GetPalette: PPalette;
  2091. const P: string[length(CPlainCluster)] = CPlainCluster;
  2092. begin
  2093. GetPalette:=@P;
  2094. end;
  2095. constructor TAdvancedListBox.Load(var S: TStream);
  2096. begin
  2097. inherited Load(S);
  2098. S.Read(Default,SizeOf(Default));
  2099. end;
  2100. procedure TAdvancedListBox.Store(var S: TStream);
  2101. begin
  2102. inherited Store(S);
  2103. S.Write(Default,SizeOf(Default));
  2104. end;
  2105. procedure TNoUpdateButton.HandleEvent(var Event: TEvent);
  2106. begin
  2107. if (Event.What<>evBroadcast) or (Event.Command<>cmCommandSetChanged) then
  2108. inherited HandleEvent(Event);
  2109. end;
  2110. constructor TPanel.Init(var Bounds: TRect);
  2111. begin
  2112. inherited Init(Bounds);
  2113. Options:=Options or (ofSelectable+ofTopSelect);
  2114. GrowMode:=gfGrowHiX+gfGrowHiY;
  2115. end;
  2116. procedure TAdvMessageBox.HandleEvent(var Event: TEvent);
  2117. var I: integer;
  2118. begin
  2119. if (not CanCancel) and (Event.What=evCommand) and (Event.Command=cmCancel) then
  2120. ClearEvent(Event);
  2121. inherited HandleEvent(Event);
  2122. case Event.What of
  2123. evCommand:
  2124. begin
  2125. for I:=Low(UserButtonCmd) to High(UserButtonCmd) do
  2126. if Event.Command=UserButtonCmd[I] then
  2127. if State and sfModal <> 0 then
  2128. begin
  2129. EndModal(Event.Command);
  2130. ClearEvent(Event);
  2131. end;
  2132. end;
  2133. end;
  2134. end;
  2135. procedure ClearFormatParams;
  2136. begin
  2137. FormatParamCount:=0; FillChar(FormatParams,sizeof(FormatParams),0);
  2138. FormatParamStrCount:=0;
  2139. end;
  2140. procedure AddFormatParam(P: pointer);
  2141. begin
  2142. AddFormatParamInt(longint(P));
  2143. end;
  2144. procedure AddFormatParamInt(L: longint);
  2145. begin
  2146. Inc(FormatParamCount);
  2147. FormatParams[FormatParamCount]:=L;
  2148. end;
  2149. procedure AddFormatParamChar(C: char);
  2150. begin
  2151. AddFormatParamInt(ord(C));
  2152. end;
  2153. procedure AddFormatParamStr(const S: string);
  2154. begin
  2155. Inc(FormatParamStrCount); FormatParamStrs[FormatParamStrCount]:=S;
  2156. AddFormatParam(@FormatParamStrs[FormatParamStrCount]);
  2157. end;
  2158. function FormatStrF(const Format: string; var Params): string;
  2159. var S: string;
  2160. begin
  2161. S:='';
  2162. FormatStr(S,Format,Params);
  2163. FormatStrF:=S;
  2164. end;
  2165. function FormatStrStr(const Format, Param: string): string;
  2166. var S: string;
  2167. P: pointer;
  2168. begin
  2169. P:=@Param;
  2170. FormatStr(S,Format,P);
  2171. FormatStrStr:=S;
  2172. end;
  2173. function FormatStrStr2(const Format, Param1,Param2: string): string;
  2174. var S: string;
  2175. P: array[1..2] of pointer;
  2176. begin
  2177. P[1]:=@Param1; P[2]:=@Param2;
  2178. FormatStr(S,Format,P);
  2179. FormatStrStr2:=S;
  2180. end;
  2181. function FormatStrStr3(const Format, Param1,Param2,Param3: string): string;
  2182. var S: string;
  2183. P: array[1..3] of pointer;
  2184. begin
  2185. P[1]:=@Param1; P[2]:=@Param2; P[3]:=@Param3;
  2186. FormatStr(S,Format,P);
  2187. FormatStrStr3:=S;
  2188. end;
  2189. function FormatStrInt(const Format: string; L: longint): string;
  2190. var S: string;
  2191. begin
  2192. FormatStr(S,Format,L);
  2193. FormatStrInt:=S;
  2194. end;
  2195. const
  2196. Cmds: array[0..3] of word =
  2197. (cmYes, cmNo, cmOK, cmCancel);
  2198. var
  2199. ButtonName: array[0..3] of string;
  2200. Titles: array[0..3] of string;
  2201. function AdvMessageBox(const Msg: String; Params: Pointer; AOptions: longint): Word;
  2202. var
  2203. R: TRect;
  2204. begin
  2205. R.Assign(0, 0, 0, 0);
  2206. AdvMessageBox := AdvMessageBoxRect(R, Msg, Params, AOptions);
  2207. end;
  2208. procedure GetStaticTextDimensions(const S: string; ViewWidth: integer; var MaxCols, Rows: integer);
  2209. var
  2210. Color: Byte;
  2211. Center: Boolean;
  2212. I, J, L, P, Y: Sw_Integer;
  2213. CurLine: string;
  2214. begin
  2215. MaxCols:=0;
  2216. L := Length(S);
  2217. P := 1;
  2218. Y := 0;
  2219. Center := False;
  2220. while (Y < 32767) and (P<=length(S)) do
  2221. begin
  2222. CurLine:='';
  2223. if P <= L then
  2224. begin
  2225. if S[P] = #3 then
  2226. begin
  2227. Center := True;
  2228. Inc(P);
  2229. end;
  2230. I := P;
  2231. repeat
  2232. J := P;
  2233. while (P <= L) and (S[P] = ' ') do Inc(P);
  2234. while (P <= L) and (S[P] <> ' ') and (S[P] <> #13) do Inc(P);
  2235. until (P > L) or (P >= I + ViewWidth) or (S[P] = #13);
  2236. if P > I + ViewWidth then
  2237. if J > I then P := J else P := I + ViewWidth;
  2238. if Center then J := (ViewWidth - P + I) div 2 else J := 0;
  2239. CurLine:=CurLine+copy(S,I,P-I);
  2240. { MoveBuf(B[J], S[I], Color, P - I);}
  2241. while (P <= L) and (S[P] = ' ') do Inc(P);
  2242. if (P <= L) and (S[P] = #13) then
  2243. begin
  2244. Center := False;
  2245. Inc(P);
  2246. if (P <= L) and (S[P] = #10) then Inc(P);
  2247. end;
  2248. end;
  2249. if length(CurLine)>MaxCols then
  2250. MaxCols:=length(CurLine);
  2251. { WriteLine(0, Y, Size.X, 1, B);}
  2252. Inc(Y);
  2253. end;
  2254. Rows:=Y;
  2255. end;
  2256. function AdvMessageBoxRect(var R: TRect; const Msg: String; Params: Pointer; AOptions: longint): Word;
  2257. var
  2258. I, X, ButtonCount: Sw_Integer;
  2259. Dialog: PAdvMessageBox;
  2260. Control: PView;
  2261. ButtonList: array[0..4] of PView;
  2262. S,BtnName: String;
  2263. Cols,Rows: integer;
  2264. begin
  2265. FormatStr(S, Msg, Params^);
  2266. if R.Empty then
  2267. begin
  2268. GetStaticTextDimensions(S,40,Cols,Rows);
  2269. if Cols<30 then Cols:=30; if Rows=0 then Rows:=1;
  2270. R.Assign(0,0,3+Cols+3,Rows+6);
  2271. if (AOptions and mfInsertInApp)= 0 then
  2272. R.Move((Desktop^.Size.X-(R.B.X-R.A.X)) div 2,(Desktop^.Size.Y-(R.B.Y-R.A.Y)) div 2)
  2273. else
  2274. R.Move((Application^.Size.X-(R.B.X-R.A.X)) div 2,(Application^.Size.Y-(R.B.Y-R.A.Y)) div 2);
  2275. end;
  2276. New(Dialog,Init(R, Titles[AOptions and $3]));
  2277. with Dialog^ do
  2278. begin
  2279. CanCancel:=(Options and mfCantCancel)=0;
  2280. R.Assign(3,2, Size.X-2,Size.Y-3);
  2281. Control := New(PStaticText, Init(R, S));
  2282. Insert(Control);
  2283. X := -2;
  2284. ButtonCount := 0;
  2285. for I := 0 to 3 do
  2286. if AOptions and ($10000 shl I) <> 0 then
  2287. begin
  2288. BtnName:=UserButtonName[I+1];
  2289. R.Assign(0, 0, Max(10,length(BtnName)+2), 2);
  2290. Control := New(PButton, Init(R, BtnName, UserButtonCmd[I+1], bfNormal));
  2291. Inc(X, Control^.Size.X + 2);
  2292. ButtonList[ButtonCount] := Control;
  2293. Inc(ButtonCount);
  2294. end;
  2295. for I := 0 to 3 do
  2296. if AOptions and ($0100 shl I) <> 0 then
  2297. begin
  2298. R.Assign(0, 0, 10, 2);
  2299. Control := New(PButton, Init(R, ButtonName[I], Cmds[i], bfNormal));
  2300. Inc(X, Control^.Size.X + 2);
  2301. ButtonList[ButtonCount] := Control;
  2302. Inc(ButtonCount);
  2303. end;
  2304. X := (Size.X - X) div 2;
  2305. for I := 0 to ButtonCount - 1 do
  2306. begin
  2307. Control := ButtonList[I];
  2308. Insert(Control);
  2309. Control^.MoveTo(X, Size.Y - 3);
  2310. Inc(X, Control^.Size.X + 2);
  2311. end;
  2312. SelectNext(False);
  2313. end;
  2314. if AOptions and mfInsertInApp = 0 then
  2315. AdvMessageBoxRect := DeskTop^.ExecView(Dialog)
  2316. else
  2317. AdvMessageBoxRect := Application^.ExecView(Dialog);
  2318. Dispose(Dialog, Done);
  2319. end;
  2320. procedure InitAdvMsgBox;
  2321. begin
  2322. ButtonName[0] := Labels^.Get(slYes);
  2323. ButtonName[1] := Labels^.Get(slNo);
  2324. ButtonName[2] := Labels^.Get(slOk);
  2325. ButtonName[3] := Labels^.Get(slCancel);
  2326. Titles[0] := Labels^.Get(sWarning);
  2327. Titles[1] := Labels^.Get(sError);
  2328. Titles[2] := Labels^.Get(sInformation);
  2329. Titles[3] := Labels^.Get(sConfirm);
  2330. end;
  2331. procedure DoneAdvMsgBox;
  2332. begin
  2333. end;
  2334. procedure RegisterWViews;
  2335. begin
  2336. {$ifndef NOOBJREG}
  2337. RegisterType(RAdvancedListBox);
  2338. RegisterType(RColorStaticText);
  2339. RegisterType(RHSListBox);
  2340. RegisterType(RDlgWindow);
  2341. {$endif}
  2342. end;
  2343. END.
  2344. {
  2345. $Log$
  2346. Revision 1.10 2004-11-08 20:28:29 peter
  2347. * Breakpoints are now deleted when removed from source, disabling is
  2348. still possible from the breakpoint list
  2349. * COMPILER_1_0, FVISION, GABOR defines removed, only support new
  2350. FV and 1.9.x compilers
  2351. * Run directory added to Run menu
  2352. * Useless programinfo window removed
  2353. Revision 1.9 2004/11/06 17:22:53 peter
  2354. * fixes for new fv
  2355. Revision 1.8 2004/02/13 06:26:46 pierre
  2356. * try to fix webbug 2931 completely
  2357. Revision 1.7 2004/02/10 07:16:28 pierre
  2358. * fix webbug 2932
  2359. Revision 1.6 2002/09/09 07:06:53 pierre
  2360. * avoid a int64 warning
  2361. Revision 1.5 2002/09/07 15:40:50 peter
  2362. * old logs removed and tabs fixed
  2363. Revision 1.4 2002/08/13 07:12:08 pierre
  2364. * use normal strings for ChoiceBox function
  2365. Revision 1.3 2002/04/12 08:59:00 pierre
  2366. + new function OKCancelBox added
  2367. }