Re: Commit: beginning of lock styles (now Patch/Commit request)


Subject: Re: Commit: beginning of lock styles (now Patch/Commit request)
From: Bryce Nesbitt (bryce@obviously.com)
Date: Fri Dec 07 2001 - 20:37:47 CST


Dom Lachowicz wrote:
>
> PD_Document has 2 new functions:
>
> bool areStylesLocked()
> void lockStyles(bool)

Here's the rest of the patch, please look at it for commit.

This feature still needs attention from the GUI experts on
each platform. It seems adding a toggle entry to the Style
dialog is platform specific. DLG_Styles_StylesLocked is
the text, lockStyles(bool b) the implementing function.

Bugs noted: The unix platform's text color toolbar widgets are implemented
differently from all other toolbard widgts, and don't respect
ghosting. Same for the menu items with submenus (e.g. "Align").

                        -Bryce

? confdefs.h
? setup.sh
? Untitled.abw
? src/Linux_2.4.2-2_i386_OBJ
Index: src/hello/ap/xp/ap_Toolbar_Functions.h
===================================================================
RCS file: /cvsroot/abi/src/hello/ap/xp/ap_Toolbar_Functions.h,v
retrieving revision 1.1
diff -u -r1.1 ap_Toolbar_Functions.h
--- src/hello/ap/xp/ap_Toolbar_Functions.h 1999/04/08 21:07:05 1.1
+++ src/hello/ap/xp/ap_Toolbar_Functions.h 2001/12/08 00:10:16
@@ -37,5 +37,6 @@
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_BlockFmt);
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_SectionFmt);
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_Zoom);
+Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_StylesLocked);
 
 #endif /* AP_TOOLBAR_FUNCTIONS_H */
Index: src/text/ptbl/xp/pd_Document.cpp
===================================================================
RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.cpp,v
retrieving revision 1.152
diff -u -r1.152 pd_Document.cpp
--- src/text/ptbl/xp/pd_Document.cpp 2001/12/07 20:42:34 1.152
+++ src/text/ptbl/xp/pd_Document.cpp 2001/12/08 00:10:17
@@ -84,7 +84,7 @@
         m_bRedrawHappenning(false),
   m_bLoading(false),
   m_bForcedDirty(false),
- m_bLockedStyles(false)
+ m_bLockedStyles(false) // same as lockStyles(false)
 {
         m_pApp = pApp;
 
Index: src/text/ptbl/xp/pd_Document.h
===================================================================
RCS file: /cvsroot/abi/src/text/ptbl/xp/pd_Document.h,v
retrieving revision 1.105
diff -u -r1.105 pd_Document.h
--- src/text/ptbl/xp/pd_Document.h 2001/12/07 20:42:34 1.105
+++ src/text/ptbl/xp/pd_Document.h 2001/12/08 00:10:18
@@ -255,9 +255,11 @@
         //! Pointer to last instatiated PD_Document. Used for debugging.
         static PD_Document* m_pDoc;
 #endif
-
- inline bool areStylesLocked () const { return m_bLockedStyles; }
- inline void lockStyles(bool b) { m_bLockedStyles = b; }
+
+ // If we're using styles to format a document, prevent accidental use of other formatting
+ // tools. Disable all explicit formatting tools (font, color, boldness, etc.)
+ inline bool areStylesLocked () const { return m_bLockedStyles; } // See also lockStyles
+ inline void lockStyles(bool b) { m_bLockedStyles = b; } // See also areStylesLocked
 
 protected:
         ~PD_Document();
Index: src/wp/ap/unix/ap_UnixDialog_Styles.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/unix/ap_UnixDialog_Styles.cpp,v
retrieving revision 1.39
diff -u -r1.39 ap_UnixDialog_Styles.cpp
--- src/wp/ap/unix/ap_UnixDialog_Styles.cpp 2001/12/04 00:28:37 1.39
+++ src/wp/ap/unix/ap_UnixDialog_Styles.cpp 2001/12/08 00:10:20
@@ -602,6 +602,7 @@
         GtkWidget * DescriptionArea;
 
         GtkWidget * hsepBot;
+ GtkWidget * stylesLocked;
 
         GtkWidget * buttonBoxStyleManip;
 
@@ -710,8 +711,20 @@
         gtk_box_pack_start(GTK_BOX(vboxContents), hsepBot, FALSE, FALSE, 0);
         gtk_widget_show(hsepBot);
 
- // Pack buttons at the bottom of the dialog
+#ifdef NOTDEFINED
+ //
+ // If we're using styles to format a document, prevent accidental use of other formatting
+ // tools. Disable all explicit formatting tools (font, color, boldness) if this
+ // check box is checked.
+ //
+ // Check with "areStylesLocked()", set with "lockStyles( bool )";
+ //
+ stylesLocked = gtk_check_button_new_with_label(pSS->getValue(AP_STRING_ID_DLG_Styles_StylesLocked));
+ gtk_box_pack_start(GTK_BOX(vboxContents), stylesLocked, FALSE, FALSE, 0);
+ gtk_widget_show( stylesLocked );
+#endif
 
+ // Pack buttons at the bottom of the dialog
         buttonBoxStyleManip = gtk_hbutton_box_new();
         gtk_hbutton_box_set_spacing_default(0);
         gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_END);
Index: src/wp/ap/xp/ap_Menu_ActionSet.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_ActionSet.cpp,v
retrieving revision 1.73
diff -u -r1.73 ap_Menu_ActionSet.cpp
--- src/wp/ap/xp/ap_Menu_ActionSet.cpp 2001/11/27 21:00:40 1.73
+++ src/wp/ap/xp/ap_Menu_ActionSet.cpp 2001/12/08 00:10:22
@@ -152,9 +152,9 @@
         _s(AP_MENU_ID_INSERT_GRAPHIC, 0,1,0, "fileInsertGraphic",NULL, NULL);
         _s(AP_MENU_ID_FORMAT, 1,0,0, NULL, NULL, NULL);
         _s(AP_MENU_ID_FMT_LANGUAGE, 0,1,0, "dlgLanguage", NULL, NULL);
- _s(AP_MENU_ID_FMT_FONT, 0,1,0, "dlgFont", NULL, NULL);
- _s(AP_MENU_ID_FMT_PARAGRAPH, 0,1,0, "dlgParagraph", NULL, NULL);
- _s(AP_MENU_ID_FMT_BULLETS, 0,1,0, "dlgBullets", NULL, NULL);
+ _s(AP_MENU_ID_FMT_FONT, 0,1,0, "dlgFont", ap_GetState_StylesLocked, NULL);
+ _s(AP_MENU_ID_FMT_PARAGRAPH, 0,1,0, "dlgParagraph", ap_GetState_StylesLocked, NULL);
+ _s(AP_MENU_ID_FMT_BULLETS, 0,1,0, "dlgBullets", ap_GetState_StylesLocked, NULL);
         _s(AP_MENU_ID_FMT_DOCUMENT, 0,1,0, "pageSetup", NULL, NULL);
         _s(AP_MENU_ID_FMT_BORDERS, 0,1,0, "dlgBorders", NULL, NULL);
         _s(AP_MENU_ID_FMT_COLUMNS, 0,1,0, "dlgColumns", NULL, NULL);
@@ -174,7 +174,7 @@
         _s(AP_MENU_ID_FMT_SUBSCRIPT, 0,0,1, "toggleSub", ap_GetState_CharFmt, NULL);
         _s(AP_MENU_ID_FMT_TOGGLECASE, 0,1,0, "dlgToggleCase", NULL, NULL);
 
- _s(AP_MENU_ID_ALIGN, 1,0,0, NULL, NULL, NULL);
+ _s(AP_MENU_ID_ALIGN, 1,0,0, NULL, ap_GetState_StylesLocked, NULL);
         _s(AP_MENU_ID_ALIGN_LEFT, 0,0,1, "alignLeft", ap_GetState_BlockFmt, NULL);
         _s(AP_MENU_ID_ALIGN_CENTER, 0,0,1, "alignCenter", ap_GetState_BlockFmt, NULL);
         _s(AP_MENU_ID_ALIGN_RIGHT, 0,0,1, "alignRight", ap_GetState_BlockFmt, NULL);
Index: src/wp/ap/xp/ap_Menu_Functions.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_Functions.cpp,v
retrieving revision 1.51
diff -u -r1.51 ap_Menu_Functions.cpp
--- src/wp/ap/xp/ap_Menu_Functions.cpp 2001/11/02 20:22:55 1.51
+++ src/wp/ap/xp/ap_Menu_Functions.cpp 2001/12/08 00:10:22
@@ -623,6 +623,11 @@
         const XML_Char * prop = NULL;
         const XML_Char * val = NULL;
 
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_MIS_Gray;
+ return s;
+ }
+
         switch(id)
         {
         case AP_MENU_ID_FMT_BOLD:
@@ -707,6 +712,7 @@
                 free(props_in);
         }
 
+
         return s;
 }
 
@@ -720,6 +726,11 @@
         const XML_Char * prop = "text-align";
         const XML_Char * val = NULL;
 
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_MIS_Gray;
+ return s;
+ }
+
         switch(id)
         {
         case AP_MENU_ID_ALIGN_LEFT:
@@ -854,4 +865,18 @@
         }
 
         return s;
+}
+
+Defun_EV_GetMenuItemState_Fn(ap_GetState_StylesLocked)
+{
+ ABIWORD_VIEW;
+ UT_ASSERT(pView);
+
+ EV_Menu_ItemState s = EV_MIS_ZERO;
+
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_MIS_Gray;
+ }
+
+ return s;
 }
Index: src/wp/ap/xp/ap_Menu_Functions.h
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Menu_Functions.h,v
retrieving revision 1.15
diff -u -r1.15 ap_Menu_Functions.h
--- src/wp/ap/xp/ap_Menu_Functions.h 2001/03/15 18:58:43 1.15
+++ src/wp/ap/xp/ap_Menu_Functions.h 2001/12/08 00:10:22
@@ -40,6 +40,7 @@
 Defun_EV_GetMenuItemState_Fn(ap_GetState_View);
 Defun_EV_GetMenuItemState_Fn(ap_GetState_Suggest);
 Defun_EV_GetMenuItemState_Fn(ap_GetState_Prefs);
+Defun_EV_GetMenuItemState_Fn(ap_GetState_StylesLocked);
 
 Defun_EV_GetMenuItemComputedLabel_Fn(ap_GetLabel_Recent);
 Defun_EV_GetMenuItemComputedLabel_Fn(ap_GetLabel_Window);
Index: src/wp/ap/xp/ap_String_Id.h
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_String_Id.h,v
retrieving revision 1.128
diff -u -r1.128 ap_String_Id.h
--- src/wp/ap/xp/ap_String_Id.h 2001/12/03 21:31:52 1.128
+++ src/wp/ap/xp/ap_String_Id.h 2001/12/08 00:10:23
@@ -173,6 +173,7 @@
 dcl(DLG_Styles_ErrStyleBuiltin, "Cannot modify a builtin style")
 dcl(DLG_Styles_ErrStyleCantDelete, "Cannot delete this style")
 dcl(DLG_Styles_ErrBlankName, "Style name cannot be left blank")
+dcl(DLG_Styles_StylesLocked, "Lock out non-style formatting commands")
 
 
 /* Paragraph dialog */
Index: src/wp/ap/xp/ap_Toolbar_ActionSet.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Toolbar_ActionSet.cpp,v
retrieving revision 1.36
diff -u -r1.36 ap_Toolbar_ActionSet.cpp
--- src/wp/ap/xp/ap_Toolbar_ActionSet.cpp 2001/11/08 19:01:39 1.36
+++ src/wp/ap/xp/ap_Toolbar_ActionSet.cpp 2001/12/08 00:10:24
@@ -79,8 +79,8 @@
         _s(AP_TOOLBAR_ID_SPELLCHECK, EV_TBIT_PushButton, "dlgSpell", AV_CHG_NONE, NULL);
         _s(AP_TOOLBAR_ID_IMG, EV_TBIT_PushButton, "fileInsertGraphic", AV_CHG_NONE, NULL);
         _s(AP_TOOLBAR_ID_HELP, EV_TBIT_PushButton, "helpContents", AV_CHG_NONE, NULL);
- _s(AP_TOOLBAR_ID_COLOR_FORE, EV_TBIT_ColorFore, "colorForeTB", AV_CHG_NONE, NULL);
- _s(AP_TOOLBAR_ID_COLOR_BACK, EV_TBIT_ColorBack, "colorBackTB", AV_CHG_NONE, NULL);
+ _s(AP_TOOLBAR_ID_COLOR_FORE, EV_TBIT_ColorFore, "colorForeTB", AV_CHG_NONE, ap_ToolbarGetState_StylesLocked);
+ _s(AP_TOOLBAR_ID_COLOR_BACK, EV_TBIT_ColorBack, "colorBackTB", AV_CHG_NONE, ap_ToolbarGetState_StylesLocked);
         _s(AP_TOOLBAR_ID_EDIT_UNDO, EV_TBIT_PushButton, "undo", AV_CHG_DO, ap_ToolbarGetState_Changes);
         _s(AP_TOOLBAR_ID_EDIT_REDO, EV_TBIT_PushButton, "redo", AV_CHG_DO, ap_ToolbarGetState_Changes);
         _s(AP_TOOLBAR_ID_EDIT_CUT, EV_TBIT_PushButton, "cut", AV_CHG_EMPTYSEL, ap_ToolbarGetState_Selection);
Index: src/wp/ap/xp/ap_Toolbar_Functions.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Toolbar_Functions.cpp,v
retrieving revision 1.39
diff -u -r1.39 ap_Toolbar_Functions.cpp
--- src/wp/ap/xp/ap_Toolbar_Functions.cpp 2001/11/02 20:22:55 1.39
+++ src/wp/ap/xp/ap_Toolbar_Functions.cpp 2001/12/08 00:10:24
@@ -209,6 +209,10 @@
         UT_ASSERT(pView);
 
         EV_Toolbar_ItemState s = EV_TIS_ZERO;
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_TIS_Gray;
+ return s;
+ }
 
         fl_BlockLayout * pBlock = pView->getCurrentBlock();
         UT_ASSERT(pBlock);
@@ -226,6 +230,10 @@
         UT_ASSERT(pView);
 
         EV_Toolbar_ItemState s = EV_TIS_ZERO;
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_TIS_Gray;
+ return s;
+ }
 
         fl_BlockLayout * pBlock = pView->getCurrentBlock();
         UT_ASSERT(pBlock);
@@ -244,11 +252,16 @@
         bool bSize = false;
         bool bString = false;
 
- EV_Toolbar_ItemState s = EV_TIS_ZERO;
-
         const XML_Char * prop = NULL;
         const XML_Char * val = NULL;
 
+ EV_Toolbar_ItemState s = EV_TIS_ZERO;
+
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_TIS_Gray;
+ return s;
+ }
+
         switch (id)
         {
         case AP_TOOLBAR_ID_FMT_FONT:
@@ -332,12 +345,6 @@
                 break;
         }
 
- //if should be disabled return
- if (s == EV_TIS_Gray)
- {
- return s;
- }
-
         if (prop && val)
         {
                 // get current char properties from pView
@@ -394,11 +401,11 @@
         if (pszState)
                 *pszState = NULL;
 
- EV_Toolbar_ItemState s = EV_TIS_ZERO;
-
         const XML_Char * prop = "";
         const XML_Char * val = NULL;
 
+ EV_Toolbar_ItemState s = EV_TIS_ZERO;
+
         switch (id)
         {
         case AP_TOOLBAR_ID_1COLUMN:
@@ -462,11 +469,16 @@
 
         bool bPoints = false;
 
- EV_Toolbar_ItemState s = EV_TIS_ZERO;
-
         const XML_Char * prop = "text-align";
         const XML_Char * val = NULL;
 
+ EV_Toolbar_ItemState s = EV_TIS_ZERO;
+
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_TIS_Gray;
+ return s;
+ }
+
         switch (id)
         {
         case AP_TOOLBAR_ID_ALIGN_LEFT:
@@ -525,12 +537,6 @@
                 break;
         }
         
- //if should be disabled return
- if (s == EV_TIS_Gray)
- {
- return s;
- }
-
         if (prop && val)
         {
                 // get current block properties from pView
@@ -626,3 +632,18 @@
 
         return s;
 }
+
+Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_StylesLocked)
+{
+ ABIWORD_VIEW;
+ UT_ASSERT(pView);
+
+ EV_Toolbar_ItemState s = EV_TIS_ZERO;
+
+ if(pView->getDocument()->areStylesLocked()) {
+ s = EV_TIS_Gray;
+ }
+
+ return s;
+}
+
Index: src/wp/ap/xp/ap_Toolbar_Functions.h
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/xp/ap_Toolbar_Functions.h,v
retrieving revision 1.9
diff -u -r1.9 ap_Toolbar_Functions.h
--- src/wp/ap/xp/ap_Toolbar_Functions.h 2001/07/27 05:22:41 1.9
+++ src/wp/ap/xp/ap_Toolbar_Functions.h 2001/12/08 00:10:24
@@ -42,6 +42,7 @@
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_Zoom);
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_View);
 Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_HdrFtr);
+Defun_EV_GetToolbarItemState_Fn(ap_ToolbarGetState_StylesLocked);
 
 #endif /* AP_TOOLBAR_FUNCTIONS_H */
 



This archive was generated by hypermail 2b25 : Fri Dec 07 2001 - 20:40:10 CST