> - Add the include and use proper namespace in your class inheritance.
>
>         #ifndef fltk_Widget_h
>         #  include <fltk/Widget.h>
>         #endif // fltk_Widget_h
>
>       class MyWidget : public fltk::Widget {...};
>
>    not just:
>       class MyWidget : public Widget {...};
>
> The #ifdef/endif guard avoids including the file again if it was already
> loaded (and can lead to a tiny bit faster compilation on large
> projects).  Using fltk:: is required.
>
> Currently, your .h and .cpp files will not compile as is.  If that
> magically works for you right now its because main.cpp does include a
> "using namespace fltk" and includes the .cpp files themselves.
>
> Your .cpp files should also do #include "<samename>.h", to get all the
> includes and the class definition.
>
> - .cpp files are never expected to be included by other .cpp files.
> They are expected to be compiled separately and then linked together
> into a single executable, for example.   .cpp files include only .h/hpp
> files or .inl (inline) files.
> If you are on windows, as the .exe suggests, this means just adding the
> ..cpp files to the project (msvc will do the rest).  If you are not using
> an IDE, then you probably should use a Makefile ( I recommend CMake, so
> you won't be constrained to a single platform ), like:
>
>       # CMakeLists.txt
>       # compile gui.exe with:  cmake . && nmake (windows) or
>       #                        cmake . && make  (any other os)
>
>       ADD_EXECUTABLE( gui source1.cpp source2.cpp source3.cpp )
>
>
> - You should probably avoid something like "A[space]->[space]B" like you
> do everywhere.  That can very easily lead to confusion with a tired
> programmer to be read as A > B or A >= B.   Just do A->B and keep
> comparisons with spaces like A > B.
>
> - Try to avoid "using namespace" as much as possible.  If you must use
> it, keep it within a function, not at a global location.  This can,
> potentially, give you trouble with portability issues (conflicts among
> libs) later on.
> Also, if you can, prefer using declarations of just a single class like:
>       using std::cerr;
>       using fltk::Widget;
>
> - Your widget classes probably should be in your own namespace, like
> 'obduk'.
>          namespace obduk {
>              class MyWidget : public fltk::Widget { ... };
>          } // namespace obduk
>
> You should NEVER put stuff in the fltk or, worse, the std namespace as
> your comment suggests.  fltk is reserved for fltk2 stuff and std for C++
> standard classes.  If fltk or std were to ever create classes with the
> same name as your own fltk/std namespaced class, your code would become
> unmaintainable.
>
> - Try to avoid private: elements and prefer protected:.  If you inherit
> from that code and ever need to access those elements you'll be hosed.
> Only if you expect your library to be used by others (ie. released as
> open source, for example), you might want to take a closer look at using
> private carefully to avoid misuse of your class (and allow you to change
> its internals easily without breaking other people's code).
>
> - A minor nitpick.  The 'and' keyword is really not used that much, as
> it is C++ only and added in '98.  Get used to using &&, instead.  That
> way you'll be able to easily take/switch your routines/brain to C if you
> need to.
>
> - Another minor nitpick.  Try to use space in function invokations, like
> f( 1, 2, 3 ), instead of f(1,2,3).  This is not necessary a convention
> you need to follow, but again, in my experience it does make code much
> easier to read.
>
> - Another minor issue. Check fltk::event_button() against
> fltk::LeftButton, fltk::RightButton, etc. (defined in events.h) instead
> of just 1,2,3.  It reads much more clear.
>
> - You really don't need the close/exit callbacks for your window.  Those
> are the default behavior of all fltk windows.

Things I am having a little problem with

I am having a little problem working out the file layouts / make stuff.

I am mainly a Linux user now, but have never had that much experience with a 
terminal, also I do not have access to a Linux machine this month, so have been 
using windows + mingw + msys.

Would you be able to outline in more detail, with reference to my code, how the 
files and includes be organized, and the make file written.

Thank you, Owen
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to