From: jpbruyere Date: Sat, 16 Nov 2013 08:16:43 +0000 (+0100) Subject: first commit X-Git-Tag: 0.2~115 X-Git-Url: https://git.osiis.dedyn.io/?a=commitdiff_plain;h=dab0f2befeda33bd1c8e59ec41a2e1768712086b;p=jp%2Fcrow.git first commit --- dab0f2befeda33bd1c8e59ec41a2e1768712086b diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..3b3b05fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +Win_x86 + +Debug + +/*.sln + +/GOLib.suo diff --git a/GOLib.csproj b/GOLib.csproj new file mode 100644 index 00000000..e32dd8f9 --- /dev/null +++ b/GOLib.csproj @@ -0,0 +1,187 @@ + + + + Debug + Linux_x86 + 8.0.30703 + 2.0 + {C2980F9B-4798-4C05-99E2-E174810F7C7B} + Library + Properties + go + Interface + 512 + True + False + False + bin\$(configuration)\$(Platform) + obj\$(Configuration)\ + 4 + False + false + False + OnBuildSuccess + + + False + False + obj\ + Full + + + 4194304 + x86 + False + False + Auto + + + AnyCPU + 4194304 + False + Auto + + + x86 + 4194304 + False + Auto + + + True + False + obj\ + None + + + TRACE;DEBUG;__linux__ + ..\bin\Debug\Linux_x86 + true + + + TRACE;DEBUG;_WIN32 + + + __linux__ + ..\bin\Release\Linux_x86 + + + _WIN32 + + + none + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + + + + + + + False + lib\OpenTK.dll + + + False + lib\OpenTK.Compatibility.dll + + + False + lib\OpenTK.GLControl.dll + + + ..\..\..\OpenTK\1.0\Binaries\OpenTK\Debug\OpenTK.Compatibility.dll + + + ..\..\..\OpenTK\1.0\Binaries\OpenTK\Debug\OpenTK.dll + + + ..\..\..\OpenTK\1.0\Binaries\OpenTK\Debug\OpenTK.GLControl.dll + + + False + gtk-sharp-2.0 + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + + \ No newline at end of file diff --git a/lib/OpenTK.Compatibility.dll b/lib/OpenTK.Compatibility.dll new file mode 100644 index 00000000..d6d8149e Binary files /dev/null and b/lib/OpenTK.Compatibility.dll differ diff --git a/lib/OpenTK.GLControl.dll b/lib/OpenTK.GLControl.dll new file mode 100644 index 00000000..e31628d5 Binary files /dev/null and b/lib/OpenTK.GLControl.dll differ diff --git a/lib/OpenTK.dll b/lib/OpenTK.dll new file mode 100644 index 00000000..afff0dd1 Binary files /dev/null and b/lib/OpenTK.dll differ diff --git a/lib/freetype6.dll b/lib/freetype6.dll new file mode 100644 index 00000000..ead809b6 Binary files /dev/null and b/lib/freetype6.dll differ diff --git a/lib/intl.dll b/lib/intl.dll new file mode 100644 index 00000000..d2612081 Binary files /dev/null and b/lib/intl.dll differ diff --git a/lib/libcairo-2.dll b/lib/libcairo-2.dll new file mode 100644 index 00000000..34f84afd Binary files /dev/null and b/lib/libcairo-2.dll differ diff --git a/lib/libcairo-gobject-2.dll b/lib/libcairo-gobject-2.dll new file mode 100644 index 00000000..f4bbf6fa Binary files /dev/null and b/lib/libcairo-gobject-2.dll differ diff --git a/lib/libcairo-script-interpreter-2.dll b/lib/libcairo-script-interpreter-2.dll new file mode 100644 index 00000000..74acaf60 Binary files /dev/null and b/lib/libcairo-script-interpreter-2.dll differ diff --git a/lib/libexpat-1.dll b/lib/libexpat-1.dll new file mode 100644 index 00000000..b3cf4100 Binary files /dev/null and b/lib/libexpat-1.dll differ diff --git a/lib/libfontconfig-1.dll b/lib/libfontconfig-1.dll new file mode 100644 index 00000000..7ad870bb Binary files /dev/null and b/lib/libfontconfig-1.dll differ diff --git a/lib/libpng14-14.dll b/lib/libpng14-14.dll new file mode 100644 index 00000000..8b93b06a Binary files /dev/null and b/lib/libpng14-14.dll differ diff --git a/lib/zlib1.dll b/lib/zlib1.dll new file mode 100644 index 00000000..869b00d4 Binary files /dev/null and b/lib/zlib1.dll differ diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs new file mode 100644 index 00000000..29cf4b58 --- /dev/null +++ b/src/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("GOLib")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("GOLib")] +[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("150376dc-e648-46a2-b692-6429d0a62362")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/Button.cs b/src/Button.cs new file mode 100644 index 00000000..d29cfbc0 --- /dev/null +++ b/src/Button.cs @@ -0,0 +1,460 @@ +using System; + + +using System.Collections.Generic; +using System.Linq; +using System.Text; +//using OpenTK.Graphics.OpenGL; + +using Cairo; + +using winColors = System.Drawing.Color; +using System.Diagnostics; + +namespace go +{ + public class Button : Group + { + public static class Theme + { + public static Color background = Color.Gray; + public static Color borderColor = Color.Black; + public static int margin = 1; + public static int borderWidth = 1; + public static VerticalAlignment verticalAlignment = VerticalAlignment.None; + public static HorizontalAlignment horizontalAlignment = HorizontalAlignment.None; + public static bool sizeToContent = false; + } + + public Button(ButtonWidgetClick _clickEvent, string _text, bool _checkable = false, int width = 0, int height = 0) + : base(width, height) + { + initButtonWidget(_clickEvent, _checkable); + label = new Label(_text); + sizeToContent = true; + label.fontColor = Color.Black; + label.fontSize = 14; + label.horizontalAlignment = HorizontalAlignment.Stretch; + label.verticalAlignment = VerticalAlignment.Stretch; + label.textAlignment = Alignment.Center; + + } + public Button(System.Drawing.Bitmap iconBitmap, ButtonWidgetClick _clickEvent, bool _checkable, int width, int height) + : base(width, height) + { + icon = new Image(iconBitmap); + initButtonWidget(_clickEvent, _checkable); + } + public Button(string iconFile, ButtonWidgetClick _clickEvent = null, bool _checkable = false, bool _affectMultiSelectState = true) + : base() + { + affectMultiSelectState = _affectMultiSelectState; + icon = new Image(iconFile); + initButtonWidget(_clickEvent, _checkable); + sizeToContent = true; + } + public Button(string iconFile, ButtonWidgetClick _clickEvent, bool _checkable, int width, int height, bool _affectMultiSelectState = true) + : base(width, height) + { + affectMultiSelectState = _affectMultiSelectState; + icon = new Image(iconFile); + initButtonWidget(_clickEvent, _checkable); + } + public Button(string iconFile, string checkedIconFile, ButtonWidgetClick _clickEvent, bool _checkable = false, int width = 30, int height = 30, bool _affectMultiSelectState = true) + : base(width, height) + { + affectMultiSelectState = _affectMultiSelectState; + icon = new Image(iconFile); + checkedIcon = new Image(checkedIconFile); + checkedIcon.isVisible = false; + + initButtonWidget(_clickEvent, _checkable); + } + + void initButtonWidget(ButtonWidgetClick _clickEvent = null, bool _checkable = false) + { + focusable = true; + IsCheckable = _checkable; + clickEvent = _clickEvent; + + background = Theme.background; + borderColor = Theme.borderColor; + borderWidth = Theme.borderWidth; + margin = Theme.margin; + horizontalAlignment = Theme.horizontalAlignment; + verticalAlignment = Theme.verticalAlignment; + sizeToContent = Theme.sizeToContent; + } + + public enum ButtonStates + { + normal, + mouseOver, + mouseDown, + Disable + } + + public static int maxIconSize = 22; + + ButtonStates _CurrentState = ButtonStates.normal; + public ButtonStates CurrentState + { + get { return _CurrentState; } + set + { + if (value == _CurrentState) + return; + _CurrentState = value; + registerForRedraw(); + //registerForGraphicUpdate(); + //needGraphicalUpdate = true; + } + } + + public ButtonWidgetClick clickEvent; + + bool _isChecked = false; + public bool IsChecked + { + get { return _isChecked; } + set + { + if (value == _isChecked) + return; + + _isChecked = value; + + if (clickEvent != null) + clickEvent(this); + + registerForGraphicUpdate(); + } + } + + public bool IsCheckable = false; + public bool affectMultiSelectState = true; + public bool border3D = false; + + Image _icon; + Image _checkedIcon; + Label _label; + + public Image icon + { + get { return _icon; } + set + { + if (_icon != null) + removeChild(_icon); + + if (value == null) + _icon = null; + else + { + _icon = addChild(value) as Image; + _icon.horizontalAlignment = go.HorizontalAlignment.Stretch; + _icon.verticalAlignment = go.VerticalAlignment.Stretch; + _icon.background = Color.Transparent; + putWidgetOnBottom(_icon); + //_icon.borderWidth = 5; + } + } + } + public Image checkedIcon + { + get { return _checkedIcon; } + set + { + if (_checkedIcon != null) + removeChild(_checkedIcon); + + if (value == null) + _checkedIcon = null; + else + { + _checkedIcon = addChild(value) as Image; + _checkedIcon.horizontalAlignment = go.HorizontalAlignment.Stretch; + _checkedIcon.verticalAlignment = go.VerticalAlignment.Stretch; + _checkedIcon.background = Color.Transparent; + + putWidgetOnBottom(_checkedIcon); + } + } + } + public Label label + { + get { return _label; } + set + { + if (_label != null) + removeChild(_label); + + if (value == null) + _label = null; + else + { + _label = addChild(value) as Label; + _label.horizontalAlignment = go.HorizontalAlignment.Stretch; + _label.verticalAlignment = go.VerticalAlignment.Stretch; + _label.textAlignment = Alignment.VerticalStretch; + putWidgetOnTop(_label); + } + } + } + + public string text + { + get { return label.text; } + set + { + label = new Label(value); + } + } + + //public ButtonWidget(string iconFile, int _x, int _y, bool _checkable = false):base() + //{ + // IsCheckable = _checkable; + // x = _x; + // y = _y; + + // icon = new ImageWidget(iconFile); + // icon.Parent = this; + //} + + + + public override bool ProcessMousePosition(Point mousePos) + { + if (CurrentState == ButtonStates.Disable) + return false; + + bool result = base.ProcessMousePosition(mousePos); + + if (result && CurrentState != ButtonStates.mouseDown) + CurrentState = ButtonStates.mouseOver; + else + CurrentState = ButtonStates.normal; + + return result; + + } + public override void ProcessMouseDown(Point mousePos) + { + //base.ProcessMouseDown(mousePos); + + + if (CurrentState != Button.ButtonStates.Disable) + { + Interface.activeWidget = this; + + if (IsCheckable) + { + if (IsChecked) + IsChecked = false; + else + { + Group wg = Parent as Group; + if (wg != null) + { + if (affectMultiSelectState && !multiSelect) + { + foreach (Button but in wg.Children.OfType