Label.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. //
  2. // System.Windows.Forms.Label.cs
  3. //
  4. // Author:
  5. // stubbed out by Daniel Carrera ([email protected])
  6. // implemented for Gtk+ by Rachel Hestilow ([email protected])
  7. // Dennis Hayes ([email protected])
  8. // WineLib implementation started by John Sohn ([email protected])
  9. //
  10. // (C) 2002 Ximian, Inc
  11. //
  12. namespace System.Windows.Forms {
  13. using System.ComponentModel;
  14. using System.Drawing;
  15. // <summary>
  16. //
  17. // </summary>
  18. public class Label : Control {
  19. Image backgroundImage;
  20. BorderStyle borderStyle;
  21. bool autoSize;
  22. Image image;
  23. ContentAlignment imageAlign;
  24. ImeMode defaultImeMode;
  25. bool renderTransparent;
  26. FlatStyle flatStyle;
  27. int preferredHeight;
  28. int preferredWidth;
  29. bool tabStop;
  30. ContentAlignment textAlign;
  31. bool useMnemonic;
  32. //
  33. // --- Constructor
  34. //
  35. public Label () : base ()
  36. {
  37. }
  38. //
  39. // --- Public Properties
  40. //
  41. public virtual bool AutoSize {
  42. get {
  43. return autoSize;
  44. }
  45. set {
  46. autoSize = value;
  47. }
  48. }
  49. public override Image BackgroundImage {
  50. get {
  51. return backgroundImage;
  52. }
  53. set {
  54. backgroundImage = value;
  55. // FIXME: force redraw
  56. }
  57. }
  58. public virtual BorderStyle BorderStyle {
  59. get {
  60. return borderStyle;
  61. }
  62. set {
  63. borderStyle = value;
  64. }
  65. }
  66. public FlatStyle FlatStyle {
  67. get {
  68. return flatStyle;
  69. }
  70. set {
  71. flatStyle = value;
  72. }
  73. }
  74. public Image Image {
  75. get {
  76. return image;
  77. }
  78. set {
  79. image = value;
  80. }
  81. }
  82. public ContentAlignment ImageAlign {
  83. get {
  84. return imageAlign;
  85. }
  86. set {
  87. imageAlign = value;
  88. }
  89. }
  90. [MonoTODO]
  91. public int ImageIndex {
  92. get {
  93. throw new NotImplementedException ();
  94. }
  95. set {
  96. throw new NotImplementedException ();
  97. }
  98. }
  99. [MonoTODO]
  100. public ImageList ImageList {
  101. get {
  102. throw new NotImplementedException ();
  103. }
  104. set {
  105. throw new NotImplementedException ();
  106. }
  107. }
  108. [MonoTODO]
  109. public new ImeMode ImeMode {
  110. get {
  111. throw new NotImplementedException ();
  112. }
  113. set {
  114. throw new NotImplementedException ();
  115. }
  116. }
  117. public int PreferredHeight {
  118. get {
  119. return preferredHeight;
  120. }
  121. }
  122. public int PreferredWidth {
  123. get {
  124. return preferredWidth;
  125. }
  126. }
  127. public new bool TabStop {
  128. get {
  129. return tabStop;
  130. }
  131. set {
  132. tabStop = value;
  133. }
  134. }
  135. public virtual ContentAlignment TextAlign {
  136. get {
  137. return textAlign;
  138. }
  139. set {
  140. textAlign = value;
  141. }
  142. }
  143. public bool UseMnemonic {
  144. get {
  145. return useMnemonic;
  146. }
  147. set {
  148. useMnemonic = value;
  149. }
  150. }
  151. //
  152. // --- Protected Properties
  153. //
  154. protected override CreateParams CreateParams {
  155. get {
  156. CreateParams createParams = new CreateParams ();
  157. window = new ControlNativeWindow (this);
  158. createParams.Caption = Text;
  159. createParams.ClassName = "STATIC";
  160. createParams.X = Top;
  161. createParams.Y = Left;
  162. createParams.Width = Width;
  163. createParams.Height = Height;
  164. createParams.ClassStyle = 0;
  165. createParams.ExStyle = 0;
  166. createParams.Param = 0;
  167. createParams.Parent = Parent.Handle;
  168. createParams.Style = (int) (
  169. Win32.WS_CHILD |
  170. Win32.WS_VISIBLE | Win32.SS_LEFT );
  171. window.CreateHandle (createParams);
  172. return createParams;
  173. }
  174. }
  175. protected override Size DefaultSize {
  176. get {
  177. // FIXME: use GetSystemMetrics?
  178. throw new NotImplementedException ();
  179. }
  180. }
  181. protected virtual bool RenderTransparent {
  182. get {
  183. return renderTransparent;
  184. }
  185. set {
  186. renderTransparent = value;
  187. }
  188. }
  189. protected override ImeMode DefaultImeMode {
  190. get {
  191. return defaultImeMode;
  192. }
  193. }
  194. //
  195. // --- Public Methods
  196. //
  197. [MonoTODO]
  198. public override bool Equals(object o)
  199. {
  200. throw new NotImplementedException ();
  201. }
  202. public override int GetHashCode() {
  203. //FIXME add our proprities
  204. return base.GetHashCode();
  205. }
  206. public new void Select()
  207. {
  208. base.Select ();
  209. }
  210. [MonoTODO]
  211. public override string ToString()
  212. {
  213. throw new NotImplementedException ();
  214. }
  215. //
  216. // --- Public Events
  217. //
  218. public event EventHandler AutoSizeChanged; // {
  219. // add {
  220. // throw new NotImplementedException ();
  221. // }
  222. // remove {
  223. // throw new NotImplementedException ();
  224. // }
  225. // }
  226. public event EventHandler TextAlignChanged; // {
  227. // add {
  228. // throw new NotImplementedException ();
  229. // }
  230. // remove {
  231. // throw new NotImplementedException ();
  232. // }
  233. // }
  234. //
  235. // --- Protected Methods
  236. //
  237. [MonoTODO]
  238. protected Rectangle CalcImageRenderBounds (
  239. Image image, Rectangle rect, ContentAlignment align)
  240. {
  241. throw new NotImplementedException ();
  242. }
  243. // [MonoTODO]
  244. // protected override AccessibleObject CreateAccessibilityInstance()
  245. // {
  246. // throw new NotImplementedException ();
  247. // }
  248. protected new virtual void Dispose()
  249. {
  250. //throw new NotImplementedException ();
  251. }
  252. protected override void Dispose(bool disposing)
  253. {
  254. //throw new NotImplementedException ();
  255. }
  256. [MonoTODO]
  257. protected void DrawImage (Graphics g, Image img,
  258. Rectangle r, ContentAlignment align)
  259. {
  260. throw new NotImplementedException ();
  261. }
  262. protected virtual void OnAutoSizeChanged (EventArgs e) {
  263. if (AutoSizeChanged != null)
  264. AutoSizeChanged (this, e);
  265. }
  266. protected override void OnEnabledChanged (EventArgs e)
  267. {
  268. base.OnEnabledChanged (e);
  269. }
  270. protected override void OnFontChanged (EventArgs e)
  271. {
  272. base.OnFontChanged (e);
  273. }
  274. protected override void OnPaint (PaintEventArgs e)
  275. {
  276. }
  277. protected override void OnParentChanged (EventArgs e)
  278. {
  279. base.OnParentChanged (e);
  280. }
  281. protected virtual void OnTextAlignChanged (EventArgs e) {
  282. if (TextAlignChanged != null)
  283. TextAlignChanged (this, e);
  284. }
  285. protected override void OnTextChanged (EventArgs e) {
  286. base.OnTextChanged (e);
  287. }
  288. protected override void OnVisibleChanged (EventArgs e)
  289. {
  290. base.OnVisibleChanged (e);
  291. }
  292. protected override bool ProcessMnemonic(char charCode)
  293. {
  294. return base.ProcessMnemonic (charCode);
  295. }
  296. [MonoTODO]
  297. protected new ContentAlignment RtlTranslateAlignment (
  298. ContentAlignment alignment)
  299. {
  300. throw new NotImplementedException ();
  301. }
  302. [MonoTODO]
  303. protected new HorizontalAlignment RtlTranslateAlignment (
  304. HorizontalAlignment alignment)
  305. {
  306. throw new NotImplementedException ();
  307. }
  308. [MonoTODO]
  309. protected new LeftRightAlignment RtlTranslateAlignment (
  310. LeftRightAlignment align)
  311. {
  312. throw new NotImplementedException ();
  313. }
  314. [MonoTODO]
  315. protected new virtual void Select (bool directed, bool forward)
  316. {
  317. throw new NotImplementedException ();
  318. }
  319. protected override void SetBoundsCore (
  320. int x, int y, int width, int height,
  321. BoundsSpecified specified)
  322. {
  323. base.SetBoundsCore (x, y, width, height, specified);
  324. }
  325. protected new void UpdateBounds()
  326. {
  327. base.UpdateBounds ();
  328. }
  329. protected new void UpdateBounds (int x, int y,
  330. int width, int height)
  331. {
  332. base.UpdateBounds (x, y, width, height);
  333. }
  334. protected new void UpdateBounds (int x, int y, int width,
  335. int height, int clientWidth,
  336. int clientHeight)
  337. {
  338. base.UpdateBounds (x, y, width, height, clientWidth,
  339. clientHeight);
  340. }
  341. protected override void WndProc(ref Message m)
  342. {
  343. base.WndProc (ref m);
  344. }
  345. }
  346. }