1 {
2 *****************************************************************************
3 * MuiFormsUnit.pas *
4 * -------------- *
5 * MUI Windows and related things *
6 * *
7 *****************************************************************************
8
9 *****************************************************************************
10 This file is part of the Lazarus Component Library (LCL)
11
12 See the file COPYING.modifiedLGPL.txt, included in this distribution,
13 for details about the license.
14 *****************************************************************************
15 }
16 unit MuiFormsUnit;
17
18 {$mode objfpc}{$H+}
19
20 interface
21
22 uses
23 Classes, SysUtils, Controls, Contnrs, Exec, AmigaDos, Intuition, Utility, Mui,
24 Forms, MuiBaseUnit, LCLMessageGlue, Menus, Math, Types, LCLType,
25 StrUtils, tagsparamshelper, muiglobal;
26
27 const
28 NM_Barlabel = -1;
29
30 type
31
32 { TMuiFamily }
33
34 TMuiFamily = class(TMuiObject)
35 private
36 ChildList: TObjectList;
37 protected
38 procedure InstallHooks; override;
39 public
40 Par: TMUIFamily;
41 procedure AddHead(AChild: TMuiFamily);
42 procedure AddTail(AChild: TMuiFamily);
43 procedure Remove(AChild: TMuiFamily);
GetListnull44 function GetList: PMinList;
45 destructor Destroy; override;
46 end;
47
48 { TMuiMenuItem }
49
50 TMuiMenuItem = class(TMuiFamily)
51 private
52 FTitle: string;
53 FShortCut: string;
54 protected
GetCheckednull55 function GetChecked: Boolean;
GetCheckItnull56 function GetCheckIt: Boolean;
GetEnablednull57 function GetEnabled: Boolean; override;
GetMenuItemnull58 function GetMenuItem: TMenuItem;
GetShortCutnull59 function GetShortCut: string;
GetTitlenull60 function GetTitle: string;
61 procedure SetChecked(const AValue: Boolean);
62 procedure SetCheckIt(const AValue: Boolean);
63 procedure SetEnabled(const AValue: Boolean); override;
64 procedure SetShortCut(const AValue: string);
65 procedure SetTitle(const AValue: string);
66 public
67 constructor Create(const Tags: TATagList); reintroduce overload virtual;
68 procedure DoMUIDraw(); override;
69 property Checked: Boolean read GetChecked write SetChecked;
70 property CheckIt: Boolean read GetCheckIt write SetCheckIt;
71 property Enabled: Boolean read GetEnabled write SetEnabled;
72 property ShortCut: string read GetShortCut write SetShortCut;
73 property Title: string read GetTitle write SetTitle;
74 property MenuItem: TMenuItem read GetMenuItem;
75 end;
76
77 { TMuiMenu }
78
79 TMuiMenu = class(TMuiFamily)
80 private
81 FTitle: string;
82 protected
GetEnablednull83 function GetEnabled: Boolean; override;
GetTitlenull84 function GetTitle: string;
85 procedure SetEnabled(const AValue: Boolean); override;
86 procedure SetTitle(const AValue: string);
87 public
88 constructor Create(const Tags: TATagList); reintroduce overload virtual;
89 destructor Destroy; override;
90 procedure DoMUIDraw(); override;
91 property Enabled: Boolean read GetEnabled write SetEnabled;
92 property Title: string read GetTitle write SetTitle;
93 end;
94
95 { TMuiMenuStrip }
96
97 TMuiMenuStrip = class(TMuiFamily)
98 protected
GetEnablednull99 function GetEnabled: Boolean; override;
100 procedure SetEnabled(const AValue: Boolean); override;
101 public
102 constructor Create(const Tags: TATagList);
103 procedure DoMUIDraw(); override;
104 Destructor Destroy; override;
105 property Enabled: Boolean read GetEnabled write SetEnabled;
106 end;
107
108 { TMuiWindow }
109
110 TMuiWindow = class(TMUIObject)
111 private
112 FCaption: string;
113 FInitWindow: Boolean; // SetVisible
114 FBlockSizeMsg: Boolean;// disable resize loopback in layout -> GetSizes
115 FMainMenu: TMuiMenuStrip;
116 FSizeable: Boolean;
117 FHasMenu: Boolean;
118 FInMoveEvent: Boolean;
119 FFocusedControl: TMuiObject;
120 FBlocksize, FBlockMove: Boolean;
GetCaptionnull121 function GetCaption: string;
122 procedure SetCaption(const AValue: string);
GetWindownull123 function GetWindow: PWindow;
124 protected
GetVisiblenull125 function GetVisible: Boolean; override;
126 procedure SetVisible(const AValue: Boolean); override;
127 procedure AddChild(ChildObj: PObject_); override;
128 procedure RemoveChild(ChildObj: PObject_); override;
129 procedure SetLeft(ALeft: LongInt); override;
130 procedure SetTop(ATop: LongInt); override;
GetTopnull131 function GetTop(): Integer; override;
GetLeftnull132 function GetLeft(): Integer; override;
GetWidthnull133 function GetWidth(): Integer; override;
GetHeightnull134 function GetHeight(): Integer; override;
135 procedure SetFocusedControl(AControl: TMUIObject); virtual;
136 procedure InstallHooks; override;
137 procedure SetEnabled(const AEnabled: Boolean); override;
GetEnablednull138 function GetEnabled: Boolean; override;
139 public
140 constructor Create(const TagList: TATagList); overload; reintroduce; virtual;
141 destructor Destroy; override;
142 procedure GetSizes;
143 procedure DoMUIDraw(); override;
GetClientRectnull144 function GetClientRect: TRect; override;
GetWindowOffsetnull145 function GetWindowOffset: Types.TPoint; override;
146 procedure GetBoundsFromMUI;
147 procedure Redraw; override;
148 property Caption: string read GetCaption write SetCaption;
149 property MainMenu: TMuiMenuStrip read FMainMenu;
150 property HasMenu: Boolean read FHasMenu write FHasMenu;
151 property Sizeable: Boolean read FSizeable write FSizeable;
152 property FocusedControl: TMUIObject read FFocusedControl write SetFocusedControl;
153 property Window: PWindow read GetWindow;
154 end;
155
156 { TMuiGroup }
157
158 TMuiGroup = class(TMuiObject)
159 private
160
161 public
162 constructor Create(const TagList: TATagList); overload; reintroduce; virtual;
163 end;
164
165 implementation
166
167 { TMuiWindow }
168
LayoutFuncnull169 function LayoutFunc(Hook: PHook; Obj: PObject_; Msg:Pointer): Longint;
170 var
171 LMsg: pMUI_LayoutMsg;
172 i: LongInt;
173 Win: TMuiWindow;
174 AWin: PWindow;
175 PasWin: TWinControl;
176 BW, BH: Integer;
177 Miw, Mih, Maw, Mah: Integer;
178 begin
179 LMsg := Msg;
180 Result := LongInt(True);
181 Win := TMuiWindow(Hook^.h_Data);
182 BW := 0;
183 BH := 0;
184 {$if defined(Amiga) or defined(MorphOS)}
185 AWin := Win.Window;
186 if Assigned(AWin) then
187 begin
188 BW := AWin^.BorderLeft + AWin^.BorderRight;
189 BH := AWin^.BorderTop + AWin^.BorderBottom;
190 end;
191 {$endif}
192 case LMsg^.lm_type of
193 MUILM_MINMAX: begin
194 if Win.Sizeable then
195 begin
196 Miw := 100;
197 Mih := 20;
198 Maw := MUI_MAXMAX;
199 Mah := MUI_MAXMAX;
200 if Assigned(Win.PasObject) then
201 begin
202 PasWin := TWinControl(Win.PasObject);
203 MiW := Max(PasWin.Constraints.MinWidth, 100);
204 MiH := Max(PasWin.Constraints.MinHeight, 20);
205 if PasWin.Constraints.MaxWidth > 0 then
206 MaW := Min(PasWin.Constraints.MaxWidth, MUI_MAXMAX);
207 if PasWin.Constraints.MaxHeight > 0 then
208 MaH := Min(PasWin.Constraints.MaxHeight, MUI_MAXMAX);
209 LMsg^.lm_MinMax.MinWidth := MiW;
210 LMsg^.lm_MinMax.MinHeight := MiH;
211 LMsg^.lm_MinMax.MaxWidth := MaW;
212 LMsg^.lm_MinMax.MaxHeight := MaH;
213 end;
214 LMsg^.lm_MinMax.DefWidth := Win.FWidth - BW;
215 LMsg^.lm_MinMax.DefHeight := Win.FHeight - BH;
216 end else
217 begin
218 LMsg^.lm_MinMax.MinWidth := Win.FWidth - BW;
219 LMsg^.lm_MinMax.MinHeight := Win.FHeight - BH;
220 LMsg^.lm_MinMax.MaxWidth := Win.FWidth - BW;
221 LMsg^.lm_MinMax.MaxHeight := Win.FHeight - BH;
222 LMsg^.lm_MinMax.DefWidth := Win.FWidth - BW;
223 LMsg^.lm_MinMax.DefHeight := Win.FHeight - BH;
224 end;
225 TWinControl(Win.PasObject).Realign;
226 end;
227 MUILM_LAYOUT:
228 begin
229 Win.GetSizes;
230 for i:= 0 to Win.FChilds.Count - 1 do
231 begin
232 if Win.FChilds.Items[i] is TMUIObject then
233 TMuiObject(Win.FChilds.Items[i]).SetOwnSize;
234 end;
235 end;
236 end;
237 end;
238
239 { TMuiMenuStrip }
240
GetEnablednull241 function TMuiMenuStrip.GetEnabled: Boolean;
242 begin
243 Result := LongBool(GetAttribute(MUIA_Menu_Enabled));
244 end;
245
246 procedure TMuiMenuStrip.SetEnabled(const AValue: Boolean);
247 begin
248 SetAttribute(MUIA_Menuitem_Enabled, AValue);
249 end;
250
251 constructor TMuiMenuStrip.Create(const Tags: TATagList);
252 begin
253 inherited Create(MUIC_MenuStrip, Tags);
254 Par := nil;
255 end;
256
257 destructor TMuiMenuStrip.Destroy;
258 begin
259 FObject := nil;
260 inherited;
261 end;
262
263 procedure TMUIMenuStrip.DoMUIDraw();
264 begin
265
266 end;
267
268 { TMuiMenu }
269
GetEnablednull270 function TMuiMenu.GetEnabled: Boolean;
271 begin
272 Result := LongBool(GetAttribute(MUIA_Menu_Enabled));
273 end;
274
TMuiMenu.GetTitlenull275 function TMuiMenu.GetTitle: string;
276 begin
277 Result := string(PChar(GetAttribute(MUIA_Menuitem_Title)));
278 end;
279
280 procedure TMuiMenu.SetEnabled(const AValue: Boolean);
281 begin
282 SetAttribute(MUIA_Menuitem_Enabled, AValue);
283 end;
284
285 procedure TMuiMenu.SetTitle(const AValue: string);
286 begin
287 FTitle := AValue;
288 SetAttribute(MUIA_Menuitem_Title, PChar(FTitle));
289 end;
290
291 constructor TMuiMenu.Create(const Tags: TATagList);
292 begin
293 inherited Create(MUIC_Menu, tags);
294 Par := nil;
295 end;
296
297 destructor TMuiMenu.Destroy;
298 begin
299 inherited;
300 end;
301
302 procedure TMUIMenu.DoMUIDraw();
303 begin
304 //
305 end;
306
307 { TMuiMenuItem }
308
TMuiMenuItem.GetCheckednull309 function TMuiMenuItem.GetChecked: Boolean;
310 begin
311 Result := LongBool(GetAttribute(MUIA_Menuitem_Checked));
312 end;
313
GetCheckItnull314 function TMuiMenuItem.GetCheckIt: Boolean;
315 begin
316 Result := LongBool(GetAttribute(MUIA_Menuitem_CheckIt));
317 end;
318
TMuiMenuItem.GetEnablednull319 function TMuiMenuItem.GetEnabled: Boolean;
320 begin
321 Result := LongBool(GetAttribute(MUIA_Menuitem_Enabled));
322 end;
323
TMuiMenuItem.GetMenuItemnull324 function TMuiMenuItem.GetMenuItem: TMenuItem;
325 begin
326 Result := TMenuItem(TObject(PasObject));
327 end;
328
GetShortCutnull329 function TMuiMenuItem.GetShortCut: string;
330 begin
331 Result := string(PChar(GetAttribute(MUIA_Menuitem_ShortCut)));
332 end;
333
GetTitlenull334 function TMuiMenuItem.GetTitle: string;
335 begin
336 Result := string(PChar(GetAttribute(MUIA_Menuitem_Title)));
337 end;
338
339 procedure TMuiMenuItem.SetChecked(const AValue: Boolean);
340 var
341 I: Integer;
342 MI: TMuiMenuItem;
343 begin
344 if AValue and Assigned(MenuItem) and (MenuItem.GroupIndex > 0) then
345 begin
346 if Assigned(Par) then
347 begin
348 for i := 0 to Par.ChildList.Count - 1 do
349 begin
350 if Par.ChildList.Items[i] is TMuiMenuItem then
351 begin
352 MI := TMuiMenuItem(Par.ChildList.Items[i]);
353 if MI.MenuItem.GroupIndex = MenuItem.GroupIndex then
354 MI.Checked := False;
355 end;
356 end;
357 end;
358 end;
359 SetAttribute(MUIA_Menuitem_Checked, AValue);
360 end;
361
362 procedure TMuiMenuItem.SetCheckIt(const AValue: Boolean);
363 begin
364 SetAttribute(MUIA_Menuitem_CheckIt, AValue);
365 end;
366
367 procedure TMuiMenuItem.SetEnabled(const AValue: Boolean);
368 begin
369 //writeln('SetEnabled: ',AValue);
370 SetAttribute(MUIA_Menuitem_Enabled, AValue);
371 //writeln('getEnabled: ', GetEnabled);
372 end;
373
374 procedure TMuiMenuItem.SetShortCut(const AValue: string);
375 begin
376 FShortCut := AValue;
377 //SetAttribute([MUIA_Menuitem_CommandString, 1, LongInt(MUIA_Menuitem_ShortCut), PChar(FShortCut), TAG_END]);
378 end;
379
380 procedure TMuiMenuItem.SetTitle(const AValue: string);
381 begin
382 FTitle := AValue;
383 if AValue = '-' then
384 SetAttribute(MUIA_Menuitem_Title, NativeUInt(NM_BARLABEL))
385 else
386 SetAttribute(MUIA_Menuitem_Title, PChar(FTitle));
387 end;
388
MenuClickedFuncnull389 function MenuClickedFunc(Hook: PHook; Obj: PObject_; Msg:Pointer): LongInt;
390 var
391 MuiObject: TMuiMenuItem;
392 TargetObject: TObject;
393 begin
394 Result := 0;
395 if TObject(Hook^.h_Data) is TMuiMenuItem then
396 begin
397 MuiObject := TMuiMenuItem(Hook^.h_Data);
398 TargetObject := MuiObject.pasobject;
399 TMenuItem(TargetObject).Click;
400 end;
401 end;
402
403 constructor TMuiMenuItem.Create(const Tags: TATagList);
404 begin
405 inherited Create(MUIC_MenuItem, Tags);
406 Par := nil;
407 ConnectHook(MUIA_Menuitem_Trigger, LongWord(MUIV_EveryTime), @MenuClickedFunc);
408 end;
409
410 procedure TMuiMenuItem.DoMUIDraw();
411 begin
412
413 end;
414
415 { TMuiFamily }
416
417 procedure TMuiFamily.InstallHooks;
418 begin
419 ChildList := TObjectList.Create;
420 ChildList.OwnsObjects := False;
421 end;
422
423 destructor TMuiFamily.Destroy;
424 var
425 i: Integer;
426 MUIObject: TMuiObject;
427 begin
428 for i := 0 to ChildList.Count - 1 do
429 begin
430 MUIObject := TMUIObject(ChildList[i]);
431 MUIObject.FObject := nil;
432 MUIObject.Free;
433 end;
434 ChildList.Free;
435 inherited;
436 end;
437
438 procedure TMuiFamily.AddHead(AChild: TMuiFamily);
439 begin
440 ChildList.Insert(0,AChild);
441 DoMethod([NativeUInt(MUIM_Family_AddHead), NativeUInt(AChild.Obj)]);
442 end;
443
444 procedure TMuiFamily.AddTail(AChild: TMuiFamily);
445 begin
446 ChildList.Add(AChild);
447 DoMethod([NativeUInt(MUIM_Family_AddTail), NativeUInt(AChild.Obj)]);
448 end;
449
450 procedure TMuiFamily.Remove(AChild: TMuiFamily);
451 begin
452 ChildList.Remove(AChild);
453 DoMethod([NativeUInt(MUIM_Family_Remove), NativeUInt(AChild.Obj)]);
454 end;
455
TMuiFamily.GetListnull456 function TMuiFamily.GetList: PMinList;
457 begin
458 Result := PMinList(GetAttribute(MUIA_Family_List));
459 end;
460
CloseWinFuncnull461 function CloseWinFunc(Hook: PHook; Obj: PObject_; Msg:Pointer): Longint;
462 var
463 MuiObject: TMuiWindow;
464 begin
465 if TObject(Hook^.h_Data) is TMuiWindow then
466 begin
467 MuiObject := TMuiWindow(Hook^.h_Data);
468 Result := LCLSendCloseQueryMsg(MuiObject.pasobject);
469 end;
470 end;
471
MoveWinFuncnull472 function MoveWinFunc(Hook: PHook; Obj: PObject_; Msg:Pointer): Longint;
473 var
474 MuiObject: TMuiWindow;
475 begin
476 if TObject(Hook^.h_Data) is TMuiWindow then
477 begin
478 MuiObject := TMuiWindow(Hook^.h_Data);
479 if Assigned(MuiObject.PasObject) and (not TMUIWindow(MUIObject).FBlockMove) then
480 begin
481 Result := LCLSendMoveMsg(MuiObject.pasobject, MuiObject.Left, MuiObject.Top, Move_Default, False);
482 end;
483 end;
484 end;
485
SizeWinFuncnull486 function SizeWinFunc(Hook: PHook; Obj: PObject_; Msg:Pointer): Longint;
487 var
488 MuiObject: TMuiWindow;
489 begin
490 if TObject(Hook^.h_Data) is TMuiWindow then
491 begin
492 MuiObject := TMuiWindow(Hook^.h_Data);
493 if Assigned(MuiObject.PasObject) and (not TMUIWindow(MUIObject).FBlockSize) then
494 begin
495 Result := LCLSendSizeMsg(MuiObject.pasobject, MuiObject.Width, MuiObject.Height, SIZENORMAL, False);
496 end;
497 end;
498 end;
499
500 constructor TMuiWindow.Create(const TagList: TATagList);
501 var
502 LT: TATagList;
503 GrpTags: TATagList;
504 AltLeft, AltTop, AltHeight, AltWidth: Integer;
505 begin
506 FBlockSize := False;
507 FBlockMove := False;
508 FFocusedControl := Self;
509 LT.Clear;
510 FMainMenu := TMuiMenuStrip.Create(LT);
511 HasMenu := False;
512 FInMoveEvent := False;
513 //FGrpObj := MUI_NewObject(MUIC_Group,[LongInt(MUIA_Group_LayoutHook), @LayoutHook, TAG_END]);
514 //
515 SetHook(LayoutHook, @LayoutFunc, self);
516 //
517 GrpTags.AddTags([
518 MUIA_Group_LayoutHook, NativeUInt(@LayoutHook),
519 MUIA_Frame, MUIV_Frame_None,
520 //MUIA_FillArea, LFalse,
521 MUIA_InnerLeft, 0,
522 MUIA_InnerTop, 0,
523 MUIA_InnerRight, 0,
524 MUIA_InnerBottom, 0
525 ]);
526 FGrpObj := NewObjectA(LCLGroupClass, nil, GrpTags);
527 if Assigned(FGrpObj) then
528 Pointer(INST_DATA(LCLGroupClass, Pointer(FGrpObj))^) := Self;
529 //
530 AltLeft := 0;
531 AltTop := 0;
532 AltWidth := IntuitionBase^.ActiveScreen^.Width;
533 AltHeight := IntuitionBase^.ActiveScreen^.Height - IntuitionBase^.ActiveScreen^.BarHeight;
534 TagList.AddTags([
535 MUIA_Window_AltLeftEdge , AltLeft,
536 MUIA_Window_AltTopEdge , AltTop,
537 MUIA_Window_AltWidth , AltWidth,
538 MUIA_Window_AltHeight , AltHeight,
539 MUIA_Window_Menustrip, NativeUInt(FMainMenu.Obj),
540 MUIA_Window_RootObject, NativeUInt(FGrpObj)
541 ]);
542 inherited Create(MUIC_Window, TagList);
543 //
544 Self.Parent := MUIApp;
545 if MuiApp.MainWin = obj then
546 SetAttribute(MUIA_Window_Activate, True);
547 end;
548
549 destructor TMuiWindow.Destroy;
550 begin
551 FMainMenu.Free;
552 inherited Destroy;
553 end;
554
555 procedure TMuiWindow.InstallHooks;
556 begin
557 //inherited;
558 ConnectHook(MUIA_Window_CloseRequest, LongWord(LTrue), @CloseWinFunc);
559 // Move Window
560 ConnectHook(MUIA_Window_LeftEdge, LongWord(MUIV_EveryTime), @MoveWinFunc);
561 ConnectHook(MUIA_Window_TopEdge, LongWord(MUIV_EveryTime), @MoveWinFunc);
562 // Resize Window
563 ConnectHook(MUIA_Window_Width, LongWord(MUIV_EveryTime), @SizeWinFunc);
564 ConnectHook(MUIA_Window_Height, LongWord(MUIV_EveryTime), @SizeWinFunc);
565 end;
566
567 procedure TMuiWindow.GetSizes;
568 begin
569 FBlockSizeMsg := not FInitWindow;
570 Left := GetAttribute(MUIA_Window_LeftEdge);
571 Top := GetAttribute(MUIA_Window_TopEdge);
572 //
573 if not Sizeable then
574 begin
575 Width := GetAttribute(MUIA_Window_Width);
576 Height := GetAttribute(MUIA_Window_Height);
577 end else
578 begin
579 Width := GetAttribute(MUIA_Window_Width);
580 Height := GetAttribute(MUIA_Window_Height);
581 end;
582 TWinControl(PasObject).SetBounds(Left, Top, Width, Height);
583 FBlockSizeMsg := False;
584 end;
585
586 procedure TMuiWindow.Redraw;
587 var
588 Msg: LongWord;
589 begin
590 if BlockRedraw then
591 Exit;
592 DoMethodObj(FGrpObj, [MUIM_Group_InitChange]);
593 DoMethodObj(FGrpObj, [MUIM_Group_ExitChange]);
594 end;
595
596 procedure TMuiWindow.DoMUIDraw();
597 begin
598 //inherited;
599 if Assigned(FGrpObj) then
600 MUI_Redraw(FGrpobj, $805);//MADF_DRAWOBJECT);
601 end;
602
GetClientRectnull603 function TMuiWindow.GetClientRect: TRect;
604 var
605 win: PWindow;
606 begin
607 Result := inherited;
608 Result.Left := 0;
609 Result.Top := 0;
610 Result.Right := Width;
611 Result.Bottom := Height;
612 {$if defined(Amiga) or defined(MorphOS)}
613 Win := Self.Window;
614 if Assigned(Win) then
615 begin
616 Result.Width := Result.Width - (Win^.BorderLeft + Win^.BorderRight);
617 Result.Height := Result.Height - (Win^.BorderTop + Win^.BorderBottom);
618 end else
619 begin
620 if Sizeable then
621 begin
622 Result.Width := Result.Width - 8;
623 Result.Height := Result.Height - 21
624 end
625 else
626 begin
627 Result.Width := Result.Width - 8;
628 Result.Height := Result.Height - 13
629 end;
630 end;
631 {$endif}
632 end;
633
GetWindownull634 function TMuiWindow.GetWindow: PWindow;
635 begin
636 Result := PWindow(GetAttribute(MUIA_Window_Window));
637 end;
638
TMuiWindow.GetWindowOffsetnull639 function TMuiWindow.GetWindowOffset: TPoint;
640 begin
641 Result.X := 0;
642 Result.Y := 0;
643 end;
644
645 procedure TMuiWindow.SetLeft(ALeft: LongInt);
646 begin
647 if FBlockSizeMsg then
648 Exit;
649 FBlockMove := True;
650 inherited;
651 SetAttribute(MUIA_Window_LeftEdge, ALeft);
652 FBlockMove := False;
653 end;
654
655 procedure TMuiWindow.SetTop(ATop: LongInt);
656 begin
657 if FBlockSizeMsg then
658 Exit;
659 FBlockMove := True;
660 inherited;
661 SetAttribute(MUIA_Window_TopEdge, ATop);
662 FBlockMove := False;
663 end;
664
GetTopnull665 function TMuiWindow.GetTop(): Integer;
666 begin
667 Result := GetAttribute(MUIA_Window_TopEdge);
668 end;
669
TMuiWindow.GetLeftnull670 function TMuiWindow.GetLeft(): Integer;
671 begin
672 Result := GetAttribute(MUIA_Window_LeftEdge);
673 end;
674
GetWidthnull675 function TMuiWindow.GetWidth(): Integer;
676 begin
677 if Sizeable then
678 Result := GetAttribute(MUIA_Window_Width)
679 else
680 Result := PasObject.Width;
681 end;
682
TMuiWindow.GetHeightnull683 function TMuiWindow.GetHeight(): Integer;
684 begin
685 if Sizeable then
686 Result := GetAttribute(MUIA_Window_Height)
687 else
688 Result := PasObject.Height;
689 end;
690
TMuiWindow.GetCaptionnull691 function TMuiWindow.GetCaption: string;
692 begin
693 inherited;
694 //Result := FCaption;
695 Result := PChar(GetAttribute(MUIA_Window_Title));
696 end;
697
TMuiWindow.GetVisiblenull698 function TMuiWindow.GetVisible: Boolean;
699 begin
700 Result := Boolean(GetAttribute(MUIA_Window_Open));
701 end;
702
703 procedure TMuiWindow.SetCaption(const AValue: string);
704 var
705 PC: PChar;
706 begin
707 FCaption := AValue;
708 PC := PChar(FCaption);
709 SetAttribute(MUIA_Window_Title, PC);
710 end;
711
712 procedure TMuiWindow.SetVisible(const AValue: Boolean);
713 begin
714 FInitWindow := True;
715 SetAttribute(MUIA_Window_Open, AValue);
716 if AValue then
717 begin
718 GetSizes;
719 TWinControl(PasObject).InvalidateClientRectCache(True);
720 end;
721 FInitWindow := False;
722 end;
723
724 procedure TMuiWindow.AddChild(ChildObj: PObject_);
725 begin
726 if Assigned(FGrpObj) and Assigned(ChildObj) then
727 begin
728 DoMethodObj(FGrpObj, [MUIM_Group_InitChange]);
729 DoMethodObj(FGrpObj, [OM_ADDMEMBER, PtrUInt(ChildObj)]);
730 DoMethodObj(FGrpObj, [MUIM_Group_ExitChange]);
731 end;
732 end;
733
734 procedure TMuiWindow.RemoveChild(ChildObj: PObject_);
735 begin
736 //writeln('-> window remove child ', HexStr(Child), ' ', HexStr(Child.obj), ' ', HexStr(Self), ' ', HexStr(FGrpObj));
737 if Assigned(FGrpObj) and Assigned(ChildObj) then
738 begin
739 //DoMethodObj(FGrpObj, [MUIM_Group_InitChange]);
740 DoMethodObj(FGrpObj, [OM_REMMEMBER, PtrUInt(ChildObj)]);
741 //DoMethodObj(FGrpObj, [MUIM_Group_ExitChange]);
742 end;
743 //writeln('<-window remove child');
744 end;
745
746 procedure TMuiWindow.GetBoundsFromMUI;
747 begin
748 FLeft := GetAttribute(MUIA_Window_LeftEdge);
749 FTop := GetAttribute(MUIA_Window_TopEdge);
750 FWidth := GetAttribute(MUIA_Window_Width);
751 FHeight := GetAttribute(MUIA_Window_Height);
752 end;
753
754 procedure TMuiWindow.SetFocusedControl(AControl: TMUIObject);
755 begin
756 FFocusedControl := AControl;
757 if Assigned(AControl) then
758 begin
759 SetAttribute([MUIA_Window_Activate, TagTrue, MUIA_Window_ActiveObject, NativeUInt(AControl.FocusObject)]);
760 end;
761 end;
762
763 procedure TMuiWindow.SetEnabled(const AEnabled: Boolean);
764 begin
765 //writeln('Enabled: ', AEnabled);
766 //SetAttObj(FgrpObj, [MUIA_Disabled, ifthen(AEnabled, LFalse, LTrue)]);
767 end;
768
GetEnablednull769 function TMuiWindow.GetEnabled: Boolean;
770 begin
771 Result := True;//not boolean(GetAttObj(FGrpObj, MUIA_Disabled));
772 end;
773
774
775 { TMuiGroup }
776
777 constructor TMuiGroup.Create(const TagList: TATagList);
778 begin
779 inherited Create(MUIC_Group, TagList);
780 end;
781
782 end.
783
784