@@ -198,7 +198,7 @@ class DialogBuilderBase
198198 }
199199 }
200200
201- T * AddDialogItem (int Type, const TCHAR *Text)
201+ T* AddDialogItem (int Type, const TCHAR *Text)
202202 {
203203 if (DialogItemsCount == DialogItemsAllocated)
204204 {
@@ -365,7 +365,7 @@ class DialogBuilderBase
365365 return -1 ;
366366 }
367367
368- DialogItemBinding<T> * FindBinding (const T *Item)
368+ DialogItemBinding<T>* FindBinding (const T *Item)
369369 {
370370 int Index = static_cast <int >(Item - DialogItems);
371371 if (Index >= 0 && Index < DialogItemsCount)
@@ -388,7 +388,7 @@ class DialogBuilderBase
388388 }
389389 }
390390
391- virtual const TCHAR * GetLangString (int MessageID)
391+ virtual const TCHAR* GetLangString (int MessageID)
392392 {
393393 return nullptr ;
394394 }
@@ -398,12 +398,17 @@ class DialogBuilderBase
398398 return -1 ;
399399 }
400400
401- virtual DialogItemBinding<T> * CreateCheckBoxBinding (BOOL *Value, int Mask)
401+ virtual DialogItemBinding<T>* CreateCheckBoxBinding (BOOL *Value, int Mask)
402402 {
403403 return nullptr ;
404404 }
405405
406- virtual DialogItemBinding<T> *CreateRadioButtonBinding (int *Value)
406+ virtual DialogItemBinding<T>* CreateComboBoxBinding (int *Value)
407+ {
408+ return nullptr ;
409+ }
410+
411+ virtual DialogItemBinding<T>* CreateRadioButtonBinding (int *Value)
407412 {
408413 return nullptr ;
409414 }
@@ -423,17 +428,17 @@ class DialogBuilderBase
423428 }
424429 delete [] DialogItems;
425430 delete [] Bindings;
426- }
431+ };
427432
428433 public:
429434 // Äîáàâëÿåò ñòàòè÷åñêèé òåêñò, ðàñïîëîæåííûé íà îòäåëüíîé ñòðîêå â äèàëîãå.
430- T * AddText (int LabelId)
435+ T* AddText (int LabelId)
431436 {
432437 T *Item = AddDialogItem (DI_TEXT, GetLangString (LabelId));
433438 SetNextY (Item);
434439 return Item;
435440 }
436- T * AddText (const TCHAR* asText)
441+ T* AddText (const TCHAR* asText)
437442 {
438443 T *Item = AddDialogItem (DI_TEXT, asText);
439444 SetNextY (Item);
@@ -446,7 +451,7 @@ class DialogBuilderBase
446451 // }
447452
448453 // Äîáàâëÿåò ÷åêáîêñ.
449- T * AddCheckbox (int TextMessageId, BOOL *Value, int Mask=0 )
454+ T* AddCheckbox (int TextMessageId, BOOL *Value, int Mask=0 )
450455 {
451456 T *Item = AddDialogItem (DI_CHECKBOX, GetLangString (TextMessageId));
452457 SetNextY (Item);
@@ -489,14 +494,33 @@ class DialogBuilderBase
489494 return nFirstID;
490495 }
491496
497+ // Äîáàâëÿåò ComboBox
498+ T* AddComboBox (int Width, FarList* ListItems, int *Value, DWORD AddFlags=DIF_DROPDOWNLIST)
499+ {
500+ T *Item = AddDialogItem (DI_COMBOBOX, nullptr );
501+ for (int i = 0 ; i < ListItems->ItemsNumber ; i++)
502+ {
503+ if (i == *Value)
504+ ListItems->Items [i].Flags |= LIF_SELECTED;
505+ else if (ListItems->Items [i].Flags & LIF_SELECTED)
506+ ListItems->Items [i].Flags &= ~LIF_SELECTED;
507+ }
508+ Item->ListItems = ListItems;
509+ Item->Flags |= AddFlags;
510+ SetNextY (Item);
511+ Item->X2 = Item->X1 + Width;
512+ SetLastItemBinding (CreateComboBoxBinding (Value));
513+ return Item;
514+ }
515+
492516 // Äîáàâëÿåò ïîëå òèïà DI_FIXEDIT äëÿ ðåäàêòèðîâàíèÿ óêàçàííîãî ÷èñëîâîãî çíà÷åíèÿ.
493- virtual T * AddIntEditField (int *Value, int Width)
517+ virtual T* AddIntEditField (int *Value, int Width)
494518 {
495519 return nullptr ;
496520 }
497521
498522 // Äîáàâëÿåò óêàçàííóþ òåêñòîâóþ ñòðîêó ñëåâà îò ýëåìåíòà RelativeTo.
499- T * AddTextBefore (T *RelativeTo, int LabelId)
523+ T* AddTextBefore (T *RelativeTo, int LabelId)
500524 {
501525 T *Item = AddDialogItem (DI_TEXT, GetLangString (LabelId));
502526 Item->Y1 = Item->Y2 = RelativeTo->Y1 ;
@@ -545,7 +569,7 @@ class DialogBuilderBase
545569 }
546570
547571 // Äîáàâëÿåò óêàçàííóþ òåêñòîâóþ ñòðîêó ñïðàâà îò ýëåìåíòà RelativeTo.
548- T * AddTextAfter (T *RelativeTo, int LabelId)
572+ T* AddTextAfter (T *RelativeTo, int LabelId)
549573 {
550574 T *Item = AddDialogItem (DI_TEXT, GetLangString (LabelId));
551575 Item->Y1 = Item->Y2 = RelativeTo->Y1 ;
@@ -735,6 +759,24 @@ class PluginRadioButtonBinding: public DialogAPIBinding
735759 }
736760};
737761
762+ class PluginComboBoxBinding : public DialogAPIBinding
763+ {
764+ private:
765+ int *Value;
766+
767+ public:
768+ PluginComboBoxBinding (const PluginStartupInfo &aInfo, HANDLE *aHandle, int aID, int *aValue)
769+ : DialogAPIBinding(aInfo, aHandle, aID),
770+ Value (aValue)
771+ {
772+ }
773+
774+ virtual void SaveValue (FarDialogItem *Item, int RadioGroupIndex)
775+ {
776+ *Value = (int )Info.SendDlgMessage (*DialogHandle, DM_LISTGETCURPOS, ID, 0 );
777+ }
778+ };
779+
738780#ifdef UNICODE
739781
740782class PluginEditFieldBinding : public DialogAPIBinding
@@ -781,12 +823,12 @@ class PluginIntEditFieldBinding: public DialogAPIBinding
781823 *Value = Info.FSF ->atoi (DataPtr);
782824 }
783825
784- TCHAR * GetBuffer ()
826+ TCHAR* GetBuffer ()
785827 {
786828 return Buffer;
787829 }
788830
789- const TCHAR * GetMask ()
831+ const TCHAR* GetMask ()
790832 {
791833 return Mask;
792834 }
@@ -834,7 +876,7 @@ class PluginIntEditFieldBinding: public DialogItemBinding<FarDialogItem>
834876 *Value = Info.FSF ->atoi (Item->Data );
835877 }
836878
837- const TCHAR * GetMask ()
879+ const TCHAR* GetMask ()
838880 {
839881 return Mask;
840882 }
@@ -857,11 +899,14 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
857899 virtual void InitDialogItem (FarDialogItem *Item, const TCHAR *Text)
858900 {
859901 memset (Item, 0 , sizeof (FarDialogItem));
860- #ifdef UNICODE
861- Item->PtrData = Text;
862- #else
863- lstrcpyn (Item->Data , Text, sizeof (Item->Data )/sizeof (Item->Data [0 ]));
864- #endif
902+ if (Text)
903+ {
904+ #ifdef UNICODE
905+ Item->PtrData = Text;
906+ #else
907+ lstrcpyn (Item->Data , Text, sizeof (Item->Data )/sizeof (Item->Data [0 ]));
908+ #endif
909+ }
865910 }
866911
867912 virtual int TextWidth (const FarDialogItem &Item)
@@ -873,7 +918,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
873918#endif
874919 }
875920
876- virtual const TCHAR * GetLangString (int MessageID)
921+ virtual const TCHAR* GetLangString (int MessageID)
877922 {
878923 return Info.GetMsg (Info.ModuleNumber , MessageID);
879924 }
@@ -892,7 +937,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
892937#endif
893938 }
894939
895- virtual DialogItemBinding<FarDialogItem> * CreateCheckBoxBinding (BOOL *Value, int Mask)
940+ virtual DialogItemBinding<FarDialogItem>* CreateCheckBoxBinding (BOOL *Value, int Mask)
896941 {
897942#ifdef UNICODE
898943 return new PluginCheckBoxBinding (Info, &DialogHandle, DialogItemsCount-1 , Value, Mask);
@@ -901,7 +946,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
901946#endif
902947 }
903948
904- virtual DialogItemBinding<FarDialogItem> * CreateRadioButtonBinding (BOOL *Value)
949+ virtual DialogItemBinding<FarDialogItem>* CreateRadioButtonBinding (BOOL *Value)
905950 {
906951#ifdef UNICODE
907952 return new PluginRadioButtonBinding (Info, &DialogHandle, DialogItemsCount-1 , Value);
@@ -910,6 +955,15 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
910955#endif
911956 }
912957
958+ virtual DialogItemBinding<FarDialogItem>* CreateComboBoxBinding (int *Value)
959+ {
960+ #ifdef UNICODE
961+ return new PluginComboBoxBinding (Info, &DialogHandle, DialogItemsCount-1 , Value);
962+ #else
963+ return new PluginComboBoxBinding<FarDialogItem>(Value);
964+ #endif
965+ }
966+
913967public:
914968 PluginDialogBuilder (const PluginStartupInfo &aInfo, int TitleMessageID, const TCHAR *aHelpTopic)
915969 : DialogFlags(0 ), Info(aInfo), DialogHandle(NULL ), HelpTopic(aHelpTopic)
@@ -928,7 +982,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
928982#endif
929983 }
930984
931- FarDialogItem * GetItemByIndex (int Index)
985+ FarDialogItem* GetItemByIndex (int Index)
932986 {
933987 if (Index >= 0 && Index < DialogItemsCount)
934988 return (DialogItems + Index);
@@ -940,7 +994,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
940994 return GetItemID (p);
941995 }
942996
943- virtual FarDialogItem * AddIntEditField (int *Value, int Width)
997+ virtual FarDialogItem* AddIntEditField (int *Value, int Width)
944998 {
945999 FarDialogItem *Item = AddDialogItem (DI_FIXEDIT, EMPTY_TEXT);
9461000 Item->Flags |= DIF_MASKEDIT;
@@ -965,7 +1019,7 @@ class PluginDialogBuilder: public DialogBuilderBase<FarDialogItem>
9651019 return Item;
9661020 }
9671021
968- FarDialogItem * AddEditField (TCHAR *Value, int MaxSize, int Width, const TCHAR *HistoryID = nullptr )
1022+ FarDialogItem* AddEditField (TCHAR *Value, int MaxSize, int Width, const TCHAR *HistoryID = nullptr )
9691023 {
9701024 FarDialogItem *Item = AddDialogItem (DI_EDIT, Value);
9711025 SetNextY (Item);
0 commit comments