]> code.citadel.org Git - citadel.git/commitdiff
Now remembers main frame position
authorArt Cancro <ajc@citadel.org>
Sat, 24 Apr 1999 01:13:13 +0000 (01:13 +0000)
committerArt Cancro <ajc@citadel.org>
Sat, 24 Apr 1999 01:13:13 +0000 (01:13 +0000)
daphne/includes.hpp
daphne/main.cpp
daphne/userlogin.cpp
daphne/utils.cpp

index 02124d8cf9e292bf71dd18b392181865761faf9d..d5c260c072275703814dfbedc97537e6a8ef4b30 100644 (file)
@@ -282,8 +282,7 @@ void load_roomlist(RoomTree *tree, CitClient *citsock);
 void variformat_to_html(wxString& outputbuf,
                         wxString inputbuf,
                         bool add_header_and_footer);
-
-
+void cleanup(int);
 
 
 
index 2233a2dc56a811574457d0c98db5f94156cc0f49..9b43b2f7159248b6f69872ffde077d7b89076701 100644 (file)
@@ -131,15 +131,21 @@ CitClient *citadel;
 // `Main program' equivalent: the program execution "starts" here
 bool Daphne::OnInit()
 {
+       int w, h;
+       wxString sizestr;
+
        // Read the configuration file
        ini = new wxConfig("daphne");
+       ini->SetRecordDefaults(TRUE);
+       ini->Read("/Window Sizes/Main", &sizestr, "600 450");
+       sscanf((const char *)sizestr, "%d %d", &w, &h);
 
        // Connect to the server
        citadel = new CitClient();
 
        // Create the main application window
        MyFrame *frame = new MyFrame("Daphne",
-                                 wxPoint(10, 10), wxSize(600, 450));
+                                 wxPoint(10, 10), wxSize(w, h));
        BigMDI = frame;
 
        // Show it and tell the application that it's our main window
@@ -302,8 +308,7 @@ void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
        // TRUE is to force the frame to close
        Close(TRUE);
 
-       // Write configuration back to disk
-       delete ini;
+       cleanup(0);
 }
 
 // User menu handler
@@ -384,9 +389,16 @@ void MyFrame::OnTestWin(wxCommandEvent& unused) {
 
 void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) )
 {
-    int w, h;
-    GetClientSize(&w, &h);
-    
-    RoomList->SetSize(0, 0, 200, h);
-    GetClientWindow()->SetSize(200, 0, w - 200, h);
+       int w, h;
+       wxString sw, sh;
+
+       // Handle the MDI and roomlist crap
+       GetClientSize(&w, &h);
+       RoomList->SetSize(0, 0, 200, h);
+       GetClientWindow()->SetSize(200, 0, w - 200, h);
+
+       // Remember the size of the window from session to session
+       GetSize(&w, &h);
+       sw.Printf("%d %d", w, h);
+       ini->Write("/Window Sizes/Main", sw);
 }
index 2c1bb5793f32174ea50f837ac2e2187e43e9dc24..003a853e69c2a85e24caf543a03964311b603e3e 100644 (file)
@@ -233,7 +233,7 @@ void UserLogin::OnButtonPressed(wxCommandEvent& whichbutton) {
        if (whichbutton.GetId() == BUTTON_EXIT) {
                sendbuf = "QUIT";
                citsock->serv_trans(sendbuf);
-               exit(0);
+               cleanup(0);
        }
 
        if (whichbutton.GetId() == BUTTON_LOGIN) {
index dadf902b9bc3360e8524a032b44c7cdb38ea07ce..c4db15295b0d2aa75286dd6bac0c5de9eb357bc6 100644 (file)
@@ -59,3 +59,12 @@ void variformat_to_html(wxString& outputbuf,
                outputbuf.Append("</BODY></HTML>\n");
        }
 }
+
+
+
+
+// Generic exit stuff
+void cleanup(int exitcode) {
+       delete ini;             // Write configuration to disk
+       exit(exitcode);         // Go away.
+}