/scilab-master-1333395999/modules/gui/src/cpp/SetUicontrolFontUnits.cpp

# · C++ · 72 lines · 46 code · 10 blank · 16 comment · 20 complexity · 530d89373f161f34d535608c8a6ad288 MD5 · raw file

  1. /*
  2. * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  3. * Copyright (C) 2007 - INRIA - Vincent COUVERT
  4. * Sets the font units of an uicontrol object
  5. *
  6. * This file must be used under the terms of the CeCILL.
  7. * This source file is licensed as described in the file COPYING, which
  8. * you should have received as part of this distribution. The terms
  9. * are also available at
  10. * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  11. *
  12. */
  13. #include "SetUicontrolFontUnits.hxx"
  14. using namespace org_scilab_modules_gui_bridge;
  15. int SetUicontrolFontUnits(sciPointObj* sciObj, size_t stackPointer, int valueType, int nbRow, int nbCol)
  16. {
  17. /* Font weight can be points, normalized, inches, centimeters or pixels */
  18. char * fontUnits = NULL;
  19. if (valueType == sci_strings)
  20. {
  21. if(nbCol != 1 || nbRow == 0)
  22. {
  23. /* Wrong string size */
  24. Scierror(999, const_cast<char*>(_("Wrong size for '%s' property: '%s', '%s', '%s', '%s' or '%s' expected.\n")), "FontUnits", "points", "normalized", "inches", "centimeters", "pixels");
  25. return SET_PROPERTY_ERROR;
  26. }
  27. fontUnits = getStringFromStack(stackPointer);
  28. if (strcmp(fontUnits, "points") == 0)
  29. {
  30. pUICONTROL_FEATURE(sciObj)->fontUnits = POINTS_UNITS;
  31. }
  32. else if(strcmp(fontUnits, "normalized") == 0)
  33. {
  34. pUICONTROL_FEATURE(sciObj)->fontUnits = NORMALIZED_UNITS;
  35. }
  36. else if(strcmp(fontUnits, "inches") == 0)
  37. {
  38. pUICONTROL_FEATURE(sciObj)->fontUnits = INCHES_UNITS;
  39. }
  40. else if(strcmp(fontUnits, "centimeters") == 0)
  41. {
  42. pUICONTROL_FEATURE(sciObj)->fontUnits = CENTIMETERS_UNITS;
  43. }
  44. else if(strcmp(fontUnits, "pixels") == 0)
  45. {
  46. pUICONTROL_FEATURE(sciObj)->fontUnits = PIXELS_UNITS;
  47. }
  48. else
  49. {
  50. /* Wrong string format */
  51. Scierror(999, const_cast<char*>(_("Wrong value for '%s' property: '%s', '%s', '%s', '%s' or '%s' expected.\n")), "FontUnits", "points", "normalized", "inches", "centimeters", "pixels");
  52. return SET_PROPERTY_ERROR;
  53. }
  54. return SET_PROPERTY_SUCCEED;
  55. }
  56. else
  57. {
  58. /* Wrong datatype */
  59. Scierror(999, const_cast<char*>(_("Wrong type for '%s' property: '%s', '%s', '%s', '%s' or '%s' expected.\n")), "FontUnits", "points", "normalized", "inches", "centimeters", "pixels");
  60. return SET_PROPERTY_ERROR;
  61. }
  62. }