Changeset 644


Ignore:
Timestamp:
2008/10/18 17:50:24 (4 years ago)
Author:
egtra
Message:

#222 3状態への対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/ActiveBasic/Windows/UI/CheckBox.ab

    r642 r644  
    1 #require <Classes/ActiveBasic/Windows/UI/Control.ab> 
     1#require <Classes/ActiveBasic/Windows/UI/ButtonBase.ab> 
    22 
    33Namespace ActiveBasic 
    44Namespace Windows 
    55Namespace UI 
     6 
     7Enum CheckState 
     8    Unchecked = BST_UNCHECKED 
     9    Checked = BST_CHECKED 
     10    Indeterminate = BST_INDETERMINATE 
     11End Enum 
    612 
    713/*! 
     
    3642 
    3743    /*! 
     44    @brief チェック状態の取得 
     45    */ 
     46    Const Function State() As CheckState 
     47        Dim ret = SendMessage(BM_GETCHECK) 
     48/* 
     49        If ret = BST_UNCHECKED Or ret = BST_CHECKED Or ret = BST_INDETERMINATE Then 
     50            State = ret As CheckState 
     51*/ 
     52        If ret = BST_CHECKED Then 
     53            State = CheckState.Checked 
     54        ElseIf ret = BST_INDETERMINATE Then 
     55            State = CheckState.Indeterminate 
     56        Else 
     57            State = CheckState.Unchecked 
     58        End If 
     59    End Function 
     60 
     61    /*! 
     62    @brief チェック状態の設定 
     63    */ 
     64    Sub State(state As CheckState) 
     65        SendMessage(BM_SETCHECK, state As WPARAM, 0) 
     66    End Sub 
     67 
     68    /*! 
    3869    @brief クリック時に自動で状態変化するかどうかの取得。 
    3970    @retval true 自動変化する 
     
    4172    */ 
    4273    Function AutoCheck() As Boolean 
    43         AutoCheck = ((Style And BS_AUTOCHECKBOX) = BS_AUTOCHECKBOX) 
     74        AutoCheck = autoCheck(Style) 
    4475    End Function 
    4576 
     
    5586        End If 
    5687    End Sub 
     88 
     89    /*! 
     90    @brief 3状態目を使用するどうかの設定。 
     91    @param[in] useThreeState 3状態目を使用するならTrue、そうでないならFalse。 
     92    */ 
     93    Sub ThreeState(useThreeState As Boolean) 
     94        Dim oldStyle = This.Style 
     95        Dim style = oldStyle And (Not 7) 
     96        Dim buttonType = oldStyle And 7 
     97        If useThreeState = threeState(buttonType) Then 
     98            Exit Sub 
     99        End If 
     100        If useThreeState Then 
     101            If buttonType = BS_AUTOCHECKBOX Then 
     102                style Or= BS_AUTO3STATE 
     103            Else 
     104                style Or= BS_3STATE 
     105            End If 
     106        Else 
     107            If buttonType = BS_AUTO3STATE Then 
     108                style Or= BS_AUTOCHECKBOX 
     109            Else 
     110                style Or= BS_CHECKBOX 
     111            End If 
     112        End If 
     113        Style = style 
     114    End Sub 
     115 
     116    /*! 
     117    @brief 3状態目を使用しているかどうかの取得。 
     118    */ 
     119    Function ThreeState() As Boolean 
     120        ThreeState = threeState(Style) 
     121    End Function 
     122Private 
     123    Static Function threeState(style As DWord) As Boolean 
     124        style And= 7 
     125        Return style = BS_3STATE Or style = BS_AUTO3STATE 
     126    End Function 
     127 
     128    Static Function autoCheck(style As DWord) As Boolean 
     129        style And= 7 
     130        Return (style = BS_AUTOCHECKBOX Or style = BS_AUTO3STATE) 
     131    End Function 
    57132End Class 
    58133 
Note: See TracChangeset for help on using the changeset viewer.