Re: Database Designer - Mailing list pgadmin-hackers
From | John McCawley |
---|---|
Subject | Re: Database Designer |
Date | |
Msg-id | 3D21CE6B.6050308@worleyco.com Whole thread Raw |
In response to | Re: Database Designer ("Dave Page" <dpage@vale-housing.co.uk>) |
List | pgadmin-hackers |
> > >I also think this would be a valuable addition to pgAdmin and would >welcome any work you care to put into it. If you need any help or >advice, please don't hesitate to email questions to the list. > >Regards, Dave. > > After all of my poo-pooing a C++ implementation of pgAdmin, now that I'm playing around with this designer I'm doing it in C++ :P I'm not sure how much I could integrate with pgAdmin from MingW (gnu) C++, but I'll look into it. I've been using FLTK as my cross platform graphics library for a while now, and it's really easy to use. For whatever reason, everyone else seems to use GTK or QT, even though they are (in my opinion) much more complex. GTK for Windows is VERY much a pain to use, and QT for Windows is a commercial product. FLTK, on the other hand, is very easy to get up and running on Windows, Linux, or (I hear) MacOS etc. As far as the database access, I was planning on implementing a class wrapper around libpq. I don't know how relavent this work is to pgAdmin since I'm doing it in C++ and may not be easy to integrate, but given our earlier talk about C++ stuff I figured I'd mention it. Just FYI, here's a snippet of code that implements a basic "drag and drop" widget. Bear in mind that everything that is necessary for a "hello world" program is in the main() function: /* Copyright (C) 2000 John R. McCawley III This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdio.h> #include <stdlib.h> #include <FL/Fl.H> #include <FL/Fl_Window.H> #include <FL/Fl_Button.H> #include <FL/fl_draw.H> #include <FL/Fl_Box.H> //Create "canvas" widget that we can use to draw graphics class MyImageWidget : public Fl_Widget { protected: //Current x and y top left coordinate of this widget int m_x; int m_y; //Current width and height of this widget int m_width; int m_height; //Position of the cursor when the mouse button was pressed int m_startx; int m_starty; //is the mouse button down? int m_bButtonDown; //Draw this widget virtual void draw() { if( m_bButtonDown ) fl_color(0,0,0); else fl_color(100,0,100); fl_line_style(FL_SOLID); fl_rectf(m_x, m_y, m_width, m_height); } //Event handler for this widget int handle(int event) { switch(event) { //Button down, set boolean to draw control a different color and store position of the cursor case FL_PUSH: m_startx = Fl::event_x(); m_starty = Fl::event_y(); m_bButtonDown = 1; Fl::redraw(); return 1; case FL_RELEASE: //Button release, unset boolean m_bButtonDown = 0; Fl::redraw(); return 1; //Drag, offset our x position by the distance the cursor has moved since we last stored it, //Then store its current position case FL_DRAG: m_x = m_x - (m_startx - Fl::event_x()); m_y = m_y - (m_starty - Fl::event_y()); m_startx = Fl::event_x(); m_starty = Fl::event_y(); position(m_x,m_y); Fl::redraw(); return 1; default: return Fl_Widget::handle(event); } } public: MyImageWidget(int x, int y, int w, int h) : Fl_Widget(x,y,w,h) { m_x=x;m_y=y;m_width=w;m_height=h; m_bButtonDown = 0; } }; int main(int argc, char ** argv) { //Initialize the main window to 640x480 size Fl_Window *window = new Fl_Window( 640,480); MyImageWidget *pMyWidget = new MyImageWidget(0,0,100,100); MyImageWidget *pMyWidget2 = new MyImageWidget(300,300,100,100); //I believe that this sets the color depth to 16 bit? Fl::visual(FL_RGB); //Allow the main window to be resizable to any size window->size_range(0, 0, 10000, 10000); //Not sure what this does window->end(); //Show the window window->show(argc,argv); //Enter main loop return Fl::run(); }
pgadmin-hackers by date: