Global hSkin.l, Width.l, Height.l, WinID.l Global Gad_a.l, Gad_b.l, Gad_c.l, Gad__a.l, Gad__b.l, Gad__c.l ;GenerateFastSkin("Dreieck.fsk", "Dreieck.bmp", "Dreieck.bmp", 1) ;End hSkin = CatchFastSkin(?Skin) Width = FastSkinWidth(hSkin) Height = FastSkinHeight(hSkin) Procedure WindowCallback(hwnd.l, msg.l, wParam.l, lParam.l) Shared BPM Select Msg Case #WM_LButtonDown ReleaseCapture_() SendMessage_(hWnd, #WM_NCLBUTTONDOWN, #HTCAPTION, 0) EndSelect ProcedureReturn #PB_ProcessPureBasicEvents EndProcedure Structure Dreieck set.l a.f ; 1 b.f ; 2 c.f ; 4 _set.l _a.f ; 1 _b.f ; 2 _c.f ; 4 EndStructure #PI = 3.14159265 #RAD2DEG = 180 / #PI #DEG2RAD = #PI / 180 Procedure.f CosD(a.f) ProcedureReturn Cos(a * #DEG2RAD) EndProcedure Procedure.f SinD(a.f) ProcedureReturn Sin(a * #DEG2RAD) EndProcedure Procedure.f ACosD(a.f) ProcedureReturn ACos(a) * #RAD2DEG EndProcedure Procedure.f ASinD(a.f) ProcedureReturn ASin(a) * #RAD2DEG EndProcedure Procedure t(setting.l, state.l) If setting & state = state : ProcedureReturn #True : EndIf ProcedureReturn #False EndProcedure Procedure.s StrF2(Value.f) Protected v.s, l.l, a.l v = StrF(value) l = Len(v) Repeat Select Right(v, 1) Case "0" l - 1 v = Left(v, l) Case "." l - 1 v = Left(v, l) ProcedureReturn v Default ProcedureReturn v EndSelect ForEver EndProcedure Procedure WWW(*a.Dreieck) If t(*a\_set, %011) And *a\_set & %100 = 0 *a\_a = 180 - (*a\_b + *a\_c) *a\_set | %100 EndIf If t(*a\_set, %101) And *a\_set & %010 = 0 *a\_b = 180 - (*a\_a + *a\_c) *a\_set | %010 EndIf If t(*a\_set, %110) And *a\_set & %001 = 0 *a\_c = 180 - (*a\_a+ *a\_b) *a\_set | %001 EndIf EndProcedure Procedure SSS(*a.Dreieck) If t(*a\set, %111) If *a\_set & %100 = 0 *a\_a = ACosD((*a\b * *a\b + *a\c * *a\c - *a\a * *a\a) / (2 * *a\b * *a\c)) *a\_set | %100 EndIf If *a\_set & %010 = 0 *a\_b = ACosD((*a\a * *a\a + *a\c * *a\c - *a\b * *a\b) / (2 * *a\a * *a\c)) *a\_set | %010 EndIf If *a\_set & %001 = 0 *a\_c = ACosD((*a\a * *a\a + *a\b * *a\b - *a\c * *a\c) / (2 * *a\a * *a\b)) *a\_set | %001 EndIf EndIf EndProcedure Procedure SWS(*a.Dreieck) If t(*a\set, %011) And *a\set & %100 = 0 And t(*a\_set, %100) *a\a = Sqr(*a\b * *a\b + *a\c * *a\c - 2 * *a\b * *a\c * CosD(*a\_a)) *a\set | %100 EndIf If t(*a\set, %101) And *a\set & %010 = 0 And t(*a\_set, %010) *a\b = Sqr(*a\a * *a\a + *a\c * *a\c - 2 * *a\a * *a\c * CosD(*a\_b)) *a\set | %010 EndIf If t(*a\set, %110) And *a\set & %001 = 0 And t(*a\_set, %001) *a\c = Sqr(*a\a * *a\a + *a\b * *a\b - 2 * *a\a * *a\b * CosD(*a\_c)) *a\set | %001 EndIf EndProcedure Procedure WSS(*a.Dreieck) If t(*a\set, %110) If *a\_set & %100 = 0 And t(*a\_set, %010) *a\_a = ASinD(*a\b * SinD(*a\_b) / *a\a) *a\_set | %100 EndIf If *a\_set & %010 = 0 And t(*a\_set, %100) *a\_b = ASinD(*a\a * SinD(*a\_a) / *a\b) *a\_set | %010 EndIf EndIf If t(*a\set, %011) If *a\_set & %010 = 0 And t(*a\_set, %001) *a\_b = ASinD(*a\c * SinD(*a\_c) / *a\b) *a\_set | %010 EndIf If *a\_set & %001 = 0 And t(*a\_set, %010) *a\_c = ASinD(*a\b * SinD(*a\_b) / *a\c) *a\_set | %001 EndIf EndIf If t(*a\set, %101) If *a\_set & %100 = 0 And t(*a\_set, %001) *a\_a = ASinD(*a\c * SinD(*a\_c) / *a\a) *a\_set | %100 EndIf If *a\_set & %001 = 0 And t(*a\_set, %100) *a\_c = ASinD(*a\a * SinD(*a\_a) / *a\c) *a\_set | %001 EndIf EndIf EndProcedure Procedure SWW(*a.Dreieck) If t(*a\_set, %110) If *a\set & %100 = 0 And t(*a\_set, %010) *a\a = *a\b * SinD(*a\_b) / SinD(*a\_a) *a\set | %100 EndIf If *a\set & %010 = 0 And t(*a\_set, %100) *a\b = *a\a * SinD(*a\_a) / SinD(*a\_b) *a\set | %010 EndIf EndIf If t(*a\_set, %011) If *a\set & %010 = 0 And t(*a\_set, %001) *a\b = *a\c * SinD(*a\_c) / SinD(*a\_b) *a\set | %010 EndIf If *a\set & %001 = 0 And t(*a\_set, %010) *a\c = *a\b * SinD(*a\_b) / SinD(*a\_c) *a\set | %001 EndIf EndIf If t(*a\_set, %101) If *a\set & %100 = 0 And t(*a\_set, %001) *a\a = *a\c * SinD(*a\_c) / SinD(*a\_a) *a\set | %100 EndIf If *a\set & %001 = 0 And t(*a\_set, %100) *a\c = *a\a * SinD(*a\_a) / SinD(*a\_c) *a\set | %001 EndIf EndIf EndProcedure Procedure CheckDreieck(*a.Dreieck) Protected set.l, _set.l set = *a\set _set = *a\_set WWW(*a) SWW(*a) SSS(*a) SWS(*a) WSS(*a) If set <> *a\set Or _set <> *a\_set : ProcedureReturn #True : EndIf ProcedureReturn #False EndProcedure Procedure ResetDreieck(*a.Dreieck) *a\set = 0 *a\_set = 0 EndProcedure Procedure SetA(*a.Dreieck, a.s) If a *a\set | %100 *a\a = ValF(a) Else *a\set & %011 *a\a = 0 EndIf EndProcedure Procedure SetB(*a.Dreieck, b.s) If b *a\set | %010 *a\b = ValF(b) Else *a\set & %101 *a\b = 0 EndIf EndProcedure Procedure SetC(*a.Dreieck, c.s) If c *a\set | %001 *a\c = ValF(c) Else *a\set & %110 *a\c = 0 EndIf EndProcedure Procedure Set_A(*a.Dreieck, _a.s) If _a *a\_set | %100 *a\_a = ValF(_a) Else *a\_set & %011 *a\_a = 0 EndIf EndProcedure Procedure Set_B(*a.Dreieck, _b.s) If _b *a\_set | %010 *a\_b = ValF(_b) Else *a\_set & %101 *a\_b = 0 EndIf EndProcedure Procedure Set_C(*a.Dreieck, _c.s) If _c *a\_set | %001 *a\_c = ValF(_c) Else *a\_set & %110 *a\_c = 0 EndIf EndProcedure Procedure CheckInput(*a.Dreieck) Protected a.s, b.s, c.s, _a.s, _b.s, _c.s a = GetGadgetText(Gad_a) b = GetGadgetText(Gad_b) c = GetGadgetText(Gad_c) _a = GetGadgetText(Gad__a) _b = GetGadgetText(Gad__b) _c = GetGadgetText(Gad__c) Select GetFocus_() Case GadgetID(Gad_a) : SetA(*a, a) Case GadgetID(Gad_b) : SetB(*a, b) Case GadgetID(Gad_c) : SetC(*a, c) Case GadgetID(Gad__a) : Set_A(*a, _a) Case GadgetID(Gad__b) : Set_B(*a, _b) Case GadgetID(Gad__c) : Set_C(*a, _c) EndSelect EndProcedure Procedure CheckInputDirect(*a.Dreieck) Protected a.s, b.s, c.s, _a.s, _b.s, _c.s a = GetGadgetText(Gad_a) b = GetGadgetText(Gad_b) c = GetGadgetText(Gad_c) _a = GetGadgetText(Gad__a) _b = GetGadgetText(Gad__b) _c = GetGadgetText(Gad__c) SetA(*a, a) SetB(*a, b) SetC(*a, c) Set_A(*a, _a) Set_B(*a, _b) Set_C(*a, _c) EndProcedure Procedure SetGadgets(*a.Dreieck) Protected a.s, b.s, c.s, _a.s, _b.s, _c.s, Focus.l Protected ta.s, tb.s, tc.s, t_a.s, t_b.s, t_c.s a = GetGadgetText(Gad_a) b = GetGadgetText(Gad_b) c = GetGadgetText(Gad_c) _a = GetGadgetText(Gad__a) _b = GetGadgetText(Gad__b) _c = GetGadgetText(Gad__c) ta = StrF2(*a\a) tb = StrF2(*a\b) tc = StrF2(*a\c) t_a = StrF2(*a\_a) t_b = StrF2(*a\_b) t_c = StrF2(*a\_c) Focus = GetFocus_() If a <> ta And Focus <> GadgetID(Gad_a) And *a\set & %100 : SetGadgetText(Gad_a, ta) : EndIf If b <> tb And Focus <> GadgetID(Gad_b) And *a\set & %010 : SetGadgetText(Gad_b, tb) : EndIf If c <> tc And Focus <> GadgetID(Gad_c) And *a\set & %001 : SetGadgetText(Gad_c, tc) : EndIf If _a <> t_a And Focus <> GadgetID(Gad__a) And *a\_set & %100 : SetGadgetText(Gad__a, t_a) : EndIf If _b <> t_b And Focus <> GadgetID(Gad__b) And *a\_set & %010 : SetGadgetText(Gad__b, t_b) : EndIf If _c <> t_c And Focus <> GadgetID(Gad__c) And *a\_set & %001 : SetGadgetText(Gad__c, t_c) : EndIf EndProcedure Procedure ClearGadgets() SetGadgetText(Gad_a, "") SetGadgetText(Gad_b, "") SetGadgetText(Gad_c, "") SetGadgetText(Gad__a, "") SetGadgetText(Gad__b, "") SetGadgetText(Gad__c, "") EndProcedure D.Dreieck WinID = OpenWindow(#PB_Any, 0, 0, Width, Height, #PB_Window_BorderLess | #PB_Window_ScreenCentered, "Dreieck") If WinID = 0 : End : EndIf If CreateGadgetList(WindowID(WinID)) = 0 : End : EndIf MakeStayOnTop(WindowID(WinID), #True) Gad_b = StringGadget(#PB_Any, 24, 102, 81, 16, "") Gad_a = StringGadget(#PB_Any, 242, 104, 81, 16, "") Gad_c = StringGadget(#PB_Any, 141, 215, 81, 16, "") Gad__a = StringGadget(#PB_Any, 94, 173, 81, 16, "") Gad__b = StringGadget(#PB_Any, 195, 176, 81, 16, "") Gad__c = StringGadget(#PB_Any, 128, 104, 81, 16, "") Gad_OK = ButtonGadget(#PB_Any, 161, 137, 22, 21, "OK") SetWindowCallback(@WindowCallback()) SkinWinFast(WindowID(WinID), hSkin) Repeat CheckInput(@D) EventID.l = WaitWindowEvent() Select EventID Case #PB_EventCloseWindow Break Case #PB_EventGadget If EventGadgetID() = Gad_OK ResetDreieck(@D) CheckInputDirect(@D) While CheckDreieck(@D) : Wend SetGadgets(@D) EndIf Case #WM_KEYDOWN Select EventwParam() Case #VK_ESCAPE If D\set = 0 And D\_set = 0 Break Else ResetDreieck(@D) ClearGadgets() EndIf EndSelect EndSelect ForEver DataSection Skin: IncludeBinary "Dreieck.fsk" EndDataSection ; jaPBe Version=3.6.3.453 ; FoldLines=000A00140016001F002500270028002A002B002D002E00300032003500360047 ; FoldLines=00490056005700660067007400750094009500B400B500C000C200C500C600CE ; FoldLines=00CF00D700D800E000E100E900EA00F200F300FB00FD010F01100120013D0144 ; Build=3 ; Language=0x0000 Language Neutral ; FirstLine=0 ; CursorPosition=345 ; UseIcon=Dreieck.ico ; ExecutableFormat=Windows ; Executable=C:\Programme\PureBasic\Programme\Projekte\Dreieck\Dreieck.exe ; DontSaveDeclare ; EOF