diff --git a/uppdev/PainterExamples/OnPath.cpp b/uppdev/PainterExamples/OnPath.cpp new file mode 100644 index 000000000..83677a478 --- /dev/null +++ b/uppdev/PainterExamples/OnPath.cpp @@ -0,0 +1,58 @@ +#include "Examples.h" + +void OnPath(Painter& sw) +{ + sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue()); + for(int i = -1; i <= 16; i++) { + sw.BeginOnPath(i / 15.0); + sw.Move(0, -6).Line(6, 0).Line(0, 6).Close().Stroke(1, Black()); + sw.End(); + } +} + +void OnTextPath(Painter& sw) +{ + sw.Text(50, 50, "Hello!", Roman(350)).Stroke(1, Black()); + for(int i = 0; i <= 100; i++) { + sw.BeginOnPath(i / 100.0); + sw.Move(0, -6).Line(6, 0).Line(0, 6).Fill(Red()); + sw.End(); + } +} + +void OnPathBee(Painter& sw) +{ + sw.Move(200, 300).Quadratic(400, 50, 600, 300).Quadratic(1000, 300).Stroke(1, Blue()); + for(int i = -1; i <= 16; i++) { + sw.BeginOnPath(i / 15.0); + sw.DrawImage(0, -TestImg::Bee().GetHeight() / 2, TestImg::Bee()); + sw.End(); + } +} + +void TextOnPath(Painter& sw) +{ + Font fnt = Roman(100); + FontInfo fi = fnt.Info(); + double pos = 0; + const char *s = "Hello world, this is text on path!"; + int l = GetTextSize(s, fnt).cx; + double r = l / (2 * M_PI); + sw.Circle(300, 300, r).Stroke(1, Red()); + while(*s) { + double w = fi[*s]; + sw.BeginOnPath(pos + w / 2, true); + sw.Character(-w / 2, -fi.GetAscent(), *s++, fnt) + .Fill(0, -fi.GetAscent(), Yellow(), 0, fi.GetDescent(), Blue()) + .Stroke(1, Black()); + sw.End(); + pos += w; + } +} + +INITBLOCK { + RegisterExample("OnPath", OnPath); + RegisterExample("OnTextPath", OnTextPath); + RegisterExample("OnPathBee", OnPathBee); + RegisterExample("TextOnPath", TextOnPath); +} diff --git a/uppdev/PainterExamples/PainterExamples.upp b/uppdev/PainterExamples/PainterExamples.upp index d98aaae0b..8d440ed59 100644 --- a/uppdev/PainterExamples/PainterExamples.upp +++ b/uppdev/PainterExamples/PainterExamples.upp @@ -25,6 +25,7 @@ file RadialMaskBlending.cpp, RichText.cpp, Stroke.cpp, + OnPath.cpp, Dash.cpp, Path.cpp, Arc.cpp, diff --git a/uppdev/PainterExamples/Test.iml b/uppdev/PainterExamples/Test.iml index 59e371e15..bd1251822 100644 --- a/uppdev/PainterExamples/Test.iml +++ b/uppdev/PainterExamples/Test.iml @@ -1,5 +1,7 @@ PREMULTIPLIED IMAGE_ID(test) +IMAGE_ID(Arrow) +IMAGE_ID(Bee) IMAGE_BEGIN_DATA IMAGE_DATA(120,156,172,189,7,119,20,89,210,181,251,125,191,250,254,129,251,206,116,3,13,13,52,86,222,33,36,156,64,32,16,242) @@ -13911,3 +13913,22 @@ IMAGE_DATA(140,59,196,235,151,13,213,239,116,182,212,128,96,93,25,149,211,155,15 IMAGE_DATA(225,124,154,248,57,110,121,53,102,178,206,114,14,6,242,121,81,243,57,231,67,206,220,237,229,215,70,25,156,147,188,252) IMAGE_DATA(255,213,165,31,190,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0) IMAGE_END_DATA(445056, 1) + +IMAGE_BEGIN_DATA +IMAGE_DATA(120,156,237,212,223,75,147,81,28,199,241,231,47,8,137,34,232,135,20,51,218,180,109,68,65,37,78,246,76,45,98,83) +IMAGE_DATA(123,44,93,225,42,182,199,49,165,229,30,199,126,20,209,99,133,142,32,43,83,204,209,212,98,185,48,218,114,153,209,69) +IMAGE_DATA(221,246,15,8,253,3,221,116,217,159,240,110,12,26,38,27,107,103,221,4,158,155,3,7,94,231,123,126,126,164,6,169) +IMAGE_DATA(65,218,212,144,234,107,212,57,7,91,122,81,47,58,199,191,216,255,182,223,246,255,167,223,33,53,214,90,172,214,130,248) +IMAGE_DATA(79,31,36,214,118,168,22,139,210,99,166,95,105,70,239,216,91,147,115,187,173,104,193,14,52,215,17,230,6,90,254,198) +IMAGE_DATA(50,60,210,74,95,191,133,160,106,39,161,117,242,176,107,103,53,199,244,147,0,87,125,50,90,180,155,165,69,149,27,222) +IMAGE_DATA(54,210,174,93,85,221,248,248,121,162,113,133,17,255,69,194,163,54,30,220,83,120,123,97,119,85,119,247,118,193,12,119) +IMAGE_DATA(18,47,212,155,184,239,32,161,187,121,55,184,175,146,43,142,191,120,25,98,45,31,43,152,62,50,153,201,130,235,101,97) +IMAGE_DATA(214,71,86,45,235,248,242,41,196,106,246,58,239,243,26,249,85,141,204,114,132,212,98,136,185,25,55,159,179,81,210,234) +IMAGE_DATA(129,178,238,67,78,231,227,155,8,107,175,194,172,164,34,188,94,138,49,51,27,32,189,224,97,121,74,97,94,61,90,113) +IMAGE_DATA(157,211,99,14,230,67,237,248,100,3,99,189,38,166,18,97,82,207,188,60,141,59,42,154,160,243,20,223,116,27,57,213) +IMAGE_DATA(74,206,127,152,141,91,102,46,181,218,25,116,25,25,56,99,36,218,109,249,185,197,146,185,115,133,201,115,199,216,184,105) +IMAGE_DATA(102,212,222,204,247,9,3,235,67,38,116,167,204,99,143,17,135,117,15,73,239,73,2,114,211,230,186,36,175,157,32,235) +IMAGE_DATA(179,145,244,152,8,186,100,126,60,50,243,252,178,133,149,161,179,124,13,26,232,178,238,167,221,216,136,124,188,133,30,167) +IMAGE_DATA(243,183,21,118,130,235,20,61,151,186,238,65,240,222,69,223,153,36,137,189,235,63,124,141,255,168,228,68,255,173,96,78) +IMAGE_DATA(20,173,64,46,149,172,64,14,22,157,96,238,22,173,64,206,151,108,57,243,11,122,3,253,103,0,0,0,0,0,0,0) +IMAGE_END_DATA(512, 2) diff --git a/uppdev/PainterExamples/main.cpp b/uppdev/PainterExamples/main.cpp index 13396a613..f2fbcaaa1 100644 --- a/uppdev/PainterExamples/main.cpp +++ b/uppdev/PainterExamples/main.cpp @@ -81,8 +81,8 @@ void App::Paint(Draw& w) { Size sz = GetSize(); if(ctrl.transparent) { - for(int y = 0; y + 32 < sz.cy; y += 32) - for(int x = 0; x + 32 < sz.cx; x += 32) + for(int y = 0; y < sz.cy; y += 32) + for(int x = 0; x < sz.cx; x += 32) w.DrawRect(x, y, 32, 32, (x ^ y) & 32 ? Color(254, 172, 120) : Color(124, 135, 253)); } ImageBuffer ib(sz); diff --git a/uppdev/SqlProblem/SqlProblem.lay b/uppdev/SqlProblem/SqlProblem.lay new file mode 100644 index 000000000..5337039e1 --- /dev/null +++ b/uppdev/SqlProblem/SqlProblem.lay @@ -0,0 +1,24 @@ +LAYOUT(SqlProblemLayout, 232, 228) + ITEM(Button, openCommander, SetLabel(t_("SQL COMMANDER")).LeftPosZ(68, 96).TopPosZ(160, 28)) + ITEM(Button, openCompetiterButton, SetLabel(t_("COMPETITER")).LeftPosZ(68, 96).TopPosZ(40, 28)) + ITEM(Button, openClubsButton, SetLabel(t_("CLUBS")).LeftPosZ(68, 96).TopPosZ(88, 28)) +END_LAYOUT + +LAYOUT(SaisieCompetiteursLayout, 400, 224) + ITEM(EditString, name, LeftPosZ(68, 84).TopPosZ(84, 28)) + ITEM(Button, openClubsButton, SetLabel(t_("MODIFY CLUBS")).LeftPosZ(172, 92).TopPosZ(84, 28)) + ITEM(EditString, clubId, LeftPosZ(68, 84).TopPosZ(124, 28)) + ITEM(Label, dv___3, SetLabel(t_("Club ID")).LeftPosZ(8, 60).TopPosZ(124, 28)) + ITEM(Label, dv___4, SetLabel(t_("Name")).LeftPosZ(8, 58).TopPosZ(84, 28)) + ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(232, 56).TopPosZ(184, 15)) + ITEM(Button, cancel, SetLabel(t_("CANCEL")).LeftPosZ(116, 56).TopPosZ(184, 15)) +END_LAYOUT + +LAYOUT(ClubsLayout, 400, 256) + ITEM(SqlArray, clubsList, LeftPosZ(216, 150).TopPosZ(12, 176)) + ITEM(EditString, city, LeftPosZ(68, 104).TopPosZ(56, 28)) + ITEM(Label, dv___2, SetLabel(t_("City")).LeftPosZ(8, 58).TopPosZ(56, 24)) + ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(236, 56).TopPosZ(220, 15)) + ITEM(Button, cancel, SetLabel(t_("CANCEL")).LeftPosZ(120, 56).TopPosZ(220, 15)) +END_LAYOUT + diff --git a/uppdev/SqlProblem/SqlProblem.upp b/uppdev/SqlProblem/SqlProblem.upp new file mode 100644 index 000000000..e2e89462d --- /dev/null +++ b/uppdev/SqlProblem/SqlProblem.upp @@ -0,0 +1,14 @@ +uses + CtrlLib, + Sql, + SqlCtrl, + plugin/sqlite3; + +file + mysql.sch, + main.cpp, + SqlProblem.lay; + +mainconfig + "" = "GUI"; + diff --git a/uppdev/SqlProblem/init b/uppdev/SqlProblem/init new file mode 100644 index 000000000..045f4bd41 --- /dev/null +++ b/uppdev/SqlProblem/init @@ -0,0 +1,7 @@ +#ifndef _SqlProblem_icpp_init_stub +#define _SqlProblem_icpp_init_stub +#include "CtrlLib/init" +#include "Sql/init" +#include "SqlCtrl/init" +#include "plugin/sqlite3/init" +#endif diff --git a/uppdev/SqlProblem/main.cpp b/uppdev/SqlProblem/main.cpp new file mode 100644 index 000000000..9551cb49a --- /dev/null +++ b/uppdev/SqlProblem/main.cpp @@ -0,0 +1,176 @@ +#include +#include + +#include + +using namespace Upp; + +#define LAYOUTFILE +#include + +#define SCHEMADIALECT +#define MODEL +#include "Sql/sch_header.h" + + + +#include +#include + + +#include +#include + +class ClubsDlg : public WithClubsLayout { + typedef ClubsDlg CLASSNAME; + +public: + ClubsDlg() + { + CtrlLayoutOKCancel(*this, ""); + clubsList.SetTable(CLUBS); + clubsList.AddKey(CLUB_ID); + clubsList.AddColumn(CLUB_NAME, "NAME"); + clubsList.AddCtrl(CLUB_CITY, city); + clubsList.Query(); + } +}; + + + +// ========================================================== +class CompetiteurDlg : public WithSaisieCompetiteursLayout { +public: + typedef CompetiteurDlg CLASSNAME; + SqlCtrls ctrls; + +public: + CompetiteurDlg() + { + CtrlLayoutOKCancel(*this, "Competiteurs"); + ctrls(COMPH_NAME, name) (COMPH_REF_CLUB_ID, clubId); + openClubsButton << THISBACK(openClubs); + } + + void openClubs() + { + ClubsDlg dlg; + dlg.Run(); + } +}; + +// ========================================================== +class SqlProblem : public WithSqlProblemLayout { +public: + typedef SqlProblem CLASSNAME; + SqlProblem() + { + CtrlLayout(*this, "Window title"); + openCompetiterButton << THISBACK(openCompetiter); + openClubsButton << THISBACK(openClubs); + openCommander << callback(SQLCommander); + } + + void openCompetiter() + { + CompetiteurDlg dlg; + Sql sql; + sql * Select( dlg.ctrls ).From(COMPETITERS).Where(COMPH_ID == 1); + if (dlg.ctrls.Fetch(sql)) + { + dlg.RunAppModal(); + } + } + + void openClubs() + { + ClubsDlg dlg; + dlg.Run(); + } +}; + + +// ========================================================== +GUI_APP_MAIN +{ + SQL; + Sqlite3Session sqlite3; + sqlite3.SetTrace(); + + // DATA BASE + // Gestion de la DB + String statsusMsg = "Ouverture de la base de donnees"; + //statusBar.Set(statsusMsg); + if(!sqlite3.Open(ConfigFile("FNPSA.db"))) { + Exclamation("Can't create or open database file\n"); + return; + } + SQL = sqlite3; + + // if DB is empty ==> create structure + { + Vector table_list = sqlite3.EnumTables(""); + if (table_list.GetCount() == 0) + { + statsusMsg = "Initialisation de la base de donnees en cours ..."; + //statusBar.Set(statsusMsg); + + // Update the schema to match the schema described in MODEL + SqlSchema sch(SQLITE3); + StdStatementExecutor se(sqlite3); + All_Tables(sch); + if(sch.ScriptChanged(SqlSchema::UPGRADE)) + Sqlite3PerformScript(sch.Upgrade(),se); + if(sch.ScriptChanged(SqlSchema::ATTRIBUTES)) { + Sqlite3PerformScript(sch.Attributes(),se); + } + if(sch.ScriptChanged(SqlSchema::CONFIG)) { + Sqlite3PerformScript(sch.ConfigDrop(),se); + Sqlite3PerformScript(sch.Config(),se); + } + sch.SaveNormal(); + + statsusMsg = "Initialisation de la base de donnees termin�e"; + //statusBar.Set(statsusMsg); + } + } + { + // Get the list of tables + Vector table_list = sqlite3.EnumTables(""); + std::cout << "Tables: " << table_list.GetCount() << std::flush; + LOG(Format("Tables: (%d)",table_list.GetCount())); + for (int i = 0; i < table_list.GetCount(); ++i) + LOG(Format(" #%d: %s",i+1,table_list[i])); + } + + + Sql sql(sqlite3); + sql.ClearError(); + + #define NEW_DB + #ifdef NEW_DB + + sql.Begin(); + sql * Delete(CLUBS); + sql * Delete(COMPETITERS); + + sql * Insert(CLUBS) (CLUB_NAME,"CLUB 1") (CLUB_CITY,"NY"); + sql * Insert(CLUBS) (CLUB_NAME,"CLUB 2") (CLUB_CITY,"PARIS"); + sql * Insert(CLUBS) (CLUB_NAME,"CLUB 3") (CLUB_CITY,"ROME"); + sql * Insert(CLUBS) (CLUB_NAME,"CLUB 4") (CLUB_CITY,"LONDON"); + + sql * Insert(COMPETITERS) (COMPH_REF_CLUB_ID, 1)(COMPH_NAME, "Didier"); + sql * Insert(COMPETITERS) (COMPH_REF_CLUB_ID, 1)(COMPH_NAME, "Alex"); + sql * Insert(COMPETITERS) (COMPH_REF_CLUB_ID, 2)(COMPH_NAME, "Mathieu"); + sql * Insert(COMPETITERS) (COMPH_REF_CLUB_ID, 2)(COMPH_NAME, "Fred"); + + // enregistrement de la DB + sql.Commit(); + + #endif + // ======================== COMPETITION ========================== + + SqlProblem().Run(); + +} + diff --git a/uppdev/SqlProblem/mysql.sch b/uppdev/SqlProblem/mysql.sch new file mode 100644 index 000000000..1be753060 --- /dev/null +++ b/uppdev/SqlProblem/mysql.sch @@ -0,0 +1,12 @@ +TABLE_(CLUBS) + INT_ (CLUB_ID) PRIMARY_KEY AUTO_INCREMENT + STRING_ (CLUB_NAME, 30) + STRING_ (CLUB_CITY, 30) +END_TABLE + +TABLE_(COMPETITERS) + INT_ (COMPH_ID) PRIMARY_KEY AUTO_INCREMENT + INT_ (COMPH_REF_CLUB_ID) REFERENCES(CLUBS) + STRING_ (COMPH_NAME, 30) INDEX +END_TABLE +