Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Abdelrazak Younes

Hi Richard,

Would it be possible to add a new item in the layout syntax to require a 
specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if the 
module is selected. Maybe a message box needs to be sown to the user 
stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to finish it.

Abdel.

--- 
C:/Users/abdel/AppData/Local/Temp/customHeadersFooters.modul-revBASE.svn001.tmp.module
  mar. déc. 14 12:47:18 2010
+++ C:/devel/lyx/lyx-devel/lib/layouts/customHeadersFooters.module  mar. 
déc. 14 12:44:16 2010
@@ -15,6 +15,7 @@
   LabelSep xx
   LatexNamelhead
   LabelString  Left Header:
+  RequiredSettingpaperpagestyle:fancy
   OptionalArgs 1
   KeepEmpty1
   ParSkip  0


Re: Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Richard Heck

On 12/14/2010 06:56 AM, Abdelrazak Younes wrote:

Hi Richard,

Would it be possible to add a new item in the layout syntax to require 
a specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if 
the module is selected. Maybe a message box needs to be sown to the 
user stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to finish 
it.


I don't see why it isn't possible. Getting it to interact correctly with 
DocumentSettings---disabling the setting, etc---will be the fun part, 
I'd think.


Richard



Re: Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Abdelrazak Younes

On 14/12/2010 15:42, Richard Heck wrote:

On 12/14/2010 06:56 AM, Abdelrazak Younes wrote:

Hi Richard,

Would it be possible to add a new item in the layout syntax to 
require a specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if 
the module is selected. Maybe a message box needs to be sown to the 
user stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to 
finish it.


I don't see why it isn't possible. Getting it to interact correctly 
with DocumentSettings---disabling the setting, etc---will be the fun 
part, I'd think.


You're right and I am sure I won't have time anyway so... Here's at the 
tiny least a beginning of a patch in case someone wants to tackle the 
idea. I actually think this is close to a bug and that we are going to 
have user reports about that issue...


Abdel.

Index: Layout.cpp
===
--- Layout.cpp  (revision 36883)
+++ Layout.cpp  (working copy)
@@ -110,6 +110,7 @@
LT_SPELLCHECK,
LT_REFPREFIX,
LT_REQARGS,
+   LT_REQSETTINGS,
LT_INTITLE // keep this last!
 };
 
@@ -222,6 +223,7 @@
{ preamble,   LT_PREAMBLE },
{ refprefix,  LT_REFPREFIX },
{ requiredargs,   LT_REQARGS },
+   { requiredsettings, LT_REQSETTINGS },
{ requires,   LT_REQUIRES },
{ rightmargin,LT_RIGHTMARGIN },
{ spacing,LT_SPACING },
@@ -335,6 +337,17 @@
lex  reqargs;
break;
 
+   case LT_REQSETTINGS: {
+   docstring setting;
+   docstring value;
+   lex  value;
+   value = split(value, setting, ':');
+   if (setting.empty())
+   break;
+   required_settings_[to_ascii(setting)] = value;
+   break;
+   }
+
case LT_NEED_PROTECT:
lex  needprotect;
break;
Index: Layout.h
===
--- Layout.h(revision 36883)
+++ Layout.h(working copy)
@@ -19,6 +19,7 @@
 #include Spacing.h
 #include support/docstring.h
 
+#include map
 #include set
 #include string
 
@@ -102,6 +103,8 @@
///
std::setstd::string const  requires() const { return requires_; }
///
+   std::mapstd::string, docstring const  requiredSettings() const { 
return required_settings_; }
+   ///
std::string const  latexparam() const { return latexparam_; }
///
std::string const  innertag() const { return innertag_; }
@@ -379,6 +382,8 @@
docstring babelpreamble_;
/// Packages needed for this layout
std::setstd::string requires_;
+   /// Document settings required for this layout
+   std::mapstd::string, docstring required_settings_;
 };
 
 } // namespace lyx


Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Abdelrazak Younes

Hi Richard,

Would it be possible to add a new item in the layout syntax to require a 
specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if the 
module is selected. Maybe a message box needs to be sown to the user 
stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to finish it.

Abdel.

--- 
C:/Users/abdel/AppData/Local/Temp/customHeadersFooters.modul-revBASE.svn001.tmp.module
  mar. déc. 14 12:47:18 2010
+++ C:/devel/lyx/lyx-devel/lib/layouts/customHeadersFooters.module  mar. 
déc. 14 12:44:16 2010
@@ -15,6 +15,7 @@
   LabelSep xx
   LatexNamelhead
   LabelString  "Left Header:"
+  RequiredSettingpaperpagestyle:fancy
   OptionalArgs 1
   KeepEmpty1
   ParSkip  0


Re: Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Richard Heck

On 12/14/2010 06:56 AM, Abdelrazak Younes wrote:

Hi Richard,

Would it be possible to add a new item in the layout syntax to require 
a specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if 
the module is selected. Maybe a message box needs to be sown to the 
user stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to finish 
it.


I don't see why it isn't possible. Getting it to interact correctly with 
Document>Settings---disabling the setting, etc---will be the fun part, 
I'd think.


Richard



Re: Modules and required document settings (ex: for header and footer module)

2010-12-14 Thread Abdelrazak Younes

On 14/12/2010 15:42, Richard Heck wrote:

On 12/14/2010 06:56 AM, Abdelrazak Younes wrote:

Hi Richard,

Would it be possible to add a new item in the layout syntax to 
require a specific document settings? Something like:


RequiredSettingsetting:value

In the case of the header and footer module that would give the 
attached. The goal is of course to automatically set the setting if 
the module is selected. Maybe a message box needs to be sown to the 
user stating that the parameter will be automatically set.


I can do the initial patch but I am not sure I would be able to 
finish it.


I don't see why it isn't possible. Getting it to interact correctly 
with Document>Settings---disabling the setting, etc---will be the fun 
part, I'd think.


You're right and I am sure I won't have time anyway so... Here's at the 
tiny least a beginning of a patch in case someone wants to tackle the 
idea. I actually think this is close to a bug and that we are going to 
have user reports about that issue...


Abdel.

Index: Layout.cpp
===
--- Layout.cpp  (revision 36883)
+++ Layout.cpp  (working copy)
@@ -110,6 +110,7 @@
LT_SPELLCHECK,
LT_REFPREFIX,
LT_REQARGS,
+   LT_REQSETTINGS,
LT_INTITLE // keep this last!
 };
 
@@ -222,6 +223,7 @@
{ "preamble",   LT_PREAMBLE },
{ "refprefix",  LT_REFPREFIX },
{ "requiredargs",   LT_REQARGS },
+   { "requiredsettings", LT_REQSETTINGS },
{ "requires",   LT_REQUIRES },
{ "rightmargin",LT_RIGHTMARGIN },
{ "spacing",LT_SPACING },
@@ -335,6 +337,17 @@
lex >> reqargs;
break;
 
+   case LT_REQSETTINGS: {
+   docstring setting;
+   docstring value;
+   lex >> value;
+   value = split(value, setting, ':');
+   if (setting.empty())
+   break;
+   required_settings_[to_ascii(setting)] = value;
+   break;
+   }
+
case LT_NEED_PROTECT:
lex >> needprotect;
break;
Index: Layout.h
===
--- Layout.h(revision 36883)
+++ Layout.h(working copy)
@@ -19,6 +19,7 @@
 #include "Spacing.h"
 #include "support/docstring.h"
 
+#include 
 #include 
 #include 
 
@@ -102,6 +103,8 @@
///
std::set const & requires() const { return requires_; }
///
+   std::map const & requiredSettings() const { 
return required_settings_; }
+   ///
std::string const & latexparam() const { return latexparam_; }
///
std::string const & innertag() const { return innertag_; }
@@ -379,6 +382,8 @@
docstring babelpreamble_;
/// Packages needed for this layout
std::set requires_;
+   /// Document settings required for this layout
+   std::map required_settings_;
 };
 
 } // namespace lyx