2
0

wviews.pas 65 KB

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