Skip to content

Commit

Permalink
FLUID: introducing subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasWM committed Nov 13, 2024
1 parent 723dff4 commit e3a1eb5
Show file tree
Hide file tree
Showing 23 changed files with 175 additions and 104 deletions.
4 changes: 4 additions & 0 deletions fluid/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ set(TARGETS fluid)
# program fluid properly

set(CPPFILES
application/application.cxx
CodeEditor.cxx
StyleParse.cxx
Fd_Snap_Action.cxx
Expand Down Expand Up @@ -58,6 +59,7 @@ set(CPPFILES
# List header files in Apple's Xcode IDE

set(HEADERFILES
application/application.h
CodeEditor.h
Fd_Snap_Action.h
Fl_Function_Type.h
Expand Down Expand Up @@ -140,6 +142,8 @@ else()
endif()

target_link_libraries(fluid PRIVATE fluid-lib)
target_include_directories(fluid-lib PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(fluid PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# Build the console app on Windows
# This is done for all Windows targets, even if cross-compiling.
Expand Down
1 change: 1 addition & 0 deletions fluid/ExternalCodeEditor_UNIX.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "ExternalCodeEditor_UNIX.h"

#include "fluid.h"
#include "application/application.h"

#include <FL/Fl.H> /* Fl_Timeout_Handler.. */
#include <FL/fl_ask.H> /* fl_alert() */
Expand Down
1 change: 1 addition & 0 deletions fluid/ExternalCodeEditor_WIN32.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "ExternalCodeEditor_WIN32.h"
#include "fluid.h"
#include "application/application.h"

#include <stdio.h> // snprintf()
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions fluid/Fl_Function_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Fl_Function_Type.h"

#include "fluid.h"
#include "application/application.h"
#include "Fl_Window_Type.h"
#include "Fl_Group_Type.h"
#include "widget_browser.h"
Expand Down
1 change: 1 addition & 0 deletions fluid/Fl_Grid_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Fl_Grid_Type.h"

#include "fluid.h"
#include "application/application.h"
#include "file.h"
#include "code.h"
#include "widget_browser.h"
Expand Down
1 change: 1 addition & 0 deletions fluid/Fl_Group_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Fl_Group_Type.h"

#include "fluid.h"
#include "application/application.h"
#include "file.h"
#include "code.h"
#include "widget_browser.h"
Expand Down
2 changes: 1 addition & 1 deletion fluid/Fl_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ static void delete_children(Fl_Type *p) {

/** Delete all nodes in the Types tree and reset project settings, or delete selected nodes.
Also calls the browser to refresh.
\note Please refactor this into two separate methods of FLUID::Project.
\note Please refactor this into two separate methods of fluid::Project.
\param[in] selected_only if set, delete only the selected widgets and
don't reset the project.
*/
Expand Down
1 change: 1 addition & 0 deletions fluid/Fl_Window_Type.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "Fl_Window_Type.h"

#include "application/application.h"
#include "Fl_Group_Type.h"
#include "Fl_Grid_Type.h"
#include "fluid.h"
Expand Down
1 change: 1 addition & 0 deletions fluid/Fluid_Image.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Fluid_Image.h"

#include "fluid.h"
#include "application/application.h"
#include "Fl_Group_Type.h"
#include "Fl_Window_Type.h"
#include "file.h"
Expand Down
58 changes: 58 additions & 0 deletions fluid/application/application.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Application Class for Fast Light User Interface Designer (FLUID).
//
// Copyright 1998-2024 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//


#include "application/application.h"

#include "fluid.h"
#include "widget_browser.h"

extern bool confirm_project_clear();

/**
Clear the current project and create a new, empty one.
If the current project was modified, FLUID will give the user the opportunity
to save the old project first.
\param[in] user_must_confirm if set, a confimation dialog is presented to the
user before resetting the project. Default is `true`.
\return false if the operation was canceled
*/
bool fluid::Application::new_project(bool user_must_confirm) {
// verify user intention
if ((user_must_confirm) && (confirm_project_clear() == false))
return false;

// clear the current project
project().reset();
set_filename(NULL);
set_modflag(0, 0);
widget_browser->rebuild();
project().update_settings_dialog();

// all is clear to continue
return true;
}

/**
* Return a reference to the current project.
*/
fluid::Project &fluid::Application::project()
{
return g_project;
}

47 changes: 47 additions & 0 deletions fluid/application/application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Application Class for Fast Light User Interface Designer (FLUID).
//
// Copyright 1998-2024 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// https://www.fltk.org/COPYING.php
//
// Please see the following page on how to report bugs and issues:
//
// https://www.fltk.org/bugs.php
//

#ifndef FLUID_APPLICATION_APPLICATION_H
#define FLUID_APPLICATION_APPLICATION_H

#include "fluid.h"

#include <string>

namespace fluid {

class Application {
public:
/// Command line arguments.
App_Args args;
/// Application settings.
App_Settings settings;
/// Application history.
App_History history;
/// Set if the application is not in interactive mode.
bool batch_mode { false };
/// current directory path at application launch
Fl_String launch_path { };

/// Clear the current project and create a new, empty one.
bool new_project(bool user_must_confirm = true);
/// Get the current project.
Project &project();
};

}; // namespace FLUID

#endif // FLUID_APPLICATION_APPLICATION_H
1 change: 1 addition & 0 deletions fluid/autodoc.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include "autodoc.h"
#include "fluid.h"
#include "application/application.h"
#include "factory.h"
#include "widget_browser.h"
#include "widget_panel.h"
Expand Down
2 changes: 1 addition & 1 deletion fluid/code.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ void Fd_Code_Writer::write_public(int state) {
/**
Create and initialize a new C++ source code writer.
*/
Fd_Code_Writer::Fd_Code_Writer(FLUID::Project &project)
Fd_Code_Writer::Fd_Code_Writer(fluid::Project &project)
: project_(project),
code_file(NULL),
header_file(NULL),
Expand Down
6 changes: 3 additions & 3 deletions fluid/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Fd_Code_Writer
{
protected:
/// Reference to the project that will be written.
FLUID::Project &project_;
fluid::Project &project_;
/// file pointer for the C++ code file
FILE *code_file;
/// file pointer for the C++ header file
Expand Down Expand Up @@ -81,9 +81,9 @@ class Fd_Code_Writer
int varused;

public:
Fd_Code_Writer(FLUID::Project &project);
Fd_Code_Writer(fluid::Project &project);
~Fd_Code_Writer();
FLUID::Project &project() { return project_; }
fluid::Project &project() { return project_; }
const char* unique_id(void* o, const char*, const char*, const char*);
/// Increment source code indentation level.
void indent_more() { indentation++; }
Expand Down
1 change: 1 addition & 0 deletions fluid/factory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "factory.h"

#include "fluid.h"
#include "application/application.h"
#include "Fl_Group_Type.h"
#include "Fl_Grid_Type.h"
#include "Fl_Menu_Type.h"
Expand Down
4 changes: 2 additions & 2 deletions fluid/file.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ void Fd_Project_Reader::expand_buffer(int length) {
}

/** \brief Construct local project reader. */
Fd_Project_Reader::Fd_Project_Reader(FLUID::Project &project)
Fd_Project_Reader::Fd_Project_Reader(fluid::Project &project)
: project_(project),
fin(NULL),
lineno(0),
Expand Down Expand Up @@ -785,7 +785,7 @@ void Fd_Project_Reader::read_fdesign() {
// ---- Fd_Project_Writer ---------------------------------------------- MARK: -

/** \brief Construct local project writer. */
Fd_Project_Writer::Fd_Project_Writer(FLUID::Project &project)
Fd_Project_Writer::Fd_Project_Writer(fluid::Project &project)
: project_(project),
fout(NULL),
needspace(0),
Expand Down
12 changes: 6 additions & 6 deletions fluid/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Fd_Project_Reader
{
protected:
/// Reference to the project that will be read.
FLUID::Project &project_;
fluid::Project &project_;
/// Project input file
FILE *fin;
/// Number of most recently read line
Expand All @@ -55,9 +55,9 @@ class Fd_Project_Reader
double read_version;

public:
Fd_Project_Reader(FLUID::Project &project);
Fd_Project_Reader(fluid::Project &project);
~Fd_Project_Reader();
FLUID::Project &project() const { return project_; }
fluid::Project &project() const { return project_; }
int open_read(const char *s);
int close_read();
const char *filename_name();
Expand All @@ -75,7 +75,7 @@ class Fd_Project_Writer
{
protected:
/// Reference to the project that will be written.
FLUID::Project &project_;
fluid::Project &project_;
// Project output file, always opened in "wb" mode
FILE *fout;
/// If set, one space is written before text unless the format starts with a newline character
Expand All @@ -84,9 +84,9 @@ class Fd_Project_Writer
bool write_codeview_;

public:
Fd_Project_Writer(FLUID::Project &project);
Fd_Project_Writer(fluid::Project &project);
~Fd_Project_Writer();
FLUID::Project &project() const { return project_; }
fluid::Project &project() const { return project_; }
int open_write(const char *s);
int close_write();
int write_project(const char *filename, int selected_only, bool codeview);
Expand Down
Loading

0 comments on commit e3a1eb5

Please sign in to comment.