X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/83448d71476c44b449f09395cda06fa72b19a50e..52f52ebc4e0be6a9899d328b08db9eb14629d219:/wxPython/src/msw/controls.py diff --git a/wxPython/src/msw/controls.py b/wxPython/src/msw/controls.py index 409663dbfd..51a5ebaeb6 100644 --- a/wxPython/src/msw/controls.py +++ b/wxPython/src/msw/controls.py @@ -53,14 +53,6 @@ class Button(core.Control): """ return _controls.Button_SetDefault(*args, **kwargs) - def SetImageLabel(*args, **kwargs): - """SetImageLabel(Bitmap bitmap)""" - return _controls.Button_SetImageLabel(*args, **kwargs) - - def SetImageMargins(*args, **kwargs): - """SetImageMargins(int x, int y)""" - return _controls.Button_SetImageMargins(*args, **kwargs) - def GetDefaultSize(*args, **kwargs): """GetDefaultSize() -> Size""" return _controls.Button_GetDefaultSize(*args, **kwargs) @@ -91,7 +83,13 @@ def Button_GetDefaultSize(*args, **kwargs): return _controls.Button_GetDefaultSize(*args, **kwargs) class BitmapButton(Button): - """A Buttont that contains a bitmap.""" + """ + A Button that contains a bitmap. A bitmap button can be supplied with a + single bitmap, and wxWindows will draw all button states using this bitmap. If + the application needs more control, additional bitmaps for the selected state, + unpressed focused state, and greyed-out state may be supplied. + + """ def __repr__(self): return "<%s.%s; proxy of C++ wxBitmapButton instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): @@ -101,7 +99,7 @@ class BitmapButton(Button): Validator validator=DefaultValidator, String name=ButtonNameStr) -> BitmapButton - Create and show a button. + Create and show a button with a bitmap for the label. """ newobj = _controls.new_BitmapButton(*args, **kwargs) self.this = newobj.this @@ -224,6 +222,12 @@ CHK_UNCHECKED = _controls.CHK_UNCHECKED CHK_CHECKED = _controls.CHK_CHECKED CHK_UNDETERMINED = _controls.CHK_UNDETERMINED class CheckBox(core.Control): + """ + A checkbox is a labelled box which by default is either on (checkmark is + visible) or off (no checkmark). Optionally (When the wxCHK_3STATE style flag + is set) it can have a third state, called the mixed or undetermined + state. Often this is used as a "Does Not Apply" state. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxCheckBox instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): @@ -231,6 +235,8 @@ class CheckBox(core.Control): __init__(Window parent, int id, String label, Point pos=DefaultPosition, Size size=DefaultSize, long style=0, Validator validator=DefaultValidator, String name=CheckBoxNameStr) -> CheckBox + + Creates and shows a CheckBox control """ newobj = _controls.new_CheckBox(*args, **kwargs) self.this = newobj.this @@ -243,35 +249,73 @@ class CheckBox(core.Control): Create(Window parent, int id, String label, Point pos=DefaultPosition, Size size=DefaultSize, long style=0, Validator validator=DefaultValidator, String name=CheckBoxNameStr) -> bool + + Actually create the GUI CheckBox for 2-phase creation. """ return _controls.CheckBox_Create(*args, **kwargs) def GetValue(*args, **kwargs): - """GetValue() -> bool""" + """ + GetValue() -> bool + + Gets the state of a 2-state CheckBox. Returns True if it is checked, + False otherwise. + """ return _controls.CheckBox_GetValue(*args, **kwargs) def IsChecked(*args, **kwargs): - """IsChecked() -> bool""" + """ + IsChecked() -> bool + + Similar to GetValue, but raises an exception if it is not a 2-state CheckBox. + """ return _controls.CheckBox_IsChecked(*args, **kwargs) def SetValue(*args, **kwargs): - """SetValue(bool state)""" + """ + SetValue(bool state) + + Set the state of a 2-state CheckBox. Pass True for checked, + False for unchecked. + """ return _controls.CheckBox_SetValue(*args, **kwargs) def Get3StateValue(*args, **kwargs): - """Get3StateValue() -> int""" + """ + Get3StateValue() -> int + + Returns wx.CHK_UNCHECKED when the CheckBox is unchecked, wx.CHK_CHECKED when + it is checked and wx.CHK_UNDETERMINED when it's in the undetermined state. + Raises an exceptiion when the function is used with a 2-state CheckBox. + """ return _controls.CheckBox_Get3StateValue(*args, **kwargs) def Set3StateValue(*args, **kwargs): - """Set3StateValue(int state)""" + """ + Set3StateValue(int state) + + Sets the CheckBox to the given state. The state parameter can be + one of the following: wx.CHK_UNCHECKED (Check is off), wx.CHK_CHECKED + (Check is on) or wx.CHK_UNDETERMINED (Check is mixed). Raises an + exception when the CheckBox is a 2-state checkbox and setting the state + to wx.CHK_UNDETERMINED. + """ return _controls.CheckBox_Set3StateValue(*args, **kwargs) def Is3State(*args, **kwargs): - """Is3State() -> bool""" + """ + Is3State() -> bool + + Returns whether or not the CheckBox is a 3-state CheckBox. + """ return _controls.CheckBox_Is3State(*args, **kwargs) def Is3rdStateAllowedForUser(*args, **kwargs): - """Is3rdStateAllowedForUser() -> bool""" + """ + Is3rdStateAllowedForUser() -> bool + + Returns whether or not the user can set the CheckBox to the third state. + """ return _controls.CheckBox_Is3rdStateAllowedForUser(*args, **kwargs) @@ -284,7 +328,11 @@ _controls.CheckBox_swigregister(CheckBoxPtr) CheckBoxNameStr = cvar.CheckBoxNameStr def PreCheckBox(*args, **kwargs): - """PreCheckBox() -> CheckBox""" + """ + PreCheckBox() -> CheckBox + + Precreate a CheckBox for 2-phase creation. + """ val = _controls.new_PreCheckBox(*args, **kwargs) val.thisown = 1 return val @@ -292,14 +340,19 @@ def PreCheckBox(*args, **kwargs): #--------------------------------------------------------------------------- class Choice(core.ControlWithItems): + """ + A Choice control is used to select one of a list of strings. Unlike a ListBox, + only the selection is visible until the user pulls down the menu of choices. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxChoice instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): """ - __init__(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, - long style=0, Validator validator=DefaultValidator, + __init__(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, + List choices=[], long style=0, Validator validator=DefaultValidator, String name=ChoiceNameStr) -> Choice + + Create and show a Choice control """ newobj = _controls.new_Choice(*args, **kwargs) self.this = newobj.this @@ -309,33 +362,39 @@ class Choice(core.ControlWithItems): def Create(*args, **kwargs): """ - Create(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, - long style=0, Validator validator=DefaultValidator, + Create(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, + List choices=[], long style=0, Validator validator=DefaultValidator, String name=ChoiceNameStr) -> bool + + Actually create the GUI Choice control for 2-phase creation """ return _controls.Choice_Create(*args, **kwargs) - def GetColumns(*args, **kwargs): - """GetColumns() -> int""" - return _controls.Choice_GetColumns(*args, **kwargs) - - def SetColumns(*args, **kwargs): - """SetColumns(int n=1)""" - return _controls.Choice_SetColumns(*args, **kwargs) - def SetSelection(*args, **kwargs): - """SetSelection(int n)""" + """ + SetSelection(int n) + + Select the n'th item (zero based) in the list. + """ return _controls.Choice_SetSelection(*args, **kwargs) def SetStringSelection(*args, **kwargs): - """SetStringSelection(String string)""" + """ + SetStringSelection(String string) + + Select the item with the specifed string + """ return _controls.Choice_SetStringSelection(*args, **kwargs) def SetString(*args, **kwargs): - """SetString(int n, String s)""" + """ + SetString(int n, String string) + + Set the label for the n'th item (zero based) in the list. + """ return _controls.Choice_SetString(*args, **kwargs) + Select = SetSelection class ChoicePtr(Choice): def __init__(self, this): @@ -346,7 +405,11 @@ _controls.Choice_swigregister(ChoicePtr) ChoiceNameStr = cvar.ChoiceNameStr def PreChoice(*args, **kwargs): - """PreChoice() -> Choice""" + """ + PreChoice() -> Choice + + Precreate a Choice control for 2-phase creation. + """ val = _controls.new_PreChoice(*args, **kwargs) val.thisown = 1 return val @@ -354,15 +417,21 @@ def PreChoice(*args, **kwargs): #--------------------------------------------------------------------------- class ComboBox(Choice): + """ + A combobox is like a combination of an edit control and a listbox. It can be + displayed as static list with editable or read-only text field; or a drop-down + list with text field. + """ def __repr__(self): return "<%s.%s; proxy of C++ wxComboBox instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): """ - __init__(Window parent, int id, String value=EmptyString, Point pos=DefaultPosition, - Size size=DefaultSize, - int choices=0, String choices_array=None, - long style=0, Validator validator=DefaultValidator, - String name=ComboBoxNameStr) -> ComboBox + __init__(Window parent, int id, String value=EmptyString, + Point pos=DefaultPosition, Size size=DefaultSize, + List choices=[], long style=0, Validator validator=DefaultValidator, + String name=ComboBoxNameStr) -> ComboBox + + Constructor, creates and shows a ComboBox control. """ newobj = _controls.new_ComboBox(*args, **kwargs) self.this = newobj.this @@ -372,16 +441,21 @@ class ComboBox(Choice): def Create(*args, **kwargs): """ - Create(Window parent, int id, String value=EmptyString, Point pos=DefaultPosition, - Size size=DefaultSize, - int choices=0, String choices_array=None, - long style=0, Validator validator=DefaultValidator, - String name=ComboBoxNameStr) -> bool + Create(Window parent, int id, String value=EmptyString, + Point pos=DefaultPosition, Size size=DefaultSize, + List choices=[], long style=0, Validator validator=DefaultValidator, + String name=ChoiceNameStr) -> bool + + Actually create the GUI Choice control for 2-phase creation """ return _controls.ComboBox_Create(*args, **kwargs) def GetValue(*args, **kwargs): - """GetValue() -> String""" + """ + GetValue() -> String + + Returns the current value in the combobox text field. + """ return _controls.ComboBox_GetValue(*args, **kwargs) def SetValue(*args, **kwargs): @@ -389,35 +463,68 @@ class ComboBox(Choice): return _controls.ComboBox_SetValue(*args, **kwargs) def Copy(*args, **kwargs): - """Copy()""" + """ + Copy() + + Copies the selected text to the clipboard. + """ return _controls.ComboBox_Copy(*args, **kwargs) def Cut(*args, **kwargs): - """Cut()""" + """ + Cut() + + Copies the selected text to the clipboard and removes the selection. + """ return _controls.ComboBox_Cut(*args, **kwargs) def Paste(*args, **kwargs): - """Paste()""" + """ + Paste() + + Pastes text from the clipboard to the text field. + """ return _controls.ComboBox_Paste(*args, **kwargs) def SetInsertionPoint(*args, **kwargs): - """SetInsertionPoint(long pos)""" + """ + SetInsertionPoint(long pos) + + Sets the insertion point in the combobox text field. + """ return _controls.ComboBox_SetInsertionPoint(*args, **kwargs) def GetInsertionPoint(*args, **kwargs): - """GetInsertionPoint() -> long""" + """ + GetInsertionPoint() -> long + + Returns the insertion point for the combobox's text field. + """ return _controls.ComboBox_GetInsertionPoint(*args, **kwargs) def GetLastPosition(*args, **kwargs): - """GetLastPosition() -> long""" + """ + GetLastPosition() -> long + + Returns the last position in the combobox text field. + """ return _controls.ComboBox_GetLastPosition(*args, **kwargs) def Replace(*args, **kwargs): - """Replace(long from, long to, String value)""" + """ + Replace(long from, long to, String value) + + Replaces the text between two positions with the given text, in the + combobox text field. + """ return _controls.ComboBox_Replace(*args, **kwargs) def SetSelection(*args, **kwargs): - """SetSelection(int n)""" + """ + SetSelection(int n) + + Selects the text between the two positions, in the combobox text field. + """ return _controls.ComboBox_SetSelection(*args, **kwargs) def SetMark(*args, **kwargs): @@ -429,11 +536,19 @@ class ComboBox(Choice): return _controls.ComboBox_SetEditable(*args, **kwargs) def SetInsertionPointEnd(*args, **kwargs): - """SetInsertionPointEnd()""" + """ + SetInsertionPointEnd() + + Sets the insertion point at the end of the combobox text field. + """ return _controls.ComboBox_SetInsertionPointEnd(*args, **kwargs) def Remove(*args, **kwargs): - """Remove(long from, long to)""" + """ + Remove(long from, long to) + + Removes the text between the two positions in the combobox text field. + """ return _controls.ComboBox_Remove(*args, **kwargs) @@ -446,7 +561,11 @@ _controls.ComboBox_swigregister(ComboBoxPtr) ComboBoxNameStr = cvar.ComboBoxNameStr def PreComboBox(*args, **kwargs): - """PreComboBox() -> ComboBox""" + """ + PreComboBox() -> ComboBox + + Precreate a ComboBox control for 2-phase creation. + """ val = _controls.new_PreComboBox(*args, **kwargs) val.thisown = 1 return val @@ -723,7 +842,7 @@ class ListBox(core.ControlWithItems): def __init__(self, *args, **kwargs): """ __init__(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, + wxArrayString choices=wxPyEmptyStringArray, long style=0, Validator validator=DefaultValidator, String name=ListBoxNameStr) -> ListBox """ @@ -736,7 +855,7 @@ class ListBox(core.ControlWithItems): def Create(*args, **kwargs): """ Create(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, + wxArrayString choices=wxPyEmptyStringArray, long style=0, Validator validator=DefaultValidator, String name=ListBoxNameStr) -> bool """ @@ -802,6 +921,18 @@ class ListBox(core.ControlWithItems): """IsSorted() -> bool""" return _controls.ListBox_IsSorted(*args, **kwargs) + def SetItemForegroundColour(*args, **kwargs): + """SetItemForegroundColour(int item, Colour c)""" + return _controls.ListBox_SetItemForegroundColour(*args, **kwargs) + + def SetItemBackgroundColour(*args, **kwargs): + """SetItemBackgroundColour(int item, Colour c)""" + return _controls.ListBox_SetItemBackgroundColour(*args, **kwargs) + + def SetItemFont(*args, **kwargs): + """SetItemFont(int item, Font f)""" + return _controls.ListBox_SetItemFont(*args, **kwargs) + class ListBoxPtr(ListBox): def __init__(self, this): @@ -825,7 +956,7 @@ class CheckListBox(ListBox): def __init__(self, *args, **kwargs): """ __init__(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, + wxArrayString choices=wxPyEmptyStringArray, long style=0, Validator validator=DefaultValidator, String name=ListBoxNameStr) -> CheckListBox """ @@ -838,7 +969,7 @@ class CheckListBox(ListBox): def Create(*args, **kwargs): """ Create(Window parent, int id, Point pos=DefaultPosition, Size size=DefaultSize, - int choices=0, String choices_array=None, + wxArrayString choices=wxPyEmptyStringArray, long style=0, Validator validator=DefaultValidator, String name=ListBoxNameStr) -> bool """ @@ -916,6 +1047,11 @@ TEXT_ATTR_ALIGNMENT = _controls.TEXT_ATTR_ALIGNMENT TEXT_ATTR_LEFT_INDENT = _controls.TEXT_ATTR_LEFT_INDENT TEXT_ATTR_RIGHT_INDENT = _controls.TEXT_ATTR_RIGHT_INDENT TEXT_ATTR_TABS = _controls.TEXT_ATTR_TABS +TE_HT_UNKNOWN = _controls.TE_HT_UNKNOWN +TE_HT_BEFORE = _controls.TE_HT_BEFORE +TE_HT_ON_TEXT = _controls.TE_HT_ON_TEXT +TE_HT_BELOW = _controls.TE_HT_BELOW +TE_HT_BEYOND = _controls.TE_HT_BEYOND class TextAttr(object): def __repr__(self): return "<%s.%s; proxy of C++ wxTextAttr instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) @@ -929,6 +1065,12 @@ class TextAttr(object): self.this = newobj.this self.thisown = 1 del newobj.thisown + def __del__(self, destroy=_controls.delete_TextAttr): + """__del__()""" + try: + if self.thisown: destroy(self) + except: pass + def Init(*args, **kwargs): """Init()""" return _controls.TextAttr_Init(*args, **kwargs) @@ -1200,6 +1342,16 @@ class TextCtrl(core.Control): """ShowPosition(long pos)""" return _controls.TextCtrl_ShowPosition(*args, **kwargs) + def HitTest(*args, **kwargs): + """ + HitTest(Point pt) -> (result, row, col) + + Find the character at position given in pixels. + NB: pt is in device coords (not adjusted for the client area + origin nor scrolling) + """ + return _controls.TextCtrl_HitTest(*args, **kwargs) + def Copy(*args, **kwargs): """Copy()""" return _controls.TextCtrl_Copy(*args, **kwargs) @@ -1590,12 +1742,13 @@ class RadioBox(core.Control): return "<%s.%s; proxy of C++ wxRadioBox instance at %s>" % (self.__class__.__module__, self.__class__.__name__, self.this,) def __init__(self, *args, **kwargs): """ - __init__(Window parent, int id, String label, Point point=DefaultPosition, - Size size=DefaultSize, int choices=0, - String choices_array=None, int majorDimension=0, + __init__(Window parent, int id, String label, Point pos=DefaultPosition, + Size size=DefaultSize, wxArrayString choices=wxPyEmptyStringArray, + int majorDimension=0, long style=RA_HORIZONTAL, Validator validator=DefaultValidator, String name=RadioBoxNameStr) -> RadioBox """ + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] newobj = _controls.new_RadioBox(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -1604,9 +1757,9 @@ class RadioBox(core.Control): def Create(*args, **kwargs): """ - Create(Window parent, int id, String label, Point point=DefaultPosition, - Size size=DefaultSize, int choices=0, - String choices_array=None, int majorDimension=0, + Create(Window parent, int id, String label, Point pos=DefaultPosition, + Size size=DefaultSize, wxArrayString choices=wxPyEmptyStringArray, + int majorDimension=0, long style=RA_HORIZONTAL, Validator validator=DefaultValidator, String name=RadioBoxNameStr) -> bool """ @@ -1737,10 +1890,11 @@ class Slider(core.Control): def __init__(self, *args, **kwargs): """ __init__(Window parent, int id, int value, int minValue, int maxValue, - Point point=DefaultPosition, Size size=DefaultSize, + Point pos=DefaultPosition, Size size=DefaultSize, long style=SL_HORIZONTAL, Validator validator=DefaultValidator, String name=SliderNameStr) -> Slider """ + if kwargs.has_key('point'): kwargs['pos'] = kwargs['point'] newobj = _controls.new_Slider(*args, **kwargs) self.this = newobj.this self.thisown = 1 @@ -1750,7 +1904,7 @@ class Slider(core.Control): def Create(*args, **kwargs): """ Create(Window parent, int id, int value, int minValue, int maxValue, - Point point=DefaultPosition, Size size=DefaultSize, + Point pos=DefaultPosition, Size size=DefaultSize, long style=SL_HORIZONTAL, Validator validator=DefaultValidator, String name=SliderNameStr) -> bool """ @@ -1809,7 +1963,7 @@ class Slider(core.Control): return _controls.Slider_GetThumbLength(*args, **kwargs) def SetTickFreq(*args, **kwargs): - """SetTickFreq(int n, int pos)""" + """SetTickFreq(int n, int pos=1)""" return _controls.Slider_SetTickFreq(*args, **kwargs) def GetTickFreq(*args, **kwargs): @@ -1942,9 +2096,7 @@ class BookCtrl(core.Control): def AssignImageList(*args, **kwargs): """AssignImageList(ImageList imageList)""" - val = _controls.BookCtrl_AssignImageList(*args, **kwargs) - args[1].thisown = 0 - return val + return _controls.BookCtrl_AssignImageList(*args, **kwargs) def GetImageList(*args, **kwargs): """GetImageList() -> ImageList""" @@ -3403,9 +3555,7 @@ class ListCtrl(core.Control): def AssignImageList(*args, **kwargs): """AssignImageList(ImageList imageList, int which)""" - val = _controls.ListCtrl_AssignImageList(*args, **kwargs) - args[1].thisown = 0 - return val + return _controls.ListCtrl_AssignImageList(*args, **kwargs) def IsVirtual(*args, **kwargs): """IsVirtual() -> bool""" @@ -3979,15 +4129,11 @@ class TreeCtrl(core.Control): def AssignImageList(*args, **kwargs): """AssignImageList(ImageList imageList)""" - val = _controls.TreeCtrl_AssignImageList(*args, **kwargs) - args[1].thisown = 0 - return val + return _controls.TreeCtrl_AssignImageList(*args, **kwargs) def AssignStateImageList(*args, **kwargs): """AssignStateImageList(ImageList imageList)""" - val = _controls.TreeCtrl_AssignStateImageList(*args, **kwargs) - args[1].thisown = 0 - return val + return _controls.TreeCtrl_AssignStateImageList(*args, **kwargs) def GetItemText(*args, **kwargs): """GetItemText(TreeItemId item) -> String""" @@ -4104,7 +4250,7 @@ class TreeCtrl(core.Control): return _controls.TreeCtrl_GetFirstChild(*args, **kwargs) def GetNextChild(*args, **kwargs): - """GetNextChild(TreeItemId item, wxTreeItemIdValue cookie) -> PyObject""" + """GetNextChild(TreeItemId item, void cookie) -> PyObject""" return _controls.TreeCtrl_GetNextChild(*args, **kwargs) def GetLastChild(*args, **kwargs): @@ -4195,14 +4341,22 @@ class TreeCtrl(core.Control): """Unselect()""" return _controls.TreeCtrl_Unselect(*args, **kwargs) + def UnselectItem(*args, **kwargs): + """UnselectItem(TreeItemId item)""" + return _controls.TreeCtrl_UnselectItem(*args, **kwargs) + def UnselectAll(*args, **kwargs): """UnselectAll()""" return _controls.TreeCtrl_UnselectAll(*args, **kwargs) def SelectItem(*args, **kwargs): - """SelectItem(TreeItemId item)""" + """SelectItem(TreeItemId item, bool select=True)""" return _controls.TreeCtrl_SelectItem(*args, **kwargs) + def ToggleItemSelection(*args, **kwargs): + """ToggleItemSelection(TreeItemId item)""" + return _controls.TreeCtrl_ToggleItemSelection(*args, **kwargs) + def EnsureVisible(*args, **kwargs): """EnsureVisible(TreeItemId item)""" return _controls.TreeCtrl_EnsureVisible(*args, **kwargs)