On Sat, 2 Aug 2014 12:56:44 +0200 Tobias Taschner wrote:
TT> wxList was the first thing I found for a "wxWidgets style" container,
Please let me know how did you find it, we need to change the
documentation to make it clear that this is not what you should be using.
TT> > - Why does LoadStream() take the stream by pointer and what does it mean
TT> > to take ownership of it?
TT>
TT> In my usage scenario the hosting frame creates/destroys the stream. take
TT> ownership simply means that wxPDFView will delete the stream in its dtor
IMHO it is unusual to pass ownership of the stream objects like this. It's
more common to do it at streambuf level. But if you really want to give the
ownership of the stream itself to PDFView, you should make it more clear in
the function signature, i.e. use auto_ptr<> (C++98) or move semantics
(C++11).
TT> > - I'd strongly consider using "pImpl" design and move all the private
TT> > data and methods into wxPDFViewImpl. This would allow to easily preserve
TT> > ABI later if wanted (maybe it isn't now but it's much simpler to plan for
TT> > it now and not really use it later than to not plan for it and later try
TT> > to retrofit it, we have a lot of painful history of wxWidgets to prove
TT> > it).
TT>
TT> Sounds like a good idea but I'm not yet 100% sure what to put in the impl
TT> and what to keep in the base.
This is simple: only the public methods and overridden virtual methods of
the base class (whether public or not) should remain in the public class.
All the rest, including all the data fields and private methods, should go
into the impl.
TT> > - It probably doesn't matter here but using std::list in
TT> > wxPDFViewBitmapCache doesn't make much sense to me, IMO it really should
TT> > be a vector too.
TT>
TT> My thought was that removing entries from cache (when it's filled) should
TT> be fast with a std::list compared to std::vector but I might be wrong there?
I think in practice std::vector<> would still be faster than std::list<>
for the numbers of elements we're speaking about here (number of pages, so
hundreds, thousands at most), but IMO you don't even need to remove them:
just invalidate the cache entry, i.e. use wxBitmap(), whose IsOk() returns
false, as the bitmap.
TT> > - I recommend not using wxDataViewTreeCtrl, better use just plain
TT> > wxTreeCtrl, wxDataViewTreeCtrl is broken in surprising ways.
TT> >
TT>
TT> From the documentation the wxDataView backed controls seemed the "modern"
TT> way to go, but I'll reconsider that :)
wxDataViewCtrl is fine. So is wxTreeCtrl. But wxDataViewTreeCtrl has quite
a few problems.
TT> > - Cast of FPDF_WIDESTRING to wchar_t* looked suspicious and looking at
TT> > fpdfview.h it is wrong: FPDF_WIDESTRING is UTF-16LE while wchar_t is
TT> > UTF-32 under Unix. You must explicitly use wxMBConvUTF16LE for
TT> > converting between it and wxString.
TT>
TT> Just compiled MSW until now as MSW and OSX are the only platforms I use
TT> wxWidgets on, but will obviously change that.
TT> Some wxString character conversions are are a mystery to me until I find
TT> the appropriate method/type cast/helper class.
I'm trying since years to make this more clear but apparently without
much success :-( IMO it's really simple: the text can be stored either as
wide (wchar_t) string or narrow (char) string. For wchar_t the encoding
used is fixed at compile time and is UTF-16 under Windows and UTF-32
everywhere else, so converting them to/from wxString just works. For char
strings, the encoding may be just about anything (including UTF-16 or
UTF-32) and so you need to specify it explicitly when creating wxString
from them or asking wxString to produce something of this type. If you
don't do this, the current locale encoding is used by default, which is
often, but not always what you want. In any case, it's always better to
be explicit and in this case you know that FPDF_WIDESTRING is UTF-16LE, so
you must always use wxMBConvUTF16LE to convert to/from it.
TT> > I also have some questions about the threading logic but I'd need to spend
TT> > more time reading the code to formulate them clearly, so I'll postpone
TT> > writing about them.
TT>
TT> I will change some of that logic (as it currently has some flaws). But the
TT> overall idea is to never render the pages in the main thread but to do that
TT> in a background thread an notify UI when requested pages are ready. Also if
TT> you change zoom, bitmaps with the "wrong" resolution are used and scaled
TT> until the correct resolutions are rendered.
Yes, this is definitely a good idea, I'm just not sure that the current
code is totally correct. But if you're going to change it anyhow, I'll wait
for the new version before diving into it again.
Good luck!
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/