From: Sebastien B. <sb...@us...> - 2002-08-29 23:19:41
|
Update of /cvsroot/jvcl/dev/restructured/source In directory usw-pr-cvs1:/tmp/cvs-serv12889 Modified Files: JvControlBar.pas Log Message: Added support for dock/undock in load/save methods and in popupmenu Index: JvControlBar.pas =================================================================== RCS file: /cvsroot/jvcl/dev/restructured/source/JvControlBar.pas,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** JvControlBar.pas 29 Aug 2002 01:57:41 -0000 1.7 --- JvControlBar.pas 29 Aug 2002 23:19:38 -0000 1.8 *************** *** 49,53 **** --- 49,55 ---- FPopup: TPopupMenu; FPopupNames: TPopupNames; + FList: TList; protected + procedure DoAddDockClient(Client: TControl; const ARect: TRect); override; procedure CMMouseEnter(var Msg: TMessage); message CM_MOUSEENTER; procedure CMMouseLeave(var Msg: TMessage); message CM_MOUSELEAVE; *************** *** 56,59 **** --- 58,62 ---- X, Y: Integer); override; procedure PopupMenuClick(Sender: TObject); + procedure Loaded;override; public constructor Create(AOwner: TComponent); override; *************** *** 89,92 **** --- 92,96 ---- begin inherited Create(AOwner); + FList := TList.Create; FColor := clInfoBk; FOver := False; *************** *** 129,133 **** var i: Integer; ! it: TMenuItem; begin inherited; --- 133,155 ---- var i: Integer; ! ! procedure DoAddControl(const AControl: TControl; const Index: Integer); ! var ! it: TMenuItem; ! begin ! it := TMenuItem.Create(FPopup); ! if PopupNames=pnHint then ! it.Caption := AControl.Hint ! else ! it.Caption := AControl.Name; ! {$IFDEF COMPILER6_UP} ! it.AutoCheck := true; ! {$ENDIF} ! it.Tag := Index; ! it.OnClick := PopupMenuClick; ! it.Checked := AControl.Visible; ! FPopup.Items.Add(it); ! end; ! begin inherited; *************** *** 138,156 **** else FPopup := TPopupMenu.Create(self); ! for i:=0 to ControlCount-1 do ! begin ! it := TMenuItem.Create(FPopup); ! if PopupNames=pnHint then ! it.Caption := Controls[i].Hint ! else ! it.Caption := Controls[i].Name; ! {$IFDEF COMPILER6_UP} ! it.AutoCheck := true; ! {$ENDIF} ! it.Tag := i; ! it.OnClick := PopupMenuClick; ! it.Checked := Controls[i].Visible; ! FPopup.Items.Add(it); ! end; with ClientToScreen(Point(X,Y)) do FPopup.Popup(X,Y); --- 160,165 ---- else FPopup := TPopupMenu.Create(self); ! for i:=0 to FList.Count-1 do ! DoAddControl(TControl(FList[i]), i); with ClientToScreen(Point(X,Y)) do FPopup.Popup(X,Y); *************** *** 162,165 **** --- 171,175 ---- destructor TJvControlBar.Destroy; begin + FList.Free; if FPopup<>nil then FPopup.Free; *************** *** 176,181 **** Checked := not Checked; {$ENDIF} ! if (Tag>=0) and (Tag<ControlCount) then ! Controls[Tag].Visible := Checked; end; end; --- 186,191 ---- Checked := not Checked; {$ENDIF} ! if (Tag>=0) and (Tag<FList.Count) then ! TControl(FList[Tag]).Visible := Checked; end; end; *************** *** 188,195 **** i,j: Integer; lLeft, lTop: Integer; begin st := Value; j := 0; ! while (Length(st)>1) and (j<ControlCount) do begin i := Pos(';',st); --- 198,206 ---- i,j: Integer; lLeft, lTop: Integer; + lDocked: Boolean; begin st := Value; j := 0; ! while (Length(st)>1) and (j<FList.Count) do begin i := Pos(';',st); *************** *** 208,227 **** if i<>0 then begin ! Controls[j].Visible := pos('true',st2)=1; st2 := Copy(st2,i+1,Length(st2)); i := pos(',',st2); if i<>0 then begin ! lLeft := StrToIntDef( Copy(st2,1,i-1), Controls[j].Left); ! lTop := StrToIntDef( Copy(st2,i+1,Length(st2)), Controls[j].Top); ! if ControlAtPos(Point(lLeft,Controls[j].Top),true)<>nil then begin ! Controls[j].Left := lLeft; ! Controls[j].Top := lTop; end else begin ! Controls[j].Top := lTop; ! Controls[j].Left := lLeft; end; end; --- 219,252 ---- if i<>0 then begin ! TControl(FList[j]).Visible := pos('true',st2)=1; st2 := Copy(st2,i+1,Length(st2)); i := pos(',',st2); if i<>0 then begin ! lLeft := StrToIntDef( Copy(st2,1,i-1), TControl(FList[j]).Left); ! lDocked := true; ! st2 := Copy(st2,i+1,Length(st2)); ! i := pos(',',st2); ! if i<>0 then begin ! if pos('undocked',st2)<>0 then ! lDocked := false; ! st2 := Copy(st2,1,i-1); ! end; ! if (lDocked) and (TControl(FList[j]).Parent<>self) then ! TControl(FList[j]).ManualDock(self) ! else if (not lDocked) and (TControl(FList[j]).Parent=self) then ! TControl(FList[j]).ManualDock(nil); ! lTop := StrToIntDef(st2, TControl(FList[j]).Top); ! ! if ControlAtPos(Point(lLeft,TControl(FList[j]).Top),true)<>nil then ! begin ! TControl(FList[j]).Left := lLeft; ! TControl(FList[j]).Top := lTop; end else begin ! TControl(FList[j]).Top := lTop; ! TControl(FList[j]).Left := lLeft; end; end; *************** *** 238,249 **** begin result := ''; ! for i:=0 to ControlCount-1 do begin ! if Controls[i].Visible then result := result+'true,' else result := result+'false,'; ! result := result + IntToStr(Controls[i].Left) + ',' + IntToStr(Controls[i].Top)+';'; end; end; --- 263,296 ---- begin result := ''; ! for i:=0 to FList.Count-1 do begin ! if TControl(FList[i]).Visible then result := result+'true,' else result := result+'false,'; ! result := result + IntToStr(TControl(FList[i]).Left) + ',' + IntToStr(TControl(Flist[i]).Top); ! if TControl(FList[i]).Parent <> self then ! result := result + ',undocked'; ! result := result + ';'; end; + end; + + {**************************************************} + + procedure TJvControlBar.Loaded; + var + i: Integer; + begin + inherited; + for i:=0 to ControlCount-1 do + FList.Add(Controls[i]); + end; + + procedure TJvControlBar.DoAddDockClient(Client: TControl; + const ARect: TRect); + begin + inherited; + if FList.IndexOf(Client)=-1 then + FList.Add(Client); end; |