_tb2k_2.1.6_patch.diff.txt 60 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748
  1. --- TB2Common.pas 2005-06-29 15:10:10.000000000 +-0400
  2. +++ TB2Common.pas 2005-08-12 08:33:58.000000000 +-0400
  3. @@ -882,46 +882,88 @@
  4. Result := CreateFontIndirect(LogFont);
  5. end;
  6. procedure DrawRotatedText(const DC: HDC; AText: String; const ARect: TRect;
  7. const AFormat: Cardinal);
  8. { Like DrawText, but draws the text at a 270 degree angle.
  9. - The only format flag this function respects is DT_HIDEPREFIX. Text is always
  10. - drawn centered. }
  11. + The format flag this function respects are
  12. + DT_NOPREFIX, DT_HIDEPREFIX, DT_CENTER, DT_END_ELLIPSIS, DT_NOCLIP }
  13. var
  14. RotatedFont, SaveFont: HFONT;
  15. TextMetrics: TTextMetric;
  16. - X, Y, P, I, SU, FU: Integer;
  17. + X, Y, P, I, SU, FU, W: Integer;
  18. SaveAlign: UINT;
  19. SavePen, Pen: HPEN;
  20. + Clip: Boolean;
  21. +
  22. + function GetSize(DC: HDC; const S: string): Integer;
  23. + var
  24. + Size: TSize;
  25. + begin
  26. + GetTextExtentPoint32(DC, PChar(S), Length(S), Size);
  27. + Result := Size.cx;
  28. + end;
  29. +
  30. begin
  31. + if Length(AText) = 0 then Exit;
  32. +
  33. RotatedFont := CreateRotatedFont(DC);
  34. SaveFont := SelectObject(DC, RotatedFont);
  35. GetTextMetrics(DC, TextMetrics);
  36. X := ARect.Left + ((ARect.Right - ARect.Left) - TextMetrics.tmHeight) div 2;
  37. - Y := ARect.Top + ((ARect.Bottom - ARect.Top) - GetTextWidth(DC, AText, True)) div 2;
  38. +
  39. + Clip := (AFormat and DT_NOCLIP) <> DT_NOCLIP;
  40. { Find the index of the character that should be underlined. Delete '&'
  41. characters from the string. Like DrawText, only the last prefixed character
  42. will be underlined. }
  43. P := 0;
  44. I := 1;
  45. - while I <= Length(AText) do begin
  46. - if AText[I] in LeadBytes then
  47. - Inc(I)
  48. - else if AText[I] = '&' then begin
  49. - Delete(AText, I, 1);
  50. - { Note: PChar cast is so that if Delete deleted the last character in
  51. - the string, we don't step past the end of the string (which would cause
  52. - an AV if AText is now empty), but rather look at the null character
  53. - and treat it as an accelerator key like DrawText. }
  54. - if PChar(AText)[I-1] <> '&' then
  55. - P := I;
  56. - end;
  57. - Inc(I);
  58. + if (AFormat and DT_NOPREFIX) <> DT_NOPREFIX then
  59. + while I <= Length(AText) do begin
  60. + if AText[I] in LeadBytes then
  61. + Inc(I)
  62. + else if AText[I] = '&' then begin
  63. + Delete(AText, I, 1);
  64. + { Note: PChar cast is so that if Delete deleted the last character in
  65. + the string, we don't step past the end of the string (which would cause
  66. + an AV if AText is now empty), but rather look at the null character
  67. + and treat it as an accelerator key like DrawText. }
  68. + if PChar(AText)[I-1] <> '&' then
  69. + P := I;
  70. + end;
  71. + Inc(I);
  72. + end;
  73. +
  74. + if (AFormat and DT_END_ELLIPSIS) = DT_END_ELLIPSIS then
  75. + begin
  76. + if (Length(AText) > 1) and (GetSize(DC, AText) > ARect.Bottom - ARect.Top) then
  77. + begin
  78. + W := ARect.Bottom - ARect.Top;
  79. + if W > 2 then
  80. + begin
  81. + Delete(AText, Length(AText), 1);
  82. + while (Length(AText) > 1) and (GetSize(DC, AText + '...') > W) do
  83. + Delete(AText, Length(AText), 1);
  84. + end
  85. + else AText := AText[1];
  86. + if P > Length(AText) then P := 0;
  87. + AText := AText + '...';
  88. + end;
  89. + end;
  90. +
  91. + if (AFormat and DT_CENTER) = DT_CENTER then
  92. + Y := ARect.Top + ((ARect.Bottom - ARect.Top) - GetSize(DC, AText)) div 2
  93. + else
  94. + Y := ARect.Top;
  95. +
  96. + if Clip then
  97. + begin
  98. + SaveDC(DC);
  99. + with ARect do IntersectClipRect(DC, Left, Top, Right, Bottom);
  100. end;
  101. SaveAlign := SetTextAlign(DC, TA_BOTTOM);
  102. TextOut(DC, X, Y, PChar(AText), Length(AText));
  103. SetTextAlign(DC, SaveAlign);
  104. { Underline }
  105. @@ -933,12 +975,14 @@
  106. SavePen := SelectObject(DC, Pen);
  107. MoveToEx(DC, X, Y + SU, nil);
  108. LineTo(DC, X, Y + FU);
  109. SelectObject(DC, SavePen);
  110. DeleteObject(Pen);
  111. end;
  112. +
  113. + if Clip then RestoreDC(DC, -1);
  114. SelectObject(DC, SaveFont);
  115. DeleteObject(RotatedFont);
  116. end;
  117. function NeedToPlaySound(const Alias: String): Boolean;
  118. --- TB2Dock.pas 2005-07-15 14:35:04.000000000 +-0400
  119. +++ TB2Dock.pas 2005-08-11 10:16:22.000000000 +-0400
  120. @@ -76,15 +76,12 @@
  121. {$ENDIF}
  122. { Internal }
  123. FDisableArrangeToolbars: Integer; { Increment to disable ArrangeToolbars }
  124. FArrangeToolbarsNeeded: Boolean;
  125. FNonClientWidth, FNonClientHeight: Integer;
  126. - DockList: TList; { List of the toolbars docked, and those floating and have LastDock
  127. - pointing to the dock. Items are casted in TTBCustomDockableWindow's. }
  128. - DockVisibleList: TList; { Similar to DockList, but lists only docked and visible toolbars }
  129. { Property access methods }
  130. //function GetVersion: TToolbar97Version;
  131. procedure SetAllowDrag(Value: Boolean);
  132. procedure SetBackground(Value: TTBBasicBackground);
  133. procedure SetBackgroundOnToolbars(Value: Boolean);
  134. @@ -96,20 +93,17 @@
  135. function GetToolbarCount: Integer;
  136. function GetToolbars(Index: Integer): TTBCustomDockableWindow;
  137. { Internal }
  138. procedure BackgroundChanged(Sender: TObject);
  139. procedure ChangeDockList(const Insert: Boolean; const Bar: TTBCustomDockableWindow);
  140. - procedure ChangeWidthHeight(const NewWidth, NewHeight: Integer);
  141. procedure CommitPositions;
  142. procedure DrawNCArea(const DrawToDC: Boolean; const ADC: HDC;
  143. const Clip: HRGN);
  144. function GetDesignModeRowOf(const XY: Integer): Integer;
  145. - function HasVisibleToolbars: Boolean;
  146. procedure RelayMsgToFloatingBars(var Message: TMessage);
  147. - function ToolbarVisibleOnDock(const AToolbar: TTBCustomDockableWindow): Boolean;
  148. procedure ToolbarVisibilityChanged(const Bar: TTBCustomDockableWindow;
  149. const ForceRemove: Boolean);
  150. { Messages }
  151. procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
  152. procedure CMDialogKey(var Message: TCMDialogKey); message CM_DIALOGKEY;
  153. @@ -122,27 +116,36 @@
  154. procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
  155. procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT;
  156. procedure WMPrint(var Message: TMessage); message WM_PRINT;
  157. procedure WMPrintClient(var Message: TMessage); message WM_PRINTCLIENT;
  158. procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
  159. protected
  160. + DockList: TList; { List of the toolbars docked, and those floating and have LastDock
  161. + pointing to the dock. Items are casted in TTBCustomDockableWindow's. }
  162. + DockVisibleList: TList; { Similar to DockList, but lists only docked and visible toolbars }
  163. + function Accepts(ADockableWindow: TTBCustomDockableWindow): Boolean; virtual;
  164. procedure AlignControls(AControl: TControl; var Rect: TRect); override;
  165. + procedure ChangeWidthHeight(const NewWidth, NewHeight: Integer);
  166. procedure DrawBackground(DC: HDC; const DrawRect: TRect); virtual;
  167. function GetPalette: HPALETTE; override;
  168. + function HasVisibleToolbars: Boolean;
  169. procedure InvalidateBackgrounds;
  170. procedure Loaded; override;
  171. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  172. procedure SetParent(AParent: TWinControl); override;
  173. + function ToolbarVisibleOnDock(const AToolbar: TTBCustomDockableWindow): Boolean;
  174. procedure Paint; override;
  175. function UsingBackground: Boolean; virtual;
  176. + property ArrangeToolbarsNeeded: Boolean read FArrangeToolbarsNeeded write FArrangeToolbarsNeeded;
  177. + property DisableArrangeToolbars: Integer read FDisableArrangeToolbars write FDisableArrangeToolbars;
  178. public
  179. constructor Create(AOwner: TComponent); override;
  180. procedure CreateParams(var Params: TCreateParams); override;
  181. destructor Destroy; override;
  182. - procedure ArrangeToolbars;
  183. + procedure ArrangeToolbars; virtual;
  184. procedure BeginUpdate;
  185. procedure EndUpdate;
  186. function GetCurrentRowSize(const Row: Integer; var AFullSize: Boolean): Integer;
  187. function GetHighestRow(const HighestEffective: Boolean): Integer;
  188. function GetMinRowSize(const Row: Integer;
  189. const ExcludeControl: TTBCustomDockableWindow): Integer;
  190. @@ -257,12 +260,13 @@
  191. TTBShrinkMode = (tbsmNone, tbsmWrap, tbsmChevron);
  192. TTBCustomDockableWindow = class(TCustomControl)
  193. private
  194. { Property variables }
  195. FAutoResize: Boolean;
  196. + FDblClickUndock: Boolean;
  197. FDockPos, FDockRow, FEffectiveDockPos, FEffectiveDockRow: Integer;
  198. FDocked: Boolean;
  199. FCurrentDock, FDefaultDock, FLastDock: TTBDock;
  200. FCurrentSize: Integer;
  201. FFloating: Boolean;
  202. FOnClose, FOnDockChanged, FOnMove, FOnRecreated,
  203. @@ -419,12 +423,13 @@
  204. function PaletteChanged(Foreground: Boolean): Boolean; override;
  205. procedure SetParent(AParent: TWinControl); override;
  206. { Methods accessible to descendants }
  207. procedure Arrange;
  208. function CalcNCSizes: TPoint; virtual;
  209. + function CanDockTo(ADock: TTBDock): Boolean; virtual;
  210. procedure ChangeSize(AWidth, AHeight: Integer);
  211. function ChildControlTransparent(Ctl: TControl): Boolean; dynamic;
  212. procedure Close;
  213. procedure ControlExistsAtPos(const P: TPoint; var ControlExists: Boolean); virtual;
  214. function DoArrange(CanMoveControls: Boolean; PreviousDockType: TTBDockType;
  215. NewFloating: Boolean; NewDock: TTBDock): TPoint; virtual; abstract;
  216. @@ -443,13 +448,16 @@
  217. function IsAutoResized: Boolean;
  218. procedure ResizeBegin(SizeHandle: TTBSizeHandle); dynamic;
  219. procedure ResizeEnd; dynamic;
  220. procedure ResizeTrack(var Rect: TRect; const OrigRect: TRect); dynamic;
  221. procedure ResizeTrackAccept; dynamic;
  222. procedure SizeChanging(const AWidth, AHeight: Integer); virtual;
  223. + property EffectiveDockPosAccess: Integer read FEffectiveDockPos write FEffectiveDockPos;
  224. + property EffectiveDockRowAccess: Integer read FEffectiveDockRow write FEffectiveDockRow;
  225. public
  226. + property DblClickUndock: Boolean read FDblClickUndock write FDblClickUndock default True;
  227. property Docked: Boolean read FDocked;
  228. property Canvas;
  229. property CurrentDock: TTBDock read FCurrentDock write SetCurrentDock stored False;
  230. property CurrentSize: Integer read FCurrentSize write FCurrentSize;
  231. property DockPos: Integer read FDockPos write SetDockPos default -1;
  232. property DockRow: Integer read FDockRow write SetDockRow default 0;
  233. @@ -1011,12 +1019,17 @@
  234. SetBounds(Left, Top-NewHeight+Height, NewWidth, NewHeight);
  235. alRight:
  236. SetBounds(Left-NewWidth+Width, Top, NewWidth, NewHeight);
  237. end;
  238. end;
  239. +function TTBDock.Accepts(ADockableWindow: TTBCustomDockableWindow): Boolean;
  240. +begin
  241. + Result := AllowDrag;
  242. +end;
  243. +
  244. procedure TTBDock.AlignControls(AControl: TControl; var Rect: TRect);
  245. begin
  246. ArrangeToolbars;
  247. end;
  248. function CompareDockRowPos(const Item1, Item2, ExtraData: Pointer): Integer; far;
  249. @@ -2523,12 +2536,13 @@
  250. [csAcceptsControls, csClickEvents, csDoubleClicks, csSetCaption] -
  251. [csCaptureMouse{capturing is done manually}, csOpaque];
  252. FAutoResize := True;
  253. FActivateParent := True;
  254. FBorderStyle := bsSingle;
  255. FCloseButton := True;
  256. + FDblClickUndock := True;
  257. FDockableTo := [dpTop, dpBottom, dpLeft, dpRight];
  258. FDockableWindowStyles := [tbdsResizeEightCorner, tbdsResizeClipCursor];
  259. FDockPos := -1;
  260. FDragHandleStyle := dhSingle;
  261. FEffectiveDockRow := -1;
  262. FHideWhenInactive := True;
  263. @@ -3020,12 +3034,17 @@
  264. procedure TTBCustomDockableWindow.RemoveDockForm(const Form: TTBCustomForm);
  265. begin
  266. RemoveFromList(FDockForms, Form);
  267. end;
  268. +function TTBCustomDockableWindow.CanDockTo(ADock: TTBDock): Boolean;
  269. +begin
  270. + Result := ADock.Position in DockableTo;
  271. +end;
  272. +
  273. function TTBCustomDockableWindow.IsAutoResized: Boolean;
  274. begin
  275. Result := AutoResize or Assigned(CurrentDock) or Floating;
  276. end;
  277. procedure TTBCustomDockableWindow.ChangeSize(AWidth, AHeight: Integer);
  278. @@ -3912,13 +3931,14 @@
  279. if FDragSplitting then
  280. MouseOverDock := CurrentDock
  281. else begin
  282. { Check if it can dock }
  283. MouseOverDock := nil;
  284. if StartDocking and not PreventDocking then
  285. - for I := 0 to DockList.Count-1 do begin
  286. + {for I := 0 to DockList.Count-1 do begin} {rl-}
  287. + for I := DockList.Count-1 downto 0 do begin {rl+} // Robert Lee: CurrentDock should not have the priority
  288. Dock := DockList[I];
  289. if CheckIfCanDockTo(Dock, FindDockedSize(Dock).BoundsRect) then begin
  290. MouseOverDock := Dock;
  291. Accept := True;
  292. if Assigned(MouseOverDock.FOnRequestDock) then
  293. MouseOverDock.FOnRequestDock(MouseOverDock, Self, Accept);
  294. @@ -3988,17 +4008,12 @@
  295. if not IsRectEmpty(MoveRect) then
  296. Dropped;
  297. end;
  298. procedure BuildDockList;
  299. - function AcceptableDock(const D: TTBDock): Boolean;
  300. - begin
  301. - Result := D.FAllowDrag and (D.Position in DockableTo);
  302. - end;
  303. -
  304. procedure Recurse(const ParentCtl: TWinControl);
  305. var
  306. D: TTBDockPosition;
  307. I: Integer;
  308. begin
  309. if ContainsControl(ParentCtl) or not ParentCtl.Showing then
  310. @@ -4009,25 +4024,25 @@
  311. if (Controls[I] is TTBDock) and (TTBDock(Controls[I]).Position = D) then
  312. Recurse(TWinControl(Controls[I]));
  313. for I := 0 to ParentCtl.ControlCount-1 do
  314. if (Controls[I] is TWinControl) and not(Controls[I] is TTBDock) then
  315. Recurse(TWinControl(Controls[I]));
  316. end;
  317. - if (ParentCtl is TTBDock) and AcceptableDock(TTBDock(ParentCtl)) and
  318. + if (ParentCtl is TTBDock) and TTBDock(ParentCtl).Accepts(Self) and CanDockTo(TTBDock(ParentCtl)) and
  319. (DockList.IndexOf(ParentCtl) = -1) then
  320. DockList.Add(ParentCtl);
  321. end;
  322. var
  323. ParentForm: TTBCustomForm;
  324. DockFormsList: TList;
  325. I, J: Integer;
  326. begin
  327. { Manually add CurrentDock to the DockList first so that it gets priority
  328. over other docks }
  329. - if Assigned(CurrentDock) and AcceptableDock(CurrentDock) then
  330. + if Assigned(CurrentDock) and CurrentDock.Accepts(Self) and CanDockTo(CurrentDock) then
  331. DockList.Add(CurrentDock);
  332. ParentForm := TBGetToolWindowParentForm(Self);
  333. DockFormsList := TList.Create;
  334. try
  335. if Assigned(FDockForms) then begin
  336. for I := 0 to Screen.{$IFDEF JR_D3}CustomFormCount{$ELSE}FormCount{$ENDIF}-1 do begin
  337. @@ -4313,25 +4328,26 @@
  338. end;
  339. end;
  340. procedure TTBCustomDockableWindow.DoubleClick;
  341. begin
  342. if Docked then begin
  343. - if DockMode = dmCanFloat then begin
  344. + if DblClickUndock and (DockMode = dmCanFloat) then begin
  345. Floating := True;
  346. MoveOnScreen(True);
  347. end;
  348. end
  349. - else
  350. - if Assigned(LastDock) then
  351. - Parent := LastDock
  352. - else
  353. - if Assigned(DefaultDock) then begin
  354. - FDockRow := ForceDockAtTopRow;
  355. - FDockPos := ForceDockAtLeftPos;
  356. - Parent := DefaultDock;
  357. + else if Floating then begin
  358. + if Assigned(LastDock) then
  359. + Parent := LastDock
  360. + else
  361. + if Assigned(DefaultDock) then begin
  362. + FDockRow := ForceDockAtTopRow;
  363. + FDockPos := ForceDockAtLeftPos;
  364. + Parent := DefaultDock;
  365. + end;
  366. end;
  367. end;
  368. function TTBCustomDockableWindow.IsMovable: Boolean;
  369. begin
  370. Result := (Docked and CurrentDock.FAllowDrag) or Floating;
  371. --- TB2DsgnItemEditor.pas 2005-01-27 00:48:54.000000000 +-0400
  372. +++ TB2DsgnItemEditor.pas 2005-05-17 19:26:48.000000000 +-0400
  373. @@ -149,12 +149,18 @@
  374. function GetValue: String; override;
  375. end;
  376. procedure TBRegisterItemClass(AClass: TTBCustomItemClass;
  377. const ACaption: String; ResInstance: HINST);
  378. +type
  379. + TTBDsgnEditorHook = procedure(Sender: TTBItemEditForm) of object;
  380. +
  381. +procedure TBRegisterDsgnEditorHook(Hook: TTBDsgnEditorHook);
  382. +procedure TBUnregisterDsgnEditorHook(Hook: TTBDsgnEditorHook);
  383. +
  384. implementation
  385. {$R *.DFM}
  386. uses
  387. TypInfo, CommCtrl, TB2Version, TB2Common, TB2DsgnConverter;
  388. @@ -176,12 +182,13 @@
  389. ImageIndex: Integer;
  390. end;
  391. var
  392. ItemClasses: TList;
  393. ItemImageList: TImageList;
  394. + EditFormHooks: TList;
  395. {$IFNDEF JR_D6}
  396. function CreateSelectionList: TDesignerSelectionList;
  397. begin
  398. Result := TDesignerSelectionList.Create;
  399. end;
  400. @@ -237,13 +244,24 @@
  401. end;
  402. procedure TBRegisterItemClass(AClass: TTBCustomItemClass;
  403. const ACaption: String; ResInstance: HINST);
  404. var
  405. Info: PItemClassInfo;
  406. + I: Integer;
  407. begin
  408. + if ItemClasses <> nil then
  409. + for I := ItemClasses.Count - 1 downto 0 do
  410. + begin
  411. + Info := ItemClasses[I];
  412. + if Info.ItemClass = AClass then
  413. + begin
  414. + Dispose(Info);
  415. + ItemClasses.Delete(I);
  416. + end;
  417. + end;
  418. New(Info);
  419. Info.ItemClass := AClass;
  420. Info.Caption := ACaption;
  421. Info.ImageIndex := LoadItemImage(ResInstance, Uppercase(AClass.ClassName));
  422. ItemClasses.Add(Info);
  423. end;
  424. @@ -357,12 +375,17 @@
  425. Item.Caption := Info.Caption;
  426. Item.ImageIndex := GetItemClassImage(Info.ItemClass);
  427. Item.Tag := Integer(Info.ItemClass);
  428. Item.OnClick := MoreItemClick;
  429. MoreMenu.Add(Item);
  430. end;
  431. + { Run the hooks }
  432. +
  433. + if EditFormHooks <> nil then
  434. + for I := 0 to EditFormHooks.Count - 1 do
  435. + TTBDsgnEditorHook(EditFormHooks[I]^)(Self);
  436. end;
  437. destructor TTBItemEditForm.Destroy;
  438. begin
  439. inherited;
  440. if Assigned(FNotifyItemList) then begin
  441. @@ -1332,17 +1355,47 @@
  442. function TTBItemsPropertyEditor.GetValue: String;
  443. begin
  444. Result := '(TB2000 Items)';
  445. end;
  446. +
  447. +procedure TBRegisterDsgnEditorHook(Hook: TTBDsgnEditorHook);
  448. +var
  449. + H: ^TTBDsgnEditorHook;
  450. +begin
  451. + New(H);
  452. + H^ := Hook;
  453. + EditFormHooks.Add(H);
  454. +end;
  455. +
  456. +procedure TBUnregisterDsgnEditorHook(Hook: TTBDsgnEditorHook);
  457. +var
  458. + H: ^TTBDsgnEditorHook;
  459. + I: Integer;
  460. +begin
  461. + for I := EditFormHooks.Count - 1 downto 0 do
  462. + begin
  463. + H := EditFormHooks[I];
  464. + if (TMethod(H^).Code = TMethod(Hook).Code) and
  465. + (TMethod(H^).Data = TMethod(Hook).Data) then
  466. + begin
  467. + Dispose(H);
  468. + EditFormHooks.Delete(I);
  469. +// Break;
  470. + end;
  471. + end;
  472. +end;
  473. +
  474. initialization
  475. ItemImageList := TImageList.Create(nil);
  476. ItemImageList.Handle := ImageList_LoadImage(HInstance, 'TB2_DSGNEDITORIMAGES',
  477. 16, 0, clFuchsia, IMAGE_BITMAP, 0);
  478. ItemClasses := TList.Create;
  479. + EditFormHooks := TList.Create;
  480. AddModuleUnloadProc(UnregisterModuleItemClasses);
  481. finalization
  482. RemoveModuleUnloadProc(UnregisterModuleItemClasses);
  483. FreeItemClasses;
  484. FreeAndNil(ItemImageList);
  485. + FreeAndNil(EditFormHooks);
  486. end.
  487. --- TB2ExtItems.pas 2005-07-03 21:49:52.000000000 +-0400
  488. +++ TB2ExtItems.pas 2005-07-11 04:36:00.000000000 +-0400
  489. @@ -40,12 +40,17 @@
  490. TTBEditItemOptions = set of TTBEditItemOption;
  491. const
  492. EditItemDefaultEditOptions = [];
  493. EditItemDefaultEditWidth = 64;
  494. +{ Change reasons for TTBEditItem.Text property }
  495. + tcrSetProperty = 0; // direct assignment to TTBEditItem.Text property
  496. + tcrActionLink = 1; // change comes from an action link
  497. + tcrEditControl = 2; // change is caused by typing in edit area
  498. +
  499. type
  500. TTBEditItem = class;
  501. TTBEditItemViewer = class;
  502. TTBAcceptTextEvent = procedure(Sender: TObject; var NewText: String;
  503. var Accept: Boolean) of object;
  504. @@ -93,12 +98,13 @@
  505. TTBEditItem = class(TTBCustomItem)
  506. private
  507. FCharCase: TEditCharCase;
  508. FEditCaption: String;
  509. FEditOptions: TTBEditItemOptions;
  510. FEditWidth: Integer;
  511. + FExtendedAccept: Boolean;
  512. FMaxLength: Integer;
  513. FOnAcceptText: TTBAcceptTextEvent;
  514. FOnBeginEdit: TTBBeginEditEvent;
  515. FText: String;
  516. function IsEditCaptionStored: Boolean;
  517. function IsEditOptionsStored: Boolean;
  518. @@ -109,16 +115,21 @@
  519. procedure SetEditOptions(Value: TTBEditItemOptions);
  520. procedure SetEditWidth(Value: Integer);
  521. procedure SetMaxLength(Value: Integer);
  522. procedure SetText(Value: String);
  523. protected
  524. procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
  525. + function DoAcceptText(var NewText: string): Boolean; virtual;
  526. procedure DoBeginEdit(Viewer: TTBEditItemViewer); virtual;
  527. + procedure DoTextChanging(const OldText: String; var NewText: String; Reason: Integer); virtual;
  528. + procedure DoTextChanged(Reason: Integer); virtual;
  529. function GetActionLinkClass: TTBCustomItemActionLinkClass; override;
  530. function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; override;
  531. function NeedToRecreateViewer(AViewer: TTBItemViewer): Boolean; override;
  532. + property ExtendedAccept: Boolean read FExtendedAccept write FExtendedAccept default False;
  533. + procedure SetTextEx(Value: String; Reason: Integer);
  534. public
  535. constructor Create(AOwner: TComponent); override;
  536. procedure Clear;
  537. procedure Click; override;
  538. published
  539. property Action;
  540. @@ -143,12 +154,14 @@
  541. property OnAcceptText: TTBAcceptTextEvent read FOnAcceptText write FOnAcceptText;
  542. property OnBeginEdit: TTBBeginEditEvent read FOnBeginEdit write FOnBeginEdit;
  543. property OnClick;
  544. property OnSelect;
  545. end;
  546. +
  547. + TEditClass = class of TEdit;
  548. TTBEditItemViewer = class(TTBItemViewer)
  549. private
  550. FEditControl: TEdit;
  551. FEditControlStatus: set of (ecsContinueLoop, ecsAccept, ecsClose);
  552. function EditLoop(const CapHandle: HWND): Boolean;
  553. @@ -160,12 +173,13 @@
  554. function CaptionShown: Boolean; override;
  555. function DoExecute: Boolean; override;
  556. function GetAccRole: Integer; override;
  557. function GetAccValue(var Value: WideString): Boolean; override;
  558. function GetCaptionText: String; override;
  559. procedure GetCursor(const Pt: TPoint; var ACursor: HCURSOR); override;
  560. + function GetEditControlClass: TEditClass; virtual;
  561. procedure GetEditRect(var R: TRect); virtual;
  562. procedure MouseDown(Shift: TShiftState; X, Y: Integer;
  563. var MouseDownOnMenu: Boolean); override;
  564. procedure MouseUp(X, Y: Integer; MouseWasDownOnMenu: Boolean); override;
  565. procedure Paint(const Canvas: TCanvas; const ClientAreaRect: TRect;
  566. IsSelected, IsPushed, UseDisabledShadow: Boolean); override;
  567. @@ -363,13 +377,13 @@
  568. begin
  569. if IsOnAcceptTextLinked then TTBEditItem(FClient).OnAcceptText := Value;
  570. end;
  571. procedure TTBEditItemActionLink.SetText(const Value: String);
  572. begin
  573. - if IsTextLinked then TTBEditItem(FClient).Text := Value;
  574. + if IsTextLinked then TTBEditItem(FClient).SetTextEx(Value , tcrActionLink);
  575. end;
  576. { TTBEditItem }
  577. constructor TTBEditItem.Create(AOwner: TComponent);
  578. @@ -387,13 +401,13 @@
  579. begin
  580. if not CheckDefaults or (Self.EditCaption = '') then
  581. Self.EditCaption := EditCaption;
  582. if not CheckDefaults or (Self.EditOptions = []) then
  583. Self.EditOptions := EditOptions;
  584. if not CheckDefaults or (Self.Text = '') then
  585. - Self.Text := Text;
  586. + Self.SetTextEx(Text, tcrActionLink);
  587. if not CheckDefaults or not Assigned(Self.OnAcceptText) then
  588. Self.OnAcceptText := OnAcceptText;
  589. end;
  590. end;
  591. function TTBEditItem.GetActionLinkClass: TTBCustomItemActionLinkClass;
  592. @@ -494,21 +508,47 @@
  593. if FMaxLength <> Value then begin
  594. FMaxLength := Value;
  595. Change(False);
  596. end;
  597. end;
  598. +function TTBEditItem.DoAcceptText(var NewText: string): Boolean;
  599. +begin
  600. + Result := True;
  601. + if Assigned(FOnAcceptText) then FOnAcceptText(Self, NewText, Result);
  602. +end;
  603. +
  604. +procedure TTBEditItem.DoTextChanging(const OldText: String; var NewText: String; Reason: Integer);
  605. +begin
  606. + case FCharCase of
  607. + ecUpperCase: NewText := AnsiUpperCase(NewText);
  608. + ecLowerCase: NewText := AnsiLowerCase(NewText);
  609. + end;
  610. +end;
  611. +
  612. +procedure TTBEditItem.DoTextChanged(Reason: Integer);
  613. +begin
  614. +end;
  615. +
  616. procedure TTBEditItem.SetText(Value: String);
  617. begin
  618. - case FCharCase of
  619. - ecUpperCase: Value := AnsiUpperCase(Value);
  620. - ecLowerCase: Value := AnsiLowerCase(Value);
  621. - end;
  622. + DoTextChanging(FText, Value, tcrSetProperty);
  623. + if FText <> Value then begin
  624. + FText := Value;
  625. + Change(False);
  626. + DoTextChanged(tcrSetProperty);
  627. + end;
  628. +end;
  629. +
  630. +procedure TTBEditItem.SetTextEx(Value: String; Reason: Integer);
  631. +begin
  632. + DoTextChanging(FText, Value, Reason);
  633. if FText <> Value then begin
  634. FText := Value;
  635. Change(False);
  636. + DoTextChanged(Reason);
  637. end;
  638. end;
  639. { TTBEditItemViewer }
  640. @@ -516,20 +556,15 @@
  641. var
  642. Item: TTBEditItem;
  643. procedure AcceptText;
  644. var
  645. S: String;
  646. - Accept: Boolean;
  647. begin
  648. S := FEditControl.Text;
  649. - Accept := True;
  650. - if Assigned(Item.FOnAcceptText) then
  651. - Item.FOnAcceptText(Self, S, Accept);
  652. - if Accept then
  653. - Item.Text := S;
  654. + if Item.DoAcceptText(S) then Item.SetTextEx(S, tcrEditControl);
  655. end;
  656. begin
  657. Item := TTBEditItem(Self.Item);
  658. if FEditControl = nil then
  659. Exit;
  660. @@ -555,12 +590,17 @@
  661. { Someone has stolen the focus from us, so 'cancel mode'. (We have to
  662. handle WM_KILLFOCUS in addition to the upstream WM_CANCELMODE handling
  663. since we don't always hold the mouse capture.) }
  664. View.CancelMode;
  665. FEditControlStatus := [ecsClose];
  666. end;
  667. +end;
  668. +
  669. +function TTBEditItemViewer.GetEditControlClass: TEditClass;
  670. +begin
  671. + Result := TEdit;
  672. end;
  673. procedure TTBEditItemViewer.GetEditRect(var R: TRect);
  674. var
  675. Item: TTBEditItem;
  676. DC: HDC;
  677. @@ -785,12 +825,13 @@
  678. end;
  679. var
  680. Item: TTBEditItem;
  681. R: TRect;
  682. ActiveWnd, FocusWnd: HWND;
  683. + S: string;
  684. begin
  685. Item := TTBEditItem(Self.Item);
  686. GetEditRect(R);
  687. if IsRectEmpty(R) then begin
  688. Result := False;
  689. Exit;
  690. @@ -798,14 +839,14 @@
  691. ActiveWnd := GetActiveWindow;
  692. FocusWnd := GetFocus;
  693. { Create the edit control }
  694. InflateRect(R, -3, -3);
  695. - //View.FreeNotification(Self);
  696. - FEditControl := TEdit.Create(nil);
  697. + //View.FreeNotification (Self);
  698. + FEditControl := GetEditControlClass.Create(nil);
  699. try
  700. FEditControl.Name := Format('%s_edit_control_%p', [ClassName,
  701. Pointer(FEditControl)]);
  702. FEditControl.Visible := False;
  703. FEditControl.BorderStyle := bsNone;
  704. FEditControl.AutoSize := False;
  705. @@ -826,14 +867,19 @@
  706. else
  707. ActiveWnd := 0;
  708. FEditControlStatus := [ecsContinueLoop];
  709. ControlMessageLoop;
  710. finally
  711. + S := FEditControl.Text;
  712. FreeAndNil(FEditControl);
  713. end;
  714. +
  715. + with TTBEditItem(Item) do
  716. + if (FEditControlStatus = [ecsContinueLoop]) and ExtendedAccept then
  717. + if DoAcceptText(S) then SetTextEx(S, tcrEditControl);
  718. { ensure the area underneath the edit control is repainted immediately }
  719. View.Window.Update;
  720. { If app is still active, set focus to previous control and restore capture
  721. to CapHandle if another control hasn't taken it }
  722. if GetActiveWindow <> 0 then begin
  723. --- TB2Item.pas 2005-06-23 16:55:44.000000000 +-0400
  724. +++ TB2Item.pas 2005-08-12 08:32:48.000000000 +-0400
  725. @@ -38,12 +38,20 @@
  726. XP with themes enabled. }
  727. uses
  728. Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  729. StdCtrls, CommCtrl, Menus, ActnList, ImgList, TB2Anim;
  730. +const
  731. + WM_TB2K_POPUPSHOWING = WM_USER + 554;
  732. +
  733. + { Parameter in LParam of WM_TB2K_POPUPSHOWING }
  734. + TPS_ANIMSTART = 1; // animation query: if Result <> 0, do not animate!
  735. + TPS_ANIMFINISHED = 2; // only fired when animation thread is done
  736. + TPS_NOANIM = 3; // fired when animation is done, or if showing with no animation
  737. +
  738. type
  739. TTBCustomItem = class;
  740. TTBCustomItemClass = class of TTBCustomItem;
  741. TTBCustomItemActionLink = class;
  742. TTBCustomItemActionLinkClass = class of TTBCustomItemActionLink;
  743. TTBItemViewer = class;
  744. @@ -79,13 +87,13 @@
  745. tboLongHintInMenuOnly, tboNoAutoHint, tboNoRotation, tboSameWidth,
  746. tboShowHint, tboToolbarStyle, tboToolbarSize);
  747. TTBItemOptions = set of TTBItemOption;
  748. TTBItemStyle = set of (tbisSubmenu, tbisSelectable, tbisSeparator,
  749. tbisEmbeddedGroup, tbisClicksTransparent, tbisCombo, tbisNoAutoOpen,
  750. tbisSubitemsEditable, tbisNoLineBreak, tbisRightAlign, tbisDontSelectFirst,
  751. - tbisRedrawOnSelChange, tbisRedrawOnMouseOverChange);
  752. + tbisRedrawOnSelChange, tbisRedrawOnMouseOverChange, tbisStretch);
  753. TTBPopupAlignment = (tbpaLeft, tbpaRight, tbpaCenter);
  754. TTBPopupEvent = procedure(Sender: TTBCustomItem; FromLink: Boolean) of object;
  755. TTBSelectEvent = procedure(Sender: TTBCustomItem; Viewer: TTBItemViewer;
  756. Selecting: Boolean) of object;
  757. ETBItemError = class(Exception);
  758. @@ -94,12 +102,24 @@
  759. private
  760. FLastWidth, FLastHeight: Integer;
  761. end;
  762. {$IFNDEF JR_D5}
  763. TImageIndex = type Integer;
  764. {$ENDIF}
  765. + TTBPopupPositionRec = record
  766. + PositionAsSubmenu: Boolean;
  767. + Alignment: TTBPopupAlignment;
  768. + Opposite: Boolean;
  769. + MonitorRect: TRect;
  770. + ParentItemRect: TRect;
  771. + NCSizeX: Integer;
  772. + NCSizeY: Integer;
  773. + X, Y, W, H: Integer;
  774. + AnimDir: TTBAnimationDirection;
  775. + PlaySound: Boolean;
  776. + end;
  777. TTBCustomItem = class(TComponent)
  778. private
  779. FActionLink: TTBCustomItemActionLink;
  780. FAutoCheck: Boolean;
  781. FCaption: String;
  782. @@ -185,12 +205,14 @@
  783. procedure DoPopup(Sender: TTBCustomItem; FromLink: Boolean); virtual;
  784. procedure EnabledChanged; virtual;
  785. function GetActionLinkClass: TTBCustomItemActionLinkClass; dynamic;
  786. function GetChevronParentView: TTBView; virtual;
  787. procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
  788. function GetItemViewerClass(AView: TTBView): TTBItemViewerClass; virtual;
  789. + procedure GetPopupPosition(ParentView: TTBView;
  790. + PopupWindow: TTBPopupWindow; var PopupPositionRec: TTBPopupPositionRec); virtual;
  791. function GetPopupWindowClass: TTBPopupWindowClass; virtual;
  792. procedure IndexError;
  793. procedure Loaded; override;
  794. function NeedToRecreateViewer(AViewer: TTBItemViewer): Boolean; virtual;
  795. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  796. function OpenPopup(const SelectFirstItem, TrackRightButton: Boolean;
  797. @@ -317,21 +339,21 @@
  798. procedure CalcSize(const Canvas: TCanvas; var AWidth, AHeight: Integer);
  799. virtual;
  800. function CaptionShown: Boolean; dynamic;
  801. function DoExecute: Boolean; virtual;
  802. procedure DrawItemCaption(const Canvas: TCanvas; ARect: TRect;
  803. const ACaption: String; ADrawDisabledShadow: Boolean; AFormat: UINT); virtual;
  804. - procedure Entering; virtual;
  805. + procedure Entering(OldSelected: TTBItemViewer); virtual;
  806. function GetAccRole: Integer; virtual;
  807. function GetAccValue(var Value: WideString): Boolean; virtual;
  808. function GetCaptionText: String; virtual;
  809. procedure GetCursor(const Pt: TPoint; var ACursor: HCURSOR); virtual;
  810. function GetImageList: TCustomImageList;
  811. function ImageShown: Boolean;
  812. function IsRotated: Boolean;
  813. - function IsToolbarSize: Boolean;
  814. + function IsToolbarSize: Boolean; virtual;
  815. function IsPtInButtonPart(X, Y: Integer): Boolean; virtual;
  816. procedure KeyDown(var Key: Word; Shift: TShiftState); virtual;
  817. procedure Leaving; virtual;
  818. procedure LosingCapture; virtual;
  819. procedure MouseDown(Shift: TShiftState; X, Y: Integer;
  820. var MouseDownOnMenu: Boolean); virtual;
  821. @@ -354,13 +376,13 @@
  822. constructor Create(AView: TTBView; AItem: TTBCustomItem; AGroupLevel: Integer); virtual;
  823. destructor Destroy; override;
  824. procedure Execute(AGivePriority: Boolean);
  825. function GetAccObject: IDispatch;
  826. function GetHintText: String;
  827. function IsAccessible: Boolean;
  828. - function IsToolbarStyle: Boolean;
  829. + function IsToolbarStyle: Boolean; virtual;
  830. function ScreenToClient(const P: TPoint): TPoint;
  831. end;
  832. PTBItemViewerArray = ^TTBItemViewerArray;
  833. TTBItemViewerArray = array[0..$7FFFFFFF div SizeOf(TTBItemViewer)-1] of TTBItemViewer;
  834. TTBViewOrientation = (tbvoHorizontal, tbvoVertical, tbvoFloating);
  835. TTBEnterToolbarLoopOptions = set of (tbetMouseDown, tbetExecuteSelected,
  836. @@ -452,12 +474,16 @@
  837. function GetRootView: TTBView;
  838. function HandleWMGetObject(var Message: TMessage): Boolean;
  839. procedure InitiateActions;
  840. procedure KeyDown(var Key: Word; Shift: TShiftState); virtual;
  841. procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  842. procedure SetAccelsVisibility(AShowAccels: Boolean);
  843. + procedure SetState(AState: TTBViewState);
  844. + property DoneActionData: TTBDoneActionData read FDoneActionData write FDoneActionData;
  845. + property ShowDownArrow: Boolean read FShowDownArrow; {vb+}
  846. + property ShowUpArrow: Boolean read FShowUpArrow; {vb+}
  847. public
  848. constructor CreateView(AOwner: TComponent; AParentView: TTBView;
  849. AParentItem: TTBCustomItem; AWindow: TWinControl;
  850. AIsToolbar, ACustomizing, AUsePriorityList: Boolean); virtual;
  851. destructor Destroy; override;
  852. procedure BeginUpdate;
  853. @@ -663,19 +689,22 @@
  854. procedure WMNCCalcSize(var Message: TWMNCCalcSize); message WM_NCCALCSIZE;
  855. procedure WMNCPaint(var Message: TMessage); message WM_NCPAINT;
  856. procedure WMPaint(var Message: TWMPaint); message WM_PAINT;
  857. procedure WMPrint(var Message: TMessage); message WM_PRINT;
  858. procedure WMPrintClient(var Message: TMessage); message WM_PRINTCLIENT;
  859. procedure WMTB2kStepAnimation(var Message: TMessage); message WM_TB2K_STEPANIMATION;
  860. + procedure WMTB2kAnimationEnded (var Message: TMessage); message WM_TB2K_ANIMATIONENDED;
  861. protected
  862. procedure CreateParams(var Params: TCreateParams); override;
  863. procedure CreateWnd; override;
  864. procedure DestroyWindowHandle; override;
  865. + function GetNCSize: TPoint; dynamic;
  866. function GetViewClass: TTBViewClass; dynamic;
  867. procedure Paint; override;
  868. procedure PaintScrollArrows; virtual;
  869. + property AnimationDirection: TTBAnimationDirection read FAnimationDirection;
  870. public
  871. constructor CreatePopupWindow(AOwner: TComponent; const AParentView: TTBView;
  872. const AItem: TTBCustomItem; const ACustomizing: Boolean); virtual;
  873. destructor Destroy; override;
  874. procedure BeforeDestruction; override;
  875. @@ -811,26 +840,12 @@
  876. procedure TBInitToolbarSystemFont;
  877. var
  878. ToolbarFont: TFont;
  879. -
  880. -implementation
  881. -
  882. -uses
  883. - MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc;
  884. -
  885. -var
  886. - LastPos: TPoint;
  887. -
  888. -threadvar
  889. - ClickWndRefCount: Integer;
  890. - ClickWnd: HWND;
  891. - ClickList: TList;
  892. -
  893. type
  894. TTBModalHandler = class
  895. private
  896. FCreatedWnd: Boolean;
  897. FInited: Boolean;
  898. FWnd: HWND;
  899. @@ -842,12 +857,29 @@
  900. procedure Loop(const RootView: TTBView; const AMouseDown, AExecuteSelected,
  901. AFromMSAA, TrackRightButton: Boolean);
  902. property RootPopup: TTBPopupWindow read FRootPopup write FRootPopup;
  903. property Wnd: HWND read FWnd;
  904. end;
  905. +function ProcessDoneAction(const DoneActionData: TTBDoneActionData;
  906. + const ReturnClickedItemOnly: Boolean): TTBCustomItem;
  907. +
  908. +implementation
  909. +
  910. +uses
  911. + MMSYSTEM, TB2Consts, TB2Common, IMM, TB2Acc;
  912. +
  913. +var
  914. + LastPos: TPoint;
  915. +
  916. +threadvar
  917. + ClickWndRefCount: Integer;
  918. + ClickWnd: HWND;
  919. + ClickList: TList;
  920. +
  921. +type
  922. PItemChangedNotificationData = ^TItemChangedNotificationData;
  923. TItemChangedNotificationData = record
  924. Proc: TTBItemChangedProc;
  925. RefCount: Integer;
  926. end;
  927. @@ -1678,16 +1710,17 @@
  928. Click;
  929. end;
  930. var
  931. PlayedSound: Boolean = False;
  932. -function TTBCustomItem.CreatePopup(const ParentView: TTBView;
  933. - const ParentViewer: TTBItemViewer; const PositionAsSubmenu, SelectFirstItem,
  934. - Customizing: Boolean; const APopupPoint: TPoint;
  935. - const Alignment: TTBPopupAlignment): TTBPopupWindow;
  936. +procedure TTBCustomItem.GetPopupPosition(ParentView: TTBView;
  937. + PopupWindow: TTBPopupWindow; var PopupPositionRec: TTBPopupPositionRec);
  938. +var
  939. + X2, Y2: Integer;
  940. + RepeatCalcX: Boolean;
  941. function CountObscured(X, Y, W, H: Integer): Integer;
  942. var
  943. I: Integer;
  944. P: TPoint;
  945. V: TTBItemViewer;
  946. @@ -1705,129 +1738,24 @@
  947. if V.Show and (V.BoundsRect.Left >= X) and (V.BoundsRect.Right <= W) and
  948. (V.BoundsRect.Top >= Y) and (V.BoundsRect.Bottom <= H) then
  949. Inc(Result);
  950. end;
  951. end;
  952. -var
  953. - EventItem, ParentItem: TTBCustomItem;
  954. - Opposite: Boolean;
  955. - ChevronParentView: TTBView;
  956. - X, X2, Y, Y2, W, H: Integer;
  957. - P: TPoint;
  958. - RepeatCalcX: Boolean;
  959. - ParentItemRect: TRect;
  960. - MonitorRect: TRect;
  961. - AnimDir: TTBAnimationDirection;
  962. begin
  963. - EventItem := ItemContainingItems(Self);
  964. - if EventItem <> Self then
  965. - EventItem.DoPopup(Self, True);
  966. - DoPopup(Self, False);
  967. -
  968. - ChevronParentView := GetChevronParentView;
  969. - if ChevronParentView = nil then
  970. - ParentItem := Self
  971. - else
  972. - ParentItem := ChevronParentView.FParentItem;
  973. -
  974. - Opposite := Assigned(ParentView) and (vsOppositePopup in ParentView.FState);
  975. - Result := GetPopupWindowClass.CreatePopupWindow(nil, ParentView, ParentItem,
  976. - Customizing);
  977. - try
  978. - if Assigned(ChevronParentView) then begin
  979. - ChevronParentView.FreeNotification(Result.View);
  980. - Result.View.FChevronParentView := ChevronParentView;
  981. - Result.View.FIsToolbar := True;
  982. - Result.View.Style := Result.View.Style +
  983. - (ChevronParentView.Style * [vsAlwaysShowHints]);
  984. - Result.Color := clBtnFace;
  985. - end;
  986. -
  987. - { Calculate ParentItemRect, and MonitorRect (the rectangle of the monitor
  988. - that the popup window will be confined to) }
  989. - if Assigned(ParentView) then begin
  990. - ParentView.ValidatePositions;
  991. - ParentItemRect := ParentViewer.BoundsRect;
  992. - P := ParentView.FWindow.ClientToScreen(Point(0, 0));
  993. - OffsetRect(ParentItemRect, P.X, P.Y);
  994. - if not IsRectEmpty(ParentView.FMonitorRect) then
  995. - MonitorRect := ParentView.FMonitorRect
  996. - else
  997. - MonitorRect := GetRectOfMonitorContainingRect(ParentItemRect, False);
  998. - end
  999. - else begin
  1000. - ParentItemRect.TopLeft := APopupPoint;
  1001. - ParentItemRect.BottomRight := APopupPoint;
  1002. - MonitorRect := GetRectOfMonitorContainingPoint(APopupPoint, False);
  1003. - end;
  1004. - Result.View.FMonitorRect := MonitorRect;
  1005. -
  1006. - { Initialize item positions and size of the popup window }
  1007. - if ChevronParentView = nil then
  1008. - Result.View.FMaxHeight := (MonitorRect.Bottom - MonitorRect.Top) -
  1009. - (PopupMenuWindowNCSize * 2)
  1010. - else
  1011. - Result.View.WrapOffset := (MonitorRect.Right - MonitorRect.Left) -
  1012. - (PopupMenuWindowNCSize * 2);
  1013. - if SelectFirstItem then
  1014. - Result.View.Selected := Result.View.FirstSelectable;
  1015. - Result.View.UpdatePositions;
  1016. - W := Result.Width;
  1017. - H := Result.Height;
  1018. -
  1019. - { Calculate initial X,Y position of the popup window }
  1020. - if Assigned(ParentView) then begin
  1021. - if not PositionAsSubmenu then begin
  1022. - if ChevronParentView = nil then begin
  1023. - if (ParentView = nil) or (ParentView.FOrientation <> tbvoVertical) then begin
  1024. - if GetSystemMetrics(SM_MENUDROPALIGNMENT) = 0 then
  1025. - X := ParentItemRect.Left
  1026. - else
  1027. - X := ParentItemRect.Right - W;
  1028. - Y := ParentItemRect.Bottom;
  1029. - end
  1030. - else begin
  1031. - X := ParentItemRect.Left - W;
  1032. - Y := ParentItemRect.Top;
  1033. - end;
  1034. - end
  1035. - else begin
  1036. - if ChevronParentView.FOrientation <> tbvoVertical then begin
  1037. - X := ParentItemRect.Right - W;
  1038. - Y := ParentItemRect.Bottom;
  1039. - end
  1040. - else begin
  1041. - X := ParentItemRect.Left - W;
  1042. - Y := ParentItemRect.Top;
  1043. - end;
  1044. - end;
  1045. - end
  1046. - else begin
  1047. - X := ParentItemRect.Right - PopupMenuWindowNCSize;
  1048. - Y := ParentItemRect.Top - PopupMenuWindowNCSize;
  1049. - end;
  1050. - end
  1051. - else begin
  1052. - X := APopupPoint.X;
  1053. - Y := APopupPoint.Y;
  1054. - case Alignment of
  1055. - tbpaRight: Dec(X, W);
  1056. - tbpaCenter: Dec(X, W div 2);
  1057. - end;
  1058. - end;
  1059. -
  1060. + with PopupPositionRec do
  1061. + begin
  1062. { Adjust the Y position of the popup window }
  1063. { If the window is going off the bottom of the monitor, try placing it
  1064. above the parent item }
  1065. if (Y + H > MonitorRect.Bottom) and
  1066. ((ParentView = nil) or (ParentView.FOrientation <> tbvoVertical)) then begin
  1067. if not PositionAsSubmenu then
  1068. Y2 := ParentItemRect.Top
  1069. else
  1070. - Y2 := ParentItemRect.Bottom + PopupMenuWindowNCSize;
  1071. + Y2 := ParentItemRect.Bottom + NCSizeY;
  1072. Dec(Y2, H);
  1073. { Only place it above the parent item if it isn't going to go off the
  1074. top of the monitor }
  1075. if Y2 >= MonitorRect.Top then
  1076. Y := Y2;
  1077. end;
  1078. @@ -1897,23 +1825,23 @@
  1079. runs out of space on the screen, switch directions }
  1080. repeat
  1081. RepeatCalcX := False;
  1082. X2 := X;
  1083. if Opposite or (X2 + W > MonitorRect.Right) then begin
  1084. if Assigned(ParentView) then
  1085. - X2 := ParentItemRect.Left + PopupMenuWindowNCSize;
  1086. + X2 := ParentItemRect.Left + NCSizeX;
  1087. Dec(X2, W);
  1088. if not Opposite then
  1089. - Include(Result.View.FState, vsOppositePopup)
  1090. + Include(PopupWindow.View.FState, vsOppositePopup)
  1091. else begin
  1092. if X2 < MonitorRect.Left then begin
  1093. Opposite := False;
  1094. RepeatCalcX := True;
  1095. end
  1096. else
  1097. - Include(Result.View.FState, vsOppositePopup);
  1098. + Include(PopupWindow.View.FState, vsOppositePopup);
  1099. end;
  1100. end;
  1101. until not RepeatCalcX;
  1102. X := X2;
  1103. if X < MonitorRect.Left then
  1104. X := MonitorRect.Left;
  1105. @@ -1934,14 +1862,149 @@
  1106. else begin
  1107. if X + W div 2 >= ParentItemRect.Left + (ParentItemRect.Right - ParentItemRect.Left) div 2 then
  1108. Include(AnimDir, tbadRight)
  1109. else
  1110. Include(AnimDir, tbadLeft);
  1111. end;
  1112. - Result.FAnimationDirection := AnimDir;
  1113. + end;
  1114. +end;
  1115. +
  1116. +function TTBCustomItem.CreatePopup(const ParentView: TTBView;
  1117. + const ParentViewer: TTBItemViewer; const PositionAsSubmenu, SelectFirstItem,
  1118. + Customizing: Boolean; const APopupPoint: TPoint;
  1119. + const Alignment: TTBPopupAlignment): TTBPopupWindow;
  1120. +var
  1121. + EventItem, ParentItem: TTBCustomItem;
  1122. + Opposite: Boolean;
  1123. + ChevronParentView: TTBView;
  1124. + X, Y, W, H: Integer;
  1125. + P: TPoint;
  1126. + ParentItemRect: TRect;
  1127. + MonitorRect: TRect;
  1128. + PopupRec: TTBPopupPositionRec;
  1129. + NCSize: TPoint;
  1130. +begin
  1131. + EventItem := ItemContainingItems(Self);
  1132. + if EventItem <> Self then
  1133. + EventItem.DoPopup(Self, True);
  1134. + DoPopup(Self, False);
  1135. +
  1136. + ChevronParentView := GetChevronParentView;
  1137. + if ChevronParentView = nil then
  1138. + ParentItem := Self
  1139. + else
  1140. + ParentItem := ChevronParentView.FParentItem;
  1141. +
  1142. + Opposite := Assigned(ParentView) and (vsOppositePopup in ParentView.FState);
  1143. + Result := GetPopupWindowClass.CreatePopupWindow(nil, ParentView, ParentItem,
  1144. + Customizing);
  1145. + try
  1146. + if Assigned(ChevronParentView) then begin
  1147. + ChevronParentView.FreeNotification(Result.View);
  1148. + Result.View.FChevronParentView := ChevronParentView;
  1149. + Result.View.FIsToolbar := True;
  1150. + Result.View.Style := Result.View.Style +
  1151. + (ChevronParentView.Style * [vsAlwaysShowHints]);
  1152. + Result.Color := clBtnFace;
  1153. + end;
  1154. + { Calculate ParentItemRect, and MonitorRect (the rectangle of the monitor
  1155. + that the popup window will be confined to) }
  1156. + if Assigned(ParentView) then begin
  1157. + ParentView.ValidatePositions;
  1158. + ParentItemRect := ParentViewer.BoundsRect;
  1159. + P := ParentView.FWindow.ClientToScreen(Point(0, 0));
  1160. + OffsetRect(ParentItemRect, P.X, P.Y);
  1161. + if not IsRectEmpty(ParentView.FMonitorRect) then
  1162. + MonitorRect := ParentView.FMonitorRect
  1163. + else
  1164. + {MonitorRect := GetRectOfMonitorContainingPoint(APopupPoint, False);} {vb-}
  1165. + MonitorRect := GetRectOfMonitorContainingPoint(APopupPoint, True); {vb+}
  1166. + end
  1167. + else begin
  1168. + ParentItemRect.TopLeft := APopupPoint;
  1169. + ParentItemRect.BottomRight := APopupPoint;
  1170. + {MonitorRect := GetRectOfMonitorContainingPoint(APopupPoint, False);} {vb-}
  1171. + MonitorRect := GetRectOfMonitorContainingPoint(APopupPoint, True); {vb+}
  1172. + end;
  1173. + Result.View.FMonitorRect := MonitorRect;
  1174. +
  1175. + { Initialize item positions and size of the popup window }
  1176. + NCSize := Result.GetNCSize;
  1177. + if ChevronParentView = nil then
  1178. + Result.View.FMaxHeight := (MonitorRect.Bottom - MonitorRect.Top) -
  1179. + (NCSize.Y * 2)
  1180. + else
  1181. + Result.View.WrapOffset := (MonitorRect.Right - MonitorRect.Left) -
  1182. + (NCSize.X * 2);
  1183. + if SelectFirstItem then
  1184. + Result.View.Selected := Result.View.FirstSelectable;
  1185. + Result.View.UpdatePositions;
  1186. + W := Result.Width;
  1187. + H := Result.Height;
  1188. +
  1189. + { Calculate initial X,Y position of the popup window }
  1190. + if Assigned(ParentView) then begin
  1191. + if not PositionAsSubmenu then begin
  1192. + if ChevronParentView = nil then begin
  1193. + if (ParentView = nil) or (ParentView.FOrientation <> tbvoVertical) then begin
  1194. + if GetSystemMetrics(SM_MENUDROPALIGNMENT) = 0 then
  1195. + X := ParentItemRect.Left
  1196. + else
  1197. + X := ParentItemRect.Right - W;
  1198. + Y := ParentItemRect.Bottom;
  1199. + end
  1200. + else begin
  1201. + X := ParentItemRect.Left - W;
  1202. + Y := ParentItemRect.Top;
  1203. + end;
  1204. + end
  1205. + else begin
  1206. + if ChevronParentView.FOrientation <> tbvoVertical then begin
  1207. + X := ParentItemRect.Right - W;
  1208. + Y := ParentItemRect.Bottom;
  1209. + end
  1210. + else begin
  1211. + X := ParentItemRect.Left - W;
  1212. + Y := ParentItemRect.Top;
  1213. + end;
  1214. + end;
  1215. + end
  1216. + else begin
  1217. + X := ParentItemRect.Right - NCSize.X;
  1218. + Y := ParentItemRect.Top - NCSize.Y;
  1219. + end;
  1220. + end
  1221. + else begin
  1222. + X := APopupPoint.X;
  1223. + Y := APopupPoint.Y;
  1224. + case Alignment of
  1225. + tbpaRight: Dec(X, W);
  1226. + tbpaCenter: Dec(X, W div 2);
  1227. + end;
  1228. + end;
  1229. +
  1230. + PopupRec.PositionAsSubmenu := PositionAsSubmenu;
  1231. + PopupRec.Alignment := Alignment;
  1232. + PopupRec.Opposite := Opposite;
  1233. + PopupRec.MonitorRect := MonitorRect;
  1234. + PopupRec.ParentItemRect := ParentItemRect;
  1235. + PopupRec.NCSizeX := NCSize.X;
  1236. + PopupRec.NCSizeY := NCSize.Y;
  1237. + PopupRec.X := X;
  1238. + PopupRec.Y := Y;
  1239. + PopupRec.W := W;
  1240. + PopupRec.H := H;
  1241. + PopupRec.AnimDir := [];
  1242. + PopupRec.PlaySound := True;
  1243. + GetPopupPosition(ParentView, Result, PopupRec);
  1244. + X := PopupRec.X;
  1245. + Y := PopupRec.Y;
  1246. + W := PopupRec.W;
  1247. + H := PopupRec.H;
  1248. + Result.FAnimationDirection := PopupRec.AnimDir;
  1249. Result.SetBounds(X, Y, W, H);
  1250. if Assigned(ParentView) then begin
  1251. Result.FreeNotification(ParentView);
  1252. ParentView.FOpenViewerWindow := Result;
  1253. ParentView.FOpenViewerView := Result.View;
  1254. ParentView.FOpenViewer := ParentViewer;
  1255. @@ -1949,13 +2012,13 @@
  1256. Include(ParentView.FState, vsDropDownMenus);
  1257. ParentView.Invalidate(ParentViewer);
  1258. ParentView.FWindow.Update;
  1259. end;
  1260. end;
  1261. Include(Result.View.FState, vsDrawInOrder);
  1262. - if not NeedToPlaySound('MenuPopup') then begin
  1263. + if not PopupRec.PlaySound or not NeedToPlaySound('MenuPopup') then begin
  1264. { Don't call PlaySound if we don't have to }
  1265. Result.Visible := True;
  1266. end
  1267. else begin
  1268. if not PlayedSound then begin
  1269. { Work around Windows 2000 "bug" where there's a 1/3 second delay upon the
  1270. @@ -2626,12 +2689,13 @@
  1271. P := Pos(#9, Result);
  1272. if P <> 0 then
  1273. SetLength(Result, P-1);
  1274. end;
  1275. function TTBItemViewer.GetHintText: String;
  1276. +var P: Integer;
  1277. begin
  1278. Result := GetShortHint(Item.Hint);
  1279. { If there is no short hint, use the caption for the hint. Like Office,
  1280. strip any trailing colon or ellipsis. }
  1281. if (Result = '') and not(tboNoAutoHint in Item.EffectiveOptions) and
  1282. (not(tbisSubmenu in Item.ItemStyle) or (tbisCombo in Item.ItemStyle) or
  1283. @@ -2643,15 +2707,22 @@
  1284. if not TCustomAction(Item.ActionLink.Action).DoHint(Result) then
  1285. Result := '';
  1286. { Note: TControlActionLink.DoShowHint actually misinterprets the result
  1287. of DoHint, but we get it right... }
  1288. end;
  1289. { Add shortcut text }
  1290. - if (Result <> '') and Application.HintShortCuts and
  1291. - (Item.ShortCut <> scNone) then
  1292. - Result := Format('%s (%s)', [Result, ShortCutToText(Item.ShortCut)]);
  1293. + if (Result <> '') and Application.HintShortCuts then
  1294. + begin
  1295. + { Custom shortcut }
  1296. + P := Pos(#9, Item.Caption);
  1297. + if (P <> 0) and (P < Length(Item.Caption)) then
  1298. + Result := Format('%s (%s)', [Result, Copy(Item.Caption, P+ 1, MaxInt)])
  1299. + else
  1300. + if (Item.ShortCut <> scNone) then
  1301. + Result := Format('%s (%s)', [Result, ShortCutToText(Item.ShortCut)]);
  1302. + end;
  1303. end;
  1304. function TTBItemViewer.CaptionShown: Boolean;
  1305. begin
  1306. Result := (GetCaptionText <> '') and (not IsToolbarSize or
  1307. (Item.ImageIndex < 0) or (Item.DisplayMode in [nbdmTextOnly, nbdmImageAndText])) or
  1308. @@ -3283,13 +3354,13 @@
  1309. procedure TTBItemViewer.LosingCapture;
  1310. begin
  1311. View.Invalidate(Self);
  1312. end;
  1313. -procedure TTBItemViewer.Entering;
  1314. +procedure TTBItemViewer.Entering(OldSelected: TTBItemViewer);
  1315. begin
  1316. if Assigned(Item.FOnSelect) then
  1317. Item.FOnSelect(Item, Self, True);
  1318. end;
  1319. procedure TTBItemViewer.Leaving;
  1320. @@ -4086,13 +4157,13 @@
  1321. FMouseOverSelected := NewMouseOverSelected;
  1322. if Assigned(OldSelected) and (tbisRedrawOnSelChange in OldSelected.Item.ItemStyle) then
  1323. Invalidate(OldSelected);
  1324. if Assigned(Value) then begin
  1325. if tbisRedrawOnSelChange in Value.Item.ItemStyle then
  1326. Invalidate(Value);
  1327. - Value.Entering;
  1328. + Value.Entering(OldSelected);
  1329. end;
  1330. NotifyFocusEvent;
  1331. { Handle automatic opening of a child popup }
  1332. if vsModal in FState then begin
  1333. { If the view is a toolbar, immediately open any child popup }
  1334. @@ -4379,13 +4450,13 @@
  1335. if LastLine and not DidWrap and (AOrientation <> tbvoFloating) then begin
  1336. { In case the toolbar is docked next to a taller/wider toolbar... }
  1337. HighestWidthOnLine := TotalSize.X;
  1338. HighestHeightOnLine := TotalSize.Y;
  1339. end;
  1340. { Make separators on toolbars as tall/wide as the tallest/widest item }
  1341. - if tbisSeparator in Item.ItemStyle then begin
  1342. + if [tbisSeparator, tbisStretch] * Item.ItemStyle <> [] then begin
  1343. if AOrientation <> tbvoVertical then
  1344. Pos.BoundsRect.Bottom := Pos.BoundsRect.Top + HighestHeightOnLine
  1345. else
  1346. Pos.BoundsRect.Right := Pos.BoundsRect.Left + HighestWidthOnLine;
  1347. end
  1348. else begin
  1349. @@ -5692,12 +5763,16 @@
  1350. { Note: This doesn't remove the selection from a top-level toolbar item.
  1351. Unfortunately, we can't do 'Selected := nil' because it would destroy
  1352. child popups and that must'nt happen for the reason stated above. }
  1353. end;
  1354. +procedure TTBView.SetState(AState: TTBViewState);
  1355. +begin
  1356. + FState := AState;
  1357. +end;
  1358. { TTBModalHandler }
  1359. const
  1360. LSFW_LOCK = 1;
  1361. LSFW_UNLOCK = 2;
  1362. @@ -6181,15 +6256,16 @@
  1363. { TTBPopupView }
  1364. procedure TTBPopupView.AutoSize(AWidth, AHeight: Integer);
  1365. begin
  1366. - with FWindow do
  1367. - SetBounds(Left, Top, AWidth + (PopupMenuWindowNCSize * 2),
  1368. - AHeight + (PopupMenuWindowNCSize * 2));
  1369. + with TTBPopupWindow(FWindow) do
  1370. + with GetNCSize do
  1371. + SetBounds(Left, Top, AWidth + (X * 2),
  1372. + AHeight + (Y * 2));
  1373. end;
  1374. function TTBPopupView.GetFont: TFont;
  1375. begin
  1376. Result := (Owner as TTBPopupWindow).Font;
  1377. end;
  1378. @@ -6260,12 +6336,18 @@
  1379. restored without generating a WM_PAINT message. }
  1380. if Assigned(FView) then
  1381. FView.CloseChildPopups;
  1382. inherited;
  1383. end;
  1384. +function TTBPopupWindow.GetNCSize: TPoint;
  1385. +begin
  1386. + Result.X := PopupMenuWindowNCSize;
  1387. + Result.Y := PopupMenuWindowNCSize;
  1388. +end;
  1389. +
  1390. function TTBPopupWindow.GetViewClass: TTBViewClass;
  1391. begin
  1392. Result := TTBPopupView;
  1393. end;
  1394. procedure TTBPopupWindow.CreateParams(var Params: TCreateParams);
  1395. @@ -6343,26 +6425,36 @@
  1396. {$IFNDEF TB2K_NO_ANIMATION}
  1397. if ((FView.ParentView = nil) or not(vsNoAnimation in FView.FParentView.FState)) and
  1398. Showing and (FView.Selected = nil) and not IsWindowVisible(WindowHandle) and
  1399. SystemParametersInfo(SPI_GETMENUANIMATION, 0, @Animate, 0) and Animate then begin
  1400. Blend := SystemParametersInfo(SPI_GETMENUFADE, 0, @Animate, 0) and Animate;
  1401. if Blend or (FAnimationDirection <> []) then begin
  1402. - TBStartAnimation(WindowHandle, Blend, FAnimationDirection);
  1403. - Exit;
  1404. + if SendMessage(WindowHandle, WM_TB2K_POPUPSHOWING, TPS_ANIMSTART, 0) = 0 then
  1405. + begin
  1406. + { Start animation only if WM_TB2K_POPUPSHOWING returns zero (or not handled) }
  1407. + TBStartAnimation(WindowHandle, Blend, FAnimationDirection);
  1408. + Exit;
  1409. + end;
  1410. end;
  1411. end;
  1412. {$ENDIF}
  1413. { No animation... }
  1414. if not Showing then begin
  1415. { Call TBEndAnimation to ensure WS_EX_LAYERED style is removed before
  1416. hiding, otherwise windows under the popup window aren't repainted
  1417. properly. }
  1418. TBEndAnimation(WindowHandle);
  1419. end;
  1420. SetWindowPos(WindowHandle, 0, 0, 0, 0, 0, ShowFlags[Showing]);
  1421. + if Showing then SendNotifyMessage(WindowHandle, WM_TB2K_POPUPSHOWING, TPS_NOANIM, 0);
  1422. +end;
  1423. +
  1424. +procedure TTBPopupWindow.WMTB2kAnimationEnded(var Message: TMessage);
  1425. +begin
  1426. + SendNotifyMessage(WindowHandle, WM_TB2K_POPUPSHOWING, TPS_ANIMFINISHED, 0);
  1427. end;
  1428. procedure TTBPopupWindow.WMTB2kStepAnimation(var Message: TMessage);
  1429. begin
  1430. TBStepAnimation(Message);
  1431. end;
  1432. @@ -6426,14 +6518,14 @@
  1433. begin
  1434. { do nothing -- ignore Alt+F4 keypresses }
  1435. end;
  1436. procedure TTBPopupWindow.WMNCCalcSize(var Message: TWMNCCalcSize);
  1437. begin
  1438. - InflateRect(Message.CalcSize_Params^.rgrc[0],
  1439. - -PopupMenuWindowNCSize, -PopupMenuWindowNCSize);
  1440. + with GetNCSize do
  1441. + InflateRect(Message.CalcSize_Params^.rgrc[0], -X, -Y);
  1442. inherited;
  1443. end;
  1444. procedure PopupWindowNCPaintProc(Wnd: HWND; DC: HDC; AppData: Longint);
  1445. var
  1446. R: TRect;
  1447. --- TB2MRU.pas 2005-01-05 21:56:50.000000000 +-0400
  1448. +++ TB2MRU.pas 2005-08-02 18:38:34.000000000 +-0400
  1449. @@ -50,12 +50,13 @@
  1450. procedure ClickHandler(Sender: TObject);
  1451. procedure SetHidePathExtension(Value: Boolean);
  1452. procedure SetList(Value: TStrings);
  1453. procedure SetMaxItems(Value: Integer);
  1454. protected
  1455. property Container: TTBCustomItem read FContainer;
  1456. + function GetFirstKey: Integer; virtual;
  1457. function GetItemClass: TTBCustomItemClass; virtual;
  1458. procedure SetItemCaptions; virtual;
  1459. public
  1460. constructor Create(AOwner: TComponent); override;
  1461. destructor Destroy; override;
  1462. procedure Add(Filename: String);
  1463. @@ -293,37 +294,39 @@
  1464. Ini.DeleteKey(Section, FPrefix + IntToStr(I));
  1465. end;
  1466. end;
  1467. procedure TTBMRUList.SetItemCaptions;
  1468. var
  1469. - I, J: Integer;
  1470. + I, J, N: Integer;
  1471. Key: Char;
  1472. S: String;
  1473. Buf: array[0..MAX_PATH-1] of Char;
  1474. begin
  1475. while FList.Count > FMaxItems do
  1476. FList.Delete(FList.Count-1);
  1477. + N := GetFirstKey;
  1478. for I := 0 to FContainer.Count-1 do begin
  1479. Key := #0;
  1480. - if I < 9 then
  1481. - Key := Chr(Ord('1') + I)
  1482. + if N < 9 then
  1483. + Key := Chr(Ord('1') + N)
  1484. else begin
  1485. { No more numbers; try letters }
  1486. - J := I - 9;
  1487. + J := N - 9;
  1488. if J < 26 then
  1489. Key := Chr(Ord('A') + J);
  1490. end;
  1491. S := FList[I];
  1492. if HidePathExtension and (GetFileTitle(PChar(S), Buf, SizeOf(Buf)) = 0) then
  1493. S := Buf;
  1494. S := EscapeAmpersands(S);
  1495. if Key <> #0 then
  1496. FContainer[I].Caption := Format('&%s %s', [Key, S])
  1497. else
  1498. FContainer[I].Caption := S;
  1499. + Inc(N);
  1500. end;
  1501. end;
  1502. procedure TTBMRUList.ClickHandler(Sender: TObject);
  1503. var
  1504. I: Integer;
  1505. @@ -358,12 +361,17 @@
  1506. function TTBMRUList.GetItemClass: TTBCustomItemClass;
  1507. begin
  1508. Result := TTBCustomItem;
  1509. end;
  1510. +function TTBMRUList.GetFirstKey: Integer;
  1511. +begin
  1512. + Result := 0;
  1513. +end;
  1514. +
  1515. { TTBMRUListItem }
  1516. constructor TTBMRUListItem.Create(AOwner: TComponent);
  1517. begin
  1518. inherited;
  1519. --- TB2Reg.pas 2005-01-05 21:56:50.000000000 +-0400
  1520. +++ TB2Reg.pas 2005-06-07 04:59:48.000000000 +-0400
  1521. @@ -33,19 +33,12 @@
  1522. uses
  1523. Windows, SysUtils, Classes, Graphics, Controls, Dialogs, ActnList, ImgList,
  1524. {$IFDEF JR_D6} DesignIntf, DesignEditors, VCLEditors, {$ELSE} DsgnIntf, {$ENDIF}
  1525. TB2Toolbar, TB2ToolWindow, TB2Dock, TB2Item, TB2ExtItems, TB2MRU, TB2MDI,
  1526. TB2DsgnItemEditor;
  1527. -procedure Register;
  1528. -
  1529. -implementation
  1530. -
  1531. -uses
  1532. - ImgEdit;
  1533. -
  1534. {$IFDEF JR_D5}
  1535. { TTBImageIndexPropertyEditor }
  1536. { Unfortunately TComponentImageIndexPropertyEditor seems to be gone in
  1537. Delphi 6, so we have to use our own image index property editor class }
  1538. @@ -64,12 +57,31 @@
  1539. procedure ListMeasureWidth(const Value: string; ACanvas: TCanvas;
  1540. var AWidth: Integer); {$IFNDEF JR_D6} override; {$ENDIF}
  1541. procedure ListDrawValue(const Value: string; ACanvas: TCanvas;
  1542. const ARect: TRect; ASelected: Boolean); {$IFNDEF JR_D6} override; {$ENDIF}
  1543. end;
  1544. +{ TTBItemImageIndexPropertyEditor }
  1545. +
  1546. +type
  1547. + TTBItemImageIndexPropertyEditor = class(TTBImageIndexPropertyEditor)
  1548. + public
  1549. + function GetImageListAt (Index: Integer): TCustomImageList; override;
  1550. + end;
  1551. +
  1552. +{$ENDIF}
  1553. +
  1554. +procedure Register;
  1555. +
  1556. +implementation
  1557. +
  1558. +uses
  1559. + ImgEdit;
  1560. +
  1561. +{$IFDEF JR_D5}
  1562. +
  1563. function TTBImageIndexPropertyEditor.GetAttributes: TPropertyAttributes;
  1564. begin
  1565. Result := [paMultiSelect, paValueList, paRevertable];
  1566. end;
  1567. function TTBImageIndexPropertyEditor.GetImageListAt(Index: Integer): TCustomImageList;
  1568. @@ -125,18 +137,12 @@
  1569. if Assigned(ImgList) then
  1570. Inc(AWidth, ImgList.Width);
  1571. end;
  1572. { TTBItemImageIndexPropertyEditor }
  1573. -type
  1574. - TTBItemImageIndexPropertyEditor = class(TTBImageIndexPropertyEditor)
  1575. - protected
  1576. - function GetImageListAt(Index: Integer): TCustomImageList; override;
  1577. - end;
  1578. -
  1579. function TTBItemImageIndexPropertyEditor.GetImageListAt(Index: Integer): TCustomImageList;
  1580. var
  1581. C: TPersistent;
  1582. Item: TTBCustomItem;
  1583. begin
  1584. Result := nil;
  1585. --- TB2Toolbar.pas 2005-07-30 13:17:20.000000000 +-0400
  1586. +++ TB2Toolbar.pas 2005-08-01 11:16:18.000000000 +-0400
  1587. @@ -891,12 +891,17 @@
  1588. if Assigned(FView.Selected) then begin
  1589. Item := FView.Selected.Item;
  1590. if not(tboLongHintInMenuOnly in Item.EffectiveOptions) then
  1591. Hint := Item.Hint
  1592. else
  1593. Hint := '';
  1594. +
  1595. + with TTBItemViewerAccess(FView.Find(Item)) do
  1596. + begin
  1597. + MouseMove(X - BoundsRect.Left, Y - BoundsRect.Top);
  1598. + end;
  1599. end
  1600. else
  1601. Hint := '';
  1602. end;
  1603. { Call TrackMouseEvent to be sure that we are notified when the mouse leaves
  1604. the window. We won't get a CM_MOUSELEAVE message if the mouse moves
  1605. --- TB2ToolWindow.pas 2005-01-05 21:56:50.000000000 +-0400
  1606. +++ TB2ToolWindow.pas 2005-02-23 04:57:58.000000000 +-0400
  1607. @@ -192,20 +192,30 @@
  1608. end;
  1609. function TTBToolWindow.CalcSize(ADock: TTBDock): TPoint;
  1610. begin
  1611. Result.X := FBarWidth;
  1612. Result.Y := FBarHeight;
  1613. - if Assigned(ADock) and (FullSize or Stretch) then begin
  1614. - { If docked and stretching, return the minimum size so that the toolbar
  1615. - can shrink below FBarWidth/FBarHeight }
  1616. - if not(ADock.Position in [dpLeft, dpRight]) then
  1617. - Result.X := FMinClientWidth
  1618. - else
  1619. - Result.Y := FMinClientHeight;
  1620. - end;
  1621. + if Assigned(ADock) then
  1622. + if FullSize then
  1623. + begin
  1624. + { If docked and full size, return the size corresponding to docked size }
  1625. + if not(ADock.Position in [dpLeft, dpRight]) then
  1626. + Result.X := ADock.ClientWidth - (Width - ClientWidth)
  1627. + else
  1628. + Result.Y := ADock.ClientHeight - (Height - ClientHeight);
  1629. + end
  1630. + else if Stretch then
  1631. + begin
  1632. + { If docked and stretching, return the minimum size so that the toolbar
  1633. + can shrink below FBarWidth/FBarHeight }
  1634. + if not(ADock.Position in [dpLeft, dpRight]) then
  1635. + Result.X := FMinClientWidth
  1636. + else
  1637. + Result.Y := FMinClientHeight;
  1638. + end;
  1639. end;
  1640. procedure TTBToolWindow.GetBaseSize(var ASize: TPoint);
  1641. begin
  1642. ASize := CalcSize(CurrentDock);
  1643. end;