Commit Graph

157 Commits

Author SHA1 Message Date
Artur Wieczorek
37f9c6f083 Implement wxEditorDialogProperty as a base class for wxPG properties with dialog editor
Properties using TextCtrlAndButton editor (like wxLongStringProperty, wxDirProperty, wxFileProperty) share some features, like button triggering the editor dialog, and share a data, like dialog window attributes, so for the sake of the clear design it would be good to derive them from the common base class in which all shared functions/data are implemented. This class is not intended to be instantiated so it's an abstract class.
2019-07-14 21:29:21 +02:00
Artur Wieczorek
48adc38bbb Refactor code for numeric validation in numeric wxPG properties
Move template function NumericValidation() to wxNumericProperty because all data necessary to validate the value are available here: acceptable value range, SpinCtrl editor value wrapping mode, etc.
2019-06-29 11:13:14 +02:00
Artur Wieczorek
69632371e3 Implement wxNumericProperty as a base class for all wxPG numeric properties
All numeric properties (wxIntProperty, wxUIntProperty, wxFloatProperty) share some features (like specific attributes, numeric validation, SpinCtrl editor support) so for the sake of clear design it would be good to derive them from the common base class (wxNumericProperty) in which all shared functions are implemented. This class is not intended to be instantiated so it's an abstract class.
2019-06-29 11:13:13 +02:00
Artur Wieczorek
bd1b5c4111 Simplify calls for numeric validation
Instantiate NumericValidation() template directly for required data type in DoValidation() and avoid this way intermediate conversions to another data types.
2019-06-29 11:12:41 +02:00
Artur Wieczorek
e96bc37066 Refactor template function to validate numeric wxPG properties
Duplicating the code of the entire NumericValidation() template function just for one specialization (for double value type) seems to be an overkill. Only small fraction of the code (to round the validated value) is really dependent on the value type and this part can be moved to the template function GetRoundedValue() which in turn can be specialized as required.
2019-06-29 11:12:40 +02:00
Artur Wieczorek
98c1b057e8 Use standard wxVariant instead of wxPropertyGrid-specific WXVARIANT
There is no need to use WXVARIANT for data types directly supported by wxVariant.
2019-06-16 19:46:44 +02:00
Artur Wieczorek
0bdc9bedbe Enable setting maximum length of the entered text in wxLongStringProperty editor
Editor used by wxLongStringProperty is wxTextCtrl-based and it should be possible to set the limit of the length of the entered text just like it's done for such editors in another properties like wxStringProperty.
2019-05-26 18:06:54 +02:00
Artur Wieczorek
1b977718d4 Make wxPG_FILE_xxx built-in attributes
All wxPG_FILE_xxx attributes are used only in wxFileProperty to set respective internal data members and don't have to be stored in the property's attribute store.
2019-05-12 20:24:55 +02:00
Artur Wieczorek
baaba42776 Refactor: display file selector dialog from within member function in wxFileProperty
By moving the code to display file selector dialog from wxPGFileDialogAdapter to wxFileProperty we can encapsulate the operation of showing the dialog because all required parameters are stored in the corresponding data members and there is no need to use call generic GetAttribute() function to retrieve them. This also helps in making wxFileProperty attributes built-ones in the future.
2019-05-12 20:24:55 +02:00
Artur Wieczorek
b2ea56b4e9 Make wxPG_FILE_DIALOG_STYLE a built-in attribute
This attribute is used only internally in wxFileProperty so it can be considered as a built-in attribute which value can be stored in the local data member and not in the property's attribute store.
2019-05-12 20:24:53 +02:00
Artur Wieczorek
50b1cfd0b5 Use dedicated function to change wxPGProperty flags
Using wxPGProperty::ChangeFlag() function makes the code simpler and more readable.
2019-04-28 16:38:48 +02:00
Artur Wieczorek
cbfff9c944 Set built-in attributes also for parent wxPGProperties
If given attribute is not a built-in attribute handled by the current property it should be passed to the parent property because it may be handled there.
2019-04-22 20:28:23 +02:00
Artur Wieczorek
36285e7fb8 Fix setting wxPG_ARRAY_DELIMITER attribute
This attribute is used only to set internal data member in wxArrayStringProperty and thus can be considered as a built-in attribute which doesn't have to be stored in the property's attribute store.
2019-04-22 20:16:14 +02:00
Artur Wieczorek
b35170dc61 Make wxPG_BOOL_USE_CHECKBOX and wxPG_BOOL_USE_DOUBLE_CLICK_CYCLING built-in attributes
Both attributes are used only in wxBoolProperty and wxFlagsProperty to set respective internal flags and don't have to be stored in the property's attribute store.
2019-04-21 23:39:32 +02:00
Artur Wieczorek
ccd877c458 Make wxPG_FLOAT_PRECISION a built-in wxFloatProperty attribute
wxPG_FLOAT_PRECISION value is used only internally in wxFloatProperty and there is no need to make it readable via getter function.
2019-04-21 23:39:30 +02:00
Artur Wieczorek
76584e2d3c Use dedicated function to get rounded value of wxFloatProperty
wxFloatProperty::ValueToString() returns string representing value rounded with required precision so we don't need to retrieve wxPG_FLOAT_PRECISION attribute and do rounding on our own.
2019-04-21 23:39:29 +02:00
Artur Wieczorek
2898e8136a Cast to wxFileProperty* only once
Result of wxDynamicCast can be used directly, no need to cast once again in case of success.
2019-04-21 23:39:29 +02:00
Artur Wieczorek
c5cdb66c82 Use dedicated function to retrieve Boolean value from wxVariant
GetBool() is dedicated for this purpose.
2019-04-21 23:39:27 +02:00
Artur Wieczorek
fcc961b379 Reset the flag only if it is necessary 2019-04-21 23:39:26 +02:00
Artur Wieczorek
e6e8f45051 Fix setting wxPG_PROP_STRING_PASSWORD attribute
For built-in attributes (like wxPG_PROP_STRING_PASSWORD) wxPGProperty::DoSetAttribute() should return true to give the option (controlled by wxPG_EX_WRITEONLY_BUILTIN_ATTRIBUTES style) to prevent the attribute from being stored into property's attribute storage.
2019-04-21 23:39:26 +02:00
Artur Wieczorek
01e21b4f38 Use predefined constants to represent wxPGProperty attribute identifiers
Use predefined constants representing attribute identifiers instead of specific strings.
2019-04-21 23:39:25 +02:00
Artur Wieczorek
86af7d5ee9 Get rid of unnecessary overriding function
OnValidationFailure() in derived class wxEnumProperty has the same implementation (empty body) as the implementation in the base class wxPGProperty so overriding this function in derived class is not necessary.
2019-03-09 18:57:56 +01:00
Paul Cornett
7c3ce912e0 Use ctor-initializer rather than assignment for non-POD class members 2019-02-25 10:23:35 -08:00
Paul Cornett
c41ff4e694 Remove unuseable wxPGArrayEditorDialog ctor
It calls Create(), which calls the pure virtual ArrayGetCount(), which will
crash, as the required override can't be called from the base class ctor.
2019-02-17 18:00:26 -08:00
Artur Wieczorek
e4198c149b Allow entering plus/minus characters for floating point numbers 2019-01-20 18:41:05 +01:00
Vadim Zeitlin
9ab3acee18 Don't allow using "-" for unsigned entries in propgrid
The changes of 36f6f8ad49 allowed using
"-" (and also "+") characters even for the unsigned properties, which
hadn't been the case before and doesn't seem desirable, so undo this
part of the changes.

See #1093.
2019-01-07 04:29:45 +01:00
ali kettab
36f6f8ad49 wxTextValidator improvements
Improve char inclusion/exclusion support; update the sample to show more
features of this class and add a unit test for it.

Closes https://github.com/wxWidgets/wxWidgets/pull/1093
2019-01-05 23:33:35 +01:00
Artur Wieczorek
0fbc4cd6ab Allow setting custom tooltip text for "New" button in wxPGArrayEditorDialog
Ability to change the tooltip can be useful if standard text "New item" is not descriptive enough.
2018-12-23 11:03:46 +01:00
Artur Wieczorek
686380c331 Initialize all wxPGArrayEditorDialog members in ctor
Initialize members of wxPGArrayEditorDialog class in its Init() method to have just created object in well-defined state.
2018-12-23 11:01:05 +01:00
Artur Wieczorek
d27a1b2770 Create standard dialog buttons with dedicated function
Use CreateStdDialogButtonSizer() function instead of constructing wxStdDialogButtonSizer manually.
2018-11-11 11:15:12 +01:00
Artur Wieczorek
e2115d0d6f Remove unneeded calls to c_str() 2018-11-10 20:44:54 +01:00
Vadim Zeitlin
d4f380e16e Use Bind() instead of Connect() in wxWidgets code
Use more modern function which allows to avoid wxXXXEventHandler()
macros use.

No real changes.
2018-05-30 13:06:20 +02:00
Paul Cornett
cd1c3fab0c Use static linkage for various local names 2017-09-24 09:29:26 -07:00
Artur Wieczorek
c3fa684a27 Fixed displaying validation error for numeric wxPG properties (wxUIntProperty, etc.)
When entered wxFloatProperty, wxIntProperty or wxUIntProperty is out of range then there is displayed a warning message presenting a valid range. Instead of displaying in this message numeric values in default (and fixed) format we should display values which are formatted based on to the current attributes of the property (like wxPG_UINT_PREFIX, wxPG_UINT_BASE, wxPG_FLOAT_PRECISION).
To do so, we shouldn't format respective values on our own in NumericValidation() but instead call wxPGProperty()::ValueToString() which returns value string formatted in line with attributes.

Closes #17601
2016-07-21 23:13:16 +02:00
Artur Wieczorek
6e97a2cbf2 Fixed displaying wxUIntProperty value
In the edit mode property's value should be displayed in the pure numeric form without any textual prefixes because all non-numeric characters will raise a warning in wxNumericPropertyValidator.
2016-07-21 23:11:33 +02:00
Artur Wieczorek
5619e7f964 Use wxSwap function to swap values of array elements in wxPGArrayStringEditorDialog::ArraySwap. 2015-08-30 19:49:29 +02:00
Artur Wieczorek
d6f2264f8b Use Boolean variable to store Boolean value. 2015-08-30 19:48:09 +02:00
Artur Wieczorek
de38b5da25 Use wxUniChar instead of wxChar for operations with wxString iterators. 2015-06-29 20:06:27 +02:00
Artur Wieczorek
7c0b52671d Use wxS macro with string literals.
To make string literals notation consistent.
2015-06-25 21:22:45 +02:00
Vadim Zeitlin
095cf87eb6 Work around "missing" LLONG_MAX &c in MinGW strict ANSI mode.
Definitions of non-standard LLONG_MAX, LLONG_MIN and ULLONG_MAX constants are
excluded from MinGW limits.h when compiling in "strict ANSI" mode, so define
them ourselves.
2015-06-14 19:52:28 +02:00
Artur Wieczorek
aeed3322f2 Fixed minor typos in comments. 2015-06-08 21:49:38 +02:00
Artur Wieczorek
cb6efbd3c3 Lay out various wxPG dialogs based on the current system screen design.
Currently, customizing some dialogs for small screen environment is done statically on the build stage by setting wxPG_SMALL_SCREEN to 1 (what is done for WXWINCE only).
Instead, we can do this for all platforms in a dynamic manner, based on the classification provided by wxSystemSettings::GetScreenType() function.
In order to do so there is introduced a static helper function wxPropertyGrid::IsSmallScreen() which is used to select right parameters (size, position) for several dialogs in order to display them correctly on the small screen.
2015-06-08 21:46:03 +02:00
Artur Wieczorek
1d9c1b35fd Use pre-increment operator to increment iterator in the loop.
When the return value is ignored, the ++it is never less efficient than the it++.
2015-06-07 23:05:42 +02:00
Artur Wieczorek
06013ea36f Reduce the scope of variables using to index single loop only.
And adjust their types if necessary.
2015-06-06 17:55:39 +02:00
Artur Wieczorek
213df7dd88 Use conditional operator instead of conditional statement in wxBoolProperty::ValueToString. 2015-06-06 17:48:59 +02:00
Jan van Dijk
72a4c3a4d0 Don't test if a reference is null, this cannot happen.
Testing for null references is unnecessary and just results in clang warnings.

Closes #17016.
2015-06-03 17:08:30 +02:00
Artur Wieczorek
67bfb78ace Replace wxT() with wxS() in wxPropertyGrid code. 2015-05-31 19:20:11 +02:00
Artur Wieczorek
65dee275f2 Fix minor typos in comments. 2015-05-30 20:12:02 +02:00
Artur Wieczorek
ff685a7a4c Use wxID_ANY symbol for internal wxPG controls. 2015-05-30 20:10:09 +02:00
Artur Wieczorek
6dfd6f4930 Use wxSizerFlags instead of multiple argument Add() overload when constructing sizers in wxPG.
Set sizer flags in wxLongStringProperty::DisplayEditorDialog and wxPGArrayEditorDialog::Create in this more convenient way.
2015-05-29 21:05:30 +02:00