The following patch fixes the display of Caption label when inserting
a new float.

The fact that "Caption" is hardcoded is not worse than before, but
this information could be defined in the float definition if lars
prefers (that's a change of layout file syntax, and can be done
later).

After that I think (hope) that real numbering of captions will be easy
(and theorems too?).

Lars?

JMarc

Index: src/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v
retrieving revision 1.2150
diff -u -p -r1.2150 ChangeLog
--- src/ChangeLog	11 Apr 2005 13:35:14 -0000	1.2150
+++ src/ChangeLog	11 Apr 2005 15:08:46 -0000
@@ -1,3 +1,8 @@
+2005-04-11  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* text3.C (dispatch): change the layout to "Caption" after inserting
+	a float.
+
 2005-04-06  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
 
 	* FontIterator.C (operator*): avoid a copy of the font.
Index: src/text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.286
diff -u -p -r1.286 text3.C
--- src/text3.C	7 Mar 2005 11:03:45 -0000	1.286
+++ src/text3.C	11 Apr 2005 15:08:46 -0000
@@ -1184,18 +1184,23 @@ void LyXText::dispatch(LCursor & cur, Fu
 	case LFUN_INSERT_BRANCH:
 	case LFUN_INSERT_BIBITEM:
 	case LFUN_INSET_ERT:
-	case LFUN_INSET_FLOAT:
 	case LFUN_INSET_FOOTNOTE:
 	case LFUN_INSET_MARGINAL:
 	case LFUN_INSET_OPTARG:
-	case LFUN_INSET_WIDE_FLOAT:
-	case LFUN_INSET_WRAP:
 	case LFUN_TABULAR_INSERT:
 	case LFUN_ENVIRONMENT_INSERT:
 		// Open the inset, and move the current selection
 		// inside it.
 		doInsertInset(cur, this, cmd, true, true);
 		cur.posRight();
+		break;
+
+	case LFUN_INSET_FLOAT:
+	case LFUN_INSET_WIDE_FLOAT: 
+	case LFUN_INSET_WRAP:
+		doInsertInset(cur, this, cmd, true, true);
+		cur.posRight();
+		cur.dispatch(FuncRequest(LFUN_LAYOUT, "Caption"));
 		break;
 
 	case LFUN_INDEX_INSERT:
Index: src/insets/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/ChangeLog,v
retrieving revision 1.1126
diff -u -p -r1.1126 ChangeLog
--- src/insets/ChangeLog	10 Apr 2005 14:07:32 -0000	1.1126
+++ src/insets/ChangeLog	11 Apr 2005 15:08:46 -0000
@@ -1,3 +1,8 @@
+2005-04-11  Jean-Marc Lasgouttes  <[EMAIL PROTECTED]>
+
+	* insetfloat.C (InsetFloat): 
+	* insetwrap.C (InsetWrap): do not set layout here.
+
 2005-04-10  Martin Vermeer  <[EMAIL PROTECTED]>
 
 	* insetcharstyle.C (metrics, draw):
Index: src/insets/insetfloat.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetfloat.C,v
retrieving revision 1.135
diff -u -p -r1.135 insetfloat.C
--- src/insets/insetfloat.C	6 Jan 2005 16:39:34 -0000	1.135
+++ src/insets/insetfloat.C	11 Apr 2005 15:08:46 -0000
@@ -142,9 +142,6 @@ InsetFloat::InsetFloat(BufferParams cons
 	setLabelFont(font);
 	params_.type = type;
 	setInsetName(type);
-	LyXTextClass const & tclass = bp.getLyXTextClass();
-	if (tclass.hasLayout(caplayout))
-		paragraphs().begin()->layout(tclass[caplayout]);
 }
 
 
Index: src/insets/insetwrap.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetwrap.C,v
retrieving revision 1.72
diff -u -p -r1.72 insetwrap.C
--- src/insets/insetwrap.C	6 Jan 2005 16:39:34 -0000	1.72
+++ src/insets/insetwrap.C	11 Apr 2005 15:08:46 -0000
@@ -68,9 +68,6 @@ InsetWrap::InsetWrap(BufferParams const 
 	params_.type = type;
 	params_.width = LyXLength(50, LyXLength::PCW);
 	setInsetName(type);
-	LyXTextClass const & tclass = bp.getLyXTextClass();
-	if (tclass.hasLayout(caplayout))
-		paragraphs().begin()->layout(tclass[caplayout]);
 }
 
 

Reply via email to