From: Patrick E. <pa...@pa...> - 2004-03-25 04:55:30
|
I also like having one class per file, though I personally don't mind having small related utility classes in with the main one. I used to hate that one class one file Java thing. ;) As to dialogs, one advantage of the "Attach" method is that different widgets can be handled automatically. For example, you could attach a long* to a resource named "number". The user would have the option of making "number" a wxTextCtrl, a wxSlider, a wxChoice, etc. With the associative array, extra logic would be necessary to know if you want, for example, a string or a long. It seems like there could be issues getting the data in the format you want without having to write much code for each dialog. I dunno, I'm sure the "Attach" system is far from perfect, but as far as I can remember, I haven't seen anything better. I'd be interested in taking a look at the template thing if you happen to remember what it is. BTW, here's an extremely rough comparison of the two techniques: // "Attach" technique. This is actual code that would work in the // current system. jppResourceDialog dialog = jppResourceDialog(parent, "myDialog"); dialog.Attach("myTextCtrl", &myString); dialog.Attach("myCheckBox", &myBool); dialog.ShowModal(); // Associative technique. jppResourceDialog dialog = jppResourceDialog(parent, "myDialog"); if(dialog.ShowModal() == wxID_OK) { myString = dialog.array["myTextControl"].asString(); myBool = dialog.array["myCheckBox"].asBool(); } If the associative version were to be non-modal, it would require data manipulation code in both the Apply and Ok handlers. I'm sure they could be combined somehow, but it still needs to run at some point. Switching the "Attach" one to non-modal would be as simple as running dialog.Show() instead of dialog.ShowModal(). Please tell me if I'm missing some piece of the puzzle, but I honestly don't see that it gets any simpler than the first method. For the STL associative arrays, is it the map and hashmap? As far as I know, those only take keys and values of one type... any type, but only one at a time. Patrick |