summaryrefslogtreecommitdiff
path: root/fluid/Project.h
blob: e68ad6d4eab600093eae1fbbac2f2662ef41fde5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// Fluid Project header for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2025 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_PROJECT_H
#define FLUID_PROJECT_H

#include "proj/undo.h"
#include "proj/i18n.h"
#include "nodes/Tree.h"

#include <FL/filename.H>

// ---- project class declaration


class Layout_Preset;
extern Layout_Preset *default_layout_preset;

/**
 Data and settings for a FLUID project file.
 */
class Project
{
public: // Member Variables
  // Undo actions for this Project.
  Undo undo;

  // Manage the node tree of the project.
  Tree tree;

  // Project internationalization.
  I18n i18n;

  /// If set, generate code to include the header file form the c++ file
  int include_H_from_C;
  /// If set, handle keyboard shortcut Ctrl on macOS using Cmd instead
  int use_FL_COMMAND;
  /// Clear if UTF-8 characters in statics texts are written as escape sequences
  int utf8_in_src;
  /// If set, <FL/Fl.H> will not be included from the header code before anything else
  int avoid_early_includes;
  /// If set, command line overrides header file name in .fl file.
  int header_file_set;
  ///  If set, command line overrides source code file name in .fl file.
  int code_file_set;
  /// later
  int write_mergeback_data;
  /// Filename of the current .fl project file
  const char *proj_filename;
  /// Hold the default extension for header files, or the entire filename if set via command line.
  char *header_file_name_;
  /// Hold the default extension for source code files, or the entire filename if set via command line.
  char *code_file_name_;
  /// Macro used in header file for #ifdef MACRO \n #defined MACRO \n ... \n #endif
  char *include_guard_;

  /// Used as a counter to set the .fl project dir as the current directory.
  int in_project_dir;
  /// Application work directory, stored here when temporarily changing to the source code directory.
  char app_work_dir_[FL_PATH_MAX];

  /// Set if the current design has been modified compared to the associated .fl design file.
  int modflag;
  /// Set if the code files are older than the current design.
  int modflag_c;

  /// Currently used layout preset.
  Layout_Preset *layout;

public: // Methods
  Project();
  ~Project();
  void reset();
  void update_settings_dialog();

  // Getters for file name settings
  const char *header_file_name() const { return header_file_name_; }
  const char *code_file_name() const { return code_file_name_; }
  const char *include_guard() const { return include_guard_; }

  // Setters for file name settings
  void set_header_file_name(const char *name);
  void set_code_file_name(const char *name);
  void set_include_guard(const char *guard);

  // Path computation methods - fill provided buffer
  void projectfile_path(char *buf, int bufsize) const;
  const char *projectfile_name() const;
  void codefile_path(char *buf, int bufsize) const;
  void codefile_name(char *buf, int bufsize) const;
  void headerfile_path(char *buf, int bufsize) const;
  void headerfile_name(char *buf, int bufsize) const;
  void stringsfile_path(char *buf, int bufsize) const;
  void stringsfile_name(char *buf, int bufsize) const;
  void basename(char *buf, int bufsize) const;

  void enter_project_dir();
  void leave_project_dir();

  void clear_filename();
  void set_filename(const char *c);
  void write_strings();

  void set_modflag(int mf, int mfc = -1);
};

#endif // FLUID_PROJECT_H