Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 33,288 of 33,346    |
|    Dan@leftfieldlabs.com to All    |
|    View Widget Structure    |
|    27 Feb 14 06:08:38    |
   
   { text reformatted to fit ~70 characters per line. -mod }   
      
   Hello, I'm not sure this is suited for this forum. It is a question of   
   Application Design, but it is based in c++ so perhaps its relevant.   
      
   I am creating a small cross-platform widget library for a project I'm   
   working on and looking for a bit of advice on how to structure it.   
      
   I have classes like TableView, ImageView, etc that can be used by code   
   that is unaware of the current platform. When these classes are   
   instantiated they are injected with platform specific code via a   
   compositional class from a view factory.   
      
   So when an ImageView is created on an IOS system, it also has an   
   IOSImageView that is connected to it that deals with the actual view   
   graph and displaying the image, but all of the application code can just   
   deal with the generic ImageView.   
      
   This seems to work fine but now I have the problem where widgets need to   
   be created inside other widgets. Like a TableView might need to create   
   an ImageView. Since the TableView doesn't know about the current   
   platform it can't create the widget itself and must rely on some view   
   factory.   
      
   So my question is. Would it be best to create one huge factory that is   
   capable of creating every possible widget and make that accessible to   
   each widget? This seems possible, but doesn't quite seem right to have   
   such a huge all-knowing class. I also am not sure if it will cause   
   compilation to slow down.   
      
   Another option would be to pass allocator function pointers to each   
   object that needs them. For instance a TableView could have a   
   setImageViewAllocator which would then give it the ability to create an   
   image view without knowing the details of it. The problem with that   
   method is that every time I create a TableView I have to remember to   
   connect up all of its allocators, and a failure to do so, won't be   
   caught at runtime.   
      
   Any advice or examples of other ideas is greatly appreciated. I realize   
   the best way to do a cross-platform widget library would just be to use   
   openGL, but I actually don't have time to implement all those kind of   
   basics.   
      
       
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca