suithemes.pas

来自「新颖按钮控件」· PAS 代码 · 共 1,023 行 · 第 1/3 页

PAS
1,023
字号
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Str,
        Bool,
        Int,
        Int,
        Int,
        Str,
        Str,
        Str,
        Int,
        Color,
        Str,
        Str,
        Str,
        Str,
        Color,
        Color,
        Color,
        Color,
        Color
    );

function GetThemeElement(
    UIStyle : TsuiUIStyle;
    Element : Integer;
    var ReturnType : TsuiType
) : Integer;
var
    pTheme : PTsuiTheme;
begin
    case UIStyle of

    MacOS     : pTheme := @MacOSTheme;
    WinXP     : pTheme := @WinXPTheme;
    DeepBlue  : pTheme := @DeepBlueTheme;
    Protein   : pTheme := @ProteinTheme;
    BlueGlass : pTheme := @BlueGlassTheme;

    else
    begin
        ReturnType := Int;
        Result := -1;
        Exit;
    end;

    end; // case

    ReturnType := ThemeElementType[Element];
    Result := Integer(pTheme^[Element]);
end;

function GetThemeString(
    UIStyle : TsuiUIStyle;
    Element : Integer
) : String;
var
    ReturnType : TsuiType;
    nResult : Integer;
begin
    Result := '';

    nResult := GetThemeElement(UIStyle, Element, ReturnType);
    if ReturnType = Str then
        Result := PCharToStr(PChar(nResult));
end;

function GetThemeInt(
    UIStyle : TsuiUIStyle;
    Element : Integer
) : Integer;
var
    ReturnType : TsuiType;
    nResult : Integer;
begin
    Result := -1;

    nResult := GetThemeElement(UIStyle, Element, ReturnType);
    if ReturnType = Int then
        Result := nResult
end;

function GetThemeBool(
    UIStyle : TsuiUIStyle;
    Element : Integer
) : Boolean;
var
    ReturnType : TsuiType;
    nResult : Integer;
begin
    Result := false;

    nResult := GetThemeElement(UIStyle, Element, ReturnType);
    if ReturnType = Bool then
        Result := Boolean(nResult);
end;

function GetThemeColor(
    UIStyle : TsuiUIStyle;
    Element : Integer
) : TColor;
var
    ReturnType : TsuiType;
    nResult : Integer;
begin
    Result := clBlack;

    nResult := GetThemeElement(UIStyle, Element, ReturnType);
    if ReturnType = Color then
        Result := nResult;
end;


function GetSUIFormColor(Form : TCustomForm) : TColor;
var
    i : Integer;
begin
    Result := clBtnFace;

    for i := 0 to Form.ControlCount - 1 do
    begin
        if Form.Controls[i] is TsuiForm then
        begin
            Result := (Form.Controls[i] as TsuiForm).Color;
            break;
        end;
    end;
end;

function GetBorderColor(Form : TCustomForm) : TColor;
var
    i : Integer;
    UIStyle : TsuiUIStyle;
begin
    Result := clBlack;

    for i := 0 to Form.ControlCount - 1 do
    begin
        if Form.Controls[i] is TsuiForm then
        begin
            UIStyle := (Form.Controls[i] as TsuiForm).UIStyle;
            Result := GetThemeColor(UIStyle, SUI_CONTROL_BORDER_COLOR);
            break;
        end;
    end;
end;

function GetSUIFormStyle(Form : TCustomForm) : TsuiUIStyle;
var
    i : Integer;
begin
    Result := SUI_THEME_DEFAULT;

    for i := 0 to Form.ControlCount - 1 do
    begin
        if Form.Controls[i] is TsuiForm then
        begin
            Result := (Form.Controls[i] as TsuiForm).UIStyle;
            break;
        end;
    end;
end;

procedure ContainerApplyUIStyle(Container : TWinControl; UIStyle : TsuiUIStyle);
var
    i : Integer;
begin
    with Container do
    begin
        for i := 0 to ControlCount - 1 do
        begin
            if Controls[i] is TsuiRadioButton then
            begin
                if (Controls[i] as TsuiRadioButton).UIStyle <> Custom then
                    (Controls[i] as TsuiRadioButton).UIStyle := UIStyle;
            end;

            if Controls[i] is TsuiCheckBox then
            begin
                if (Controls[i] as TsuiCheckBox).UIStyle <> Custom then
                    (Controls[i] as TsuiCheckBox).UIStyle := UIStyle;
            end;

            if Controls[i] is TsuiProgressBar then
            begin
                if (Controls[i] as TsuiProgressBar).UIStyle <> Custom then
                    (Controls[i] as TsuiProgressBar).UIStyle := UIStyle;
            end;

            if Controls[i] is TsuiButton then
            begin
                if (Controls[i] as TsuiButton).UIStyle <> Custom then
                    (Controls[i] as TsuiButton).UIStyle := UIStyle;
            end;

            if Controls[i] is TsuiListBox then
                (Controls[i] as TsuiListBox).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiGroupBox then
            begin
                (Controls[i] as TsuiGroupBox).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );
                (Controls[i] as TsuiGroupBox).Font.Color := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_FONT_COLOR
                );
                (Controls[i] as TsuiGroupBox).Color := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BACKGROUND_COLOR
                );
            end;

            if Controls[i] is TsuiEdit then
                (Controls[i] as TsuiEdit).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiMemo then
                (Controls[i] as TsuiMemo).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiCheckListBox then
                (Controls[i] as TsuiCheckListBox).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiSideChannel then
            begin
                (Controls[i] as TsuiSideChannel).Color := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BACKGROUND_COLOR
                );
                (Controls[i] as TsuiSideChannel).SideBarColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BACKGROUND_COLOR
                );
            end;

            if Controls[i] is TsuiCheckGroup then
                (Controls[i] as TsuiCheckGroup).UIStyle := UIStyle;

            if Controls[i] is TsuiComboBox then
                (Controls[i] as TsuiComboBox).UIStyle := UIStyle;

            if Controls[i] is TsuiListView then
                (Controls[i] as TsuiListView).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiTreeView then
                (Controls[i] as TsuiTreeView).BorderColor := GetThemeColor(
                    UIStyle,
                    SUI_CONTROL_BORDER_COLOR
                );

            if Controls[i] is TsuiTabControl then
                (Controls[i] as TsuiTabControl).UIStyle := UIStyle;

            if Controls[i] is TsuiTrackBar then
                (Controls[i] as TsuiTrackBar).UIStyle := UIStyle;

            if Controls[i] is TsuiToolBar then
                (Controls[i] as TsuiToolBar).UIStyle := UIStyle;

            if Controls[i] is TsuiPageControl then
                (Controls[i] as TsuiPageControl).UIStyle := UIStyle;
        end;
    end;
end;

procedure SubContainerApplyUIStyle(Container : TWinControl; UIStyle : TsuiUIStyle);
var
    i : Integer;
begin
    for i := 0 to Container.ControlCount - 1 do
    begin
        if Container.Controls[i] is TsuiImagePanel then
            (Container.Controls[i] as TsuiImagePanel).UpdateUIStyle(UIStyle);

        if Container.Controls[i] is TsuiGroupBox then
            (Container.Controls[i] as TsuiGroupBox).UpdateUIStyle(UIStyle);

        if Container.Controls[i] is TsuiTabControl then
            (Container.Controls[i] as TsuiTabControl).UpdateUIStyle(UIStyle);

        if Container.Controls[i] is TsuiTabSheet then
            (Container.Controls[i] as TsuiTabSheet).UpdateUIStyle(UIStyle);
    end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?