swad-core/swad_button.c

147 lines
4.8 KiB
C
Raw Normal View History

2017-06-11 19:13:51 +02:00
// swad_button.c: buttons to submit forms
/*
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.
2019-01-07 21:52:19 +01:00
Copyright (C) 1999-2019 Antonio Ca<EFBFBD>as Vargas
2017-06-11 19:13:51 +02:00
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 <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
#include <stdio.h> // For fprintf
#include "swad_button.h"
#include "swad_global.h"
2019-10-23 20:07:56 +02:00
#include "swad_HTML.h"
2017-06-11 19:13:51 +02:00
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/********************** Put a button to submit a form ************************/
/*****************************************************************************/
void Btn_PutButton (Btn_Button_t Button,const char *TxtButton)
{
if (TxtButton)
if (TxtButton[0])
switch (Button)
{
case Btn_NO_BUTTON:
break;
case Btn_CREATE_BUTTON:
Btn_PutCreateButton (TxtButton);
break;
case Btn_CONFIRM_BUTTON:
Btn_PutConfirmButton (TxtButton);
break;
case Btn_REMOVE_BUTTON:
Btn_PutRemoveButton (TxtButton);
break;
}
}
void Btn_PutButtonInline (Btn_Button_t Button,const char *TxtButton)
{
if (TxtButton)
if (TxtButton[0])
switch (Button)
{
case Btn_NO_BUTTON:
break;
case Btn_CREATE_BUTTON:
Btn_PutCreateButtonInline (TxtButton);
break;
case Btn_CONFIRM_BUTTON:
Btn_PutConfirmButtonInline (TxtButton);
break;
case Btn_REMOVE_BUTTON:
Btn_PutRemoveButtonInline (TxtButton);
break;
}
}
void Btn_PutCreateButton (const char *TxtButton)
{
2019-10-23 21:37:01 +02:00
HTM_DIV_Begin ("class=\"CM\"");
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CREATE",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2017-06-11 19:13:51 +02:00
}
void Btn_PutCreateButtonInline (const char *TxtButton)
{
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CREATE",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2017-06-11 19:13:51 +02:00
}
void Btn_PutConfirmButton (const char *TxtButton)
{
2019-10-23 21:37:01 +02:00
HTM_DIV_Begin ("class=\"CM\"");
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_CONFIRM",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2017-06-11 19:13:51 +02:00
}
void Btn_PutConfirmButtonInline (const char *TxtButton)
{
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_CONFIRM",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2017-06-11 19:13:51 +02:00
}
void Btn_PutRemoveButton (const char *TxtButton)
{
2019-10-23 21:37:01 +02:00
HTM_DIV_Begin ("class=\"CM\"");
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT BT_REMOVE",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2019-10-23 20:07:56 +02:00
HTM_DIV_End ();
2017-06-11 19:13:51 +02:00
}
void Btn_PutRemoveButtonInline (const char *TxtButton)
{
2019-11-20 10:17:42 +01:00
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_SUBMIT_INLINE BT_REMOVE",NULL);
2019-11-10 12:36:37 +01:00
HTM_Txt (TxtButton);
2019-11-09 20:15:38 +01:00
HTM_BUTTON_End ();
2017-06-11 19:13:51 +02:00
}