Label.cs 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. //Compact Framework
  136. public virtual ContentAlignment TextAlign {
  137. get {
  138. return textAlign;
  139. }
  140. set {
  141. textAlign = value;
  142. }
  143. }
  144. public bool UseMnemonic {
  145. get {
  146. return useMnemonic;
  147. }
  148. set {
  149. useMnemonic = value;
  150. }
  151. }
  152. //
  153. // --- Protected Properties
  154. //
  155. protected override CreateParams CreateParams {
  156. get {
  157. CreateParams createParams = new CreateParams ();
  158. window = new ControlNativeWindow (this);
  159. createParams.Caption = Text;
  160. createParams.ClassName = "STATIC";
  161. createParams.X = Left;
  162. createParams.Y = Top;
  163. createParams.Width = Width;
  164. createParams.Height = Height;
  165. createParams.ClassStyle = 0;
  166. createParams.ExStyle = 0;
  167. createParams.Param = 0;
  168. createParams.Parent = Parent.Handle;
  169. createParams.Style = (int) (
  170. Win32.WS_CHILD |
  171. Win32.WS_VISIBLE | Win32.SS_LEFT );
  172. window.CreateHandle (createParams);
  173. return createParams;
  174. }
  175. }
  176. protected override Size DefaultSize {
  177. get {
  178. // FIXME: use GetSystemMetrics?
  179. throw new NotImplementedException ();
  180. }
  181. }
  182. protected virtual bool RenderTransparent {
  183. get {
  184. return renderTransparent;
  185. }
  186. set {
  187. renderTransparent = value;
  188. }
  189. }
  190. protected override ImeMode DefaultImeMode {
  191. get {
  192. return defaultImeMode;
  193. }
  194. }
  195. //
  196. // --- Public Methods
  197. //
  198. [MonoTODO]
  199. public override bool Equals(object o)
  200. {
  201. throw new NotImplementedException ();
  202. }
  203. public override int GetHashCode() {
  204. //FIXME add our proprities
  205. return base.GetHashCode();
  206. }
  207. public new void Select()
  208. {
  209. base.Select ();
  210. }
  211. //Compact Framework
  212. [MonoTODO]
  213. public override string ToString()
  214. {
  215. throw new NotImplementedException ();
  216. }
  217. //
  218. // --- Public Events
  219. //
  220. public event EventHandler AutoSizeChanged; // {
  221. // add {
  222. // throw new NotImplementedException ();
  223. // }
  224. // remove {
  225. // throw new NotImplementedException ();
  226. // }
  227. // }
  228. public event EventHandler TextAlignChanged; // {
  229. // add {
  230. // throw new NotImplementedException ();
  231. // }
  232. // remove {
  233. // throw new NotImplementedException ();
  234. // }
  235. // }
  236. //
  237. // --- Protected Methods
  238. //
  239. [MonoTODO]
  240. protected Rectangle CalcImageRenderBounds (
  241. Image image, Rectangle rect, ContentAlignment align)
  242. {
  243. throw new NotImplementedException ();
  244. }
  245. // [MonoTODO]
  246. // protected override AccessibleObject CreateAccessibilityInstance()
  247. // {
  248. // throw new NotImplementedException ();
  249. // }
  250. protected new virtual void Dispose()
  251. {
  252. //throw new NotImplementedException ();
  253. }
  254. protected override void Dispose(bool disposing)
  255. {
  256. //throw new NotImplementedException ();
  257. }
  258. [MonoTODO]
  259. protected void DrawImage (Graphics g, Image img,
  260. Rectangle r, ContentAlignment align)
  261. {
  262. throw new NotImplementedException ();
  263. }
  264. protected virtual void OnAutoSizeChanged (EventArgs e) {
  265. if (AutoSizeChanged != null)
  266. AutoSizeChanged (this, e);
  267. }
  268. protected override void OnEnabledChanged (EventArgs e)
  269. {
  270. base.OnEnabledChanged (e);
  271. }
  272. protected override void OnFontChanged (EventArgs e)
  273. {
  274. base.OnFontChanged (e);
  275. }
  276. protected override void OnPaint (PaintEventArgs e)
  277. {
  278. }
  279. //Compact Framework
  280. protected override void OnParentChanged (EventArgs e)
  281. {
  282. base.OnParentChanged (e);
  283. }
  284. protected virtual void OnTextAlignChanged (EventArgs e) {
  285. if (TextAlignChanged != null)
  286. TextAlignChanged (this, e);
  287. }
  288. //Compact Framework
  289. protected override void OnTextChanged (EventArgs e) {
  290. base.OnTextChanged (e);
  291. }
  292. protected override void OnVisibleChanged (EventArgs e)
  293. {
  294. base.OnVisibleChanged (e);
  295. }
  296. protected override bool ProcessMnemonic(char charCode)
  297. {
  298. return base.ProcessMnemonic (charCode);
  299. }
  300. [MonoTODO]
  301. protected new ContentAlignment RtlTranslateAlignment (
  302. ContentAlignment alignment)
  303. {
  304. throw new NotImplementedException ();
  305. }
  306. [MonoTODO]
  307. protected new HorizontalAlignment RtlTranslateAlignment (
  308. HorizontalAlignment alignment)
  309. {
  310. throw new NotImplementedException ();
  311. }
  312. [MonoTODO]
  313. protected new LeftRightAlignment RtlTranslateAlignment (
  314. LeftRightAlignment align)
  315. {
  316. throw new NotImplementedException ();
  317. }
  318. [MonoTODO]
  319. protected new virtual void Select (bool directed, bool forward)
  320. {
  321. throw new NotImplementedException ();
  322. }
  323. protected override void SetBoundsCore (
  324. int x, int y, int width, int height,
  325. BoundsSpecified specified)
  326. {
  327. base.SetBoundsCore (x, y, width, height, specified);
  328. }
  329. protected new void UpdateBounds()
  330. {
  331. base.UpdateBounds ();
  332. }
  333. protected new void UpdateBounds (int x, int y,
  334. int width, int height)
  335. {
  336. base.UpdateBounds (x, y, width, height);
  337. }
  338. protected new void UpdateBounds (int x, int y, int width,
  339. int height, int clientWidth,
  340. int clientHeight)
  341. {
  342. base.UpdateBounds (x, y, width, height, clientWidth,
  343. clientHeight);
  344. }
  345. protected override void WndProc(ref Message m)
  346. {
  347. base.WndProc (ref m);
  348. }
  349. }
  350. }