MenuItem.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. // Permission is hereby granted, free of charge, to any person obtaining
  2. // a copy of this software and associated documentation files (the
  3. // "Software"), to deal in the Software without restriction, including
  4. // without limitation the rights to use, copy, modify, merge, publish,
  5. // distribute, sublicense, and/or sell copies of the Software, and to
  6. // permit persons to whom the Software is furnished to do so, subject to
  7. // the following conditions:
  8. //
  9. // The above copyright notice and this permission notice shall be
  10. // included in all copies or substantial portions of the Software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  13. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  14. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  15. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  16. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  17. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  18. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  19. //
  20. // Copyright (c) 2004 Novell, Inc.
  21. //
  22. // Authors:
  23. // Jordi Mas i Hernandez, [email protected]
  24. //
  25. //
  26. // NOT COMPLETE
  27. using System.ComponentModel;
  28. using System.Collections;
  29. namespace System.Windows.Forms
  30. {
  31. public abstract class MenuItem : Menu
  32. {
  33. internal Menu parent_menu = null;
  34. internal bool separator;
  35. internal bool break_;
  36. internal bool bar_break;
  37. private string text;
  38. public MenuItem (): base (null)
  39. {
  40. CommonConstructor ();
  41. }
  42. public MenuItem (string s) : base (null)
  43. {
  44. CommonConstructor ();
  45. Text = s; // Text can change separator status
  46. }
  47. public MenuItem (string s, EventHandler e) : base (null)
  48. {
  49. CommonConstructor ();
  50. }
  51. public MenuItem (string s, MenuItem[] items) : base (items)
  52. {
  53. CommonConstructor ();
  54. }
  55. public MenuItem (string s, EventHandler e, Shortcut shortcut) : base (null)
  56. {
  57. CommonConstructor ();
  58. throw new NotImplementedException ();
  59. }
  60. public MenuItem (MenuMerge mergeType, int mergeOrder, Shortcut shortcut, string text,
  61. EventHandler onClick, EventHandler onPopup, EventHandler onSelect, MenuItem[] items)
  62. : base (items)
  63. {
  64. CommonConstructor ();
  65. throw new NotImplementedException ();
  66. }
  67. private void CommonConstructor ()
  68. {
  69. Text = string.Empty;
  70. separator = false;
  71. break_ = false;
  72. bar_break = false;
  73. }
  74. #region Public Properties
  75. public bool BarBreak {
  76. get { return break_; }
  77. set { break_ = value; }
  78. }
  79. public bool Break {
  80. get { return bar_break; }
  81. set { bar_break = value; }
  82. }
  83. public bool Checked {
  84. get {
  85. throw new NotImplementedException ();
  86. }
  87. set{
  88. throw new NotImplementedException ();
  89. }
  90. }
  91. public bool DefaultItem {
  92. get {
  93. throw new NotImplementedException ();
  94. }
  95. set{
  96. throw new NotImplementedException ();
  97. }
  98. }
  99. public bool Enabled {
  100. get {
  101. throw new NotImplementedException ();
  102. }
  103. set{
  104. throw new NotImplementedException ();
  105. }
  106. }
  107. public int Index {
  108. get {
  109. throw new NotImplementedException ();
  110. }
  111. set{
  112. throw new NotImplementedException ();
  113. }
  114. }
  115. public override bool IsParent {
  116. get {
  117. throw new NotImplementedException ();
  118. }
  119. }
  120. public bool MdiList {
  121. get {
  122. throw new NotImplementedException ();
  123. }
  124. set{
  125. throw new NotImplementedException ();
  126. }
  127. }
  128. public MenuItem MdiListItem {
  129. get {
  130. throw new NotImplementedException ();
  131. }
  132. set{
  133. throw new NotImplementedException ();
  134. }
  135. }
  136. public int MergeOrder{
  137. get {
  138. throw new NotImplementedException ();
  139. }
  140. set{
  141. throw new NotImplementedException ();
  142. }
  143. }
  144. public System.Windows.Forms.MenuMerge MergeType {
  145. get {
  146. throw new NotImplementedException ();
  147. }
  148. set{
  149. throw new NotImplementedException ();
  150. }
  151. }
  152. public char Mnemonic {
  153. get {
  154. throw new NotImplementedException ();
  155. }
  156. set{
  157. throw new NotImplementedException ();
  158. }
  159. }
  160. public bool OwnerDraw {
  161. get {
  162. throw new NotImplementedException ();
  163. }
  164. set{
  165. throw new NotImplementedException ();
  166. }
  167. }
  168. public Menu Parent {
  169. get { return parent_menu;}
  170. }
  171. public bool RadioCheck {
  172. get {
  173. throw new NotImplementedException ();
  174. }
  175. set{
  176. throw new NotImplementedException ();
  177. }
  178. }
  179. public Shortcut Shortcut {
  180. get {
  181. throw new NotImplementedException ();
  182. }
  183. set{
  184. throw new NotImplementedException ();
  185. }
  186. }
  187. public bool ShowShortcut {
  188. get {
  189. throw new NotImplementedException ();
  190. }
  191. set{
  192. throw new NotImplementedException ();
  193. }
  194. }
  195. public string Text {
  196. get { return text; }
  197. set {
  198. text = value;
  199. if (text == "-")
  200. separator = true;
  201. else
  202. separator = false;
  203. //TODO: Force recalc sizes
  204. }
  205. }
  206. public bool Visible {
  207. get {
  208. throw new NotImplementedException ();
  209. }
  210. set{
  211. throw new NotImplementedException ();
  212. }
  213. }
  214. #endregion Public Properties
  215. #region Private Properties
  216. internal bool IsPopup {
  217. get {
  218. if (menu_items.Count > 0)
  219. return true;
  220. else
  221. return false;
  222. }
  223. }
  224. internal bool Separator {
  225. get { return separator; }
  226. set { separator = value; }
  227. }
  228. #endregion Private Properties
  229. #region Public Methods
  230. public virtual MenuItem CloneMenu ()
  231. {
  232. throw new NotImplementedException ();
  233. }
  234. protected void CloneMenu (MenuItem menuitem)
  235. {
  236. throw new NotImplementedException ();
  237. }
  238. protected override void Dispose (bool disposing)
  239. {
  240. throw new NotImplementedException ();
  241. }
  242. public virtual void Dispose ()
  243. {
  244. throw new NotImplementedException ();
  245. }
  246. public virtual void MergeMenu ()
  247. {
  248. throw new NotImplementedException ();
  249. }
  250. public virtual void MergeMenu (Menu menu)
  251. {
  252. throw new NotImplementedException ();
  253. }
  254. public void MergeMenu (MenuItem menuteim)
  255. {
  256. throw new NotImplementedException ();
  257. }
  258. protected virtual void OnClick (EventArgs e)
  259. {
  260. }
  261. protected virtual void OnDrawItem (DrawItemEventArgs e)
  262. {
  263. }
  264. protected virtual void OnInitMenuPopup (EventArgs e)
  265. {
  266. }
  267. protected virtual void OnMeasureItem (MeasureItemEventArgs e)
  268. {
  269. }
  270. protected virtual void OnPopup (EventArgs e)
  271. {
  272. }
  273. protected virtual void OnSelect (EventArgs e)
  274. {
  275. }
  276. public void PerformClick ()
  277. {
  278. throw new NotImplementedException ();
  279. }
  280. public virtual void PerformSelect ()
  281. {
  282. throw new NotImplementedException ();
  283. }
  284. public override string ToString ()
  285. {
  286. return "item:" + text;
  287. }
  288. #endregion Public Methods
  289. #region Private Methods
  290. internal void Create ()
  291. {
  292. MenuAPI.InsertMenuItem (Parent.Handle, -1, true, this);
  293. }
  294. #endregion Private Methods
  295. }
  296. }