From dc196a2e6c37b5b78183bdc637cf6c88da2711a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 10 Jun 2017 21:38:48 +0200 Subject: [PATCH] Version 16.239 --- swad_box.c | 240 +++++++++++++++++++++++++++++++++++++++++++++++++++++ swad_box.h | 65 +++++++++++++++ 2 files changed, 305 insertions(+) create mode 100644 swad_box.c create mode 100644 swad_box.h diff --git a/swad_box.c b/swad_box.c new file mode 100644 index 000000000..1cc508b5c --- /dev/null +++ b/swad_box.c @@ -0,0 +1,240 @@ +// swad_box.c: layout of boxes + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2017 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +// #include // For NULL +#include // For boolean type +#include // For fprintf +// #include // For exit, system, malloc, calloc, free, etc +// #include // For string functions + +#include "swad_action.h" +#include "swad_box.h" +// #include "swad_calendar.h" +// #include "swad_changelog.h" +// #include "swad_config.h" +// #include "swad_connected.h" +// #include "swad_database.h" +// #include "swad_exam.h" +// #include "swad_follow.h" +#include "swad_global.h" +#include "swad_help.h" +// #include "swad_hierarchy.h" +// #include "swad_language.h" +// #include "swad_logo.h" +// #include "swad_MFU.h" +// #include "swad_notice.h" +// #include "swad_notification.h" +// #include "swad_parameter.h" +// #include "swad_preference.h" +// #include "swad_social.h" +// #include "swad_tab.h" +// #include "swad_theme.h" +// #include "swad_web_service.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************* Private types *******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +static void Box_StartBoxInternal (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable, + const char *ClassFrame); + +/*****************************************************************************/ +/****************** Start and end a table with rounded frame *****************/ +/*****************************************************************************/ +// CellPadding must be 0, 1, 2, 4 or 8 + +void Box_StartBoxTable (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable, + unsigned CellPadding) // CellPadding must be 0, 1, 2, 5 or 10 + { + Box_StartBox (Width,Title,FunctionToDrawContextualIcons, + HelpLink, + Closable); + Lay_StartTableWide (CellPadding); + } + +void Box_StartBoxTableShadow (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink, + unsigned CellPadding) // CellPadding must be 0, 1, 2, 5 or 10 + { + Box_StartBoxShadow (Width,Title, + FunctionToDrawContextualIcons, + HelpLink); + Lay_StartTableWide (CellPadding); + } + +void Box_StartBox (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable) + { + Box_StartBoxInternal (Width,Title, + FunctionToDrawContextualIcons, + HelpLink, + Closable, + "FRAME"); + } + +void Box_StartBoxShadow (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink) + { + Box_StartBoxInternal (Width,Title, + FunctionToDrawContextualIcons, + HelpLink, + false, // Not closable + "FRAME_SHADOW"); + } + +static void Box_StartBoxInternal (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable, + const char *ClassFrame) + { + extern const char *Txt_Help; + extern const char *Txt_Close; + char IdFrame[Act_MAX_BYTES_ID]; + + /***** Start frame container *****/ + fprintf (Gbl.F.Out,"
"); + + /***** Start frame *****/ + fprintf (Gbl.F.Out,"
"); + + /***** Row for left and right icons *****/ + fprintf (Gbl.F.Out,"
"); + + /* Contextual icons at left */ + if (FunctionToDrawContextualIcons) + { + fprintf (Gbl.F.Out,"
"); + FunctionToDrawContextualIcons (); + fprintf (Gbl.F.Out,"
"); + } + + /* Icons at right: help and close */ + fprintf (Gbl.F.Out,"
"); + + if (HelpLink) // Link to help + fprintf (Gbl.F.Out,"" + "
" + "\"%s\"" + "
" + "
", + Hlp_WIKI,HelpLink, + Gbl.Prefs.IconsURL, + Txt_Help,Txt_Help); + + if (Closable) // Icon to close the frame + fprintf (Gbl.F.Out,"" + "
" + "\"%s\"" + "
" + "
", + IdFrame, + Gbl.Prefs.IconsURL, + Txt_Close,Txt_Close); + + fprintf (Gbl.F.Out,"
"); + + /***** End row for left and right icons *****/ + fprintf (Gbl.F.Out,"
"); + + /***** Frame title *****/ + if (Title) + fprintf (Gbl.F.Out,"
" + "%s" + "
", + Gbl.Layout.FrameNested ? "FRAME_TITLE_SMALL" : + "FRAME_TITLE_BIG", + Title); + + Gbl.Layout.FrameNested++; + } + +void Box_EndBoxTable (void) + { + Lay_EndTable (); + Box_EndBox (); + } + +void Box_EndBoxTableWithButton (Lay_Button_t Button,const char *TxtButton) + { + Lay_EndTable (); + Box_EndBoxWithButton (Button,TxtButton); + } + +void Box_EndBoxWithButton (Lay_Button_t Button,const char *TxtButton) + { + Lay_PutButton (Button,TxtButton); + Box_EndBox (); + } + +void Box_EndBox (void) + { + Gbl.Layout.FrameNested--; + + /***** End frame and frame container *****/ + fprintf (Gbl.F.Out,"
" + "
"); + } diff --git a/swad_box.h b/swad_box.h new file mode 100644 index 000000000..4ff972544 --- /dev/null +++ b/swad_box.h @@ -0,0 +1,65 @@ +// swad_box.h: layout of boxes + +#ifndef _SWAD_BOX +#define _SWAD_BOX +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2017 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include // For boolean type + +#include "swad_layout.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/********************************* Public types ******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +void Box_StartBoxTable (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable, + unsigned CellPadding); +void Box_StartBox (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink,bool Closable); +void Box_StartBoxShadow (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink); +void Box_StartBoxTableShadow (const char *Width,const char *Title, + void (*FunctionToDrawContextualIcons) (void), + const char *HelpLink, + unsigned CellPadding); +void Box_EndBoxTable (void); +void Box_EndBoxTableWithButton (Lay_Button_t Button,const char *TxtButton); +void Box_EndBoxWithButton (Lay_Button_t Button,const char *TxtButton); +void Box_EndBox (void); + +#endif