I encountered the same problem. Let me share my findings/thoughts. There are two things relevant here, the location in a physical folder (read: where is the file on the hard drive) and the location in a virtual folder (read: where is the file in the codeblocks project). In both cases the default behavior of codeblocks differs from the OpenFrameworks ProjectGenerator solution.
In all OF examples the source and header files are in the same folder (namely the src folder). When you add a new class in CB, the source file is placed in the src folder, but the header file is placed in the include folder. So the location on the hard drive differs.
Solution: To ensure the header file of a class is also added to the src folder, you can manually set the folder location in the “create new class” dialog box. You can find it in the bottom left under “Header file” and then “Folder”. Change the end from \include to \src. Then the header file is placed in the src folder and thus both class files are in the same location.
Note: Unfortunately this has to be done manually, each time you add a class. I haven’t found a way yet to change the default header file folder.
In the CB project (as generated by the ProjectGenerator) of all OF examples the files are placed in a virtual folder in CB called src. When adding a new class the source file is added to a Sources folder and the header file is added to a Headers folder. So they are not in the src virtual folder as the rest of the OF-added files.
There are multiple ways to correct this.
Solution 1: Manually drag both files (in CB’s project structure) from respectively the Sources and the Headers folder (and perhaps a subfolder inside that) to the src virtual folder. This has to be done each time you add a class.
Solution 2: Change the view. In the menu, go to “Project”, then “Project tree” and uncheck “Categorize by file types”. Then the Sources and Headers folders in the CB project disappear and all files are shown under their physical folder (which is src if you followed the steps for the single physical folder solution as mentioned above). Changing this view setting has to be done only once.
Solution 3: Once the class files have been added, go through the following steps. Close CB. Remove the CB project files from the project’s root folder. Run the ProjectGenerator to create an OF-style project (read: with all the files in the src folder inside a virtual folder called src in the CB project).
Note: The last solution is probably the most work. The second solution is the least work, if you like these view settings and make sure the header file is also in the src folder (and not CB’s default include folder). The first solution is pretty quick, but has to be repeated for each class. Solution 1 and 3 are clean solutions, solution 2 is a workaround. It does not seem possible to prevent files from being added to these default Header and Sources folders in CB. But at least there are alternative option on how to deal with this.
Hope this may be of use to you and others who face the same problem!