📄 suiform.pas
字号:
m_MenuBar.Free();
m_MenuBar := nil;
end;
m_TitleBar.Free();
m_TitleBar := nil;
if m_BorderBuf <> nil then
begin
m_BorderBuf.Free();
m_BorderBuf := nil;
end;
inherited;
end;
procedure TsuiForm.DestroyMenuBar;
begin
if m_Form.FormStyle <> fsMDIChild then
begin
if m_MenuBar <> nil then
begin
m_MenuBar.Free();
m_MenuBar := nil;
end;
end;
m_Menu := nil;
end;
procedure TsuiForm.DrawButton(Sender: TToolBar; Button: TToolButton;
State: TCustomDrawState; var DefaultDraw: Boolean);
var
ACanvas : TCanvas;
ARect : TRect;
R : TRect;
Bmp : TBitmap;
Buf : TBitmap;
Style : TsuiUIStyle;
OutUIStyle : TsuiUIStyle;
CanSetFont : Boolean;
AFileTheme : TsuiFileTheme;
bUseFileTheme : Boolean;
begin
Style := m_UIStyle;
AFileTheme := m_FileTheme;
CanSetFont := false;
ACanvas := Sender.Canvas;
ARect := Button.BoundsRect;
DefaultDraw := false;
if Menu <> nil then
begin
if Menu is TsuiMainMenu then
begin
Style := (Menu as TsuiMainMenu).UIStyle;
AFileTheme := (Menu as TsuiMainMenu).FileTheme;
if (m_Menu as TsuiMainMenu).UseSystemFont then
Menu_GetSystemFont(ACanvas.Font)
else
begin
ACanvas.Font.Name := (m_Menu as TsuiMainMenu).FontName;
ACanvas.Font.Size := (m_Menu as TsuiMainMenu).FontSize;
ACanvas.Font.Charset := (m_Menu as TsuiMainMenu).FontCharset;
ACanvas.Font.Color := (m_Menu as TsuiMainMenu).FontColor;
CanSetFont := true;
end;
end;
end;
// MacOS
if (
((cdsHot in State) or (cdsSelected in State)) and
{$IFDEF RES_MACOS} (Style = MacOS) {$ELSE} false {$ENDIF}
) then
begin
DefaultDraw := false;
Buf := TBitmap.Create();
Bmp := TBitmap.Create();
Buf.Width := Button.Width;
Buf.Height := Button.Height;
R := Rect(0, 0, Buf.Width, Buf.Height);
Bmp.LoadFromResourceName(hInstance, 'MACOS_MENU_SELECT');
Buf.Canvas.StretchDraw(R, Bmp);
Buf.Canvas.Brush.Style := bsClear;
if CanSetFont then
begin
Buf.Canvas.Font.Name := (m_Menu as TsuiMainMenu).FontName;
Buf.Canvas.Font.Size := (m_Menu as TsuiMainMenu).FontSize;
Buf.Canvas.Font.Charset := (m_Menu as TsuiMainMenu).FontCharset;
end
else
begin
Buf.Canvas.Font.Name := ACanvas.Font.Name;
Buf.Canvas.Font.Size := ACanvas.Font.Size;
Buf.Canvas.Font.Charset := ACanvas.Font.Charset;
end;
if UsingFileTheme(AFileTheme, Style, OutUIStyle) then
Buf.Canvas.Font.Color := AFileTheme.GetColor(SUI_THEME_MENU_SELECTED_FONT_COLOR)
else
Buf.Canvas.Font.Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_MENU_SELECTED_FONT_COLOR);
R.Bottom := R.Bottom + 2;
DrawText(Buf.Canvas.Handle, PChar(Button.Caption), -1, R, DT_CENTER or DT_VCENTER or DT_SINGLELINE);
ACanvas.Draw(ARect.Left, ARect.Top, Buf);
Bmp.Free();
Buf.Free();
end
else if (
(cdsHot in State) or
(cdsSelected in State)
) then
begin // selected or hot top menu
// draw client background
if cdsSelected in State then
ARect.Right := ARect.Right - 2;
if UsingFileTheme(AFileTheme, Style, OutUIStyle) then
begin
ACanvas.Brush.Color := AFileTheme.GetColor(SUI_THEME_MENU_SELECTED_BACKGROUND_COLOR);
bUseFileTheme := true
end
else
begin
ACanvas.Brush.Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_MENU_SELECTED_BACKGROUND_COLOR);
bUseFileTheme := false
end;
ACanvas.FillRect(ARect);
// draw border
if bUseFileTheme then
ACanvas.Brush.Color := AFileTheme.GetColor(SUI_THEME_MENU_SELECTED_BORDER_COLOR)
else
ACanvas.Brush.Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_MENU_SELECTED_BORDER_COLOR);
ACanvas.FrameRect(ARect);
// draw text
if cdsSelected in State then
ARect.Left := ARect.Left + 2;
ARect.Top := ARect.Top + 2;
if bUseFileTheme then
ACanvas.Font.Color := AFileTheme.GetColor(SUI_THEME_MENU_SELECTED_FONT_COLOR)
else
ACanvas.Font.Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_MENU_SELECTED_FONT_COLOR);
DrawText(ACanvas.Handle, PChar(Button.Caption), -1, ARect, DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end
// not select and not hot top menu
else
begin
ACanvas.Brush.Style := bsClear;
ARect.Top := ARect.Top + 2;
if UsingFileTheme(AFileTheme, Style, OutUIStyle) then
begin
if AFileTheme.GetColor(SUI_THEME_CONTROL_FONT_COLOR) = 196608 then
ACanvas.Font.Color := clWhite
else
ACanvas.Font.Color := AFileTheme.GetColor(SUI_THEME_MENU_FONT_COLOR);
end
else
ACanvas.Font.Color := GetInsideThemeColor(OutUIStyle, SUI_THEME_MENU_FONT_COLOR);
if not Button.Enabled then
ACanvas.Font.Color := clGray;
DrawText(ACanvas.Handle, PChar(Button.Caption), -1, ARect, DT_CENTER or DT_VCENTER or DT_SINGLELINE);
end;
end;
procedure TsuiForm.DrawMenuBar(Sender: TToolBar; const ARect: TRect;
var DefaultDraw: Boolean);
var
ACanvas : TCanvas;
Buf : TBitmap;
Style : TsuiUIStyle;
begin
Style := m_UIStyle;
if Menu <> nil then
begin
if Menu is TsuiMainMenu then
Style := (Menu as TsuiMainMenu).UIStyle;
end;
{$IFDEF RES_MACOS}
if (Style = MacOS) then
begin
ACanvas := Sender.Canvas;
Buf := TBitmap.Create();
Buf.LoadFromResourceName(hInstance, 'MACOS_MENU_BAR');
ACanvas.StretchDraw(ARect, Buf);
Buf.Free();
end;
{$ENDIF}
end;
function TsuiForm.GetButtons: TsuiTitleBarButtons;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.Buttons;
end;
function TsuiForm.GetCaption: TCaption;
begin
if m_TitleBar = nil then
Result := ''
else
Result := m_TitleBar.Caption;
end;
function TsuiForm.GetDrawAppIcon: Boolean;
begin
if m_TitleBar = nil then
Result := false
else
Result := m_TitleBar.DrawAppIcon;
end;
function TsuiForm.GetFont: TFont;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.Font;
end;
function TsuiForm.GetMDIChild: Boolean;
begin
Result := (m_Form.FormStyle = fsMDIChild);
end;
function TsuiForm.GetOnBtnClick: TsuiTitleBarButtonClickEvent;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.OnCustomBtnsClick;
end;
function TsuiForm.GetOnHelpBtnClick: TsuiTitleBarButtonClickEvent;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.OnHelpBtnClick;
end;
function TsuiForm.GetRoundCorner: Integer;
begin
if m_TitleBar = nil then
Result := 0
else if not m_TitleBar.Visible then
Result := 0
else
Result := m_TitleBar.RoundCorner;
end;
function TsuiForm.GetRoundCornerBottom: Integer;
begin
if m_TitleBar = nil then
Result := 0
else if not m_TitleBar.Visible then
Result := 0
else
Result := m_TitleBar.RoundCornerBottom;
end;
function TsuiForm.GetSections: TsuiTitleBarSections;
begin
if m_TitleBar = nil then
Result := nil
else
Result := m_TitleBar.Sections;
end;
function TsuiForm.GetTitleBarCustom: Boolean;
begin
if m_TitleBar = nil then
Result := false
else
Result := m_TitleBar.Custom;
end;
function TsuiForm.GetTitleBarHeight: Integer;
begin
if (m_TitleBar = nil) or (not TitleBarVisible) then
Result := 0
else
Result := m_TitleBar.Height;
end;
function TsuiForm.GetTitleBarVisible: Boolean;
begin
if m_TitleBar = nil then
Result := false
else
Result := m_TitleBar.Visible;
end;
function TsuiForm.GetVersion: String;
begin
Result := '5.8';
end;
var
l_InFlag : Integer = 0;
l_MaxFlag : Boolean = false;
procedure TsuiForm.NewParentWndProc(var Msg: TMessage);
var
Rect : TRect;
pcsp: PNCCalcSizeParams;
P : PWindowPos;
begin
if m_Destroyed then
Exit;
if Msg.Msg = WM_NCCALCSIZE then
begin
if Boolean(Msg.wParam) then
begin
pcsp := PNCCalcSizeParams(Msg.lParam);
P := pcsp^.lppos;
with pcsp^.rgrc[0] do
begin
Top := P^.y;
if m_BorderBuf <> nil then
begin
Right := P^.x + P^.cx - m_BorderBuf.Width + 2;
Left := P^.x + m_BorderBuf.Width - 2;
end
else
begin
Right := P^.x + P^.cx;
Left := P^.x;
end;
if m_BottomBorderWidth <> 0 then
Bottom := P^.y + P^.cy - m_BottomBorderWidth + 2
else if m_Width = 3 then
Bottom := P^.y + P^.cy
else
Bottom := P^.y + P^.cy - m_Width + 2;
end;
pcsp^.rgrc[1] := pcsp^.rgrc[0];
Msg.lParam := LongInt(pcsp);
Msg.Result := WVR_VALIDRECTS;
end
else
Msg.Result := 0;
end;
if Msg.Msg = SUIM_GETBORDERWIDTH then
begin
if m_BorderBuf <> nil then
Msg.Result := m_BorderBuf.Width
else
Msg.Result := 0;
Exit;
end;
if Msg.Msg <> WM_NCPAINT then
m_OldWndProc(Msg);
if Msg.Msg = WM_MDIACTIVATE then
begin
if TWMMDIActivate(Msg).ActiveWnd = m_Form.Handle then
begin
SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU, m_Form.Handle, 0);
m_TitleBar.FormActive := true;
end
else
m_TitleBar.FormActive := false
end;
if Msg.Msg = WM_KEYDOWN then
ProcessKeyPress(Msg);
if Msg.Msg = WM_SHOWWINDOW then
begin
m_Form.Menu := nil;
end;
if Msg.Msg = WM_DESTROY then
begin
if m_Form.FormStyle = fsMDIChild then
begin
if Application = nil then
Exit;
if Application.MainForm.MDIChildCount = 1 then
SendMessage(Application.MainForm.ClientHandle, WM_MDIREFRESHMENU, m_Form.Handle, 0);
if m_Form.WindowState = wsMaximized then
SendMessage(Application.MainForm.ClientHandle, WM_MDIRESTORE, m_Form.Handle, 0);
end;
end;
if Msg.Msg = WM_ACTIVATE then
begin
if Msg.WParamLo = WA_INACTIVE then
m_TitleBar.FormActive := false
else
m_TitleBar.FormActive := true;
end;
if Msg.Msg = WM_NCPAINT then
begin
if m_Form.WindowState = wsMinimized then
m_OldWndProc(Msg)
else
PaintFormBorder();
end;
if (Msg.Msg = CM_RECREATEWND) or (Msg.Msg = CN_PARENTNOTIFY) or (Msg.Msg = CM_FLOAT) then
begin
if WS_CAPTION and GetWindowLong(m_Form.Handle, GWL_STYLE) <> 0 then
begin
SetWindowLong(m_Form.Handle, GWL_STYLE, GetWindowLong(m_Form.Handle, GWL_STYLE) and (not WS_CAPTION));
SetWindowPos(m_Form.Handle, 0, 0, 0, 0, 0, SWP_DRAWFRAME or SWP_NOMOVE or SWP_NOZORDER or SWP_NOSIZE or SWP_NOACTIVATE);
end;
end;
if Msg.Msg = WM_SIZE then
begin
if (m_Form.WindowState = wsMaximized) and (csDesigning in ComponentState) then
Exit;
if m_FormInitMax then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -