panel.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* SLiM - Simple Login Manager
  2. Copyright (C) 1997, 1998 Per Liden
  3. Copyright (C) 2004-06 Simone Rota <sip@varlock.com>
  4. Copyright (C) 2004-06 Johannes Winkelmann <jw@tks6.net>
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. */
  10. #ifndef _PANEL_H_
  11. #define _PANEL_H_
  12. #include <X11/Xlib.h>
  13. #include <X11/keysym.h>
  14. #include <X11/Xft/Xft.h>
  15. #include <X11/cursorfont.h>
  16. #include <X11/Xmu/WinUtil.h>
  17. #include <sys/wait.h>
  18. #include <stdlib.h>
  19. #include <signal.h>
  20. #include <iostream>
  21. #include <string>
  22. #ifdef NEEDS_BASENAME
  23. #include <libgen.h>
  24. #endif
  25. #include "switchuser.h"
  26. #include "const.h"
  27. #include "image.h"
  28. class Panel {
  29. public:
  30. enum ActionType {
  31. Login,
  32. Console,
  33. Reboot,
  34. Halt,
  35. Exit,
  36. Suspend
  37. };
  38. enum FieldType {
  39. Get_Name,
  40. Get_Passwd
  41. };
  42. Panel(Display* dpy, int scr, Window root, Cfg* config,
  43. const std::string& themed);
  44. ~Panel();
  45. void OpenPanel();
  46. void ClosePanel();
  47. void ClearPanel();
  48. void Message(const std::string& text);
  49. void Error(const std::string& text);
  50. void EventHandler(const FieldType& curfield);
  51. std::string getSession();
  52. ActionType getAction(void) const;
  53. void Reset(void);
  54. void ResetName(void);
  55. void ResetPasswd(void);
  56. void SetName(const std::string& name);
  57. const std::string& GetName(void) const;
  58. const std::string& GetPasswd(void) const;
  59. private:
  60. Panel();
  61. void Cursor(int visible);
  62. unsigned long GetColor(const char* colorname);
  63. void OnExpose(void);
  64. bool OnKeyPress(XEvent& event);
  65. void ShowText();
  66. void SwitchSession();
  67. void ShowSession();
  68. void SlimDrawString8(XftDraw *d, XftColor *color, XftFont *font,
  69. int x, int y, const std::string& str,
  70. XftColor* shadowColor,
  71. int xOffset, int yOffset);
  72. Cfg* cfg;
  73. // Private data
  74. Window Win;
  75. Window Root;
  76. Display* Dpy;
  77. int Scr;
  78. int X, Y;
  79. GC TextGC;
  80. XftFont* font;
  81. XftColor inputshadowcolor;
  82. XftColor inputcolor;
  83. XftColor msgcolor;
  84. XftColor msgshadowcolor;
  85. XftFont* msgfont;
  86. XftColor introcolor;
  87. XftFont* introfont;
  88. XftFont* welcomefont;
  89. XftColor welcomecolor;
  90. XftFont* sessionfont;
  91. XftColor sessioncolor;
  92. XftColor sessionshadowcolor;
  93. XftColor welcomeshadowcolor;
  94. XftFont* enterfont;
  95. XftColor entercolor;
  96. XftColor entershadowcolor;
  97. ActionType action;
  98. FieldType field;
  99. // Username/Password
  100. std::string NameBuffer;
  101. std::string PasswdBuffer;
  102. std::string HiddenPasswdBuffer;
  103. // Configuration
  104. int input_name_x;
  105. int input_name_y;
  106. int input_pass_x;
  107. int input_pass_y;
  108. int inputShadowXOffset;
  109. int inputShadowYOffset;
  110. int input_cursor_height;
  111. int welcome_x;
  112. int welcome_y;
  113. int welcome_shadow_xoffset;
  114. int welcome_shadow_yoffset;
  115. int session_shadow_xoffset;
  116. int session_shadow_yoffset;
  117. int intro_x;
  118. int intro_y;
  119. int username_x;
  120. int username_y;
  121. int username_shadow_xoffset;
  122. int username_shadow_yoffset;
  123. int password_x;
  124. int password_y;
  125. std::string welcome_message;
  126. std::string intro_message;
  127. // Pixmap data
  128. Pixmap PanelPixmap;
  129. Image* image;
  130. // For thesting themes
  131. bool testing;
  132. std::string themedir;
  133. // Session handling
  134. std::string session;
  135. };
  136. #endif