/* Hyperbolic Tessellations Copyright (C) 2007 Dmitry Brant http://dmitrybrant.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ //--------------------------------------------------------------------------- #include #pragma hdrstop #include #include "MainForm.h" #include "ChildForm.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner), totalForms(0) { } //--------------------------------------------------------------------------- void __fastcall TForm1::FormShow(TObject *Sender) { //automatically start with a new one mnuNewClick(NULL); } //--------------------------------------------------------------------------- void __fastcall TForm1::StatusBar1DrawPanel(TStatusBar *StatusBar, TStatusPanel *Panel, const TRect &Rect){ TCanvas *pCanvas = StatusBar->Canvas; if(Panel->Index == 1){ pCanvas->Brush->Color = clBtnFace; pCanvas->Brush->Style = bsSolid; pCanvas->FillRect(Rect); pCanvas->TextOut(Rect.left + 2, Rect.top + 1, Panel->Text); } } //--------------------------------------------------------------------------- void __fastcall TForm1::mnuAboutClick(TObject *Sender){ MessageBox(this->Handle, "Hyperbolic Tessellation Generator\n\nDmitry Brant, 2007\nhttp://dmitrybrant.com", "About...", MB_ICONINFORMATION); } //--------------------------------------------------------------------------- void __fastcall TForm1::Exit1Click(TObject *Sender){ Close(); } //--------------------------------------------------------------------------- void __fastcall TForm1::mnuNewClick(TObject *Sender){ TfrmChild *theForm = new TfrmChild(this); theForm->Caption = "Tessellation " + String(++totalForms); theForm->Show(); theForm->FormResize(NULL); } //--------------------------------------------------------------------------- void __fastcall TForm1::mnuCopyClick(TObject *Sender){ if(!ActiveMDIChild) return; Graphics::TBitmap* bmp = new Graphics::TBitmap; bmp->PixelFormat = pf24bit; bmp->Width = ActiveMDIChild->ClientWidth; bmp->Height = ActiveMDIChild->ClientHeight; BitBlt(bmp->Canvas->Handle, 0, 0, ActiveMDIChild->ClientWidth, ActiveMDIChild->ClientHeight, ActiveMDIChild->Canvas->Handle, 0, 0, SRCCOPY); Clipboard()->Assign(bmp); delete bmp; } //--------------------------------------------------------------------------- void __fastcall TForm1::SaveasWindowsBitmap1Click(TObject *Sender){ if(!ActiveMDIChild) return; Graphics::TBitmap* bmp = new Graphics::TBitmap; TSaveDialog* SaveDialog0 = new TSaveDialog(this); try{ bmp->PixelFormat = pf24bit; bmp->Width = ActiveMDIChild->ClientWidth; bmp->Height = ActiveMDIChild->ClientHeight; BitBlt(bmp->Canvas->Handle, 0, 0, ActiveMDIChild->ClientWidth, ActiveMDIChild->ClientHeight, ActiveMDIChild->Canvas->Handle, 0, 0, SRCCOPY); //do the saving here SaveDialog0->Title = "Save Picture As..."; SaveDialog0->Filter = "Bitmap Image Files (*.bmp)|*.bmp|All Files (*.*)|*.*"; SaveDialog0->FilterIndex = 1; SaveDialog0->DefaultExt = ".bmp"; SaveDialog0->FileName = (ActiveMDIChild->Caption + ".bmp"); SaveDialog0->Options << ofOverwritePrompt << ofEnableSizing; //SaveDialog0->OnShow = Form1->commonDialogCallback; if(!SaveDialog0->Execute()) return; bmp->SaveToFile(SaveDialog0->FileName); }__finally{ delete SaveDialog0; delete bmp; } } //---------------------------------------------------------------------------