Update of /cvsroot/mahogany/M/src/adb
In directory usw-pr-cvs1:/tmp/cvs-serv18973/src/adb
Modified Files:
AdbDialogs.cpp AdbManager.cpp
Log Message:
preparations for ADB expansion enhancements: no real changes yet but the
code refactored to allow for them soon
Index: AdbDialogs.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/AdbDialogs.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -b -u -2 -r1.14 -r1.15
--- AdbDialogs.cpp 24 Sep 2001 00:33:24 -0000 1.14
+++ AdbDialogs.cpp 16 Apr 2002 22:48:23 -0000 1.15
@@ -38,4 +38,5 @@
#include "adb/AdbExport.h"
#include "adb/AdbImpExp.h"
+#include "adb/AdbManager.h"
#include "gui/wxIconManager.h"
@@ -45,23 +46,14 @@
// ----------------------------------------------------------------------------
-// private functions
-// ----------------------------------------------------------------------------
-
-// FIXME there is also one in wxMDialogs.cpp!
-static inline wxFrame *GetDialogParent(wxWindow *parent)
-{
- return parent == NULL ? mApplication->TopLevelFrame()
- : GetFrame(parent);
-}
-
-// ----------------------------------------------------------------------------
// dialog classes
// ----------------------------------------------------------------------------
+// the dialog allowing the user to choose the file name to import addresses
+// from and the format they are in
class wxAdbImportDialog : public wxManuallyLaidOutDialog
{
public:
// ctor & dtor
- wxAdbImportDialog(wxFrame *parent);
+ wxAdbImportDialog(wxWindow *parent);
virtual ~wxAdbImportDialog();
@@ -120,4 +112,26 @@
};
+// the dialog allowing the user to choose from possibly many ADB expansions
+class wxAdbExpandDialog : public wxManuallyLaidOutDialog
+{
+public:
+ wxAdbExpandDialog(ArrayAdbElements& aEverything,
+ ArrayAdbEntries& aMoreEntries,
+ wxFrame *parent);
+
+ // get the index of the selected item in the listbox
+ int GetSelection() const { return m_listbox->GetSelection(); }
+
+protected:
+ // event handlers
+ void OnLboxDblClick(wxCommandEvent& /* event */) { EndModal(wxID_OK); }
+
+private:
+ // the listbox containing the expansion possibilities
+ wxListBox *m_listbox;
+
+ DECLARE_EVENT_TABLE()
+};
+
// ----------------------------------------------------------------------------
// event tables
@@ -129,4 +143,8 @@
END_EVENT_TABLE()
+BEGIN_EVENT_TABLE(wxAdbExpandDialog, wxManuallyLaidOutDialog)
+ EVT_LISTBOX_DCLICK(-1, wxAdbExpandDialog::OnLboxDblClick)
+END_EVENT_TABLE()
+
// ============================================================================
// implementation
@@ -137,5 +155,5 @@
// ----------------------------------------------------------------------------
-wxAdbImportDialog::wxAdbImportDialog(wxFrame *parent)
+wxAdbImportDialog::wxAdbImportDialog(wxWindow *parent)
: wxManuallyLaidOutDialog(parent,
_("Import address book"),
@@ -341,4 +359,48 @@
// ----------------------------------------------------------------------------
+// wxAdbExpandDialog
+// ----------------------------------------------------------------------------
+
+wxAdbExpandDialog::wxAdbExpandDialog(ArrayAdbElements& aEverything,
+ ArrayAdbEntries& aMoreEntries,
+ wxFrame *parent)
+ : wxManuallyLaidOutDialog(parent,
+ _("Expansion options"),
+ "AdrListSelect")
+{
+ /*
+ the dialog layout is like this:
+
+ listbox
+ listbox [more...]
+ listbox [delete ]
+ listbox
+
+ [ok] [cancel]
+ */
+
+ wxStaticBox *box = CreateStdButtonsAndBox(_("Please choose an entry:"));
+
+ m_listbox = new wxListBox(this, -1);
+
+ // we have to fill the listbox here or it won't have the correct size
+ size_t nEntryCount = aEverything.GetCount();
+ for( size_t nEntry = 0; nEntry < nEntryCount; nEntry++ )
+ {
+ m_listbox->Append(aEverything[nEntry]->GetDescription());
+ }
+
+ wxLayoutConstraints *c;
+ c = new wxLayoutConstraints;
+ c->left.SameAs(box, wxLeft, 2*LAYOUT_X_MARGIN);
+ c->right.SameAs(box, wxRight, 2*LAYOUT_X_MARGIN);
+ c->top.SameAs(box, wxTop, 3*LAYOUT_Y_MARGIN);
+ c->bottom.SameAs(box, wxBottom, 2*LAYOUT_Y_MARGIN);
+ m_listbox->SetConstraints(c);
+
+ SetDefaultSize(5*wBtn, 10*hBtn);
+}
+
+// ----------------------------------------------------------------------------
// public interface
// ----------------------------------------------------------------------------
@@ -346,5 +408,5 @@
bool AdbShowImportDialog(wxWindow *parent, String *nameOfNativeAdb)
{
- wxFrame *frame = GetDialogParent(parent);
+ wxWindow *frame = GetDialogParent(parent);
wxAdbImportDialog dlg(frame);
if ( dlg.ShowModal() != wxID_OK )
@@ -495,2 +557,33 @@
return ok;
}
+
+int
+AdbShowExpandDialog(ArrayAdbElements& aEverything,
+ ArrayAdbEntries& aMoreEntries,
+ wxFrame *parent)
+{
+ int choice;
+
+ size_t count = aEverything.GetCount();
+ switch ( count )
+ {
+ case 0:
+ // nothing to choose from
+ choice = -1;
+ break;
+
+ case 1:
+ // don't ask user to choose among one entry and itself!
+ choice = 0;
+ break;
+
+ default:
+ // do show the dialog
+ wxAdbExpandDialog dialog(aEverything, aMoreEntries, parent);
+
+ choice = dialog.ShowModal() == wxID_OK ? dialog.GetSelection() : -1;
+ }
+
+ return choice;
+}
+
Index: AdbManager.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/adb/AdbManager.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -b -u -2 -r1.32 -r1.33
--- AdbManager.cpp 14 Apr 2002 09:03:57 -0000 1.32
+++ AdbManager.cpp 16 Apr 2002 22:48:23 -0000 1.33
@@ -36,7 +36,5 @@
#include "adb/AdbManager.h"
#include "adb/AdbDataProvider.h"
-
-#include "guidef.h"
-#include "MDialogs.h"
+#include "adb/AdbDialogs.h"
// ----------------------------------------------------------------------------
@@ -243,8 +241,7 @@
if ( aEntries.IsEmpty() ) {
aEntries = aMoreEntries;
- }
- else {
- // we don't need them at all
- CLEAR_ADB_ARRAY(aMoreEntries);
+
+ // prevent the dialog below from showing "more matches" button
+ aMoreEntries.Clear();
}
@@ -278,5 +275,5 @@
// let the user choose the one he wants
- int rc = MDialog_AdbLookupList(aEverything, frame);
+ int rc = AdbShowExpandDialog(aEverything, aMoreEntries, frame);
if ( rc != -1 ) {
@@ -303,6 +300,8 @@
}
else {
- // one entry
- AdbEntry *entry = (AdbEntry *)aEverything[index];
+ // one entry, but in which array?
+ size_t count = aEverything.GetCount();
+ AdbEntry *entry = index < count ? (AdbEntry *)aEverything[index]
+ : aMoreEntries[index - count];
results.Add(entry->GetDescription());
@@ -318,4 +317,5 @@
// free all entries and groups
+ CLEAR_ADB_ARRAY(aMoreEntries);
CLEAR_ADB_ARRAY(aEverything);
}
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates